[glib: 2/30] tests: Fix non-atomic access to a shared variable
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/30] tests: Fix non-atomic access to a shared variable
- Date: Fri, 20 Nov 2020 14:55:05 +0000 (UTC)
commit a6ce0e742a5c75c53a7c702ebb1af1084065160a
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed Nov 11 18:14:29 2020 +0000
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
glib/tests/642026.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/tests/642026.c b/glib/tests/642026.c
index ef54f14bb..26ab2ed06 100644
--- a/glib/tests/642026.c
+++ b/glib/tests/642026.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]