summary refs log tree commit diff
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-03-05 00:07:01 +0000
committerMiles Bader <miles@gnu.org>1996-03-05 00:07:01 +0000
commite9ef1cf37a4d067c730b1df5c7a3fed3fdf06044 (patch)
treed74299851113ea49e8b10f94db303a19d7188abc
parentbba51ac77a00f156da6d02f59d03f708522280bc (diff)
downloadglibc-e9ef1cf37a4d067c730b1df5c7a3fed3fdf06044.tar.gz
glibc-e9ef1cf37a4d067c730b1df5c7a3fed3fdf06044.tar.xz
glibc-e9ef1cf37a4d067c730b1df5c7a3fed3fdf06044.zip
(__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.
-rw-r--r--sysdeps/mach/hurd/select.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/sysdeps/mach/hurd/select.c b/sysdeps/mach/hurd/select.c
index 58818a78d9..001a28b541 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;