Commit e4ca5dbe authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

server: Add new pipe servers to the end of the servers list.

This ensures instances created first will be connected to first. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41670Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 22b304fd
......@@ -3671,6 +3671,43 @@ static void test_namedpipe_session_id(void)
CloseHandle(server);
}
static void test_multiple_instances(void)
{
HANDLE server[2], client;
int i;
BOOL ret;
OVERLAPPED ov;
for (i = 0; i < ARRAY_SIZE(server); i++)
{
server[i] = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_READMODE_BYTE | PIPE_WAIT, 2, 1024, 1024,
NMPWAIT_USE_DEFAULT_WAIT, NULL);
ok(server[i] != INVALID_HANDLE_VALUE, "got invalid handle\n");
}
client = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(client != INVALID_HANDLE_VALUE, "got invalid handle\n");
/* Show that this has connected to server[0] not server[1] */
memset(&ov, 0, sizeof(ov));
ret = ConnectNamedPipe(server[1], &ov);
ok(ret == FALSE, "got %d\n", ret);
ok(GetLastError() == ERROR_IO_PENDING, "got %d\n", GetLastError());
memset(&ov, 0, sizeof(ov));
ret = ConnectNamedPipe(server[0], &ov);
ok(ret == FALSE, "got %d\n", ret);
ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %d\n", GetLastError());
DisconnectNamedPipe(server[1]);
DisconnectNamedPipe(server[0]);
CloseHandle(client);
CloseHandle(server[1]);
CloseHandle(server[0]);
}
START_TEST(pipe)
{
char **argv;
......@@ -3736,4 +3773,5 @@ START_TEST(pipe)
test_TransactNamedPipe();
test_namedpipe_process_id();
test_namedpipe_session_id();
test_multiple_instances();
}
......@@ -1162,7 +1162,7 @@ static struct pipe_server *create_pipe_server( struct named_pipe *pipe, unsigned
server->pipe_end.server_pid = get_process_id( current->process );
init_async_queue( &server->listen_q );
list_add_head( &pipe->servers, &server->entry );
list_add_tail( &pipe->servers, &server->entry );
if (!(server->pipe_end.fd = alloc_pseudo_fd( &pipe_server_fd_ops, &server->pipe_end.obj, options )))
{
release_object( server );
......
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