[glib] unix signals: stop using atomics
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] unix signals: stop using atomics
- Date: Fri, 3 Jan 2014 01:38:51 +0000 (UTC)
commit 1867fc210fa14d68d1b139a04c5d79a0e344c6bc
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Jan 2 16:43:13 2014 -0500
unix signals: stop using atomics
They are not required here. See the discussion in the bug report.
https://bugzilla.gnome.org/show_bug.cgi?id=711090
glib/gmain.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index 7de3ff3..37df32c 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -4835,7 +4835,20 @@ dispatch_unix_signals_unlocked (void)
* races.
*/
for (i = 0; i < NSIG; i++)
- pending[i] = g_atomic_int_compare_and_exchange (&unix_signal_pending[i], TRUE, FALSE);
+ {
+ /* Be very careful with (the volatile) unix_signal_pending.
+ *
+ * We must ensure that it's not possible that we clear it without
+ * handling the signal. We therefore must ensure that our pending
+ * array has a field set (ie: we will do something about the
+ * signal) before we clear the item in unix_signal_pending.
+ *
+ * Note specifically: we must check _our_ array.
+ */
+ pending[i] = unix_signal_pending[i];
+ if (pending[i])
+ unix_signal_pending[i] = FALSE;
+ }
/* handle GChildWatchSource instances */
if (pending[SIGCHLD])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]