Commit abb1ce10 authored by Brendan Shanks's avatar Brendan Shanks Committed by Alexandre Julliard

server: Don't block when reading from named pipes in PIPE_NOWAIT mode.

Fixes Rockstar Games Launcher hanging for some users. Signed-off-by: 's avatarBrendan Shanks <bshanks@codeweavers.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 11a554ee
...@@ -3910,7 +3910,7 @@ static void test_nowait(void) ...@@ -3910,7 +3910,7 @@ static void test_nowait(void)
ol.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL); ol.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ok(ReadFile(piperead, readbuf, sizeof(readbuf), &read, &ol) == FALSE, "ReadFile should fail\n"); ok(ReadFile(piperead, readbuf, sizeof(readbuf), &read, &ol) == FALSE, "ReadFile should fail\n");
todo_wine ok(GetLastError() == ERROR_NO_DATA, "got %d should be ERROR_NO_DATA\n", GetLastError()); ok(GetLastError() == ERROR_NO_DATA, "got %d should be ERROR_NO_DATA\n", GetLastError());
if (GetLastError() == ERROR_IO_PENDING) if (GetLastError() == ERROR_IO_PENDING)
CancelIo(piperead); CancelIo(piperead);
......
...@@ -851,6 +851,11 @@ static int pipe_end_read( struct fd *fd, struct async *async, file_pos_t pos ) ...@@ -851,6 +851,11 @@ static int pipe_end_read( struct fd *fd, struct async *async, file_pos_t pos )
switch (pipe_end->state) switch (pipe_end->state)
{ {
case FILE_PIPE_CONNECTED_STATE: case FILE_PIPE_CONNECTED_STATE:
if ((pipe_end->flags & NAMED_PIPE_NONBLOCKING_MODE) && list_empty( &pipe_end->message_queue ))
{
set_error( STATUS_PIPE_EMPTY );
return 0;
}
break; break;
case FILE_PIPE_DISCONNECTED_STATE: case FILE_PIPE_DISCONNECTED_STATE:
set_error( STATUS_PIPE_DISCONNECTED ); set_error( STATUS_PIPE_DISCONNECTED );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment