quartz: Free outstanding advise requests when destroying a system clock.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-07-19 22:25:27 -05:00 committed by Alexandre Julliard
parent ff231dad75
commit 4e74fdcebe
2 changed files with 18 additions and 2 deletions

View File

@ -90,6 +90,7 @@ static ULONG WINAPI system_clock_inner_Release(IUnknown *iface)
{
struct system_clock *clock = impl_from_IUnknown(iface);
ULONG refcount = InterlockedDecrement(&clock->refcount);
struct advise_sink *sink, *cursor;
TRACE("%p decreasing refcount to %u.\n", clock, refcount);
@ -104,6 +105,13 @@ static ULONG WINAPI system_clock_inner_Release(IUnknown *iface)
WaitForSingleObject(clock->thread, INFINITE);
CloseHandle(clock->thread);
}
LIST_FOR_EACH_ENTRY_SAFE(sink, cursor, &clock->sinks, struct advise_sink, entry)
{
list_remove(&sink->entry);
heap_free(sink);
}
clock->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&clock->cs);
heap_free(clock);

View File

@ -272,11 +272,19 @@ static void test_advise(void)
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(WaitForSingleObject(semaphore, 200) == WAIT_TIMEOUT, "Semaphore should not be signaled.\n");
CloseHandle(event);
CloseHandle(semaphore);
ResetEvent(event);
hr = IReferenceClock_GetTime(clock, &current);
ok(SUCCEEDED(hr), "Got hr %#x.\n", hr);
hr = IReferenceClock_AdviseTime(clock, current, 500 * 10000, (HEVENT)event, &cookie);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ref = IReferenceClock_Release(clock);
ok(!ref, "Got outstanding refcount %d.\n", ref);
ok(WaitForSingleObject(event, 0) == WAIT_TIMEOUT, "Event should not be signaled.\n");
CloseHandle(event);
CloseHandle(semaphore);
}
START_TEST(systemclock)