server: Improve FSCTL_PIPE_PEEK error handling.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2018-08-08 22:00:41 +02:00 committed by Alexandre Julliard
parent 8e5bc0daf7
commit 0973b8d2c3
3 changed files with 10 additions and 5 deletions

View file

@ -214,7 +214,6 @@ static void test_CreateNamedPipe(int pipemode)
test_signaled(hnp);
ret = PeekNamedPipe(hnp, NULL, 0, NULL, &readden, NULL);
todo_wine
ok(!ret && GetLastError() == ERROR_BAD_PIPE, "PeekNamedPipe returned %x (%u)\n",
ret, GetLastError());
@ -1463,7 +1462,6 @@ static int test_DisconnectNamedPipe(void)
ok(!ret && GetLastError() == ERROR_PIPE_NOT_CONNECTED, "PeekNamedPipe returned %x (%u)\n",
ret, GetLastError());
ret = PeekNamedPipe(hnp, NULL, 0, NULL, &readden, NULL);
todo_wine
ok(!ret && GetLastError() == ERROR_BAD_PIPE, "PeekNamedPipe returned %x (%u)\n",
ret, GetLastError());
ok(CloseHandle(hFile), "CloseHandle\n");

View file

@ -1286,7 +1286,7 @@ static void test_pipe_state(HANDLE pipe, BOOL is_server, DWORD state)
expected_status = STATUS_PIPE_BROKEN;
break;
}
todo_wine_if(expected_status && expected_status != STATUS_PIPE_BROKEN)
todo_wine_if(expected_status == STATUS_BUFFER_OVERFLOW || expected_status == STATUS_PIPE_DISCONNECTED)
ok(status == expected_status, "status = %x, expected %x in %s state %u\n",
status, expected_status, is_server ? "server" : "client", state);
if (!status)
@ -1397,7 +1397,7 @@ static void test_pipe_with_data_state(HANDLE pipe, BOOL is_server, DWORD state)
expected_status = STATUS_BUFFER_OVERFLOW;
break;
}
todo_wine
todo_wine_if(expected_status == STATUS_BUFFER_OVERFLOW || expected_status == STATUS_PIPE_DISCONNECTED)
ok(status == expected_status, "status = %x, expected %x in %s state %u\n",
status, expected_status, is_server ? "server" : "client", state);
if (status == STATUS_BUFFER_OVERFLOW)

View file

@ -868,10 +868,17 @@ static int pipe_end_peek( struct pipe_end *pipe_end )
}
reply_size -= offsetof( FILE_PIPE_PEEK_BUFFER, Data );
if (!pipe_end->connection && list_empty( &pipe_end->message_queue ))
switch (pipe_end->state)
{
case FILE_PIPE_CONNECTED_STATE:
break;
case FILE_PIPE_CLOSING_STATE:
if (!list_empty( &pipe_end->message_queue )) break;
set_error( STATUS_PIPE_BROKEN );
return 0;
default:
set_error( STATUS_INVALID_PIPE_STATE );
return 0;
}
LIST_FOR_EACH_ENTRY( message, &pipe_end->message_queue, struct pipe_message, entry )