From 4c5f325333da4562b18af8ea846c780221ff319c Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 28 Feb 2020 21:45:31 -0600 Subject: [PATCH] httpapi: Wait for overlapped I/O completion only if ERROR_IO_PENDING is returned. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/httpapi/httpapi_main.c | 21 ++++++++++++++------- dlls/httpapi/tests/httpapi.c | 9 +++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/dlls/httpapi/httpapi_main.c b/dlls/httpapi/httpapi_main.c index 61432143462..9904ed18dbf 100644 --- a/dlls/httpapi/httpapi_main.c +++ b/dlls/httpapi/httpapi_main.c @@ -304,13 +304,17 @@ ULONG WINAPI HttpReceiveRequestEntityBody(HANDLE queue, HTTP_REQUEST_ID id, ULON ovl = &sync_ovl; } - if (!DeviceIoControl(queue, IOCTL_HTTP_RECEIVE_BODY, ¶ms, sizeof(params), buffer, size, NULL, ovl)) + if (!DeviceIoControl(queue, IOCTL_HTTP_RECEIVE_BODY, ¶ms, sizeof(params), buffer, size, ret_size, ovl)) ret = GetLastError(); if (ovl == &sync_ovl) { - if (!GetOverlappedResult(queue, ovl, ret_size, TRUE)) - ret = GetLastError(); + if (ret == ERROR_IO_PENDING) + { + ret = ERROR_SUCCESS; + if (!GetOverlappedResult(queue, ovl, ret_size, TRUE)) + ret = GetLastError(); + } CloseHandle(sync_ovl.hEvent); } @@ -348,14 +352,17 @@ ULONG WINAPI HttpReceiveHttpRequest(HANDLE queue, HTTP_REQUEST_ID id, ULONG flag ovl = &sync_ovl; } - if (!DeviceIoControl(queue, IOCTL_HTTP_RECEIVE_REQUEST, ¶ms, sizeof(params), request, size, NULL, ovl)) + if (!DeviceIoControl(queue, IOCTL_HTTP_RECEIVE_REQUEST, ¶ms, sizeof(params), request, size, ret_size, ovl)) ret = GetLastError(); if (ovl == &sync_ovl) { - ret = ERROR_SUCCESS; - if (!GetOverlappedResult(queue, ovl, ret_size, TRUE)) - ret = GetLastError(); + if (ret == ERROR_IO_PENDING) + { + ret = ERROR_SUCCESS; + if (!GetOverlappedResult(queue, ovl, ret_size, TRUE)) + ret = GetLastError(); + } CloseHandle(sync_ovl.hEvent); } diff --git a/dlls/httpapi/tests/httpapi.c b/dlls/httpapi/tests/httpapi.c index a52a3f6c344..fced1b5e2f1 100644 --- a/dlls/httpapi/tests/httpapi.c +++ b/dlls/httpapi/tests/httpapi.c @@ -188,6 +188,9 @@ static void test_v1_server(void) ret = CloseHandle(queue2); ok(ret, "Failed to close queue handle, error %u.\n", GetLastError()); + ret_size = 0xdeadbeef; + ret = HttpReceiveHttpRequest(NULL, HTTP_NULL_ID, 0, (HTTP_REQUEST *)req, sizeof(req_buffer), &ret_size, NULL); + ok(ret == ERROR_INVALID_HANDLE, "Got error %u.\n", ret); ret = HttpReceiveHttpRequest(NULL, HTTP_NULL_ID, 0, (HTTP_REQUEST *)req, sizeof(req_buffer), NULL, &ovl); ok(ret == ERROR_INVALID_HANDLE, "Got error %u.\n", ret); ret = HttpReceiveHttpRequest(queue, 0xdeadbeef, 0, (HTTP_REQUEST *)req, sizeof(req_buffer), NULL, &ovl); @@ -769,6 +772,12 @@ static void test_v1_entity_body(void) /* Test HttpReceiveRequestEntityBody(). */ + ret_size = 0xdeadbeef; + ret = HttpReceiveRequestEntityBody(NULL, HTTP_NULL_ID, 0, recv_body, sizeof(recv_body), &ret_size, NULL); + ok(ret == ERROR_INVALID_HANDLE, "Got error %u.\n", ret); + ret = HttpReceiveRequestEntityBody(NULL, HTTP_NULL_ID, 0, recv_body, sizeof(recv_body), NULL, &ovl); + ok(ret == ERROR_INVALID_HANDLE, "Got error %u.\n", ret); + sprintf(req_text, post_req, port); ret = send(s, req_text, strlen(req_text) + 1, 0); ok(ret == strlen(req_text) + 1, "send() returned %d.\n", ret);