Module: wine Branch: master Commit: 851866e22a731141da7e3cbd2550c67c59968959 URL: http://source.winehq.org/git/wine.git/?a=commit;h=851866e22a731141da7e3cbd25...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Feb 14 18:05:14 2013 +0100
wininet: Set available bytes in InternetQueryDataAvailable even if it ends up in async call.
---
dlls/wininet/http.c | 24 ++++++++++++++++-------- dlls/wininet/tests/http.c | 9 ++++++++- 2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index d4c822d..81439ca 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2763,7 +2763,7 @@ static void send_request_complete(http_request_t *req, DWORD_PTR result, DWORD e sizeof(INTERNET_ASYNC_RESULT)); }
-static void HTTP_ReceiveRequestData(http_request_t *req, BOOL first_notif) +static void HTTP_ReceiveRequestData(http_request_t *req, BOOL first_notif, DWORD *ret_size) { DWORD res, read = 0, avail = 0; read_mode_t mode; @@ -2776,6 +2776,8 @@ static void HTTP_ReceiveRequestData(http_request_t *req, BOOL first_notif) res = refill_read_buffer(req, mode, &read); if(res == ERROR_SUCCESS && !first_notif) avail = get_avail_data(req); + if(ret_size) + *ret_size = get_avail_data(req);
LeaveCriticalSection( &req->read_section );
@@ -2993,11 +2995,16 @@ static DWORD HTTPREQ_WriteFile(object_header_t *hdr, const void *buffer, DWORD s return res; }
-static void AsyncQueryDataAvailableProc(task_header_t *task) +typedef struct { + task_header_t hdr; + DWORD *ret_size; +} http_data_available_task_t; + +static void AsyncQueryDataAvailableProc(task_header_t *hdr) { - http_request_t *req = (http_request_t*)task->hdr; + http_data_available_task_t *task = (http_data_available_task_t*)hdr;
- HTTP_ReceiveRequestData(req, FALSE); + HTTP_ReceiveRequestData((http_request_t*)task->hdr.hdr, FALSE, task->ret_size); }
static DWORD HTTPREQ_QueryDataAvailable(object_header_t *hdr, DWORD *available, DWORD flags, DWORD_PTR ctx) @@ -3008,7 +3015,7 @@ static DWORD HTTPREQ_QueryDataAvailable(object_header_t *hdr, DWORD *available,
if (req->session->appInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC) { - task_header_t *task; + http_data_available_task_t *task;
/* never wait, if we can't enter the section we queue an async request right away */ if (TryEnterCriticalSection( &req->read_section )) @@ -3020,7 +3027,8 @@ static DWORD HTTPREQ_QueryDataAvailable(object_header_t *hdr, DWORD *available, }
task = alloc_async_task(&req->hdr, AsyncQueryDataAvailableProc, sizeof(*task)); - INTERNET_AsyncCall(task); + task->ret_size = available; + INTERNET_AsyncCall(&task->hdr); return ERROR_IO_PENDING; }
@@ -4923,7 +4931,7 @@ lend: { if (res == ERROR_SUCCESS) { if(bEndRequest && request->contentLength && request->bytesWritten == request->bytesToWrite) - HTTP_ReceiveRequestData(request, TRUE); + HTTP_ReceiveRequestData(request, TRUE, NULL); else send_request_complete(request, request->session->hdr.dwInternalFlags & INET_OPENURL ? (DWORD_PTR)request->hdr.hInternet : 1, 0); @@ -5034,7 +5042,7 @@ static DWORD HTTP_HttpEndRequestW(http_request_t *request, DWORD dwFlags, DWORD_ create_cache_entry(request);
if (res == ERROR_SUCCESS && request->contentLength) - HTTP_ReceiveRequestData(request, TRUE); + HTTP_ReceiveRequestData(request, TRUE, NULL); else send_request_complete(request, res == ERROR_SUCCESS, res);
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index ba4ec4d..6083900 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -448,7 +448,7 @@ static void InternetReadFile_test(int flags, const test_data_t *test) char *post_data = NULL; BOOL res, on_async = TRUE; CHAR buffer[4000]; - DWORD length, post_len = 0; + DWORD length, exlen = 0, post_len = 0; const char *types[2] = { "*", NULL }; HINTERNET hi, hic = 0, hor = 0;
@@ -649,12 +649,17 @@ static void InternetReadFile_test(int flags, const test_data_t *test) { if (flags & INTERNET_FLAG_ASYNC) SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + length = 0; res = InternetQueryDataAvailable(hor,&length,0x0,0x0); if (flags & INTERNET_FLAG_ASYNC) { if (res) { CHECK_NOT_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + if(exlen) { + ok(length >= exlen, "length %u < exlen %u\n", length, exlen); + exlen = 0; + } } else if (GetLastError() == ERROR_IO_PENDING) { @@ -663,6 +668,8 @@ static void InternetReadFile_test(int flags, const test_data_t *test) if(!(test->flags & TESTF_CHUNKED)) ok(!length, "InternetQueryDataAvailable returned ERROR_IO_PENDING and %u length\n", length); WaitForSingleObject(hCompleteEvent, INFINITE); + exlen = length; + ok(exlen, "length = 0\n"); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); ok(req_error, "req_error = 0\n"); continue;