2006-12-26 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / gdb / mingw-hdep.c
index 79b23dc2556b65669676678069298d81cb0a69c0..2b92a1ce2f8e606d35162e0a931e246788fc6d19 100644 (file)
@@ -105,8 +105,8 @@ gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
         if something starts using it.  */
       gdb_assert (!writefds || !FD_ISSET (fd, writefds));
 
-      if (!FD_ISSET (fd, readfds)
-         && !FD_ISSET (fd, exceptfds))
+      if ((!readfds || !FD_ISSET (fd, readfds))
+         && (!exceptfds || !FD_ISSET (fd, exceptfds)))
        continue;
       h = (HANDLE) _get_osfhandle (fd);
 
@@ -124,13 +124,13 @@ gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
          except = never_handle;
        }
 
-      if (FD_ISSET (fd, readfds))
+      if (readfds && FD_ISSET (fd, readfds))
        {
          gdb_assert (num_handles < MAXIMUM_WAIT_OBJECTS);
          handles[num_handles++] = read;
        }
 
-      if (FD_ISSET (fd, exceptfds))
+      if (exceptfds && FD_ISSET (fd, exceptfds))
        {
          gdb_assert (num_handles < MAXIMUM_WAIT_OBJECTS);
          handles[num_handles++] = except;
@@ -167,8 +167,13 @@ gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
   for (fd = 0, indx = 0; fd < n; ++fd)
     {
       HANDLE fd_h;
+      struct serial *scb;
+
+      if ((!readfds || !FD_ISSET (fd, readfds))
+         && (!exceptfds || !FD_ISSET (fd, exceptfds)))
+       continue;
 
-      if (FD_ISSET (fd, readfds))
+      if (readfds && FD_ISSET (fd, readfds))
        {
          fd_h = handles[indx++];
          /* This handle might be ready, even though it wasn't the handle
@@ -179,7 +184,7 @@ gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
            num_ready++;
        }
 
-      if (FD_ISSET (fd, exceptfds))
+      if (exceptfds && FD_ISSET (fd, exceptfds))
        {
          fd_h = handles[indx++];
          /* This handle might be ready, even though it wasn't the handle
@@ -189,6 +194,12 @@ gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
          else
            num_ready++;
        }
+
+      /* We created at least one event handle for this fd.  Let the
+        device know we are finished with it.  */
+      scb = serial_for_fd (fd);
+      if (scb)
+       serial_done_wait_handle (scb);
     }
 
   return num_ready;
This page took 0.025163 seconds and 4 git commands to generate.