aboutsummaryrefslogtreecommitdiff
path: root/lib/libc_r
diff options
context:
space:
mode:
authorTor Egge <tegge@FreeBSD.org>2006-10-13 20:04:13 +0000
committerTor Egge <tegge@FreeBSD.org>2006-10-13 20:04:13 +0000
commitc8b69d87c0df659e38dd5bbb187d51b1bf2e448a (patch)
tree18fd986a114924f6824a5e814e2e0c0972cec1cb /lib/libc_r
parented5348ec199a2c5ef4582da5ec06f9f4a468b908 (diff)
downloadsrc-c8b69d87c0df659e38dd5bbb187d51b1bf2e448a.tar.gz
src-c8b69d87c0df659e38dd5bbb187d51b1bf2e448a.zip
Delay setting wakeup time until after poll array has been allocated.
Blocking on the malloc spinlock would cause the select timeout to be lost.
Notes
Notes: svn path=/head/; revision=163322
Diffstat (limited to 'lib/libc_r')
-rw-r--r--lib/libc_r/uthread/uthread_select.c40
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 2776cb2c80fc..b05676950bc2 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;