[PATCH 4/4] server: Don't block ConnectNamedPipe when pipe is in PIPE_NOWAIT mode.

Brendan Shanks bshanks at codeweavers.com
Tue Oct 1 11:17:00 CDT 2019


Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
---
 dlls/kernel32/tests/pipe.c | 12 ++++++------
 server/named_pipe.c        |  6 ++++++
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c
index d5e516fe7d..e018c557bc 100644
--- a/dlls/kernel32/tests/pipe.c
+++ b/dlls/kernel32/tests/pipe.c
@@ -3974,21 +3974,21 @@ static void test_nowait(void)
     hThread = CreateThread(NULL, 0, test_nowait_connect_thread, NULL, 0, NULL);
     ok(hThread != NULL, "CreateThread failed. %d\n", GetLastError());
     SetLastError(0xdeadbeef);
-    todo_wine ok(ConnectNamedPipe(pipewrite,NULL) == FALSE, "ConnectNamedPipe should fail\n");
-    todo_wine ok(GetLastError() == ERROR_PIPE_LISTENING, "got %d should be ERROR_PIPE_LISTENING\n", GetLastError());
+    ok(ConnectNamedPipe(pipewrite,NULL) == FALSE, "ConnectNamedPipe should fail\n");
+    ok(GetLastError() == ERROR_PIPE_LISTENING, "got %d should be ERROR_PIPE_LISTENING\n", GetLastError());
     /* wait for thread to finish (connects and disconnects), then test ConnectNamedPipe again */
     ok(WaitForSingleObject(hThread,INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject\n");
     ok(CloseHandle(hThread), "CloseHandle for the thread failed\n");
     SetLastError(0xdeadbeef);
-    todo_wine ok(ConnectNamedPipe(pipewrite,NULL) == FALSE, "ConnectNamedPipe should fail\n");
-    todo_wine ok(GetLastError() == ERROR_NO_DATA, "got %d should be ERROR_NO_DATA\n", GetLastError());
+    ok(ConnectNamedPipe(pipewrite,NULL) == FALSE, "ConnectNamedPipe should fail\n");
+    ok(GetLastError() == ERROR_NO_DATA, "got %d should be ERROR_NO_DATA\n", GetLastError());
     /* call DisconnectNamedPipe and test ConnectNamedPipe again */
     ok(DisconnectNamedPipe(pipewrite) == TRUE, "DisconnectNamedPipe should succeed\n");
     hThread = CreateThread(NULL, 0, test_nowait_connect_thread, NULL, 0, NULL);
     ok(hThread != NULL, "CreateThread failed. %d\n", GetLastError());
     SetLastError(0xdeadbeef);
-    todo_wine ok(ConnectNamedPipe(pipewrite,NULL) == FALSE, "ConnectNamedPipe should fail\n");
-    todo_wine ok(GetLastError() == ERROR_PIPE_LISTENING, "got %d should be ERROR_PIPE_LISTENING\n", GetLastError());
+    ok(ConnectNamedPipe(pipewrite,NULL) == FALSE, "ConnectNamedPipe should fail\n");
+    ok(GetLastError() == ERROR_PIPE_LISTENING, "got %d should be ERROR_PIPE_LISTENING\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 d5716f1a1a..e4f7a89aa3 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -1102,6 +1102,12 @@ static int pipe_server_ioctl( struct fd *fd, ioctl_code_t code, struct async *as
             return 0;
         }
 
+        if (server->pipe_end.flags & NAMED_PIPE_NONBLOCKING_MODE)
+        {
+            set_error( STATUS_PIPE_LISTENING );
+            return 0;
+        }
+
         queue_async( &server->listen_q, async );
         async_wake_up( &server->pipe_end.pipe->waiters, STATUS_SUCCESS );
         set_error( STATUS_PENDING );
-- 
2.17.1




More information about the wine-devel mailing list