diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index fcc1d11f8..34d37d8f3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,15 @@ +2012-03-12 Corinna Vinschen + Christopher Faylor + + * 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. + 2012-03-10 Christopher Faylor * dtable.cc (fh_alloc): Treat pc.dev as unsigned. 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; } diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 3b186bd8b..3eeb4d561 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -629,6 +629,7 @@ protected: overlapped_unknown = 0, overlapped_success, overlapped_nonblocking_no_data, + overlapped_nullread, overlapped_error }; bool io_pending;