urlmon: Fix race in protocol tests.

The value of *called is set asynchronously and so the callback
function could be called after IInternetProtocol_Read returns
E_PENDING. The value of *called is only predictable after the
WaitForSingleObject call returns. Therefore, remove the checks on
*called before this call.
This commit is contained in:
Rob Shearman 2008-09-28 16:38:05 +01:00 committed by Alexandre Julliard
parent 4730205ffb
commit 601b3b2732
1 changed files with 4 additions and 5 deletions

View File

@ -1557,7 +1557,6 @@ static void test_http_protocol_url(LPCWSTR url, BOOL is_first)
if(SUCCEEDED(hres)) {
BYTE buf[3600];
DWORD cb;
int *called = (bindf & BINDF_FROMURLMON) ? &called_Switch : &called_ReportData;
test_priority(http_protocol);
@ -1579,8 +1578,8 @@ static void test_http_protocol_url(LPCWSTR url, BOOL is_first)
expect_hrResult = S_OK;
hres = IInternetProtocol_Read(http_protocol, buf, 1, &cb);
ok((!*called && hres == E_PENDING && cb==0) ||
(*called && hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
ok((hres == E_PENDING && cb==0) ||
(hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
WaitForSingleObject(event_complete, INFINITE);
if(bindf & BINDF_FROMURLMON)
@ -1596,8 +1595,8 @@ static void test_http_protocol_url(LPCWSTR url, BOOL is_first)
hres = IInternetProtocol_Read(http_protocol, buf, sizeof(buf), &cb);
if(hres == E_PENDING) {
hres = IInternetProtocol_Read(http_protocol, buf, 1, &cb);
ok((!*called && hres == E_PENDING && cb==0) ||
(*called && hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
ok((hres == E_PENDING && cb==0) ||
(hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
WaitForSingleObject(event_complete, INFINITE);
if(bindf & BINDF_FROMURLMON)
CHECK_CALLED(Switch);