mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-07 14:10:05 +02:00
prevent race covered by g_once_init_enter(), by checking for previous
Tue Aug 14 02:06:10 2007 Tim Janik <timj@imendio.com> * glib/gthread.c (g_once_init_enter_impl): prevent race covered by g_once_init_enter(), by checking for previous initializations before entering initialisation branch. * tests/onceinit.c: added multi-thread/multi-initializer stress test using unoptimized g_once_init_enter_impl(). svn path=/trunk/; revision=5701
This commit is contained in:
@@ -332,7 +332,7 @@ void g_once_init_leave (volatile gsize *value_location,
|
||||
G_INLINE_FUNC gboolean
|
||||
g_once_init_enter (volatile gsize *value_location)
|
||||
{
|
||||
if G_LIKELY (g_atomic_pointer_get ((void**) value_location) !=0)
|
||||
if G_LIKELY (g_atomic_pointer_get ((void**) value_location) != 0)
|
||||
return FALSE;
|
||||
else
|
||||
return g_once_init_enter_impl (value_location);
|
||||
|
Reference in New Issue
Block a user