diff options
-rw-r--r-- | lib/libkse/thread/thr_select.c | 13 | ||||
-rw-r--r-- | lib/libpthread/thread/thr_select.c | 13 |
2 files changed, 18 insertions, 8 deletions
diff --git a/lib/libkse/thread/thr_select.c b/lib/libkse/thread/thr_select.c index 6714af0..25be6a9 100644 --- a/lib/libkse/thread/thr_select.c +++ b/lib/libkse/thread/thr_select.c @@ -50,11 +50,16 @@ __select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { struct pthread *curthread = _get_curthread(); + struct timespec ts; int ret; - _thr_enter_cancellation_point(curthread); - ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout); - _thr_leave_cancellation_point(curthread); - + if (numfds == 0 && timeout != NULL) { + TIMEVAL_TO_TIMESPEC(timeout, &ts); + return nanosleep(&ts, NULL); + } else { + _thr_enter_cancellation_point(curthread); + ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout); + _thr_leave_cancellation_point(curthread); + } return ret; } diff --git a/lib/libpthread/thread/thr_select.c b/lib/libpthread/thread/thr_select.c index 6714af0..25be6a9 100644 --- a/lib/libpthread/thread/thr_select.c +++ b/lib/libpthread/thread/thr_select.c @@ -50,11 +50,16 @@ __select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { struct pthread *curthread = _get_curthread(); + struct timespec ts; int ret; - _thr_enter_cancellation_point(curthread); - ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout); - _thr_leave_cancellation_point(curthread); - + if (numfds == 0 && timeout != NULL) { + TIMEVAL_TO_TIMESPEC(timeout, &ts); + return nanosleep(&ts, NULL); + } else { + _thr_enter_cancellation_point(curthread); + ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout); + _thr_leave_cancellation_point(curthread); + } return ret; } |