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:
Tim Janik
2007-08-14 00:05:52 +00:00
committed by Tim Janik
parent db68b8efa9
commit d5c4370813
4 changed files with 155 additions and 15 deletions

View File

@@ -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);