From c9cc098ccd7f0cdb82b8e52d00c415042c5ff717 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 19 Oct 2020 12:43:04 +0300 Subject: [PATCH] comsvcs: Create MTA without initialization thread. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49679 Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- 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);