Nikolay Sivov : comsvcs: Create MTA without initialization thread.

Alexandre Julliard julliard at winehq.org
Mon Oct 19 15:54:06 CDT 2020


Module: wine
Branch: master
Commit: c9cc098ccd7f0cdb82b8e52d00c415042c5ff717
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=c9cc098ccd7f0cdb82b8e52d00c415042c5ff717

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Oct 19 12:43:04 2020 +0300

comsvcs: Create MTA without initialization thread.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49679
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comsvcs/main.c | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/dlls/comsvcs/main.c b/dlls/comsvcs/main.c
index 9ab77dfceda..74704077ecb 100644
--- a/dlls/comsvcs/main.c
+++ b/dlls/comsvcs/main.c
@@ -40,7 +40,7 @@ typedef struct dispensermanager
 {
     IDispenserManager IDispenserManager_iface;
     LONG ref;
-    HANDLE mta_thread, mta_stop_event;
+    CO_MTA_USAGE_COOKIE mta_cookie;
 } dispensermanager;
 
 typedef struct holder
@@ -285,27 +285,14 @@ static ULONG WINAPI dismanager_Release(IDispenserManager *iface)
 
     if (!ref)
     {
-        if (This->mta_thread)
-        {
-            SetEvent(This->mta_stop_event);
-            WaitForSingleObject(This->mta_thread, INFINITE);
-            CloseHandle(This->mta_stop_event);
-            CloseHandle(This->mta_thread);
-        }
+        if (This->mta_cookie)
+            CoDecrementMTAUsage(This->mta_cookie);
         heap_free(This);
     }
 
     return ref;
 }
 
-static DWORD WINAPI mta_thread_proc(void *arg)
-{
-    CoInitializeEx(NULL, COINIT_MULTITHREADED);
-    WaitForSingleObject(arg, INFINITE);
-    CoUninitialize();
-    return 0;
-}
-
 static HRESULT WINAPI dismanager_RegisterDispenser(IDispenserManager *iface, IDispenserDriver *driver,
                         LPCOLESTR name, IHolder **dispenser)
 {
@@ -319,11 +306,8 @@ static HRESULT WINAPI dismanager_RegisterDispenser(IDispenserManager *iface, IDi
 
     hr = create_holder(driver, dispenser);
 
-    if (!This->mta_thread)
-    {
-        This->mta_stop_event = CreateEventA(NULL, TRUE, FALSE, NULL);
-        This->mta_thread = CreateThread(NULL, 0, mta_thread_proc, This->mta_stop_event, 0, NULL);
-    }
+    if (!This->mta_cookie)
+        CoIncrementMTAUsage(&This->mta_cookie);
 
     TRACE("<-- 0x%08x, %p\n", hr, *dispenser);
 




More information about the wine-cvs mailing list