threaded and forked select with timeout is impacted by syste

  • Thread starter Robert Williams
  • Start date
R

Robert Williams

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.
 
G

Gary Wright

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 Wright
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top