Commit 48b713ef authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplat: Cleanup user queues.

parent a23e658a
......@@ -254,6 +254,28 @@ static HRESULT lock_user_queue(DWORD queue)
return hr;
}
static void shutdown_queue(struct queue *queue)
{
struct work_item *item, *item2;
if (!queue->pool)
return;
CloseThreadpoolCleanupGroupMembers(queue->env.CleanupGroup, TRUE, NULL);
CloseThreadpool(queue->pool);
queue->pool = NULL;
EnterCriticalSection(&queue->cs);
LIST_FOR_EACH_ENTRY_SAFE(item, item2, &queue->pending_items, struct work_item, entry)
{
list_remove(&item->entry);
release_work_item(item);
}
LeaveCriticalSection(&queue->cs);
DeleteCriticalSection(&queue->cs);
}
static HRESULT unlock_user_queue(DWORD queue)
{
HRESULT hr = MF_E_INVALID_WORKQUEUE;
......@@ -268,6 +290,8 @@ static HRESULT unlock_user_queue(DWORD queue)
{
if (--entry->refcount == 0)
{
shutdown_queue((struct queue *)entry->obj);
heap_free(entry->obj);
entry->obj = next_free_user_queue;
next_free_user_queue = entry;
}
......@@ -277,28 +301,6 @@ static HRESULT unlock_user_queue(DWORD queue)
return hr;
}
static void shutdown_queue(struct queue *queue)
{
struct work_item *item, *item2;
if (!queue->pool)
return;
CloseThreadpoolCleanupGroupMembers(queue->env.CleanupGroup, TRUE, NULL);
CloseThreadpool(queue->pool);
queue->pool = NULL;
EnterCriticalSection(&queue->cs);
LIST_FOR_EACH_ENTRY_SAFE(item, item2, &queue->pending_items, struct work_item, entry)
{
list_remove(&item->entry);
release_work_item(item);
}
LeaveCriticalSection(&queue->cs);
DeleteCriticalSection(&queue->cs);
}
void shutdown_system_queues(void)
{
unsigned int i;
......
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