Mercurial > flash_v2
diff packages/io/fileio/current/src/select.cxx @ 281:fc52fa818b5f
* src/select.cxx (select): Changed mechanism for calculating
select timeout to avoid possible race conditions between this code
and the timer DSR.
| author | nickg |
|---|---|
| date | Fri, 09 Aug 2002 17:10:21 +0000 |
| parents | d2c90368aeef |
| children | 064536ee7f68 |
line wrap: on
line diff
--- 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 {
