winhttp: Factor out socket_close_complete() function.

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:28 +03:00 committed by Alexandre Julliard
parent 673a01a442
commit 1c9ea6cd94
1 changed files with 13 additions and 8 deletions

View File

@ -3886,24 +3886,29 @@ static DWORD socket_close( struct socket *socket )
return receive_close_status( socket, count ); 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; if (!ret) send_callback( &socket->hdr, WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE, NULL, 0 );
DWORD ret;
ret = socket_close( s->socket );
if (!ret) send_callback( &s->socket->hdr, WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE, NULL, 0 );
else else
{ {
WINHTTP_WEB_SOCKET_ASYNC_RESULT result; WINHTTP_WEB_SOCKET_ASYNC_RESULT result;
result.AsyncResult.dwResult = API_READ_DATA; /* FIXME */ result.AsyncResult.dwResult = API_READ_DATA; /* FIXME */
result.AsyncResult.dwError = ret; result.AsyncResult.dwError = ret;
result.Operation = WINHTTP_WEB_SOCKET_CLOSE_OPERATION; 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); TRACE("running %p\n", work);
ret = socket_close( s->socket );
socket_close_complete( s->socket, ret );
release_object( &s->socket->hdr ); release_object( &s->socket->hdr );
free( s ); free( s );
} }