[PATCH 09/10] mfplat: Cleanup user queues.

Nikolay Sivov nsivov at codeweavers.com
Fri Mar 1 00:59:38 CST 2019


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/mfplat/queue.c | 46 +++++++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/dlls/mfplat/queue.c b/dlls/mfplat/queue.c
index c793caa4e9..23e54a5cbf 100644
--- a/dlls/mfplat/queue.c
+++ b/dlls/mfplat/queue.c
@@ -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;
-- 
2.20.1




More information about the wine-devel mailing list