diff options
author | Christopher Faylor <me@cgf.cx> | 2011-02-21 06:18:30 +0300 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2011-02-21 06:18:30 +0300 |
commit | 05901e6aee8af35b4d4d24bdefe2d307a86398aa (patch) | |
tree | d9203c619707321f69cf82e6a10a4392e399667b /winsup/cygwin/fhandler.cc | |
parent | 734e1c50ff010a2c7aaab6bdcdb3e7756574f7da (diff) |
* fhandler.cc (fhandler_base_overlapped::close): Finish any pending I/O before
closing.
(fhandler_base_overlapped::wait_overlapped): Defensively zero bytes read. Add
more info to debugging output.
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r-- | winsup/cygwin/fhandler.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 2ff6827be..cea9c1bb0 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1046,6 +1046,12 @@ fhandler_base::close () int fhandler_base_overlapped::close () { + if (is_nonblocking () && io_pending) + { + DWORD bytes; + set_nonblocking (false); + wait_overlapped (1, !!(get_access () & GENERIC_WRITE), &bytes); + } destroy_overlapped (); return fhandler_base::close (); } @@ -1749,6 +1755,7 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte DWORD wfres = WaitForMultipleObjects (n, w4, false, INFINITE); if (wfres != WAIT_OBJECT_0) CancelIo (h); + *bytes = 0; BOOL wores = GetOverlappedResult (h, get_overlapped (), bytes, false); bool signalled = !wores && (wfres == WAIT_OBJECT_0 + 1); if (signalled) @@ -1762,7 +1769,7 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte else if (!wores) { err = GetLastError (); - debug_printf ("GetOverLappedResult failed"); + debug_printf ("GetOverLappedResult failed, bytes %u", *bytes); } else { |