gthreadpool: Remove a dummy item from the queue before freeing

Now that `g_thread_pool_new_full()` can be used to set a user-provided
free function for queue elements, ensure that the internal dummy item
used to wake up the worker threads is removed from the queue before it’s
called.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2456
This commit is contained in:
Philip Withnall 2021-08-19 14:15:37 +01:00
parent 51b0cd3ccc
commit b402f66c07

View File

@ -964,6 +964,11 @@ g_thread_pool_free_internal (GRealThreadPool* pool)
g_return_if_fail (pool->running == FALSE);
g_return_if_fail (pool->num_threads == 0);
/* Ensure the dummy item pushed on by g_thread_pool_wakeup_and_stop_all() is
* removed, before its potentially passed to the user-provided
* @item_free_func. */
g_async_queue_remove (pool->queue, GUINT_TO_POINTER (1));
g_async_queue_unref (pool->queue);
g_cond_clear (&pool->cond);