[PATCH 2/4] server: Don't block when reading from named pipes in PIPE_NOWAIT mode.
Brendan Shanks
bshanks at codeweavers.com
Tue Oct 1 11:16:58 CDT 2019
Fixes Rockstar Games Launcher hanging for some users.
Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
---
dlls/kernel32/tests/pipe.c | 4 ++--
server/named_pipe.c | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c
index 227575ece3..7f2a6adca1 100644
--- a/dlls/kernel32/tests/pipe.c
+++ b/dlls/kernel32/tests/pipe.c
@@ -3937,8 +3937,8 @@ static void test_nowait(void)
hThread = CreateThread(NULL, 0, test_nowait_read_thread, &pipewrite, 0, NULL);
ok(hThread != NULL, "CreateThread failed. %d\n", GetLastError());
SetLastError(0xdeadbeef);
- todo_wine ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL) == FALSE, "ReadFile should fail\n");
- todo_wine ok(GetLastError() == ERROR_NO_DATA, "got %d should be ERROR_NO_DATA\n", GetLastError());
+ ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL) == FALSE, "ReadFile should fail\n");
+ ok(GetLastError() == ERROR_NO_DATA, "got %d should be ERROR_NO_DATA\n", GetLastError());
ok(WaitForSingleObject(hThread,INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject\n");
ok(CloseHandle(hThread), "CloseHandle for the thread failed\n");
ok(CloseHandle(pipewrite), "CloseHandle for the write pipe failed\n");
diff --git a/server/named_pipe.c b/server/named_pipe.c
index 8e0380d060..6926712b8c 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -851,6 +851,11 @@ static int pipe_end_read( struct fd *fd, struct async *async, file_pos_t pos )
switch (pipe_end->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;
case FILE_PIPE_DISCONNECTED_STATE:
set_error( STATUS_PIPE_DISCONNECTED );
--
2.17.1
More information about the wine-devel
mailing list