]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: check for STATUS_PENDING in fhandler_base::raw_read
authorKen Brown <kbrown@cornell.edu>
Sun, 14 Apr 2019 19:15:59 +0000 (19:15 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 16 Apr 2019 10:54:43 +0000 (12:54 +0200)
If NtReadFile returns STATUS_PENDING, wait for the read to complete.
This can happen, for instance, in the case of a FIFO opened with
O_RDRW.

winsup/cygwin/fhandler.cc

index b0c9c50c317d078b718c13a2b9322cace67cdad6..a0c3dcce2473165fa451929d689a862938ccc8f1 100644 (file)
@@ -215,11 +215,23 @@ fhandler_base::raw_read (void *ptr, size_t& len)
   NTSTATUS status;
   IO_STATUS_BLOCK io;
   int try_noreserve = 1;
+  DWORD waitret = WAIT_OBJECT_0;
 
 retry:
   status = NtReadFile (get_handle (), NULL, NULL, NULL, &io, ptr, len,
                       NULL, NULL);
-  if (NT_SUCCESS (status))
+  if (status == STATUS_PENDING)
+    {
+      waitret = cygwait (get_handle (), cw_infinite,
+                        cw_cancel | cw_sig_eintr);
+      if (waitret == WAIT_OBJECT_0)
+       status = io.Status;
+    }
+  if (waitret == WAIT_CANCELED)
+    pthread::static_cancel_self ();
+  else if (waitret == WAIT_SIGNALED)
+    set_errno (EINTR);
+  else if (NT_SUCCESS (status))
     len = io.Information;
   else
     {
This page took 0.033845 seconds and 5 git commands to generate.