From 3d6f441f96339a41bf6e02703d689ee87cc1c365 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sun, 6 Aug 2000 23:33:29 +0000 Subject: [PATCH] New function, that calls g_source_remove(). Check return value of 2000-08-07 Tor Lillqvist * tests/gio-test.c (shutdown_source): New function, that calls g_source_remove(). Check return value of g_source_remove(), and decrement running subprocess counter only if g_source_remove() actually did remove the source. (recv_message): Call shutdown_source() on EOF condition. Return FALSE on G_IO_HUP and G_IO_ERR condition. Fix printf format typo. --- ChangeLog | 10 ++++++++++ ChangeLog.pre-2-0 | 10 ++++++++++ ChangeLog.pre-2-10 | 10 ++++++++++ ChangeLog.pre-2-12 | 10 ++++++++++ ChangeLog.pre-2-2 | 10 ++++++++++ ChangeLog.pre-2-4 | 10 ++++++++++ ChangeLog.pre-2-6 | 10 ++++++++++ ChangeLog.pre-2-8 | 10 ++++++++++ tests/gio-test.c | 26 +++++++++++++++++++------- 9 files changed, 99 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 01bdb6a66..d71f07b96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2000-08-07 Tor Lillqvist + + * tests/gio-test.c (shutdown_source): New function, that calls + g_source_remove(). Check return value of g_source_remove(), and + decrement running subprocess counter only if g_source_remove() + actually did remove the source. + + (recv_message): Call shutdown_source() on EOF condition. Return + FALSE on G_IO_HUP and G_IO_ERR condition. Fix printf format typo. + Sun Aug 6 20:06:02 2000 Tim Janik * gmessages.c (g_log_domain_check_free): keep *last updated while diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 01bdb6a66..d71f07b96 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,13 @@ +2000-08-07 Tor Lillqvist + + * tests/gio-test.c (shutdown_source): New function, that calls + g_source_remove(). Check return value of g_source_remove(), and + decrement running subprocess counter only if g_source_remove() + actually did remove the source. + + (recv_message): Call shutdown_source() on EOF condition. Return + FALSE on G_IO_HUP and G_IO_ERR condition. Fix printf format typo. + Sun Aug 6 20:06:02 2000 Tim Janik * gmessages.c (g_log_domain_check_free): keep *last updated while diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 01bdb6a66..d71f07b96 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,13 @@ +2000-08-07 Tor Lillqvist + + * tests/gio-test.c (shutdown_source): New function, that calls + g_source_remove(). Check return value of g_source_remove(), and + decrement running subprocess counter only if g_source_remove() + actually did remove the source. + + (recv_message): Call shutdown_source() on EOF condition. Return + FALSE on G_IO_HUP and G_IO_ERR condition. Fix printf format typo. + Sun Aug 6 20:06:02 2000 Tim Janik * gmessages.c (g_log_domain_check_free): keep *last updated while diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 01bdb6a66..d71f07b96 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,13 @@ +2000-08-07 Tor Lillqvist + + * tests/gio-test.c (shutdown_source): New function, that calls + g_source_remove(). Check return value of g_source_remove(), and + decrement running subprocess counter only if g_source_remove() + actually did remove the source. + + (recv_message): Call shutdown_source() on EOF condition. Return + FALSE on G_IO_HUP and G_IO_ERR condition. Fix printf format typo. + Sun Aug 6 20:06:02 2000 Tim Janik * gmessages.c (g_log_domain_check_free): keep *last updated while diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 01bdb6a66..d71f07b96 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,13 @@ +2000-08-07 Tor Lillqvist + + * tests/gio-test.c (shutdown_source): New function, that calls + g_source_remove(). Check return value of g_source_remove(), and + decrement running subprocess counter only if g_source_remove() + actually did remove the source. + + (recv_message): Call shutdown_source() on EOF condition. Return + FALSE on G_IO_HUP and G_IO_ERR condition. Fix printf format typo. + Sun Aug 6 20:06:02 2000 Tim Janik * gmessages.c (g_log_domain_check_free): keep *last updated while diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 01bdb6a66..d71f07b96 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,13 @@ +2000-08-07 Tor Lillqvist + + * tests/gio-test.c (shutdown_source): New function, that calls + g_source_remove(). Check return value of g_source_remove(), and + decrement running subprocess counter only if g_source_remove() + actually did remove the source. + + (recv_message): Call shutdown_source() on EOF condition. Return + FALSE on G_IO_HUP and G_IO_ERR condition. Fix printf format typo. + Sun Aug 6 20:06:02 2000 Tim Janik * gmessages.c (g_log_domain_check_free): keep *last updated while diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 01bdb6a66..d71f07b96 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,13 @@ +2000-08-07 Tor Lillqvist + + * tests/gio-test.c (shutdown_source): New function, that calls + g_source_remove(). Check return value of g_source_remove(), and + decrement running subprocess counter only if g_source_remove() + actually did remove the source. + + (recv_message): Call shutdown_source() on EOF condition. Return + FALSE on G_IO_HUP and G_IO_ERR condition. Fix printf format typo. + Sun Aug 6 20:06:02 2000 Tim Janik * gmessages.c (g_log_domain_check_free): keep *last updated while diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 01bdb6a66..d71f07b96 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,13 @@ +2000-08-07 Tor Lillqvist + + * tests/gio-test.c (shutdown_source): New function, that calls + g_source_remove(). Check return value of g_source_remove(), and + decrement running subprocess counter only if g_source_remove() + actually did remove the source. + + (recv_message): Call shutdown_source() on EOF condition. Return + FALSE on G_IO_HUP and G_IO_ERR condition. Fix printf format typo. + Sun Aug 6 20:06:02 2000 Tim Janik * gmessages.c (g_log_domain_check_free): keep *last updated while diff --git a/tests/gio-test.c b/tests/gio-test.c index 0a22e2767..80a944928 100644 --- a/tests/gio-test.c +++ b/tests/gio-test.c @@ -18,7 +18,7 @@ */ /* A test program for the main loop and IO channel code. - * Just run it. + * Just run it. Optional parameter is number of sub-processes. */ #include "config.h" @@ -93,6 +93,16 @@ read_all (int fd, return error; } +static void +shutdown_source (gpointer data) +{ + if (g_source_remove (*(guint *) data)) + { + nrunning--; + if (nrunning == 0) + g_main_quit (main_loop); + } +} static gboolean recv_message (GIOChannel *channel, @@ -100,6 +110,7 @@ recv_message (GIOChannel *channel, gpointer data) { gint fd = g_io_channel_unix_get_fd (channel); + gboolean retval = TRUE; g_print ("gio-test: ...from %d:%s%s%s%s\n", fd, (cond & G_IO_ERR) ? " ERR" : "", @@ -109,10 +120,8 @@ recv_message (GIOChannel *channel, if (cond & (G_IO_ERR | G_IO_HUP)) { - g_source_remove (*(guint *) data); - nrunning--; - if (nrunning == 0) - g_main_quit (main_loop); + shutdown_source (data); + retval = FALSE; } if (cond & G_IO_IN) @@ -129,6 +138,7 @@ recv_message (GIOChannel *channel, if (nb == 0) { g_print ("gio-test: ...from %d: EOF\n", fd); + shutdown_source (data); return FALSE; } @@ -139,7 +149,7 @@ recv_message (GIOChannel *channel, { if (seq != seqtab[i].seq) { - g_print ("gio-test: ...from &d: invalid sequence number %d, expected %d\n", + g_print ("gio-test: ...from %d: invalid sequence number %d, expected %d\n", seq, seqtab[i].seq); g_assert_not_reached (); } @@ -156,6 +166,7 @@ recv_message (GIOChannel *channel, if (nb == 0) { g_print ("gio-test: ...from %d: EOF\n", fd); + shutdown_source (data); return FALSE; } @@ -180,6 +191,7 @@ recv_message (GIOChannel *channel, if (nb == 0) { g_print ("gio-test: ...from %d: EOF\n", fd); + shutdown_source (data); return FALSE; } @@ -193,7 +205,7 @@ recv_message (GIOChannel *channel, g_print ("gio-test: ...from %d: OK\n", fd); } } - return TRUE; + return retval; } int