* syscalls.cc (dup3): Fix debug typo.

* fhandler.cc (flush_async_io): Assume only called for writer.  Call
GetOverlappedResult directly rather than kluding call to has_ongoing_io.
(fhandler_base_overlapped::close): Only start flush thread when closing write
handle.  Only cancel I/O when reading.
This commit is contained in:
Christopher Faylor 2012-01-31 23:52:52 +00:00
parent 37fbb8a741
commit d3cb1dffef
3 changed files with 19 additions and 8 deletions

View File

@ -1,3 +1,13 @@
2012-01-31 Christopher Faylor <me.cygwin2012@cgf.cx>
* syscalls.cc (dup3): Fix debug typo.
* fhandler.cc (flush_async_io): Assume only called for writer. Call
GetOverlappedResult directly rather than kluding call to
has_ongoing_io.
(fhandler_base_overlapped::close): Only start flush thread when closing
write handle. Only cancel I/O when reading.
2012-01-28 Corinna Vinschen <corinna@vinschen.de> 2012-01-28 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Fix order (DATA first). * cygwin.din: Fix order (DATA first).

View File

@ -1156,11 +1156,10 @@ DWORD WINAPI
flush_async_io (void *arg) flush_async_io (void *arg)
{ {
fhandler_base_overlapped *fh = (fhandler_base_overlapped *) arg; fhandler_base_overlapped *fh = (fhandler_base_overlapped *) arg;
debug_only_printf ("waiting for %s I/O for %s", debug_only_printf ("waiting for write I/O for %s", fh->get_name ());
(fh->get_access () & GENERIC_WRITE) ? "write" : "read", DWORD nbytes;
fh->get_name ()); bool res = GetOverlappedResult (fh->get_output_handle (),
SetEvent (fh->get_overlapped ()->hEvent); /* force has_ongoing_io to block */ fh->get_overlapped (), &nbytes, true);
bool res = fh->has_ongoing_io ();
debug_printf ("finished waiting for I/O from %s, res %d", fh->get_name (), debug_printf ("finished waiting for I/O from %s, res %d", fh->get_name (),
res); res);
fh->close (); fh->close ();
@ -1210,9 +1209,10 @@ int
fhandler_base_overlapped::close () fhandler_base_overlapped::close ()
{ {
int res; int res;
int writer = (get_access () & GENERIC_WRITE);
/* Need to treat non-blocking I/O specially because Windows appears to /* Need to treat non-blocking I/O specially because Windows appears to
be brain-dead */ be brain-dead */
if (is_nonblocking () && has_ongoing_io ()) if (writer && is_nonblocking () && has_ongoing_io ())
{ {
clone (HEAP_3_FHANDLER)->check_later (); clone (HEAP_3_FHANDLER)->check_later ();
res = 0; res = 0;
@ -1221,6 +1221,7 @@ fhandler_base_overlapped::close ()
{ {
/* Cancelling seems to be necessary for cases where a reader is /* Cancelling seems to be necessary for cases where a reader is
still executing when a signal handler performs a close. */ still executing when a signal handler performs a close. */
if (!writer)
CancelIo (get_io_handle ()); CancelIo (get_io_handle ());
destroy_overlapped (); destroy_overlapped ();
res = fhandler_base::close (); res = fhandler_base::close ();

View File

@ -163,7 +163,7 @@ dup3 (int oldfd, int newfd, int flags)
} }
else else
res = cygheap->fdtab.dup3 (oldfd, newfd, flags); res = cygheap->fdtab.dup3 (oldfd, newfd, flags);
syscall_printf ("%R = dup2(%d, %d, %p)", res, oldfd, newfd, flags); syscall_printf ("%R = dup3(%d, %d, %p)", res, oldfd, newfd, flags);
return res; return res;
} }