From 9bcb9c16ec8394f3dbae1a553378bb935bf46e20 Mon Sep 17 00:00:00 2001 From: Misha Koshelev Date: Mon, 23 Jul 2007 20:29:55 -0500 Subject: [PATCH] urlmon: Fix timing issue with FLAG_REQUEST_COMPLETE and InternetQueryDataAvailable in HttpProtocol. --- dlls/urlmon/http.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dlls/urlmon/http.c b/dlls/urlmon/http.c index 2afe267ca34..a720651e9b6 100644 --- a/dlls/urlmon/http.c +++ b/dlls/urlmon/http.c @@ -725,11 +725,14 @@ static HRESULT WINAPI HttpProtocol_Read(IInternetProtocol *iface, void *pv, { if (This->available_bytes == 0) { + /* InternetQueryDataAvailable may immediately fork and perform its asynchronous + * read, so clear the flag _before_ calling so it does not incorrectly get cleared + * after the status callback is called */ + This->flags &= ~FLAG_REQUEST_COMPLETE; if (!InternetQueryDataAvailable(This->request, &This->available_bytes, 0, 0)) { if (GetLastError() == ERROR_IO_PENDING) { - This->flags &= ~FLAG_REQUEST_COMPLETE; hres = E_PENDING; } else @@ -778,6 +781,9 @@ done: if (pcbRead) *pcbRead = read; + if (hres != E_PENDING) + This->flags |= FLAG_REQUEST_COMPLETE; + return hres; }