winhttp: Don't allow queueing websocket receive if another is pending.
Signed-off-by: Paul Gofman <pgofman@codeweavers.com> Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
04fcadacca
commit
d44e752fa2
|
@ -3743,13 +3743,24 @@ DWORD WINAPI WinHttpWebSocketReceive( HINTERNET hsocket, void *buf, DWORD len, D
|
|||
{
|
||||
struct socket_receive *r;
|
||||
|
||||
if (!(r = malloc( sizeof(*r) ))) return FALSE;
|
||||
if (InterlockedIncrement( &socket->hdr.pending_receives ) > 1)
|
||||
{
|
||||
InterlockedDecrement( &socket->hdr.pending_receives );
|
||||
WARN( "Attempt to queue receive while another is pending.\n" );
|
||||
release_object( &socket->hdr );
|
||||
return ERROR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
if (!(r = malloc( sizeof(*r) )))
|
||||
{
|
||||
InterlockedDecrement( &socket->hdr.pending_receives );
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
r->socket = socket;
|
||||
r->buf = buf;
|
||||
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 );
|
||||
|
|
|
@ -1104,6 +1104,8 @@ static void test_websocket(BOOL secure)
|
|||
|
||||
err = pWinHttpWebSocketReceive( socket, buffer, sizeof(buffer), &size, &type );
|
||||
ok( err == ERROR_SUCCESS, "got %u\n", err );
|
||||
err = pWinHttpWebSocketReceive( socket, buffer, sizeof(buffer), &size, &type );
|
||||
ok( err == ERROR_INVALID_OPERATION, "got %u\n", err );
|
||||
|
||||
setup_test( &info, winhttp_websocket_shutdown, __LINE__ );
|
||||
ws_status = (WINHTTP_WEB_SOCKET_STATUS *)info.buffer;
|
||||
|
|
Loading…
Reference in New Issue