4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-18 12:29:32 +08:00

* 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.
This commit is contained in:
Christopher Faylor 2011-05-28 18:49:13 +00:00
parent d1dded4d67
commit beaedec545
2 changed files with 20 additions and 9 deletions

View 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> 2011-05-28 Christopher Faylor <me.cygwin2011@cgf.cx>
* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Don't set * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Don't set

View File

@ -1810,15 +1810,21 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
DWORD err = GetLastError (); DWORD err = GetLastError ();
if (nonblocking) if (nonblocking)
{ {
if (!inres && err != ERROR_IO_PENDING) if (inres)
res = overlapped_success;
else if (err != ERROR_IO_PENDING)
res = overlapped_error; res = overlapped_error;
else else
{ {
io_pending = !inres && err == ERROR_IO_PENDING; if (writing)
if (writing && !inres)
*bytes = len; *bytes = len;
else
{
set_errno (EAGAIN);
*bytes = (DWORD) -1;
}
res = overlapped_success; res = overlapped_success;
err = 0; io_pending = true;
} }
} }
else if (!inres && err != ERROR_IO_PENDING) 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); set_errno (EINTR);
res = overlapped_error; res = overlapped_error;
err = 0;
} }
*bytes = (DWORD) -1;
err = 0;
} }
else if (canceled) else if (canceled)
pthread::static_cancel_self (); pthread::static_cancel_self ();
@ -1863,13 +1868,12 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
} }
else else
{ {
err = 0;
debug_printf ("normal %s, %u bytes", writing ? "write" : "read", *bytes); debug_printf ("normal %s, %u bytes", writing ? "write" : "read", *bytes);
res = overlapped_success; res = overlapped_success;
} }
} }
if (!err) if (res != overlapped_error)
/* nothing to do */; /* nothing to do */;
else if (err == ERROR_HANDLE_EOF || err == ERROR_BROKEN_PIPE) 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 (); HANDLE h = writing ? get_output_handle () : get_handle ();
CancelIo (h); CancelIo (h);
ResetEvent (get_overlapped ()); ResetEvent (get_overlapped ());
__seterrno_from_win_error (err); if (err)
__seterrno_from_win_error (err);
*bytes = (DWORD) -1; *bytes = (DWORD) -1;
} }