glib-aux: fix thread-safe initialization in _nm_g_source_sentinel_get_init()

Fixes: ce7c28c514 ('glib-aux: add nm_g_source_sentinel_get() util')
This commit is contained in:
Thomas Haller 2021-08-05 08:38:07 +02:00
parent f9fa3fbf9f
commit 2140bbf7f5
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -5000,14 +5000,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;