]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: FIFO: improve the interruptibility of raw_read
authorKen Brown <kbrown@cornell.edu>
Mon, 11 May 2020 13:03:37 +0000 (09:03 -0400)
committerKen Brown <kbrown@cornell.edu>
Mon, 11 May 2020 13:52:23 +0000 (09:52 -0400)
During a blocking read, we sleep for 1 ms after each iteration through
the connected writers.  Currently we do this by calling Sleep (1).
Remove this call to Sleep and instead change the timeout in the
cygwait call from 0 to 1, so that raw_read can be interrupted while
sleeping.

winsup/cygwin/fhandler_fifo.cc

index 9cc00d5e7c38b0095fe37c96769c4fec6589ce68..e8a05dfbfd699f10ad1d681705aa3bd64fe313a2 100644 (file)
@@ -1335,8 +1335,8 @@ fhandler_fifo::raw_read (void *in_ptr, size_t& len)
        }
       else
        {
-         /* Allow interruption. */
-         DWORD waitret = cygwait (NULL, cw_nowait, cw_cancel | cw_sig_eintr);
+         /* Allow interruption and don't hog the CPU. */
+         DWORD waitret = cygwait (NULL, 1, cw_cancel | cw_sig_eintr);
          if (waitret == WAIT_CANCELED)
            pthread::static_cancel_self ();
          else if (waitret == WAIT_SIGNALED)
@@ -1356,8 +1356,6 @@ fhandler_fifo::raw_read (void *in_ptr, size_t& len)
          set_errno (EBADF);
          goto errout;
        }
-      /* Don't hog the CPU. */
-      Sleep (1);
     }
 errout:
   len = (size_t) -1;
This page took 0.0314 seconds and 5 git commands to generate.