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.
This commit is contained in:
Christopher Faylor 2012-03-12 21:29:36 +00:00
parent 6c95669d23
commit 3617fc8859
3 changed files with 22 additions and 1 deletions

View File

@ -1,3 +1,15 @@
2012-03-12 Corinna Vinschen <corinna@vinschen.de>
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.
2012-03-10 Christopher Faylor <me.cygwin2012@cgf.cx> 2012-03-10 Christopher Faylor <me.cygwin2012@cgf.cx>
* dtable.cc (fh_alloc): Treat pc.dev as unsigned. * dtable.cc (fh_alloc): Treat pc.dev as unsigned.

View File

@ -1982,7 +1982,11 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
} }
if (res == overlapped_success) 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) else if (res == overlapped_nonblocking_no_data)
{ {
*bytes = (DWORD) -1; *bytes = (DWORD) -1;
@ -2020,6 +2024,9 @@ fhandler_base_overlapped::raw_read (void *ptr, size_t& len)
get_overlapped ()); get_overlapped ());
switch (wait_overlapped (res, false, &nbytes, is_nonblocking ())) switch (wait_overlapped (res, false, &nbytes, is_nonblocking ()))
{ {
case overlapped_nullread:
keep_looping = true;
break;
default: /* Added to quiet gcc */ default: /* Added to quiet gcc */
case overlapped_success: case overlapped_success:
case overlapped_error: case overlapped_error:
@ -2076,6 +2083,7 @@ fhandler_base_overlapped::raw_write (const void *ptr, size_t len)
case overlapped_error: case overlapped_error:
len = 0; /* terminate loop */ len = 0; /* terminate loop */
case overlapped_unknown: case overlapped_unknown:
case overlapped_nullread:
case overlapped_nonblocking_no_data: case overlapped_nonblocking_no_data:
break; break;
} }

View File

@ -629,6 +629,7 @@ protected:
overlapped_unknown = 0, overlapped_unknown = 0,
overlapped_success, overlapped_success,
overlapped_nonblocking_no_data, overlapped_nonblocking_no_data,
overlapped_nullread,
overlapped_error overlapped_error
}; };
bool io_pending; bool io_pending;