tests: Fix non-atomic access to a shared variable

And drop the `volatile` qualifier from the variable, as that doesn’t
help with thread safety.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #600
This commit is contained in:
Philip Withnall 2020-11-11 18:14:29 +00:00
parent fab561f8d0
commit a6ce0e742a

View File

@ -25,7 +25,7 @@ static GMutex *mutex;
static GCond *cond;
static guint i;
static volatile gint freed = 0;
static gint freed = 0; /* (atomic) */
static void
notify (gpointer p)
@ -63,7 +63,7 @@ testcase (void)
GThread *t1;
g_static_private_init (&sp);
freed = 0;
g_atomic_int_set (&freed, 0);
t1 = g_thread_create (thread_func, NULL, TRUE, NULL);
g_assert (t1 != NULL);