Zebediah Figura : httpapi: Wait for overlapped I/O completion only if ERROR_IO_PENDING is returned.

Alexandre Julliard julliard at winehq.org
Mon Mar 2 16:22:22 CST 2020


Module: wine
Branch: master
Commit: 4c5f325333da4562b18af8ea846c780221ff319c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4c5f325333da4562b18af8ea846c780221ff319c

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Fri Feb 28 21:45:31 2020 -0600

httpapi: Wait for overlapped I/O completion only if ERROR_IO_PENDING is returned.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 6143214346..9904ed18db 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, &params, sizeof(params), buffer, size, NULL, ovl))
+    if (!DeviceIoControl(queue, IOCTL_HTTP_RECEIVE_BODY, &params, 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, &params, sizeof(params), request, size, NULL, ovl))
+    if (!DeviceIoControl(queue, IOCTL_HTTP_RECEIVE_REQUEST, &params, 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 a52a3f6c34..fced1b5e2f 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);




More information about the wine-cvs mailing list