From 1ee9ea91a5e60c3839235c4d6b55a0da2d85a11a Mon Sep 17 00:00:00 2001 From: Misha Koshelev Date: Wed, 22 Aug 2007 00:12:52 -0500 Subject: [PATCH] wininet: Fix reference count on internet handle for asynchronous InternetReadFileEx call. --- dlls/wininet/internet.c | 11 ++++++----- dlls/wininet/tests/http.c | 12 ++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index bfad36c6f0b..d24eed34157 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -1883,11 +1883,11 @@ BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOu req = &workRequest.u.InternetReadFileExA; req->lpBuffersOut = lpBuffersOut; - retval = INTERNET_AsyncCall(&workRequest); - if (!retval) return FALSE; - - INTERNET_SetLastError(ERROR_IO_PENDING); - return FALSE; + if (!INTERNET_AsyncCall(&workRequest)) + WININET_Release( lpwh ); + else + INTERNET_SetLastError(ERROR_IO_PENDING); + goto end; } } @@ -1903,6 +1903,7 @@ BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOu sizeof(dwBytesReceived)); } +end: WININET_Release( lpwh ); TRACE("-- %s (bytes read: %d)\n", retval ? "TRUE": "FALSE", lpBuffersOut->dwBufferLength); diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 699aaa01089..d69999895ae 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -704,6 +704,8 @@ static void InternetReadFileExA_test(int flags) abort: SET_EXPECT2(INTERNET_STATUS_HANDLE_CLOSING, (hor != 0x0) + (hic != 0x0)); if (hor) { + SET_WINE_ALLOW(INTERNET_STATUS_CLOSING_CONNECTION); + SET_WINE_ALLOW(INTERNET_STATUS_CONNECTION_CLOSED); rc = InternetCloseHandle(hor); ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n"); rc = InternetCloseHandle(hor); @@ -721,6 +723,16 @@ abort: Sleep(100); CHECK_NOTIFIED2(INTERNET_STATUS_HANDLE_CLOSING, (hor != 0x0) + (hic != 0x0)); } + if (hor != 0x0) todo_wine + { + CHECK_NOT_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); + CHECK_NOT_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); + } + else + { + CHECK_NOT_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); + CHECK_NOT_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); + } CloseHandle(hCompleteEvent); first_connection_to_test_url = FALSE; }