[glib/wip/pwithnall/io-channel-double-close-source] tests: Fix a double-close of a GSource in tests
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/pwithnall/io-channel-double-close-source] tests: Fix a double-close of a GSource in tests
- Date: Mon, 16 May 2022 13:12:06 +0000 (UTC)
commit 7c714527080973781e45ed355369999444d4f695
Author: Philip Withnall <pwithnall endlessos org>
Date: Mon May 16 14:11:13 2022 +0100
tests: Fix a double-close of a GSource in tests
This bug only gets triggered on BSD, because it calls `recv_message()`
with `G_IO_HUP | G_IO_IN`. That takes two code paths in
`recv_message()`, and ends up calling `shutdown_source()` twice. The
second call causes a critical warning.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
glib/tests/io-channel-basic.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/glib/tests/io-channel-basic.c b/glib/tests/io-channel-basic.c
index 70b3a9dfca..b608a3cd45 100644
--- a/glib/tests/io-channel-basic.c
+++ b/glib/tests/io-channel-basic.c
@@ -96,8 +96,13 @@ read_all (int fd,
static void
shutdown_source (gpointer data)
{
- if (g_source_remove (*(guint *) data))
+ guint *fd_ptr = data;
+
+ if (*fd_ptr != 0)
{
+ g_source_remove (*fd_ptr);
+ *fd_ptr = 0;
+
nrunning--;
if (nrunning == 0)
g_main_loop_quit (main_loop);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]