From: Paul Gofman Subject: [PATCH v2 2/6] winhttp: Count queued websocket receive operations. Message-Id: <20220126131419.1337268-2-pgofman@codeweavers.com> Date: Wed, 26 Jan 2022 16:14:15 +0300 In-Reply-To: <20220126131419.1337268-1-pgofman@codeweavers.com> References: <20220126131419.1337268-1-pgofman@codeweavers.com> Signed-off-by: Paul Gofman --- v2: - no changes. 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.34.1