Delay setting wakeup time until after poll array has been allocated.

Blocking on the malloc spinlock would cause the select timeout to be lost.
This commit is contained in:
Tor Egge 2006-10-13 20:04:13 +00:00
parent ed5348ec19
commit c8b69d87c0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=163322

View File

@ -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;