glib2/gmain-Make-GChildWatchSource-child_exited-field-atom.patch
2019-09-30 10:40:42 -04:00

67 lines
2.4 KiB
Diff

From d2fd53df036af9a931a39b6d28d42fea9f6b5d18 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 260/682] gmain: Make GChildWatchSource child_exited field
atomic
Ensure synchronization between prepare / check of GChildWatchsource and
UNIX signal dispatcher by making operations on `child_exited` field
atomic. Use `child_exited` as publication flag for `child_status`.
Issue #1312.
---
glib/gmain.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/glib/gmain.c b/glib/gmain.c
index e1a680433..ad57b4927 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -5107,7 +5107,7 @@ dispatch_unix_signals_unlocked (void)
{
GChildWatchSource *source = node->data;
- if (!source->child_exited)
+ if (!g_atomic_int_get (&source->child_exited))
{
pid_t pid;
do
@@ -5117,14 +5117,14 @@ dispatch_unix_signals_unlocked (void)
pid = waitpid (source->pid, &source->child_status, WNOHANG);
if (pid > 0)
{
- source->child_exited = TRUE;
+ g_atomic_int_set (&source->child_exited, TRUE);
wake_source ((GSource *) source);
}
else if (pid == -1 && errno == ECHILD)
{
g_warning ("GChildWatchSource: Exit status of a child process was requested but ECHILD was received by waitpid(). See the documentation of g_child_watch_source_new() for possible causes.");
- source->child_exited = TRUE;
source->child_status = 0;
+ g_atomic_int_set (&source->child_exited, TRUE);
wake_source ((GSource *) source);
}
}
@@ -5167,7 +5167,7 @@ g_child_watch_prepare (GSource *source,
child_watch_source = (GChildWatchSource *) source;
- return child_watch_source->child_exited;
+ return g_atomic_int_get (&child_watch_source->child_exited);
}
static gboolean
@@ -5177,7 +5177,7 @@ g_child_watch_check (GSource *source)
child_watch_source = (GChildWatchSource *) source;
- return child_watch_source->child_exited;
+ return g_atomic_int_get (&child_watch_source->child_exited);
}
static gboolean
--
2.19.1