Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2011-05-28 22:49:13 +0400
committerChristopher Faylor <me@cgf.cx>2011-05-28 22:49:13 +0400
commitbeaedec5453dec03fa3646f9c98847aaf4c2d9f4 (patch)
tree1d5b51e7816591e800aae44430e2627ca8c387dd /winsup
parentd1dded4d6738981418cf1461cd4c52622bd2361b (diff)
* 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.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/fhandler.cc23
2 files changed, 20 insertions, 9 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index a3ce468c0..422d1e736 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,11 @@
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
io_pending unless ReadFile has returned an error. (this is a partial fix,
accidentally checked in)
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index e5f5371cb..ea0ca31b9 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -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;
}