[PATCH v2 2/5] winhttp: Count queued websocket receive operations.

Hans Leidekker hans at codeweavers.com
Wed Jan 26 08:25:21 CST 2022


From: Paul Gofman <pgofman at codeweavers.com>

Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/winhttp/request.c         | 9 +++++++++
 dlls/winhttp/winhttp_private.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index bddbf4a03b2..7666bae4e68 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -3244,6 +3244,12 @@ static void send_io_complete( struct object_header *hdr )
     assert( count >= 0 );
 }
 
+static void receive_io_complete( struct socket *socket )
+{
+    LONG count = InterlockedDecrement( &socket->hdr.pending_receives );
+    assert( count >= 0 );
+}
+
 static enum socket_opcode map_buffer_type( WINHTTP_WEB_SOCKET_BUFFER_TYPE type )
 {
     switch (type)
@@ -3614,6 +3620,7 @@ static void CALLBACK task_socket_receive( TP_CALLBACK_INSTANCE *instance, void *
 
     TRACE("running %p\n", work);
     ret = socket_receive( r->socket, r->buf, r->len, &count, &type );
+    receive_io_complete( r->socket );
 
     if (!ret)
     {
@@ -3667,8 +3674,10 @@ DWORD WINAPI WinHttpWebSocketReceive( HINTERNET hsocket, void *buf, DWORD len, D
         r->len    = len;
 
         addref_object( &socket->hdr );
+        InterlockedIncrement( &socket->hdr.pending_receives );
         if ((ret = queue_task( &socket->recv_q, task_socket_receive, r )))
         {
+            InterlockedDecrement( &socket->hdr.pending_receives );
             release_object( &socket->hdr );
             free( r );
         }
diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h
index 5eb3e97a916..a6638aba30f 100644
--- a/dlls/winhttp/winhttp_private.h
+++ b/dlls/winhttp/winhttp_private.h
@@ -52,6 +52,7 @@ struct object_header
     LONG recursion_count;
     struct list entry;
     volatile LONG pending_sends;
+    volatile LONG pending_receives;
 };
 
 struct hostdata
-- 
2.30.2




More information about the wine-devel mailing list