Alexandre Julliard : rpcrt4: Properly handle the case of a client having disconnected in rpcrt4_conn_listen_pipe .
Module: wine Branch: master Commit: 853db9a79dd9fff15a608b7d2b702a15ebc15bc2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=853db9a79dd9fff15a608b7d2b... Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Jun 9 12:56:42 2008 +0200 rpcrt4: Properly handle the case of a client having disconnected in rpcrt4_conn_listen_pipe. --- dlls/rpcrt4/rpc_transport.c | 35 ++++++++++++++++++++++------------- 1 files changed, 22 insertions(+), 13 deletions(-) diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c index 8bca0fe..86c4e4f 100644 --- a/dlls/rpcrt4/rpc_transport.c +++ b/dlls/rpcrt4/rpc_transport.c @@ -118,20 +118,29 @@ static RPC_STATUS rpcrt4_conn_listen_pipe(RpcConnection_np *npc) return RPC_S_OK; npc->listening = TRUE; - if (ConnectNamedPipe(npc->pipe, &npc->ovl)) - return RPC_S_OK; + for (;;) + { + if (ConnectNamedPipe(npc->pipe, &npc->ovl)) + return RPC_S_OK; - if (GetLastError() == ERROR_PIPE_CONNECTED) { - SetEvent(npc->ovl.hEvent); - return RPC_S_OK; - } - if (GetLastError() == ERROR_IO_PENDING) { - /* will be completed in rpcrt4_protseq_np_wait_for_new_connection */ - return RPC_S_OK; + switch(GetLastError()) + { + case ERROR_PIPE_CONNECTED: + SetEvent(npc->ovl.hEvent); + return RPC_S_OK; + case ERROR_IO_PENDING: + /* will be completed in rpcrt4_protseq_np_wait_for_new_connection */ + return RPC_S_OK; + case ERROR_NO_DATA_DETECTED: + /* client has disconnected, retry */ + DisconnectNamedPipe( npc->pipe ); + break; + default: + npc->listening = FALSE; + WARN("Couldn't ConnectNamedPipe (error was %d)\n", GetLastError()); + return RPC_S_OUT_OF_RESOURCES; + } } - npc->listening = FALSE; - WARN("Couldn't ConnectNamedPipe (error was %d)\n", GetLastError()); - return RPC_S_OUT_OF_RESOURCES; } static RPC_STATUS rpcrt4_conn_create_pipe(RpcConnection *Connection, LPCSTR pname)
participants (1)
-
Alexandre Julliard