I am using ruby 1.8.6 on Fedora Core 6 and 7
I have encountered a problem with the timeout for a select statement
inside a thread or fork.
If the timeout is set for a duration of time and the system time is
moved back one hour the duration is increased 1
hour. If the time is moved forward 1 hour the duration is shortened one
hour or fires instantly once the duration has
been exceeded.
I tested this functionality in c and timeout duration is not impacted by
a system time change.
For a simple test…
create a thread that loops 30 times
sleep for 1 second (select with 1 second timeout)
and put a string to the console
While the program is running set the system time back say 5 seconds
you will see a 5 second gap between prints.
On Nov 6, 2007, at 9:25 AM, Robert W.iams wrote:
If the timeout is set for a duration of time and the system time is
moved back one hour the duration is increased 1
hour. If the time is moved forward 1 hour the duration is
shortened one
hour or fires instantly once the duration has
been exceeded.
I’m not sure why the Ruby version fails and the C version works, but
it is generally considered a really big mistake to alter a system clock
in this way. Are you adjusting for daylight savings? The underlying
clock should be in GMT and then daylight savings is simply handled by
changing the way the GMT time is displayed. That is to say, the
underlying clock doesn’t change at all for daylight savings.
If you really have to change the underlying system clock, I would do
it in single user mode or at least after stopping any daemons or
long running applications.
Gary W.