diff -u -r1.32 fade.c
--- fade.c 9 Jul 2005 03:11:42 -0000 1.32
+++ fade.c 26 Jan 2008 23:10:18 -0000
@@ -157,6 +157,28 @@
}
+static void
+sleep_from (struct timeval *now, struct timeval *then, long usecs_per_step)
+{
+ /* If several seconds have passed, the machine must have been asleep
+ or thrashing or something. Don't sleep in that case, to avoid
+ overflowing and sleeping for an unconscionably long time. This
+ function should only be sleeping for very short periods.
+ */
+ if (now->tv_sec - then->tv_sec < 5)
+ {
+ long diff = (((now->tv_sec - then->tv_sec) * 1000000) +
+ now->tv_usec - then->tv_usec);
+ if (usecs_per_step > diff)
+ usleep (usecs_per_step - diff);
+ }
+
+ then->tv_sec = now->tv_sec;
+ then->tv_usec = now->tv_usec;
+}
+
+
+
/* The business with `cmaps_per_screen' is to fake out the SGI 8-bit video
hardware, which is capable of installing multiple (4) colormaps
simultaneously. We have to install multiple copies of the same set of
@@ -329,14 +351,7 @@
/* If we haven't already used up our alotted time, sleep to avoid
changing the colormap too fast. */
- {
- long diff = (((now.tv_sec - then.tv_sec) * 1000000) +
- now.tv_usec - then.tv_usec);
- then.tv_sec = now.tv_sec;
- then.tv_usec = now.tv_usec;
- if (usecs_per_step > diff)
- usleep (usecs_per_step - diff);
- }
+ sleep_from (&now, &then, usecs_per_step);
}
DONE:
@@ -530,14 +545,7 @@
/* If we haven't already used up our alotted time, sleep to avoid
changing the colormap too fast. */
- {
- long diff = (((now.tv_sec - then.tv_sec) * 1000000) +
- now.tv_usec - then.tv_usec);
- then.tv_sec = now.tv_sec;
- then.tv_usec = now.tv_usec;
- if (usecs_per_step > diff)
- usleep (usecs_per_step - diff);
- }
+ sleep_from (&now, &then, usecs_per_step);
}
}
@@ -757,14 +765,7 @@
/* If we haven't already used up our alotted time, sleep to avoid
changing the colormap too fast. */
- {
- long diff = (((now.tv_sec - then.tv_sec) * 1000000) +
- now.tv_usec - then.tv_usec);
- then.tv_sec = now.tv_sec;
- then.tv_usec = now.tv_usec;
- if (usecs_per_step > diff)
- usleep (usecs_per_step - diff);
- }
+ sleep_from (&now, &then, usecs_per_step);
}
}
Thanks! I think this is a bit simpler, though: does this patch work
for you?
- Bug#454523: xscreensaver hangs if machine is suspended ... Jamie Zawinski
- Bug#454523: xscreensaver hangs if machine is suspe... BUCHMULLER Norbert

