mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-05 21:29:20 +02:00
Merge branch '3712-clean-up-on-fail' into 'main'
gthreadpool: Clean up when g_thread_pool_new fails See merge request GNOME/glib!4706
This commit is contained in:
@@ -631,6 +631,18 @@ g_thread_pool_new_full (GFunc func,
|
|||||||
spawn_thread_queue = g_async_queue_new ();
|
spawn_thread_queue = g_async_queue_new ();
|
||||||
g_cond_init (&spawn_thread_cond);
|
g_cond_init (&spawn_thread_cond);
|
||||||
pool_spawner = g_thread_try_new ("pool-spawner", g_thread_pool_spawn_thread, NULL, &local_error);
|
pool_spawner = g_thread_try_new ("pool-spawner", g_thread_pool_spawn_thread, NULL, &local_error);
|
||||||
|
if (pool_spawner == NULL)
|
||||||
|
{
|
||||||
|
/* The only way to know that the pool_spawner exists is
|
||||||
|
* if (spawn_thread_queue != NULL), so if creating the pool_spawner
|
||||||
|
* failed, we must destroy the queue.
|
||||||
|
*/
|
||||||
|
g_clear_pointer (&spawn_thread_queue, g_async_queue_unref);
|
||||||
|
/* We must also clear spawn_thread_cond, so that a future attempt
|
||||||
|
* to create a non-exclusive pool can safely initialize it.
|
||||||
|
*/
|
||||||
|
g_cond_clear (&spawn_thread_cond);
|
||||||
|
}
|
||||||
g_ignore_leak (pool_spawner);
|
g_ignore_leak (pool_spawner);
|
||||||
}
|
}
|
||||||
G_UNLOCK (init);
|
G_UNLOCK (init);
|
||||||
|
Reference in New Issue
Block a user