Dmitry Timoshkov : rpcrt4: Reimplement rpcrt4_conn_np_wait_for_incoming_data() using asynchronous read with zero sized buffer.

Alexandre Julliard julliard at winehq.org
Wed Sep 25 16:45:20 CDT 2019


Module: wine
Branch: master
Commit: a6fe4f6e65e595ffcba625d22a62e340c5e22e62
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a6fe4f6e65e595ffcba625d22a62e340c5e22e62

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Wed Sep 25 15:25:20 2019 +0800

rpcrt4: Reimplement rpcrt4_conn_np_wait_for_incoming_data() using asynchronous read with zero sized buffer.

The problem with NtFsControlFile(FSCTL_PIPE_PEEK) is that it happily returns
STATUS_SUCCESS with 0 bytes of data available. That makes the client think
that the server already sent a reply and try to read the reply data, which
hangs. A solution to this is call NtReadFile() with zero sized buffer, which
has correct behaviour: just waits for incoming data to appear without mangling
the data in the pipe.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/rpcrt4/rpc_transport.c | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)

diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c
index 12d15f8654..243c4780bf 100644
--- a/dlls/rpcrt4/rpc_transport.c
+++ b/dlls/rpcrt4/rpc_transport.c
@@ -465,31 +465,7 @@ static void rpcrt4_conn_np_cancel_call(RpcConnection *conn)
 
 static int rpcrt4_conn_np_wait_for_incoming_data(RpcConnection *conn)
 {
-    RpcConnection_np *connection = (RpcConnection_np *)conn;
-    FILE_PIPE_PEEK_BUFFER buf;
-    HANDLE event;
-    NTSTATUS status;
-    int ret;
-
-    event = get_np_event(connection);
-    if (!event) return -1;
-
-    status = NtFsControlFile(connection->pipe, event, NULL, NULL, &connection->io_status, FSCTL_PIPE_PEEK, NULL, 0, &buf, sizeof(buf));
-    if (status == STATUS_SUCCESS)
-        ret = 0;
-    else if (status == STATUS_PENDING)
-    {
-        WaitForSingleObject(event, INFINITE);
-        ret = 0;
-    }
-    else
-    {
-        WARN("NtFsControlFile error %08x\n", status);
-        ret = -1;
-    }
-
-    release_np_event(connection, event);
-    return ret;
+    return rpcrt4_conn_np_read(conn, NULL, 0);
 }
 
 static size_t rpcrt4_ncacn_np_get_top_of_tower(unsigned char *tower_data,




More information about the wine-cvs mailing list