diff options
author | tegge <tegge@FreeBSD.org> | 2006-10-13 20:04:13 +0000 |
---|---|---|
committer | tegge <tegge@FreeBSD.org> | 2006-10-13 20:04:13 +0000 |
commit | 8f000653f2466e5a55a55aa95a212c4478f15b89 (patch) | |
tree | 18fd986a114924f6824a5e814e2e0c0972cec1cb /lib/libc_r | |
parent | 6ddeb6ab39fbfce4dea1c98477fb2f165b2745ab (diff) | |
download | FreeBSD-src-8f000653f2466e5a55a55aa95a212c4478f15b89.zip FreeBSD-src-8f000653f2466e5a55a55aa95a212c4478f15b89.tar.gz |
Delay setting wakeup time until after poll array has been allocated.
Blocking on the malloc spinlock would cause the select timeout to be lost.
Diffstat (limited to 'lib/libc_r')
-rw-r--r-- | lib/libc_r/uthread/uthread_select.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/libc_r/uthread/uthread_select.c b/lib/libc_r/uthread/uthread_select.c index 2776cb2..b056769 100644 --- a/lib/libc_r/uthread/uthread_select.c +++ b/lib/libc_r/uthread/uthread_select.c @@ -58,26 +58,6 @@ _select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, if (numfds > _thread_dtablesize) { numfds = _thread_dtablesize; } - /* Check if a timeout was specified: */ - if (timeout) { - if (timeout->tv_sec < 0 || - timeout->tv_usec < 0 || timeout->tv_usec >= 1000000) { - errno = EINVAL; - return (-1); - } - - /* Convert the timeval to a timespec: */ - TIMEVAL_TO_TIMESPEC(timeout, &ts); - - /* Set the wake up time: */ - _thread_kern_set_timeout(&ts); - if (ts.tv_sec == 0 && ts.tv_nsec == 0) - f_wait = 0; - } else { - /* Wait for ever: */ - _thread_kern_set_timeout(NULL); - } - /* Count the number of file descriptors to be polled: */ if (readfds || writefds || exceptfds) { for (i = 0; i < numfds; i++) { @@ -111,6 +91,26 @@ _select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, curthread->poll_data.nfds = MAX(128, fd_count); } } + /* Check if a timeout was specified: */ + if (timeout) { + if (timeout->tv_sec < 0 || + timeout->tv_usec < 0 || timeout->tv_usec >= 1000000) { + errno = EINVAL; + return (-1); + } + + /* Convert the timeval to a timespec: */ + TIMEVAL_TO_TIMESPEC(timeout, &ts); + + /* Set the wake up time: */ + _thread_kern_set_timeout(&ts); + if (ts.tv_sec == 0 && ts.tv_nsec == 0) + f_wait = 0; + } else { + /* Wait for ever: */ + _thread_kern_set_timeout(NULL); + } + if (ret == 0) { /* Setup the wait data. */ data.fds = curthread->poll_data.fds; |