Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/winhttp/request.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index ff2c18c469b..10c1beb0d2b 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -3591,6 +3591,8 @@ static DWORD receive_close_status( struct socket *socket, unsigned int len )
static DWORD handle_control_frame( struct socket *socket ) { + DWORD ret; + TRACE( "opcode %u.\n", socket->opcode );
switch (socket->opcode) @@ -3602,7 +3604,7 @@ static DWORD handle_control_frame( struct socket *socket ) return socket_drain( socket );
case SOCKET_OPCODE_CLOSE: - if (socket->state != SOCKET_STATE_CLOSED) + if (socket->state < SOCKET_STATE_SHUTDOWN) WARN( "SOCKET_OPCODE_CLOSE received, socket->state %u.\n", socket->state ); if (socket->close_frame_received) { @@ -3610,9 +3612,9 @@ static DWORD handle_control_frame( struct socket *socket ) return ERROR_WINHTTP_INVALID_SERVER_RESPONSE; }
- receive_close_status( socket, socket->read_size ); + ret = receive_close_status( socket, socket->read_size ); socket->read_size = 0; - return ERROR_WINHTTP_INVALID_SERVER_RESPONSE; + return ret;
default: ERR("unhandled control opcode %02x\n", socket->opcode); @@ -3654,7 +3656,8 @@ static DWORD socket_receive( struct socket *socket, void *buf, DWORD len, DWORD { if (!(ret = receive_frame( socket, &socket->read_size, &socket->opcode ))) { - if (!(socket->opcode & CONTROL_BIT) || (ret = handle_control_frame( socket ))) break; + if (!(socket->opcode & CONTROL_BIT) || (ret = handle_control_frame( socket )) + || socket->opcode == SOCKET_OPCODE_CLOSE) break; } else if (ret == WSAETIMEDOUT) ret = socket_send_pong( socket ); if (ret) break;
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/winhttp/tests/notification.c | 110 +++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-)
diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c index 1ae7e1af2e7..6545a1d92fe 100644 --- a/dlls/winhttp/tests/notification.c +++ b/dlls/winhttp/tests/notification.c @@ -707,6 +707,30 @@ static const struct notification websocket_test2[] = { 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 }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL } +}; + +static const struct notification websocket_test3[] = +{ + { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, NF_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, NF_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE, NF_SIGNAL }, + { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE }, + { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED }, + { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE, NF_SIGNAL }, + { winhttp_websocket_complete_upgrade, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, NF_SIGNAL }, + { winhttp_websocket_receive, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL }, + + { 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_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 }, { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL } @@ -996,7 +1020,7 @@ static void test_websocket(BOOL secure) ok( err == ERROR_SUCCESS, "got %u\n", err );
setup_test( &info, winhttp_websocket_close, __LINE__ ); - ret = pWinHttpWebSocketClose( socket, 1000, (void *)"success", sizeof("success") ); + err = pWinHttpWebSocketClose( socket, 1000, (void *)"success", sizeof("success") ); ok( err == ERROR_SUCCESS, "got %u\n", err ); ok( info.buflen == sizeof(*result), "got unexpected buflen %u.\n", info.buflen ); result = (WINHTTP_WEB_SOCKET_ASYNC_RESULT *)info.buffer; @@ -1022,6 +1046,90 @@ static void test_websocket(BOOL secure) ok( close_status == 1000, "got %u\n", close_status ); ok( size <= sizeof(buffer), "got %u\n", size );
+ setup_test( &info, winhttp_close_handle, __LINE__ ); + WinHttpCloseHandle( socket ); + WinHttpCloseHandle( request ); + + WaitForSingleObject( info.wait, INFINITE ); + end_test( &info, __LINE__ ); + + /* Test socket shutdown while receive is pending. */ + info.test = websocket_test3; + info.count = ARRAY_SIZE( websocket_test3 ); + info.index = 0; + + setup_test( &info, winhttp_open_request, __LINE__ ); + request = WinHttpOpenRequest( connection, NULL, L"/", NULL, NULL, NULL, secure ? WINHTTP_FLAG_SECURE : 0); + ok( request != NULL, "got %u\n", err ); + + if (secure) + { + flags = SECURITY_FLAG_IGNORE_UNKNOWN_CA | SECURITY_FLAG_IGNORE_CERT_DATE_INVALID | + SECURITY_FLAG_IGNORE_CERT_CN_INVALID; + ret = WinHttpSetOption(request, WINHTTP_OPTION_SECURITY_FLAGS, &flags, sizeof(flags)); + ok(ret, "failed to set security flags %u\n", GetLastError()); + } + + ret = WinHttpSetOption( request, WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET, NULL, 0 ); + ok( ret, "got %u\n", GetLastError() ); + + setup_test( &info, winhttp_send_request, __LINE__ ); + ret = WinHttpSendRequest( request, NULL, 0, NULL, 0, 0, 0 ); + ok( ret, "got %u\n", GetLastError() ); + WaitForSingleObject( info.wait, INFINITE ); + + setup_test( &info, winhttp_receive_response, __LINE__ ); + ret = WinHttpReceiveResponse( request, NULL ); + ok( ret, "got %u\n", err ); + WaitForSingleObject( info.wait, INFINITE ); + + size = sizeof(status); + ret = WinHttpQueryHeaders( request, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL ); + ok( ret, "failed unexpectedly %u\n", err ); + ok( status == 101, "got %u\n", status ); + + setup_test( &info, winhttp_websocket_complete_upgrade, __LINE__ ); + socket = pWinHttpWebSocketCompleteUpgrade( request, (DWORD_PTR)context ); + ok( socket != NULL, "got %u\n", err ); + WaitForSingleObject( info.wait, INFINITE ); + + setup_test( &info, winhttp_websocket_receive, __LINE__ ); + buffer[0] = 0; + err = pWinHttpWebSocketReceive( socket, buffer, sizeof(buffer), &size, &type ); + ok( err == ERROR_SUCCESS, "got %u\n", err ); + WaitForSingleObject( info.wait, INFINITE ); + ok( buffer[0] == 'R', "unexpected data\n" ); + + err = pWinHttpWebSocketReceive( socket, buffer, sizeof(buffer), &size, &type ); + ok( err == ERROR_SUCCESS, "got %u\n", err ); + + setup_test( &info, winhttp_websocket_shutdown, __LINE__ ); + ws_status = (WINHTTP_WEB_SOCKET_STATUS *)info.buffer; + ws_status->eBufferType = ~0u; + err = pWinHttpWebSocketShutdown( socket, 1000, (void *)"success", sizeof("success") ); + ok( err == ERROR_SUCCESS, "got %u\n", err ); + + close_status = 0xdead; + size = sizeof(buffer) + 1; + err = pWinHttpWebSocketQueryCloseStatus( socket, &close_status, buffer, sizeof(buffer), &size ); + ok( err == ERROR_INVALID_OPERATION, "got %u\n", err ); + ok( close_status == 0xdead, "got %u\n", close_status ); + ok( size == sizeof(buffer) + 1, "got %u\n", size ); + + WaitForSingleObject( info.wait, INFINITE ); + + ok( info.buflen == sizeof(*ws_status), "got unexpected buflen %u.\n", info.buflen ); + ok( ws_status->eBufferType == WINHTTP_WEB_SOCKET_CLOSE_BUFFER_TYPE, "Got unexpected eBufferType %u.\n", + ws_status->eBufferType ); + ok( !ws_status->dwBytesTransferred, "got unexpected dwBytesTransferred %u.\n", ws_status->dwBytesTransferred ); + + close_status = 0xdead; + size = sizeof(buffer) + 1; + err = pWinHttpWebSocketQueryCloseStatus( socket, &close_status, buffer, sizeof(buffer), &size ); + todo_wine ok( err == ERROR_SUCCESS, "got %u\n", err ); + todo_wine ok( close_status == 1000, "got %u\n", close_status ); + todo_wine ok( size <= sizeof(buffer), "got %u\n", size ); + setup_test( &info, winhttp_close_handle, __LINE__ );
WinHttpCloseHandle( socket );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=106252
Your paranoid android.
=== w8adm (32 bit report) ===
winhttp: notification.c:256: Test failed: failed to send request 12007 notification.c:258: Test failed: unexpected function 3, expected 4. probably some notifications were missing notification.c:260: Test failed: failed to receive response 12019 notification.c:264: Test failed: failed unexpectedly 12019 notification.c:265: Test failed: request failed unexpectedly 0 notification.c:268: Test failed: unexpected function 3, expected 13. probably some notifications were missing notification.c:116: Test failed: 268: expected status 0x00000002 got 0x00000800 notification.c:117: Test failed: 268: expected function 3 got 13 notification: Timeout
Signed-off-by: Hans Leidekker hans@codeweavers.com
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/winhttp/request.c | 5 ----- dlls/winhttp/tests/notification.c | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 10c1beb0d2b..8e13e678e22 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -3991,11 +3991,6 @@ DWORD WINAPI WinHttpWebSocketQueryCloseStatus( HINTERNET hsocket, USHORT *status release_object( &socket->hdr ); return ERROR_WINHTTP_INCORRECT_HANDLE_TYPE; } - if (socket->state < SOCKET_STATE_CLOSED) - { - release_object( &socket->hdr ); - return ERROR_INVALID_OPERATION; - }
if (!socket->close_frame_received || socket->close_frame_receive_err) { diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c index 6545a1d92fe..1ae1bb537b0 100644 --- a/dlls/winhttp/tests/notification.c +++ b/dlls/winhttp/tests/notification.c @@ -1126,9 +1126,9 @@ static void test_websocket(BOOL secure) close_status = 0xdead; size = sizeof(buffer) + 1; err = pWinHttpWebSocketQueryCloseStatus( socket, &close_status, buffer, sizeof(buffer), &size ); - todo_wine ok( err == ERROR_SUCCESS, "got %u\n", err ); - todo_wine ok( close_status == 1000, "got %u\n", close_status ); - todo_wine ok( size <= sizeof(buffer), "got %u\n", size ); + ok( err == ERROR_SUCCESS, "got %u\n", err ); + ok( close_status == 1000, "got %u\n", close_status ); + ok( size <= sizeof(buffer), "got %u\n", size );
setup_test( &info, winhttp_close_handle, __LINE__ );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=106253
Your paranoid android.
=== w8adm (32 bit report) ===
winhttp: notification.c:256: Test failed: failed to send request 12007 notification.c:258: Test failed: unexpected function 3, expected 4. probably some notifications were missing notification.c:260: Test failed: failed to receive response 12019 notification.c:264: Test failed: failed unexpectedly 12019 notification.c:265: Test failed: request failed unexpectedly 0 notification.c:268: Test failed: unexpected function 3, expected 13. probably some notifications were missing notification.c:116: Test failed: 268: expected status 0x00000002 got 0x00000800 notification.c:117: Test failed: 268: expected function 3 got 13 notification: Timeout
Signed-off-by: Hans Leidekker hans@codeweavers.com
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/winhttp/request.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 8e13e678e22..5568f04d0d0 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -3886,24 +3886,29 @@ static DWORD socket_close( struct socket *socket ) return receive_close_status( socket, count ); }
-static void CALLBACK task_socket_close( TP_CALLBACK_INSTANCE *instance, void *ctx, TP_WORK *work ) +static void socket_close_complete( struct socket *socket, DWORD ret ) { - struct socket_shutdown *s = ctx; - DWORD ret; - - ret = socket_close( s->socket ); - - if (!ret) send_callback( &s->socket->hdr, WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE, NULL, 0 ); + if (!ret) send_callback( &socket->hdr, WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE, NULL, 0 ); else { WINHTTP_WEB_SOCKET_ASYNC_RESULT result; result.AsyncResult.dwResult = API_READ_DATA; /* FIXME */ result.AsyncResult.dwError = ret; result.Operation = WINHTTP_WEB_SOCKET_CLOSE_OPERATION; - send_callback( &s->socket->hdr, WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, &result, sizeof(result) ); + send_callback( &socket->hdr, WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, &result, sizeof(result) ); } +} + +static void CALLBACK task_socket_close( TP_CALLBACK_INSTANCE *instance, void *ctx, TP_WORK *work ) +{ + struct socket_shutdown *s = ctx; + DWORD ret;
TRACE("running %p\n", work); + + ret = socket_close( s->socket ); + socket_close_complete( s->socket, ret ); + release_object( &s->socket->hdr ); free( s ); }
Signed-off-by: Hans Leidekker hans@codeweavers.com
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/winhttp/request.c | 7 +++++++ dlls/winhttp/tests/notification.c | 10 ++++++++++ 2 files changed, 17 insertions(+)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 5568f04d0d0..04df90f74d7 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -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; diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c index 1ae1bb537b0..3dc94a909b4 100644 --- a/dlls/winhttp/tests/notification.c +++ b/dlls/winhttp/tests/notification.c @@ -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 );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=106255
Your paranoid android.
=== w8adm (32 bit report) ===
winhttp: notification.c:256: Test failed: failed to send request 12007 notification.c:258: Test failed: unexpected function 3, expected 4. probably some notifications were missing notification.c:260: Test failed: failed to receive response 12019 notification.c:264: Test failed: failed unexpectedly 12019 notification.c:265: Test failed: request failed unexpectedly 0 notification.c:268: Test failed: unexpected function 3, expected 13. probably some notifications were missing notification.c:116: Test failed: 268: expected status 0x00000002 got 0x00000800 notification.c:117: Test failed: 268: expected function 3 got 13 notification: Timeout
=== debian11 (64 bit WoW report) ===
winhttp: notification.c:116: Test failed: 994: expected status 0x00000008 got 0x00200000 notification: Timeout
Signed-off-by: Hans Leidekker hans@codeweavers.com
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/winhttp/request.c | 14 ++++++++++++-- dlls/winhttp/tests/notification.c | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 04df90f74d7..a61355da7b9 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -3287,6 +3287,16 @@ static BOOL receive_io_complete( struct socket *socket ) return count >= 0; }
+static BOOL socket_can_send( struct socket *socket ) +{ + return socket->state == SOCKET_STATE_OPEN && !socket->close_frame_received; +} + +static BOOL socket_can_receive( struct socket *socket ) +{ + return socket->state <= SOCKET_STATE_SHUTDOWN && !socket->close_frame_received; +} + static enum socket_opcode map_buffer_type( WINHTTP_WEB_SOCKET_BUFFER_TYPE type ) { switch (type) @@ -3364,7 +3374,7 @@ DWORD WINAPI WinHttpWebSocketSend( HINTERNET hsocket, WINHTTP_WEB_SOCKET_BUFFER_ release_object( &socket->hdr ); return ERROR_WINHTTP_INCORRECT_HANDLE_TYPE; } - if (socket->state != SOCKET_STATE_OPEN) + if (!socket_can_send( socket )) { release_object( &socket->hdr ); return ERROR_INVALID_OPERATION; @@ -3723,7 +3733,7 @@ DWORD WINAPI WinHttpWebSocketReceive( HINTERNET hsocket, void *buf, DWORD len, D release_object( &socket->hdr ); return ERROR_WINHTTP_INCORRECT_HANDLE_TYPE; } - if (socket->state > SOCKET_STATE_SHUTDOWN) + if (!socket_can_receive( socket )) { release_object( &socket->hdr ); return ERROR_INVALID_OPERATION; diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c index 3dc94a909b4..fabc5a03a46 100644 --- a/dlls/winhttp/tests/notification.c +++ b/dlls/winhttp/tests/notification.c @@ -1132,6 +1132,9 @@ static void test_websocket(BOOL secure) ok( close_status == 1000, "got %u\n", close_status ); ok( size <= sizeof(buffer), "got %u\n", size );
+ err = pWinHttpWebSocketReceive( socket, buffer, sizeof(buffer), &size, &type ); + ok( err == ERROR_INVALID_OPERATION, "got %u\n", err ); + info.buflen = 0xdeadbeef; setup_test( &info, winhttp_websocket_close, __LINE__ ); err = pWinHttpWebSocketClose( socket, 1000, (void *)"success", sizeof("success") );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=106256
Your paranoid android.
=== w8adm (32 bit report) ===
winhttp: notification.c:256: Test failed: failed to send request 12007 notification.c:258: Test failed: unexpected function 3, expected 4. probably some notifications were missing notification.c:260: Test failed: failed to receive response 12019 notification.c:264: Test failed: failed unexpectedly 12019 notification.c:265: Test failed: request failed unexpectedly 0 notification.c:268: Test failed: unexpected function 3, expected 13. probably some notifications were missing notification.c:116: Test failed: 268: expected status 0x00000002 got 0x00000800 notification.c:117: Test failed: 268: expected function 3 got 13 notification: Timeout
Signed-off-by: Hans Leidekker hans@codeweavers.com
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/winhttp/request.c | 15 +++++++++++++-- dlls/winhttp/tests/notification.c | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index a61355da7b9..728b1895ba7 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -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 ); diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c index fabc5a03a46..121190ba9d2 100644 --- a/dlls/winhttp/tests/notification.c +++ b/dlls/winhttp/tests/notification.c @@ -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;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=106257
Your paranoid android.
=== w8adm (32 bit report) ===
winhttp: notification.c:256: Test failed: failed to send request 12007 notification.c:258: Test failed: unexpected function 3, expected 4. probably some notifications were missing notification.c:260: Test failed: failed to receive response 12019 notification.c:264: Test failed: failed unexpectedly 12019 notification.c:265: Test failed: request failed unexpectedly 0 notification.c:268: Test failed: unexpected function 3, expected 13. probably some notifications were missing notification.c:116: Test failed: 268: expected status 0x00000002 got 0x00000800 notification.c:117: Test failed: 268: expected function 3 got 13 notification: Timeout
Signed-off-by: Hans Leidekker hans@codeweavers.com