[PATCH] urlmon/tests: Make sure we don't run more than one thread at once.

Zebediah Figura z.figura12 at gmail.com
Mon Jan 8 20:23:38 CST 2018


On occasion the second thread, started by Continue(), will run far enough
that it effectively steals the Switch() call out from under the first thread.
Ensure that this doesn't happen by causing the second thread to wait for the
first thread to finish before running any code.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/urlmon/tests/protocol.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/dlls/urlmon/tests/protocol.c b/dlls/urlmon/tests/protocol.c
index d88aa07..1d9a803 100644
--- a/dlls/urlmon/tests/protocol.c
+++ b/dlls/urlmon/tests/protocol.c
@@ -156,6 +156,7 @@ static DWORD prot_read, filter_state, http_post_test, thread_id;
 static BOOL security_problem, test_async_req, impl_protex;
 static BOOL async_read_pending, mimefilter_test, direct_read, wait_for_switch, emulate_prot, short_read, test_abort;
 static BOOL empty_file, no_mime, bind_from_cache, file_with_hash;
+static HANDLE last_thread, thread;
 
 enum {
     STATE_CONNECTING,
@@ -1592,6 +1593,10 @@ static DWORD WINAPI thread_proc(PVOID arg)
     BOOL redirect_only = redirect_on_continue;
     HRESULT hres;
 
+    /* make sure that the last thread terminates before we start this one */
+    if (last_thread)
+        ok(WaitForSingleObject(last_thread, 90000) == WAIT_OBJECT_0, "wait timed out\n");
+
     memset(&protocoldata, -1, sizeof(protocoldata));
 
     prot_state = 0;
@@ -1719,7 +1724,6 @@ static void protocol_start(IInternetProtocolSink *pOIProtSink, IInternetBindInfo
         LPWSTR additional_headers = NULL;
         BYTE sec_id[100];
         DWORD fetched = 0, size = 100;
-        DWORD tid;
 
         SET_EXPECT(GetBindString_USER_AGENT);
         hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
@@ -1777,7 +1781,8 @@ static void protocol_start(IInternetProtocolSink *pOIProtSink, IInternetBindInfo
 
         IServiceProvider_Release(service_provider);
 
-        CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
+        last_thread = thread;
+        thread = CreateThread(NULL, 0, thread_proc, NULL, 0, NULL);
         return;
     }
 
-- 
2.7.4




More information about the wine-devel mailing list