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
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2008-12-21 04:54:32 +0300
committerChristopher Faylor <me@cgf.cx>2008-12-21 04:54:32 +0300
commit91ad1942a2ec19a654bce314c185ee1c8db8d18f (patch)
tree5385db195da267d6bf9a1a87b07697e95c83c9b2
parent0cf888799b6874ba6a341af9dec8d4ce72f69f49 (diff)
* pipe.cc (getov_result): Add parameters to facilitate better EOF checking.
(pipe_handler): Pass extra arguments to getov_result.
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/pipe.cc14
2 files changed, 15 insertions, 5 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 2d12203e7..9ce596289 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,11 @@
2008-12-20 Christopher Faylor <me+cygwin@cgf.cx>
+ * pipe.cc (getov_result): Add parameters to facilitate better EOF
+ checking.
+ (pipe_handler): Pass extra arguments to getov_result.
+
+2008-12-20 Christopher Faylor <me+cygwin@cgf.cx>
+
* fhandler.cc (fhandler_base::wait_overlapped): Reorganize to eliminate
gotos and to hopefully eliminate one race when a signal is detected or
there is a WFMO error.
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 5f4717b0d..5b5a55aa6 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -39,10 +39,14 @@ struct pipesync
};
inline bool
-getov_result (HANDLE h, DWORD& nbytes, LPOVERLAPPED ov)
+getov_result (BOOL res, bool reading, HANDLE h, DWORD& nbytes, LPOVERLAPPED ov)
{
- if (ov && (GetLastError () != ERROR_IO_PENDING
- || !GetOverlappedResult (h, ov, &nbytes, true)))
+ DWORD err = GetLastError ();
+ if (res || (reading && ov && !res && err == ERROR_HANDLE_EOF))
+ /* not an error */;
+ else if (!ov || (err != ERROR_IO_PENDING)
+ || (!GetOverlappedResult (h, ov, &nbytes, true)
+ && (!reading || (GetLastError () != ERROR_HANDLE_EOF))))
{
__seterrno ();
return false;
@@ -91,13 +95,13 @@ pipe_handler (LPVOID in_ps)
{
ResetEvent (ov.hEvent);
BOOL res = ReadFile (hread, buf, 4096, &read_bytes, rov);
- if (!res && !getov_result (hread, read_bytes, rov))
+ if (!getov_result (res, true, hread, read_bytes, rov))
break;
if (!read_bytes)
break;
res = WriteFile (hwrite, buf, read_bytes, &write_bytes, wov);
- if (!res && !getov_result (hwrite, write_bytes, wov))
+ if (!getov_result (res, false, hwrite, write_bytes, wov))
break;
if (write_bytes != read_bytes)
break;