Module: wine Branch: master Commit: 221590213ea12375cb2549afd774855dcc6c46e6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=221590213ea12375cb2549afd7...
Author: Michael Müller michael@fds-team.de Date: Thu Apr 28 05:14:47 2016 +0200
wininet: Handle async mode in HTTPREQ_ReadFile.
Signed-off-by: Michael Müller michael@fds-team.de Signed-off-by: Sebastian Lackner sebastian@fds-team.de Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wininet/http.c | 60 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 17 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 66ee6ba..775ff61 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -3101,23 +3101,6 @@ static BOOL drain_content(http_request_t *req, BOOL blocking) return ret; }
-static DWORD HTTPREQ_ReadFile(object_header_t *hdr, void *buffer, DWORD size, DWORD *read) -{ - http_request_t *req = (http_request_t*)hdr; - DWORD res; - - EnterCriticalSection( &req->read_section ); - if(hdr->dwError == INTERNET_HANDLE_IN_USE) - hdr->dwError = ERROR_INTERNET_INTERNAL_ERROR; - - res = HTTPREQ_Read(req, buffer, size, read); - if(res == ERROR_SUCCESS) - res = hdr->dwError; - LeaveCriticalSection( &req->read_section ); - - return res; -} - typedef struct { task_header_t hdr; void *buf; @@ -3241,6 +3224,49 @@ static DWORD HTTPREQ_WriteFile(object_header_t *hdr, const void *buffer, DWORD s return res; }
+static DWORD HTTPREQ_ReadFile(object_header_t *hdr, void *buffer, DWORD size, DWORD *read) +{ + http_request_t *req = (http_request_t*)hdr; + DWORD res; + + if (req->session->appInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC) + { + read_file_ex_task_t *task; + + if (TryEnterCriticalSection( &req->read_section )) + { + if (get_avail_data(req)) + { + res = HTTPREQ_Read(req, buffer, size, read); + LeaveCriticalSection( &req->read_section ); + return res; + } + LeaveCriticalSection( &req->read_section ); + } + + task = alloc_async_task(&req->hdr, AsyncReadFileExProc, sizeof(*task)); + task->buf = buffer; + task->size = size; + task->ret_read = read; + + *read = 0; + INTERNET_AsyncCall(&task->hdr); + + return ERROR_IO_PENDING; + } + + EnterCriticalSection( &req->read_section ); + if(hdr->dwError == INTERNET_HANDLE_IN_USE) + hdr->dwError = ERROR_INTERNET_INTERNAL_ERROR; + + res = HTTPREQ_Read(req, buffer, size, read); + if(res == ERROR_SUCCESS) + res = hdr->dwError; + LeaveCriticalSection( &req->read_section ); + + return res; +} + typedef struct { task_header_t hdr; DWORD *ret_size;