blob: fada7cc38e7562731ecb9d5f14a0d376a9cb6141 [file] [log] [blame]
Andrew Geissler95ac1b82021-03-31 14:34:31 -05001From a6ce0e742a5c75c53a7c702ebb1af1084065160a Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@endlessos.org>
3Date: Wed, 11 Nov 2020 18:14:29 +0000
4Subject: [PATCH 02/29] tests: Fix non-atomic access to a shared variable
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9And drop the `volatile` qualifier from the variable, as that doesnt
10help with thread safety.
11
12Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
13
14Helps: #600
15Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719]
16---
17 glib/tests/642026.c | 4 ++--
18 1 file changed, 2 insertions(+), 2 deletions(-)
19
20diff --git a/glib/tests/642026.c b/glib/tests/642026.c
21index ef54f14bb..26ab2ed06 100644
22--- a/glib/tests/642026.c
23+++ b/glib/tests/642026.c
24@@ -25,7 +25,7 @@ static GMutex *mutex;
25 static GCond *cond;
26 static guint i;
27
28-static volatile gint freed = 0;
29+static gint freed = 0; /* (atomic) */
30
31 static void
32 notify (gpointer p)
33@@ -63,7 +63,7 @@ testcase (void)
34 GThread *t1;
35
36 g_static_private_init (&sp);
37- freed = 0;
38+ g_atomic_int_set (&freed, 0);
39
40 t1 = g_thread_create (thread_func, NULL, TRUE, NULL);
41 g_assert (t1 != NULL);
42--
432.30.1
44