Jacek Caban : server: Improve named pipe read error handling.
Alexandre Julliard
julliard at winehq.org
Wed Aug 15 14:39:54 CDT 2018
Module: wine
Branch: master
Commit: 91852564dc7f51ac8f18be600905d4aff4b156de
URL: https://source.winehq.org/git/wine.git/?a=commit;h=91852564dc7f51ac8f18be600905d4aff4b156de
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Aug 8 22:00:48 2018 +0200
server: Improve named pipe read error handling.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/tests/pipe.c | 2 --
server/named_pipe.c | 12 +++++++++++-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/tests/pipe.c b/dlls/ntdll/tests/pipe.c
index 67141f1..a2ef008 100644
--- a/dlls/ntdll/tests/pipe.c
+++ b/dlls/ntdll/tests/pipe.c
@@ -1338,7 +1338,6 @@ static void test_pipe_state(HANDLE pipe, BOOL is_server, DWORD state)
break;
}
status = NtReadFile(pipe, NULL, NULL, NULL, &io, buf, 1, NULL, NULL);
- todo_wine_if(state == FILE_PIPE_DISCONNECTED_STATE && !is_server)
ok(status == expected_status, "NtReadFile failed in %s state %u: %x\n",
is_server ? "server" : "client", state, status);
}
@@ -1427,7 +1426,6 @@ static void test_pipe_with_data_state(HANDLE pipe, BOOL is_server, DWORD state)
if (state == FILE_PIPE_CLOSING_STATE)
expected_status = STATUS_SUCCESS;
status = NtReadFile(pipe, NULL, NULL, NULL, &io, buf, 1, NULL, NULL);
- todo_wine_if(state == FILE_PIPE_DISCONNECTED_STATE && status != STATUS_PIPE_DISCONNECTED)
ok(status == expected_status, "NtReadFile failed in %s state %u: %x\n",
is_server ? "server" : "client", state, status);
}
diff --git a/server/named_pipe.c b/server/named_pipe.c
index cb74051..425a369 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -798,8 +798,18 @@ static int pipe_end_read( struct fd *fd, struct async *async, file_pos_t pos )
{
struct pipe_end *pipe_end = get_fd_user( fd );
- if (!pipe_end->connection && list_empty( &pipe_end->message_queue ))
+ switch (pipe_end->state)
{
+ case FILE_PIPE_CONNECTED_STATE:
+ break;
+ case FILE_PIPE_DISCONNECTED_STATE:
+ set_error( STATUS_PIPE_DISCONNECTED );
+ return 0;
+ case FILE_PIPE_LISTENING_STATE:
+ set_error( STATUS_PIPE_LISTENING );
+ return 0;
+ case FILE_PIPE_CLOSING_STATE:
+ if (!list_empty( &pipe_end->message_queue )) break;
set_error( STATUS_PIPE_BROKEN );
return 0;
}
More information about the wine-cvs
mailing list