Commit dd1769a1 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

server: Improve error handling of disconnected named pipe clients.

parent 0fe08b79
...@@ -1506,7 +1506,6 @@ static int test_DisconnectNamedPipe(void) ...@@ -1506,7 +1506,6 @@ static int test_DisconnectNamedPipe(void)
ok(ret == WAIT_TIMEOUT, "WaitForSingleObject returned %X\n", ret); ok(ret == WAIT_TIMEOUT, "WaitForSingleObject returned %X\n", ret);
ret = PeekNamedPipe(hFile, NULL, 0, NULL, &readden, NULL); ret = PeekNamedPipe(hFile, NULL, 0, NULL, &readden, NULL);
todo_wine
ok(!ret && GetLastError() == ERROR_PIPE_NOT_CONNECTED, "PeekNamedPipe returned %x (%u)\n", ok(!ret && GetLastError() == ERROR_PIPE_NOT_CONNECTED, "PeekNamedPipe returned %x (%u)\n",
ret, GetLastError()); ret, GetLastError());
ret = PeekNamedPipe(hnp, NULL, 0, NULL, &readden, NULL); ret = PeekNamedPipe(hnp, NULL, 0, NULL, &readden, NULL);
......
...@@ -1348,7 +1348,6 @@ static void test_pipe_state(HANDLE pipe, BOOL is_server, DWORD state) ...@@ -1348,7 +1348,6 @@ static void test_pipe_state(HANDLE pipe, BOOL is_server, DWORD state)
expected_status = STATUS_PIPE_BROKEN; expected_status = STATUS_PIPE_BROKEN;
break; break;
} }
todo_wine_if(expected_status == STATUS_PIPE_DISCONNECTED)
ok(status == expected_status, "status = %x, expected %x in %s state %u\n", ok(status == expected_status, "status = %x, expected %x in %s state %u\n",
status, expected_status, is_server ? "server" : "client", state); status, expected_status, is_server ? "server" : "client", state);
if (!status) if (!status)
...@@ -1363,7 +1362,6 @@ static void test_pipe_state(HANDLE pipe, BOOL is_server, DWORD state) ...@@ -1363,7 +1362,6 @@ static void test_pipe_state(HANDLE pipe, BOOL is_server, DWORD state)
buf, 1, buf+1, 1); buf, 1, buf+1, 1);
if (!status || status == STATUS_PENDING) if (!status || status == STATUS_PENDING)
status = io.Status; status = io.Status;
todo_wine_if(expected_status == STATUS_PIPE_DISCONNECTED)
ok(status == expected_status, ok(status == expected_status,
"NtFsControlFile(FSCTL_PIPE_TRANSCEIVE) failed in %s state %u: %x\n", "NtFsControlFile(FSCTL_PIPE_TRANSCEIVE) failed in %s state %u: %x\n",
is_server ? "server" : "client", state, status); is_server ? "server" : "client", state, status);
...@@ -1373,7 +1371,6 @@ static void test_pipe_state(HANDLE pipe, BOOL is_server, DWORD state) ...@@ -1373,7 +1371,6 @@ static void test_pipe_state(HANDLE pipe, BOOL is_server, DWORD state)
status = NtFlushBuffersFile(pipe, &io); status = NtFlushBuffersFile(pipe, &io);
if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE) if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE)
{ {
todo_wine
ok(status == STATUS_PIPE_DISCONNECTED, "status = %x in %s state %u\n", ok(status == STATUS_PIPE_DISCONNECTED, "status = %x in %s state %u\n",
status, is_server ? "server" : "client", state); status, is_server ? "server" : "client", state);
} }
...@@ -1472,7 +1469,6 @@ static void test_pipe_with_data_state(HANDLE pipe, BOOL is_server, DWORD state) ...@@ -1472,7 +1469,6 @@ static void test_pipe_with_data_state(HANDLE pipe, BOOL is_server, DWORD state)
expected_status = STATUS_BUFFER_OVERFLOW; expected_status = STATUS_BUFFER_OVERFLOW;
break; break;
} }
todo_wine_if(expected_status == STATUS_PIPE_DISCONNECTED)
ok(status == expected_status, "status = %x, expected %x in %s state %u\n", ok(status == expected_status, "status = %x, expected %x in %s state %u\n",
status, expected_status, is_server ? "server" : "client", state); status, expected_status, is_server ? "server" : "client", state);
if (status == STATUS_BUFFER_OVERFLOW) if (status == STATUS_BUFFER_OVERFLOW)
......
...@@ -501,6 +501,12 @@ static int pipe_end_flush( struct fd *fd, struct async *async ) ...@@ -501,6 +501,12 @@ static int pipe_end_flush( struct fd *fd, struct async *async )
{ {
struct pipe_end *pipe_end = get_fd_user( fd ); struct pipe_end *pipe_end = get_fd_user( fd );
if (!pipe_end->pipe)
{
set_error( STATUS_PIPE_DISCONNECTED );
return 0;
}
if (pipe_end->connection && !list_empty( &pipe_end->connection->message_queue )) if (pipe_end->connection && !list_empty( &pipe_end->connection->message_queue ))
{ {
fd_queue_async( pipe_end->fd, async, ASYNC_TYPE_WAIT ); fd_queue_async( pipe_end->fd, async, ASYNC_TYPE_WAIT );
...@@ -888,7 +894,7 @@ static int pipe_end_peek( struct pipe_end *pipe_end ) ...@@ -888,7 +894,7 @@ static int pipe_end_peek( struct pipe_end *pipe_end )
set_error( STATUS_PIPE_BROKEN ); set_error( STATUS_PIPE_BROKEN );
return 0; return 0;
default: default:
set_error( STATUS_INVALID_PIPE_STATE ); set_error( pipe_end->pipe ? STATUS_INVALID_PIPE_STATE : STATUS_PIPE_DISCONNECTED );
return 0; return 0;
} }
...@@ -932,7 +938,7 @@ static int pipe_end_transceive( struct pipe_end *pipe_end, struct async *async ) ...@@ -932,7 +938,7 @@ static int pipe_end_transceive( struct pipe_end *pipe_end, struct async *async )
if (!pipe_end->connection) if (!pipe_end->connection)
{ {
set_error( STATUS_INVALID_PIPE_STATE ); set_error( pipe_end->pipe ? STATUS_INVALID_PIPE_STATE : STATUS_PIPE_DISCONNECTED );
return 0; return 0;
} }
......
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