From 71375917759a0110e6ed53a31242fbd02a8d5851 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 16 May 2022 14:11:13 +0100 Subject: [PATCH] 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. Fixes: https://gitlab.gnome.org/GNOME/glib/-/jobs/2004192 Signed-off-by: Philip Withnall --- 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 70b3a9dfc..b608a3cd4 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);