Commit 6d7d9226 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

winhttp: Use lock when attempting to send frame synchronously().

parent e41b3529
......@@ -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)
{
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment