From cb89c75141a1b0899e7ba5bc7be4488aca91cbd2 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 9 Apr 2016 05:11:17 +0200 Subject: [PATCH] Added patch to implement support for async handling in InternetReadFile. --- patches/patchinstall.sh | 20 +++++ ...nused-sync-argument-from-HTTPREQ_Rea.patch | 70 +++++++++++++++ ...ix-async-check-in-HTTPREQ_ReadFileEx.patch | 25 ++++++ ...andle-async-mode-in-HTTPREQ_ReadFile.patch | 87 +++++++++++++++++++ .../wininet-HTTPREQ_ReadFile_Async/definition | 1 + 5 files changed, 203 insertions(+) create mode 100644 patches/wininet-HTTPREQ_ReadFile_Async/0001-wininet-Remove-unused-sync-argument-from-HTTPREQ_Rea.patch create mode 100644 patches/wininet-HTTPREQ_ReadFile_Async/0002-wininet-Fix-async-check-in-HTTPREQ_ReadFileEx.patch create mode 100644 patches/wininet-HTTPREQ_ReadFile_Async/0003-wininet-Handle-async-mode-in-HTTPREQ_ReadFile.patch create mode 100644 patches/wininet-HTTPREQ_ReadFile_Async/definition diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 7b695d45..172341d1 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -377,6 +377,7 @@ patch_enable_all () enable_winex11_wglShareLists="$1" enable_winhttp_System_Proxy_Autoconfig="$1" enable_wininet_Cleanup="$1" + enable_wininet_HTTPREQ_ReadFile_Async="$1" enable_wininet_HttpOpenRequestW="$1" enable_wininet_Internet_Settings="$1" enable_wininet_ParseX509EncodedCertificateForListBoxEntry="$1" @@ -1303,6 +1304,9 @@ patch_enable () wininet-Cleanup) enable_wininet_Cleanup="$2" ;; + wininet-HTTPREQ_ReadFile_Async) + enable_wininet_HTTPREQ_ReadFile_Async="$2" + ;; wininet-HttpOpenRequestW) enable_wininet_HttpOpenRequestW="$2" ;; @@ -7469,6 +7473,22 @@ if test "$enable_wininet_Cleanup" -eq 1; then ) >> "$patchlist" fi +# Patchset wininet-HTTPREQ_ReadFile_Async +# | +# | Modified files: +# | * dlls/wininet/http.c +# | +if test "$enable_wininet_HTTPREQ_ReadFile_Async" -eq 1; then + patch_apply wininet-HTTPREQ_ReadFile_Async/0001-wininet-Remove-unused-sync-argument-from-HTTPREQ_Rea.patch + patch_apply wininet-HTTPREQ_ReadFile_Async/0002-wininet-Fix-async-check-in-HTTPREQ_ReadFileEx.patch + patch_apply wininet-HTTPREQ_ReadFile_Async/0003-wininet-Handle-async-mode-in-HTTPREQ_ReadFile.patch + ( + echo '+ { "Sebastian Lackner", "wininet: Remove unused '\''sync'\'' argument from HTTPREQ_Read.", 1 },'; + echo '+ { "Michael Müller", "wininet: Fix async check in HTTPREQ_ReadFileEx.", 1 },'; + echo '+ { "Michael Müller", "wininet: Handle async mode in HTTPREQ_ReadFile.", 1 },'; + ) >> "$patchlist" +fi + # Patchset wininet-HttpOpenRequestW # | # | This patchset fixes the following Wine bugs: diff --git a/patches/wininet-HTTPREQ_ReadFile_Async/0001-wininet-Remove-unused-sync-argument-from-HTTPREQ_Rea.patch b/patches/wininet-HTTPREQ_ReadFile_Async/0001-wininet-Remove-unused-sync-argument-from-HTTPREQ_Rea.patch new file mode 100644 index 00000000..79b200aa --- /dev/null +++ b/patches/wininet-HTTPREQ_ReadFile_Async/0001-wininet-Remove-unused-sync-argument-from-HTTPREQ_Rea.patch @@ -0,0 +1,70 @@ +From bacfca9bbf82b6105cd377b7872c9d65bf27be57 Mon Sep 17 00:00:00 2001 +From: Sebastian Lackner +Date: Sat, 9 Apr 2016 05:01:18 +0200 +Subject: wininet: Remove unused 'sync' argument from HTTPREQ_Read. + +--- + dlls/wininet/http.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c +index 143dc75..bdc659d 100644 +--- a/dlls/wininet/http.c ++++ b/dlls/wininet/http.c +@@ -3036,7 +3036,7 @@ static void HTTP_ReceiveRequestData(http_request_t *req, BOOL first_notif, DWORD + } + + /* read data from the http connection (the read section must be held) */ +-static DWORD HTTPREQ_Read(http_request_t *req, void *buffer, DWORD size, DWORD *read, BOOL sync) ++static DWORD HTTPREQ_Read(http_request_t *req, void *buffer, DWORD size, DWORD *read) + { + DWORD current_read = 0, ret_read = 0; + blocking_mode_t blocking_mode; +@@ -3090,7 +3090,7 @@ static BOOL drain_content(http_request_t *req, BOOL blocking) + DWORD bytes_read, res; + BYTE buf[4096]; + +- res = HTTPREQ_Read(req, buf, sizeof(buf), &bytes_read, TRUE); ++ res = HTTPREQ_Read(req, buf, sizeof(buf), &bytes_read); + if(res != ERROR_SUCCESS) { + ret = FALSE; + break; +@@ -3114,7 +3114,7 @@ static DWORD HTTPREQ_ReadFile(object_header_t *hdr, void *buffer, DWORD size, DW + if(hdr->dwError == INTERNET_HANDLE_IN_USE) + hdr->dwError = ERROR_INTERNET_INTERNAL_ERROR; + +- res = HTTPREQ_Read(req, buffer, size, read, TRUE); ++ res = HTTPREQ_Read(req, buffer, size, read); + if(res == ERROR_SUCCESS) + res = hdr->dwError; + LeaveCriticalSection( &req->read_section ); +@@ -3137,7 +3137,7 @@ static void AsyncReadFileExProc(task_header_t *hdr) + + TRACE("INTERNETREADFILEEXW %p\n", task->hdr.hdr); + +- res = HTTPREQ_Read(req, task->buf, task->size, task->ret_read, TRUE); ++ res = HTTPREQ_Read(req, task->buf, task->size, task->ret_read); + send_request_complete(req, res == ERROR_SUCCESS, res); + } + +@@ -3161,7 +3161,7 @@ static DWORD HTTPREQ_ReadFileEx(object_header_t *hdr, void *buf, DWORD size, DWO + { + if (get_avail_data(req)) + { +- res = HTTPREQ_Read(req, buf, size, &read, FALSE); ++ res = HTTPREQ_Read(req, buf, size, &read); + LeaveCriticalSection( &req->read_section ); + goto done; + } +@@ -3187,7 +3187,7 @@ static DWORD HTTPREQ_ReadFileEx(object_header_t *hdr, void *buf, DWORD size, DWO + hdr->dwError = ERROR_INTERNET_INTERNAL_ERROR; + + while(1) { +- res = HTTPREQ_Read(req, (char*)buf+read, size-read, &cread, !(flags & IRF_NO_WAIT)); ++ res = HTTPREQ_Read(req, (char*)buf+read, size-read, &cread); + if(res != ERROR_SUCCESS) + break; + +-- +2.7.1 + diff --git a/patches/wininet-HTTPREQ_ReadFile_Async/0002-wininet-Fix-async-check-in-HTTPREQ_ReadFileEx.patch b/patches/wininet-HTTPREQ_ReadFile_Async/0002-wininet-Fix-async-check-in-HTTPREQ_ReadFileEx.patch new file mode 100644 index 00000000..c3fe166a --- /dev/null +++ b/patches/wininet-HTTPREQ_ReadFile_Async/0002-wininet-Fix-async-check-in-HTTPREQ_ReadFileEx.patch @@ -0,0 +1,25 @@ +From c0897fede8556c5970ff7a5db97795a0ccd88b43 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Tue, 5 Apr 2016 17:55:47 +0200 +Subject: wininet: Fix async check in HTTPREQ_ReadFileEx. + +--- + dlls/wininet/http.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c +index bdc659d..2774ab0 100644 +--- a/dlls/wininet/http.c ++++ b/dlls/wininet/http.c +@@ -3153,7 +3153,7 @@ static DWORD HTTPREQ_ReadFileEx(object_header_t *hdr, void *buf, DWORD size, DWO + + INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); + +- if (hdr->dwFlags & INTERNET_FLAG_ASYNC) ++ if (req->session->appInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC) + { + read_file_ex_task_t *task; + +-- +2.7.1 + diff --git a/patches/wininet-HTTPREQ_ReadFile_Async/0003-wininet-Handle-async-mode-in-HTTPREQ_ReadFile.patch b/patches/wininet-HTTPREQ_ReadFile_Async/0003-wininet-Handle-async-mode-in-HTTPREQ_ReadFile.patch new file mode 100644 index 00000000..32a7952e --- /dev/null +++ b/patches/wininet-HTTPREQ_ReadFile_Async/0003-wininet-Handle-async-mode-in-HTTPREQ_ReadFile.patch @@ -0,0 +1,87 @@ +From e2da56d0cda302fbc815da6f35ef5cc0cf5f7c95 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Tue, 5 Apr 2016 17:58:29 +0200 +Subject: wininet: Handle async mode in HTTPREQ_ReadFile. + +--- + dlls/wininet/http.c | 57 +++++++++++++++++++++++++++++++++++++---------------- + 1 file changed, 40 insertions(+), 17 deletions(-) + +diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c +index 2774ab0..fac3d4d 100644 +--- a/dlls/wininet/http.c ++++ b/dlls/wininet/http.c +@@ -3105,23 +3105,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; +@@ -3238,6 +3221,46 @@ 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)) ++ goto read_data; ++ ++ LeaveCriticalSection( &req->read_section ); ++ } ++ ++ task = alloc_async_task(&req->hdr, AsyncReadFileExProc, sizeof(*task)); ++ task->buf = buffer; ++ task->size = size; ++ task->ret_read = read; ++ ++ 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; ++ ++read_data: ++ 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; +-- +2.7.1 + diff --git a/patches/wininet-HTTPREQ_ReadFile_Async/definition b/patches/wininet-HTTPREQ_ReadFile_Async/definition new file mode 100644 index 00000000..a3f3512c --- /dev/null +++ b/patches/wininet-HTTPREQ_ReadFile_Async/definition @@ -0,0 +1 @@ +Fixes: Add support for async handling in InternetReadFile()