New function, that calls g_source_remove(). Check return value of
authorTor Lillqvist <tml@iki.fi>
Sun, 6 Aug 2000 23:33:29 +0000 (23:33 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Sun, 6 Aug 2000 23:33:29 +0000 (23:33 +0000)
2000-08-07  Tor Lillqvist  <tml@iki.fi>

* 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
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
tests/gio-test.c

index 01bdb6a..d71f07b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-08-07  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <timj@gtk.org>
 
         * gmessages.c (g_log_domain_check_free): keep *last updated while
index 01bdb6a..d71f07b 100644 (file)
@@ -1,3 +1,13 @@
+2000-08-07  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <timj@gtk.org>
 
         * gmessages.c (g_log_domain_check_free): keep *last updated while
index 01bdb6a..d71f07b 100644 (file)
@@ -1,3 +1,13 @@
+2000-08-07  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <timj@gtk.org>
 
         * gmessages.c (g_log_domain_check_free): keep *last updated while
index 01bdb6a..d71f07b 100644 (file)
@@ -1,3 +1,13 @@
+2000-08-07  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <timj@gtk.org>
 
         * gmessages.c (g_log_domain_check_free): keep *last updated while
index 01bdb6a..d71f07b 100644 (file)
@@ -1,3 +1,13 @@
+2000-08-07  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <timj@gtk.org>
 
         * gmessages.c (g_log_domain_check_free): keep *last updated while
index 01bdb6a..d71f07b 100644 (file)
@@ -1,3 +1,13 @@
+2000-08-07  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <timj@gtk.org>
 
         * gmessages.c (g_log_domain_check_free): keep *last updated while
index 01bdb6a..d71f07b 100644 (file)
@@ -1,3 +1,13 @@
+2000-08-07  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <timj@gtk.org>
 
         * gmessages.c (g_log_domain_check_free): keep *last updated while
index 01bdb6a..d71f07b 100644 (file)
@@ -1,3 +1,13 @@
+2000-08-07  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <timj@gtk.org>
 
         * gmessages.c (g_log_domain_check_free): keep *last updated while
index 0a22e27..80a9449 100644 (file)
@@ -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