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

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Zebediah Figura 2020-02-28 21:45:31 -06:00 committed by Alexandre Julliard
parent 534fdf8f46
commit 4c5f325333
2 changed files with 23 additions and 7 deletions

View File

@ -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);
}

View File

@ -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);