http.sys: Factor out get_connection().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-11-03 20:20:36 -06:00 committed by Alexandre Julliard
parent 61928e8160
commit 6360ea8932
1 changed files with 34 additions and 28 deletions

View File

@ -1159,6 +1159,18 @@ static NTSTATUS http_remove_url(struct request_queue *queue, IRP *irp)
return STATUS_SUCCESS;
}
static struct connection *get_connection(HTTP_REQUEST_ID req_id)
{
struct connection *conn;
LIST_FOR_EACH_ENTRY(conn, &connections, struct connection, entry)
{
if (conn->req_id == req_id)
return conn;
}
return NULL;
}
static NTSTATUS http_receive_request(struct request_queue *queue, IRP *irp)
{
const struct http_receive_request_params *params = irp->AssociatedIrp.SystemBuffer;
@ -1170,15 +1182,12 @@ static NTSTATUS http_receive_request(struct request_queue *queue, IRP *irp)
EnterCriticalSection(&http_cs);
LIST_FOR_EACH_ENTRY(conn, &connections, struct connection, entry)
{
if (conn->available && conn->queue == queue && params->id == conn->req_id)
if ((conn = get_connection(params->id)) && conn->available && conn->queue == queue)
{
ret = complete_irp(conn, irp);
LeaveCriticalSection(&http_cs);
return ret;
}
}
if (params->id == HTTP_NULL_ID)
{
@ -1203,9 +1212,7 @@ static NTSTATUS http_send_response(struct request_queue *queue, IRP *irp)
EnterCriticalSection(&http_cs);
LIST_FOR_EACH_ENTRY(conn, &connections, struct connection, entry)
{
if (conn->req_id == response->id)
if ((conn = get_connection(response->id)))
{
if (send(conn->socket, response->buffer, response->len, 0) >= 0)
{
@ -1230,7 +1237,6 @@ static NTSTATUS http_send_response(struct request_queue *queue, IRP *irp)
LeaveCriticalSection(&http_cs);
return STATUS_SUCCESS;
}
}
LeaveCriticalSection(&http_cs);
return STATUS_CONNECTION_INVALID;