From: Miles Bader Date: Tue, 5 Mar 1996 00:07:01 +0000 (+0000) Subject: (__select): Don't increment GOT only because READ/WRITE/EXCEPTFDS is 0! Don't... X-Git-Tag: upstream/2.30~29634 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e9ef1cf37a4d067c730b1df5c7a3fed3fdf06044;p=external%2Fglibc.git (__select): Don't increment GOT only because READ/WRITE/EXCEPTFDS is 0! Don't return without frobbing the bitmasks after a timeout. When clearing the bitmasks, only loop from FIRSTFD to LASTFD. --- diff --git a/sysdeps/mach/hurd/select.c b/sysdeps/mach/hurd/select.c index 58818a7..001a28b 100644 --- a/sysdeps/mach/hurd/select.c +++ b/sysdeps/mach/hurd/select.c @@ -244,13 +244,13 @@ DEFUN(__select, (nfds, readfds, writefds, exceptfds, timeout), } } - if (err == MACH_RCV_TIMED_OUT) - /* This is the normal value for ERR. We might have timed out and - read no messages. Otherwise, after receiving the first message, - we poll for more messages. We receive with a timeout of 0 to - effect a poll, so ERR is MACH_RCV_TIMED_OUT when the poll finds no - message waiting. */ - err = 0; + if (err == MACH_RCV_TIMED_OUT) + /* This is the normal value for ERR. We might have timed out and + read no messages. Otherwise, after receiving the first message, + we poll for more messages. We receive with a timeout of 0 to + effect a poll, so ERR is MACH_RCV_TIMED_OUT when the poll finds no + message waiting. */ + err = 0; if (got && err == EINTR) /* Some calls were interrupted, but at least one descriptor @@ -266,12 +266,6 @@ DEFUN(__select, (nfds, readfds, writefds, exceptfds, timeout), but the descriptor may have changed to a different server. */ __mach_port_destroy (__mach_task_self (), port); - if (timeout && got == 0 && err == MACH_RCV_TIMED_OUT) - /* No io_select call returned success immediately, and the last call - blocked for our full timeout period and then timed out. So the - multiplex times out too. */ - return 0; - if (err) return __hurd_fail (err); @@ -281,25 +275,25 @@ DEFUN(__select, (nfds, readfds, writefds, exceptfds, timeout), /* Set the user bitarrays. We only ever have to clear bits, as all desired ones are initially set. */ - for (i = 0; i < nfds; ++i) + for (i = firstfd; i < lastfd; ++i) { int type = types[i]; if ((type & SELECT_RETURNED) == 0) type = 0; - if (readfds != NULL && (type & SELECT_READ) == 0) - FD_CLR (i, readfds); - else + if (type & SELECT_READ) got++; - if (writefds != NULL && (type & SELECT_WRITE) == 0) - FD_CLR (i, writefds); else + FD_CLR (i, readfds); + if (type & SELECT_WRITE) got++; - if (exceptfds != NULL && (type & SELECT_URG) == 0) - FD_CLR (i, exceptfds); else + FD_CLR (i, writefds); + if (type & SELECT_URG) got++; + else + FD_CLR (i, exceptfds); } return got;