* fhandler.cc (fhandler_base::wait_overlapped): Handle read EOF better and

issue a SIGPIPE when we get ERROR_NO_DATA.
This commit is contained in:
Christopher Faylor 2007-07-29 17:24:54 +00:00
parent 9d017bd09c
commit 5990b3399c
2 changed files with 26 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2007-07-29 Christopher Faylor <me+cygwin@cgf.cx>
* fhandler.cc (fhandler_base::wait_overlapped): Handle read EOF better
and issue a SIGPIPE when we get ERROR_NO_DATA.
2007-07-29 Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Don't allow

View File

@ -1699,8 +1699,15 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
{
if (bytes)
*bytes = (DWORD) -1;
if (!res && GetLastError () != ERROR_IO_PENDING)
__seterrno ();
DWORD err = GetLastError ();
if (!res && err != ERROR_IO_PENDING)
{
if (err != ERROR_HANDLE_EOF && err != ERROR_BROKEN_PIPE)
goto err;
res = 1;
if (*bytes)
*bytes = 0;
}
else
{
#ifdef DEBUGGING
@ -1723,8 +1730,8 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
res = 1;
else
{
__seterrno ();
res = -1;
err = GetLastError ();
goto err;
}
break;
case WAIT_OBJECT_0 + 1:
@ -1733,11 +1740,19 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
res = 0;
break;
default:
__seterrno ();
res = -1;
err = GetLastError ();
goto err;
break;
}
}
goto out;
err:
__seterrno_from_win_error (err);
res = -1;
if (err == ERROR_NO_DATA)
raise (SIGPIPE);
out:
ResetEvent (get_overlapped ()->hEvent);
return res;
}