Commit ac1bb453 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

comsvcs: Create an implicit MTA thread in RegisterDispenser().

parent 62d67bde
......@@ -40,7 +40,7 @@ typedef struct dispensermanager
{
IDispenserManager IDispenserManager_iface;
LONG ref;
HANDLE mta_thread, mta_stop_event;
} dispensermanager;
typedef struct holder
......@@ -264,12 +264,27 @@ 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);
}
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)
{
......@@ -283,6 +298,12 @@ 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);
}
TRACE("<-- 0x%08x, %p\n", hr, *dispenser);
return hr;
......@@ -313,7 +334,7 @@ static HRESULT WINAPI comsvcscf_CreateInstance(IClassFactory *cf,IUnknown* outer
TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), object);
dismanager = heap_alloc(sizeof(*dismanager));
dismanager = heap_alloc_zero(sizeof(*dismanager));
if (!dismanager)
{
*object = NULL;
......
......@@ -188,7 +188,6 @@ static void create_dispenser(void)
thread = CreateThread(NULL, 0, com_thread, NULL, 0, NULL);
ok(!WaitForSingleObject(thread, 1000), "wait failed\n");
GetExitCodeThread(thread, &ret);
todo_wine
ok(ret == S_OK, "got unexpected hr %#x\n", ret);
hr = IDispenserManager_RegisterDispenser(dispenser, &DispenserDriver, pool0, &holder2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment