68 lines
1.8 KiB
Diff
68 lines
1.8 KiB
Diff
From 9e652f94d285b1722ea82a0465c6724eee346738 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= <tomasz.miasko@gmail.com>
|
|
Date: Thu, 1 Nov 2018 00:00:00 +0000
|
|
Subject: [PATCH 261/682] gmain: Make GUnixSignalWatchSource pending field
|
|
atomic
|
|
|
|
Ensure synchronization between prepare / check /dispatch of
|
|
GUnixSignalWatchSource and UNIX signal dispatcher by making operations
|
|
on `pending` field atomic.
|
|
|
|
Issue #1312.
|
|
---
|
|
glib/gmain.c | 16 ++++++----------
|
|
1 file changed, 6 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/glib/gmain.c b/glib/gmain.c
|
|
index ad57b4927..07ec867bc 100644
|
|
--- a/glib/gmain.c
|
|
+++ b/glib/gmain.c
|
|
@@ -5138,14 +5138,10 @@ dispatch_unix_signals_unlocked (void)
|
|
{
|
|
GUnixSignalWatchSource *source = node->data;
|
|
|
|
- if (!source->pending)
|
|
+ if (pending[source->signum] &&
|
|
+ g_atomic_int_compare_and_exchange (&source->pending, FALSE, TRUE))
|
|
{
|
|
- if (pending[source->signum])
|
|
- {
|
|
- source->pending = TRUE;
|
|
-
|
|
- wake_source ((GSource *) source);
|
|
- }
|
|
+ wake_source ((GSource *) source);
|
|
}
|
|
}
|
|
|
|
@@ -5188,7 +5184,7 @@ g_unix_signal_watch_prepare (GSource *source,
|
|
|
|
unix_signal_source = (GUnixSignalWatchSource *) source;
|
|
|
|
- return unix_signal_source->pending;
|
|
+ return g_atomic_int_get (&unix_signal_source->pending);
|
|
}
|
|
|
|
static gboolean
|
|
@@ -5198,7 +5194,7 @@ g_unix_signal_watch_check (GSource *source)
|
|
|
|
unix_signal_source = (GUnixSignalWatchSource *) source;
|
|
|
|
- return unix_signal_source->pending;
|
|
+ return g_atomic_int_get (&unix_signal_source->pending);
|
|
}
|
|
|
|
static gboolean
|
|
@@ -5220,7 +5216,7 @@ g_unix_signal_watch_dispatch (GSource *source,
|
|
|
|
again = (callback) (user_data);
|
|
|
|
- unix_signal_source->pending = FALSE;
|
|
+ g_atomic_int_set (&unix_signal_source->pending, FALSE);
|
|
|
|
return again;
|
|
}
|
|
--
|
|
2.19.1
|
|
|