From 1ae0cd1335fd4874c7d3291e397d665cb4a19477 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Tue, 27 Jan 2009 05:21:08 +0000 Subject: [PATCH] * fhandler.cc (fhandler_base::wait_overlapped): Set bytes to -1 on EINTR or real error. (fhandler_base::write_overlapped): Assume that bytes_written will contain proper error value. * pipe.cc (fhandler_pipe::fhandler_pipe): Set uninterruptible_io since signals are handled by pipe functions now. --- winsup/cygwin/ChangeLog | 9 +++++++++ winsup/cygwin/fhandler.cc | 9 +++++---- winsup/cygwin/pipe.cc | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 59876c61a..8924885df 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2009-01-27 Christopher Faylor + + * fhandler.cc (fhandler_base::wait_overlapped): Set bytes to -1 on + EINTR or real error. + (fhandler_base::write_overlapped): Assume that bytes_written will + contain proper error value. + * pipe.cc (fhandler_pipe::fhandler_pipe): Set uninterruptible_io since + signals are handled by pipe functions now. + 2009-01-26 Corinna Vinschen * shared.cc (shared_name): New function for WCHAR names. diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index cb2877dd8..d1f21ec23 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1697,7 +1697,7 @@ fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes) return inres; int res = 0; - *bytes = (DWORD) -1; + DWORD err; if (inres || ((err = GetLastError ()) == ERROR_IO_PENDING)) { @@ -1722,6 +1722,7 @@ fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes) { debug_printf ("got a signal"); set_errno (EINTR); + *bytes = (DWORD) -1; res = 0; err = 0; } @@ -1732,7 +1733,7 @@ fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes) } else { - debug_printf ("normal read"); + debug_printf ("normal %s, %u bytes", writing ? "write" : "read", *bytes); res = 1; err = 0; } @@ -1744,6 +1745,7 @@ fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes) { debug_printf ("err %u", err); __seterrno_from_win_error (err); + *bytes = (DWORD) -1; res = -1; } else @@ -1787,10 +1789,9 @@ fhandler_base::write_overlapped (const void *ptr, size_t len) bool res = WriteFile (get_output_handle (), ptr, len, &bytes_written, get_overlapped ()); int wres = wait_overlapped (res, true, &bytes_written); - if (wres < 0) - return -1; if (wres || !_my_tls.call_signal_handler ()) break; } + debug_printf ("returning %u", bytes_written); return bytes_written; } diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc index 43b34b6f4..787cc398d 100644 --- a/winsup/cygwin/pipe.cc +++ b/winsup/cygwin/pipe.cc @@ -26,6 +26,7 @@ fhandler_pipe::fhandler_pipe () : fhandler_base (), popen_pid (0), overlapped (NULL) { need_fork_fixup (true); + uninterruptible_io (true); } void