Paul Gofman : winhttp: Use lock when attempting to send frame synchronously().
Alexandre Julliard
julliard at winehq.org
Thu Feb 3 16:06:56 CST 2022
Module: wine
Branch: master
Commit: 6d7d92269a7cde33c44db0b19d9af1151f5ad6e5
URL: https://source.winehq.org/git/wine.git/?a=commit;h=6d7d92269a7cde33c44db0b19d9af1151f5ad6e5
Author: Paul Gofman <pgofman at codeweavers.com>
Date: Wed Feb 2 15:38:24 2022 +0300
winhttp: Use lock when attempting to send frame synchronously().
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winhttp/request.c | 15 +++++++++++----
dlls/winhttp/winhttp_private.h | 1 +
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index 728b1895ba7..a3a6389a938 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -3111,6 +3111,7 @@ HINTERNET WINAPI WinHttpWebSocketCompleteUpgrade( HINTERNET hrequest, DWORD_PTR
socket->hdr.callback = request->hdr.callback;
socket->hdr.notify_mask = request->hdr.notify_mask;
socket->hdr.context = context;
+ InitializeSRWLock( &socket->send_lock );
addref_object( &request->hdr );
socket->request = request;
@@ -3391,6 +3392,7 @@ DWORD WINAPI WinHttpWebSocketSend( HINTERNET hsocket, WINHTTP_WEB_SOCKET_BUFFER_
return ERROR_OUTOFMEMORY;
}
+ AcquireSRWLockExclusive( &socket->send_lock );
async_send = InterlockedIncrement( &socket->hdr.pending_sends ) > 1 || socket->hdr.recursion_count >= 3;
if (!async_send)
{
@@ -3419,10 +3421,11 @@ DWORD WINAPI WinHttpWebSocketSend( HINTERNET hsocket, WINHTTP_WEB_SOCKET_BUFFER_
free( s );
}
}
- else
+ else InterlockedDecrement( &socket->hdr.pending_sends );
+ ReleaseSRWLockExclusive( &socket->send_lock );
+ if (!async_send)
{
TRACE("sent sync.\n");
- InterlockedDecrement( &socket->hdr.pending_sends );
free( s );
socket_send_complete( socket, ret, type, len );
ret = ERROR_SUCCESS;
@@ -3535,6 +3538,7 @@ static DWORD socket_send_pong( struct socket *socket )
if (!(s = malloc( sizeof(*s) ))) return ERROR_OUTOFMEMORY;
+ AcquireSRWLockExclusive( &socket->send_lock );
async_send = InterlockedIncrement( &socket->hdr.pending_sends ) > 1;
if (!async_send)
{
@@ -3563,6 +3567,7 @@ static DWORD socket_send_pong( struct socket *socket )
InterlockedDecrement( &socket->hdr.pending_sends );
free( s );
}
+ ReleaseSRWLockExclusive( &socket->send_lock );
return ret;
}
return send_frame( socket, SOCKET_OPCODE_PONG, 0, NULL, 0, TRUE, NULL );
@@ -3817,6 +3822,7 @@ static DWORD send_socket_shutdown( struct socket *socket, USHORT status, const v
if (!(s = malloc( sizeof(*s) ))) return FALSE;
+ AcquireSRWLockExclusive( &socket->send_lock );
async_send = InterlockedIncrement( &socket->hdr.pending_sends ) > 1 || socket->hdr.recursion_count >= 3;
if (!async_send)
{
@@ -3845,9 +3851,10 @@ static DWORD send_socket_shutdown( struct socket *socket, USHORT status, const v
free( s );
}
}
- else
+ else InterlockedDecrement( &socket->hdr.pending_sends );
+ ReleaseSRWLockExclusive( &socket->send_lock );
+ if (!async_send)
{
- InterlockedDecrement( &socket->hdr.pending_sends );
free( s );
if (send_callback)
{
diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h
index 3e4e1eb298d..732f0afaa88 100644
--- a/dlls/winhttp/winhttp_private.h
+++ b/dlls/winhttp/winhttp_private.h
@@ -259,6 +259,7 @@ struct socket
unsigned int send_remaining_size;
unsigned int bytes_in_send_frame_buffer;
unsigned int client_buffer_offset;
+ SRWLOCK send_lock;
};
struct send_request
More information about the wine-cvs
mailing list