Jacek Caban : urlmon: Avoid multiple InternetQueryDataAvailable calls in pending state.
Alexandre Julliard
julliard at winehq.org
Thu May 26 10:56:28 CDT 2011
Module: wine
Branch: master
Commit: dd61ebe6cf93f6d6ea270f64793a1348b3ce44d0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=dd61ebe6cf93f6d6ea270f64793a1348b3ce44d0
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu May 26 13:34:11 2011 +0200
urlmon: Avoid multiple InternetQueryDataAvailable calls in pending state.
---
dlls/urlmon/protocol.c | 44 ++++++++++++++++++++++----------------------
1 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/dlls/urlmon/protocol.c b/dlls/urlmon/protocol.c
index 1b8b5e3..326564b 100644
--- a/dlls/urlmon/protocol.c
+++ b/dlls/urlmon/protocol.c
@@ -335,7 +335,7 @@ HRESULT protocol_continue(Protocol *protocol, PROTOCOLDATA *data)
protocol->flags |= FLAG_FIRST_CONTINUE_COMPLETE;
}
- if(data->pData >= (LPVOID)BINDSTATUS_DOWNLOADINGDATA) {
+ if(data->pData >= (LPVOID)BINDSTATUS_DOWNLOADINGDATA && !protocol->available_bytes) {
BOOL res;
/* InternetQueryDataAvailable may immediately fork and perform its asynchronous
@@ -367,33 +367,33 @@ HRESULT protocol_read(Protocol *protocol, void *buf, ULONG size, ULONG *read_ret
return S_FALSE;
}
- if(!(protocol->flags & FLAG_REQUEST_COMPLETE)) {
+ if(!(protocol->flags & FLAG_REQUEST_COMPLETE) || !protocol->available_bytes) {
*read_ret = 0;
return E_PENDING;
}
- while(read < size) {
- if(protocol->available_bytes) {
- ULONG len;
+ while(read < size && protocol->available_bytes) {
+ ULONG len;
- res = InternetReadFile(protocol->request, ((BYTE *)buf)+read,
- protocol->available_bytes > size-read ? size-read : protocol->available_bytes, &len);
- if(!res) {
- WARN("InternetReadFile failed: %d\n", GetLastError());
- hres = INET_E_DOWNLOAD_FAILURE;
- report_result(protocol, hres);
- break;
- }
+ res = InternetReadFile(protocol->request, ((BYTE *)buf)+read,
+ protocol->available_bytes > size-read ? size-read : protocol->available_bytes, &len);
+ if(!res) {
+ WARN("InternetReadFile failed: %d\n", GetLastError());
+ hres = INET_E_DOWNLOAD_FAILURE;
+ report_result(protocol, hres);
+ break;
+ }
- if(!len) {
- all_data_read(protocol);
- break;
- }
+ if(!len) {
+ all_data_read(protocol);
+ break;
+ }
+
+ read += len;
+ protocol->current_position += len;
+ protocol->available_bytes -= len;
- read += len;
- protocol->current_position += len;
- protocol->available_bytes -= len;
- }else {
+ if(!protocol->available_bytes) {
/* 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 */
More information about the wine-cvs
mailing list