Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/winhttp/request.c | 54 +++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 25 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index d9c5174f152..51e450c5ff1 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -3650,11 +3650,6 @@ DWORD WINAPI WinHttpWebSocketReceive( HINTERNET hsocket, void *buf, DWORD len, D return ret; }
-static DWORD socket_shutdown( struct socket *socket, USHORT status, const void *reason, DWORD len ) -{ - return send_frame( socket, SOCKET_OPCODE_CLOSE, status, reason, len, TRUE, NULL ); -} - static void CALLBACK task_socket_shutdown( TP_CALLBACK_INSTANCE *instance, void *ctx, TP_WORK *work ) { struct socket_shutdown *s = ctx; @@ -3662,7 +3657,7 @@ static void CALLBACK task_socket_shutdown( TP_CALLBACK_INSTANCE *instance, void
TRACE("running %p\n", work);
- ret = socket_shutdown( s->socket, s->status, s->reason, s->len ); + ret = send_frame( s->socket, SOCKET_OPCODE_CLOSE, s->status, s->reason, s->len, TRUE, NULL ); send_io_complete( &s->socket->hdr );
if (!ret) send_callback( &s->socket->hdr, WINHTTP_CALLBACK_STATUS_SHUTDOWN_COMPLETE, NULL, 0 ); @@ -3679,27 +3674,11 @@ static void CALLBACK task_socket_shutdown( TP_CALLBACK_INSTANCE *instance, void free( s ); }
-DWORD WINAPI WinHttpWebSocketShutdown( HINTERNET hsocket, USHORT status, void *reason, DWORD len ) +static DWORD send_socket_shutdown( struct socket *socket, USHORT status, const void *reason, DWORD len, + BOOL send_callback) { - struct socket *socket; DWORD ret;
- TRACE("%p, %u, %p, %u\n", hsocket, status, reason, len); - - if ((len && !reason) || len > sizeof(socket->reason)) return ERROR_INVALID_PARAMETER; - - if (!(socket = (struct socket *)grab_object( hsocket ))) return ERROR_INVALID_HANDLE; - if (socket->hdr.type != WINHTTP_HANDLE_TYPE_SOCKET) - { - release_object( &socket->hdr ); - return ERROR_WINHTTP_INCORRECT_HANDLE_TYPE; - } - if (socket->state >= SOCKET_STATE_SHUTDOWN) - { - release_object( &socket->hdr ); - return ERROR_INVALID_OPERATION; - } - socket->state = SOCKET_STATE_SHUTDOWN;
if (socket->request->connect->hdr.flags & WINHTTP_FLAG_ASYNC) @@ -3721,8 +3700,33 @@ DWORD WINAPI WinHttpWebSocketShutdown( HINTERNET hsocket, USHORT status, void *r free( s ); } } - else ret = socket_shutdown( socket, status, reason, len ); + else ret = send_frame( socket, SOCKET_OPCODE_CLOSE, status, reason, len, TRUE, NULL ); + + return ret; +} + +DWORD WINAPI WinHttpWebSocketShutdown( HINTERNET hsocket, USHORT status, void *reason, DWORD len ) +{ + struct socket *socket; + DWORD ret; + + TRACE("%p, %u, %p, %u\n", hsocket, status, reason, len); + + if ((len && !reason) || len > sizeof(socket->reason)) return ERROR_INVALID_PARAMETER; + + if (!(socket = (struct socket *)grab_object( hsocket ))) return ERROR_INVALID_HANDLE; + if (socket->hdr.type != WINHTTP_HANDLE_TYPE_SOCKET) + { + release_object( &socket->hdr ); + return ERROR_WINHTTP_INCORRECT_HANDLE_TYPE; + } + if (socket->state >= SOCKET_STATE_SHUTDOWN) + { + release_object( &socket->hdr ); + return ERROR_INVALID_OPERATION; + }
+ ret = send_socket_shutdown( socket, status, reason, len, TRUE ); release_object( &socket->hdr ); return ret; }