gresource: Ensure lazy_register_resources is always accessed atomically

On some platforms, pointer-sized reads are not necessarily atomic, so we
always need to use the correct atomic access primitives.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2023-05-30 12:31:55 +01:00
parent f792b2ce64
commit 28f83c9cf7

View File

@ -1367,7 +1367,7 @@ register_lazy_static_resources_unlocked (void)
GStaticResource *list; GStaticResource *list;
do do
list = lazy_register_resources; list = g_atomic_pointer_get (&lazy_register_resources);
while (!g_atomic_pointer_compare_and_exchange (&lazy_register_resources, list, NULL)); while (!g_atomic_pointer_compare_and_exchange (&lazy_register_resources, list, NULL));
while (list != NULL) while (list != NULL)
@ -1416,7 +1416,7 @@ g_static_resource_init (GStaticResource *static_resource)
do do
{ {
next = lazy_register_resources; next = g_atomic_pointer_get (&lazy_register_resources);
static_resource->next = next; static_resource->next = next;
} }
while (!g_atomic_pointer_compare_and_exchange (&lazy_register_resources, next, static_resource)); while (!g_atomic_pointer_compare_and_exchange (&lazy_register_resources, next, static_resource));