winhttp: Don't queue socket_close() in WinHttpWebSocketClose() if close frame is already received.

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:
Paul Gofman 2022-01-28 02:06:29 +03:00 committed by Alexandre Julliard
parent 1c9ea6cd94
commit 41ea7fb0e1
2 changed files with 17 additions and 0 deletions

View File

@ -3959,6 +3959,13 @@ DWORD WINAPI WinHttpWebSocketClose( HINTERNET hsocket, USHORT status, void *reas
if (prev_state < SOCKET_STATE_SHUTDOWN
&& (ret = send_socket_shutdown( socket, status, reason, len, FALSE ))) goto done;
if (!pending_receives && socket->close_frame_received)
{
if (socket->request->connect->hdr.flags & WINHTTP_FLAG_ASYNC)
socket_close_complete( socket, socket->close_frame_receive_err );
goto done;
}
if (socket->request->connect->hdr.flags & WINHTTP_FLAG_ASYNC)
{
struct socket_shutdown *s;

View File

@ -728,6 +728,8 @@ static const struct notification websocket_test3[] =
{ winhttp_websocket_shutdown, WINHTTP_CALLBACK_STATUS_SHUTDOWN_COMPLETE, NF_MAIN_THREAD },
{ winhttp_websocket_shutdown, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SAVE_BUFFER | NF_SIGNAL },
{ winhttp_websocket_close, WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE,
NF_MAIN_THREAD| NF_SAVE_BUFFER | NF_SIGNAL },
{ winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING },
{ winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, NF_WINE_ALLOW },
{ winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, NF_WINE_ALLOW },
@ -1130,6 +1132,14 @@ static void test_websocket(BOOL secure)
ok( close_status == 1000, "got %u\n", close_status );
ok( size <= sizeof(buffer), "got %u\n", size );
info.buflen = 0xdeadbeef;
setup_test( &info, winhttp_websocket_close, __LINE__ );
err = pWinHttpWebSocketClose( socket, 1000, (void *)"success", sizeof("success") );
ok( err == ERROR_SUCCESS, "got %u\n", err );
WaitForSingleObject( info.wait, INFINITE );
ok( !info.buflen, "Got unexpected buflen %u.\n", info.buflen );
setup_test( &info, winhttp_close_handle, __LINE__ );
WinHttpCloseHandle( socket );