From 660932163f7d0c5e9fe6af3dc867394775bbee4b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 5 Aug 2021 08:38:07 +0200 Subject: [PATCH] glib-aux: fix thread-safe initialization in _nm_g_source_sentinel_get_init() Fixes: ce7c28c514c8 ('glib-aux: add nm_g_source_sentinel_get() util') (cherry picked from commit 2140bbf7f52429a34993ed98098b2afb5443c676) (cherry picked from commit c37f72acd314c707bdf6912f47e0fbdd4c6b3969) --- shared/nm-glib-aux/nm-shared-utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index 7fd6b93e6c..bdf2f67093 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -4696,14 +4696,14 @@ _nm_g_source_sentinel_get_init(GSource **p_source) }; GSource *source; -again: source = g_source_new((GSourceFuncs *) &source_funcs, sizeof(GSource)); g_source_set_priority(source, G_PRIORITY_DEFAULT_IDLE); g_source_set_name(source, "nm_g_source_sentinel"); if (!g_atomic_pointer_compare_and_exchange(p_source, NULL, source)) { g_source_unref(source); - goto again; + source = g_atomic_pointer_get(p_source); + nm_assert(source); } return source;