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

Alexandre Julliard julliard at winehq.org
Wed Oct 16 16:59:29 CDT 2019


Module: wine
Branch: master
Commit: abb1ce10870d12ce5752abce81fd50bddf236180
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=abb1ce10870d12ce5752abce81fd50bddf236180

Author: Brendan Shanks <bshanks at codeweavers.com>
Date:   Wed Oct 16 14:50:02 2019 +0200

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

Fixes Rockstar Games Launcher hanging for some users.

Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/pipe.c | 2 +-
 server/named_pipe.c        | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c
index 0980c4ef8c..02df7374c8 100644
--- a/dlls/kernel32/tests/pipe.c
+++ b/dlls/kernel32/tests/pipe.c
@@ -3910,7 +3910,7 @@ static void test_nowait(void)
     ol.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
     SetLastError(0xdeadbeef);
     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)
         CancelIo(piperead);
 
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 );




More information about the wine-cvs mailing list