Cygwin: FIFO: fix the error checking in raw_read

If the pipe is empty, we can get either ERROR_NO_DATA or
ERROR_PIPE_LISTENING.
This commit is contained in:
Ken Brown 2019-04-14 19:15:58 +00:00 committed by Corinna Vinschen
parent 0c72e766e2
commit 513f050cbf

View File

@ -749,19 +749,16 @@ fhandler_fifo::raw_read (void *in_ptr, size_t& len)
fifo_client_unlock (); fifo_client_unlock ();
return; return;
} }
/* In the duplex case with no data, we seem to get nread /* If the pipe is empty, we usually get nread == -1 with
== -1 with ERROR_PIPE_LISTENING on the first attempt to ERROR_NO_DATA or ERROR_PIPE_LISTENING. An exception is
read from the duplex pipe (fc_handler[0]), and nread == 0 that in the duplex case we may get nread == 0 when we
on subsequent attempts. */ attempt to read from the duplex pipe (fc_handler[0]). */
else if (nread < 0) else if (nread < 0)
switch (GetLastError ()) switch (GetLastError ())
{ {
case ERROR_NO_DATA: case ERROR_NO_DATA:
break;
case ERROR_PIPE_LISTENING: case ERROR_PIPE_LISTENING:
if (_duplexer && i == 0) break;
break;
/* Fall through. */
default: default:
fifo_client_unlock (); fifo_client_unlock ();
goto errout; goto errout;