# HG changeset patch # User nickg # Date 1028913021 0 # Node ID fc52fa818b5f2e4e13836f6171371f5a05bc9b81 # Parent 96e3418e1f5bbfa1bc7598da5a23be0ff79bfbdd * src/select.cxx (select): Changed mechanism for calculating select timeout to avoid possible race conditions between this code and the timer DSR. diff --git a/packages/io/fileio/current/ChangeLog b/packages/io/fileio/current/ChangeLog --- a/packages/io/fileio/current/ChangeLog +++ b/packages/io/fileio/current/ChangeLog @@ -1,3 +1,9 @@ +2002-08-08 Nick Garnett + + * src/select.cxx (select): Changed mechanism for calculating + select timeout to avoid possible race conditions between this code + and the timer DSR. + 2002-05-29 Jesper Skov * tests/fileio1.c: Removed strcat definition. Rely on string.h to diff --git a/packages/io/fileio/current/src/select.cxx b/packages/io/fileio/current/src/select.cxx --- a/packages/io/fileio/current/src/select.cxx +++ b/packages/io/fileio/current/src/select.cxx @@ -162,8 +162,7 @@ select(int nfd, fd_set *in, fd_set *out, // Compute end time if (tv) - ticks = Cyg_Clock::real_time_clock->current_value() + - cyg_timeval_to_ticks( tv ); + ticks = cyg_timeval_to_ticks( tv ); else ticks = 0; // Lock the mutex @@ -226,11 +225,14 @@ select(int nfd, fd_set *in, fd_set *out, FILEIO_RETURN_VALUE(0); } + ticks += Cyg_Clock::real_time_clock->current_value(); + if( !selwait.wait( ticks ) ) { // A non-standard wakeup, if the current time is equal to // or past the timeout, return zero. Otherwise return // EINTR, since we have been released. + if( Cyg_Clock::real_time_clock->current_value() >= ticks ) { select_mutex.unlock(); @@ -239,6 +241,8 @@ select(int nfd, fd_set *in, fd_set *out, } else error = EINTR; } + + ticks -= Cyg_Clock::real_time_clock->current_value(); } else {