summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-03-12 21:29:36 +0000
committerChristopher Faylor <me@cgf.cx>2012-03-12 21:29:36 +0000
commit3617fc885911df0e436ff03ae944316d23052506 (patch)
tree706d686c2e679b0c10c78e68112cd0734fbcc326 /winsup/cygwin/fhandler.cc
parent6c95669d23c27bad29a47a70ff2dec7136f6cdf6 (diff)
downloadcygnal-3617fc885911df0e436ff03ae944316d23052506.tar.gz
cygnal-3617fc885911df0e436ff03ae944316d23052506.tar.bz2
cygnal-3617fc885911df0e436ff03ae944316d23052506.zip
Christopher Faylor <me.cygwin2012@cgf.cx>
* fhandler.h (wait_return): Add overlapped_nullread. * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Detect zero-byte read as a special case. (fhandler_base_overlapped::raw_read): Keep looping when zero-byte read detected without EOF. (fhandler_base_overlapped::raw_write): Quiet gcc warning by adding overlapped_nullread to switch statement even though it will never actually be hit.
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r--winsup/cygwin/fhandler.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index d0210f83b..a22fe2496 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1982,7 +1982,11 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
}
if (res == overlapped_success)
- debug_printf ("normal %s, %u bytes", writing ? "write" : "read", *bytes);
+ {
+ debug_printf ("normal %s, %u bytes ispipe() %d", writing ? "write" : "read", *bytes, ispipe ());
+ if (*bytes == 0 && !writing && ispipe ())
+ res = overlapped_nullread;
+ }
else if (res == overlapped_nonblocking_no_data)
{
*bytes = (DWORD) -1;
@@ -2020,6 +2024,9 @@ fhandler_base_overlapped::raw_read (void *ptr, size_t& len)
get_overlapped ());
switch (wait_overlapped (res, false, &nbytes, is_nonblocking ()))
{
+ case overlapped_nullread:
+ keep_looping = true;
+ break;
default: /* Added to quiet gcc */
case overlapped_success:
case overlapped_error:
@@ -2076,6 +2083,7 @@ fhandler_base_overlapped::raw_write (const void *ptr, size_t len)
case overlapped_error:
len = 0; /* terminate loop */
case overlapped_unknown:
+ case overlapped_nullread:
case overlapped_nonblocking_no_data:
break;
}