Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 1 | From a6ce0e742a5c75c53a7c702ebb1af1084065160a Mon Sep 17 00:00:00 2001 |
| 2 | From: Philip Withnall <pwithnall@endlessos.org> |
| 3 | Date: Wed, 11 Nov 2020 18:14:29 +0000 |
| 4 | Subject: [PATCH 02/29] tests: Fix non-atomic access to a shared variable |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | And drop the `volatile` qualifier from the variable, as that doesn’t |
| 10 | help with thread safety. |
| 11 | |
| 12 | Signed-off-by: Philip Withnall <pwithnall@endlessos.org> |
| 13 | |
| 14 | Helps: #600 |
| 15 | Upstream-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 | |
| 20 | diff --git a/glib/tests/642026.c b/glib/tests/642026.c |
| 21 | index 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 | -- |
| 43 | 2.30.1 |
| 44 | |