]> sourceware.org Git - newlib-cygwin.git/commitdiff
* fhandler.cc (handler_base_overlapped::wait_overlapped): Rework to attempt to
authorChristopher Faylor <me@cgf.cx>
Sat, 28 May 2011 18:49:13 +0000 (18:49 +0000)
committerChristopher Faylor <me@cgf.cx>
Sat, 28 May 2011 18:49:13 +0000 (18:49 +0000)
properly set errno and bytes read for non-blocking case.  Change to just rely
on res to indicate error conditions.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler.cc

index a3ce468c0c3520e1bb74abb12a90afeea3c81c3c..422d1e7367076f6304c28aba4b5f27d89ed6b6d5 100644 (file)
@@ -1,3 +1,9 @@
+2011-05-28  Christopher Faylor  <me.cygwin2011@cgf.cx>
+
+       * fhandler.cc (handler_base_overlapped::wait_overlapped): Rework to
+       attempt to properly set errno and bytes read for non-blocking case.
+       Change to just rely on res to indicate error conditions.
+
 2011-05-28  Christopher Faylor  <me.cygwin2011@cgf.cx>
 
        * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Don't set
index e5f5371cb7bf12d6a51b26e04824eb6887d176f5..ea0ca31b9fe090fe3016da5cf6f86f66f2d3d64a 100644 (file)
@@ -1810,15 +1810,21 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
   DWORD err = GetLastError ();
   if (nonblocking)
     {
-      if (!inres && err != ERROR_IO_PENDING)
+      if (inres)
+       res = overlapped_success;
+      else if (err != ERROR_IO_PENDING)
        res = overlapped_error;
       else
        {
-         io_pending = !inres && err == ERROR_IO_PENDING;
-         if (writing && !inres)
+         if (writing)
            *bytes = len;
+         else
+           {
+             set_errno (EAGAIN);
+             *bytes = (DWORD) -1;
+           }
          res = overlapped_success;
-         err = 0;
+         io_pending = true;
        }
     }
   else if (!inres && err != ERROR_IO_PENDING)
@@ -1849,9 +1855,8 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
            {
              set_errno (EINTR);
              res = overlapped_error;
+             err = 0;
            }
-         *bytes = (DWORD) -1;
-         err = 0;
        }
       else if (canceled)
        pthread::static_cancel_self ();
@@ -1863,13 +1868,12 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
        }
       else
        {
-         err = 0;
          debug_printf ("normal %s, %u bytes", writing ? "write" : "read", *bytes);
          res = overlapped_success;
        }
     }
 
-  if (!err)
+  if (res != overlapped_error)
     /* nothing to do */;
   else if (err == ERROR_HANDLE_EOF || err == ERROR_BROKEN_PIPE)
     {
@@ -1883,7 +1887,8 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
       HANDLE h = writing ? get_output_handle () : get_handle ();
       CancelIo (h);
       ResetEvent (get_overlapped ());
-      __seterrno_from_win_error (err);
+      if (err)
+       __seterrno_from_win_error (err);
       *bytes = (DWORD) -1;
     }
 
This page took 0.036246 seconds and 5 git commands to generate.