X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fxscreensaver.c;h=5ce1a90917104e3f2dd014989e7c5b9df4655f5e;hb=3f9592851ce4ed76a9979bfdd6ec7dc5c457e183;hp=628bcf1d442b4090899e397bed66979fbddf7de6;hpb=a94197e76a5dea5cb60542840809d6c20d0abbf3;p=xscreensaver diff --git a/driver/xscreensaver.c b/driver/xscreensaver.c index 628bcf1d..5ce1a909 100644 --- a/driver/xscreensaver.c +++ b/driver/xscreensaver.c @@ -289,6 +289,7 @@ saver_ehandler (Display *dpy, XErrorEvent *error) { saver_info *si = global_si_kludge; /* I hate C so much... */ int i; + Bool fatal_p; if (!real_stderr) real_stderr = stderr; @@ -309,9 +310,19 @@ saver_ehandler (Display *dpy, XErrorEvent *error) "#######################################" "#######################################\n\n"); - if (XmuPrintDefaultErrorMessage (dpy, error, real_stderr)) + fatal_p = XmuPrintDefaultErrorMessage (dpy, error, real_stderr); + + fatal_p = True; /* The only time I've ever seen a supposedly nonfatal error, + it has been BadImplementation / Xlib sequence lost, which + are in truth pretty damned fatal. + */ + + fprintf (real_stderr, "\n"); + + if (! fatal_p) + fprintf (real_stderr, "%s: nonfatal error.\n\n", blurb()); + else { - fprintf (real_stderr, "\n"); if (si->prefs.xsync_p) { saver_exit (si, -1, "because of synchronous X Error"); @@ -342,8 +353,7 @@ saver_ehandler (Display *dpy, XErrorEvent *error) saver_exit (si, -1, 0); } } - else - fprintf (real_stderr, " (nonfatal.)\n"); + return 0; } @@ -484,8 +494,6 @@ lock_initialization (saver_info *si, int *argc, char **argv) si->nolock_reason = "running under GDM"; } #endif /* NO_LOCKING */ - - hack_uid (si); } @@ -500,13 +508,17 @@ connect_to_server (saver_info *si, int *argc, char **argv) char *d = getenv ("DISPLAY"); if (!d || !*d) { - char ndpy[] = "DISPLAY=:0.0"; + char *ndpy = strdup("DISPLAY=:0.0"); /* if (si->prefs.verbose_p) */ /* sigh, too early to test this... */ fprintf (stderr, "%s: warning: $DISPLAY is not set: defaulting to \"%s\".\n", blurb(), ndpy+8); if (putenv (ndpy)) abort (); + /* don't free (ndpy) -- some implementations of putenv (BSD 4.4, + glibc 2.0) copy the argument, but some (libc4,5, glibc 2.1.2) + do not. So we must leak it (and/or the previous setting). Yay. + */ } #endif /* HAVE_PUTENV */ @@ -953,7 +965,13 @@ main_loop (saver_info *si) while (1) { Bool was_locked = False; + + if (p->verbose_p) + fprintf (stderr, "%s: awaiting idleness.\n", blurb()); + + check_for_leaks ("unblanked A"); sleep_until_idle (si, True); + check_for_leaks ("unblanked B"); if (p->verbose_p) { @@ -1059,7 +1077,10 @@ main_loop (saver_info *si) ok_to_unblank = True; do { + check_for_leaks ("blanked A"); sleep_until_idle (si, False); /* until not idle */ + check_for_leaks ("blanked B"); + maybe_reload_init_file (si); #ifndef NO_LOCKING @@ -1181,9 +1202,6 @@ main_loop (saver_info *si) } XSync (si->dpy, False); } - - if (p->verbose_p) - fprintf (stderr, "%s: awaiting idleness.\n", blurb()); } } @@ -1954,3 +1972,20 @@ display_is_on_console_p (saver_info *si) } return !not_on_console; } + + +/* Do a little bit of heap introspection... + */ +void +check_for_leaks (const char *where) +{ +#ifdef HAVE_SBRK + static unsigned long last_brk = 0; + int b = (unsigned long) sbrk(0); + if (last_brk && last_brk < b) + fprintf (stderr, "%s: %s: brk grew by %luK.\n", + blurb(), where, + (((b - last_brk) + 1023) / 1024)); + last_brk = b; +#endif /* HAVE_SBRK */ +}