[glib] Bug 627188 – gdbus-non-socket test occasionally fails



commit 7d6a6ca57b5a5dc1ad55a785dfd79fa98d7e4093
Author: David Zeuthen <davidz redhat com>
Date:   Wed Aug 18 13:07:25 2010 -0400

    Bug 627188 â?? gdbus-non-socket test occasionally fails
    
    Fix logical bug in test case to avoid race condition between the
    client and the server.
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 gio/tests/gdbus-non-socket.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/gio/tests/gdbus-non-socket.c b/gio/tests/gdbus-non-socket.c
index ea475e5..cf8853f 100644
--- a/gio/tests/gdbus-non-socket.c
+++ b/gio/tests/gdbus-non-socket.c
@@ -237,9 +237,20 @@ test_non_socket (void)
       stream = my_io_stream_new_for_fds (read_fd, write_fd);
       guid = g_dbus_generate_guid ();
       error = NULL;
+      /* We need to delay message processing to avoid the race
+       * described in
+       *
+       *  https://bugzilla.gnome.org/show_bug.cgi?id=627188
+       *
+       * This is because (early) dispatching is done on the IO thread
+       * (method_call() isn't called until we're in the right thread
+       * though) so in rare cases the parent sends the message before
+       * we (the child) register the object
+       */
       connection = g_dbus_connection_new_sync (stream,
                                                guid,
-                                               G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER,
+                                               G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER |
+                                               G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING,
                                                NULL, /* GDBusAuthObserver */
                                                NULL,
                                                &error);
@@ -250,9 +261,6 @@ test_non_socket (void)
       /* make sure we exit along with the parent */
       g_dbus_connection_set_exit_on_close (connection, TRUE);
 
-      /* btw, no need to delay message processing since method
-       * invocations are delivered via the main loop
-       */
       error = NULL;
       g_dbus_connection_register_object (connection,
                                          "/pokee",
@@ -263,6 +271,9 @@ test_non_socket (void)
                                          &error);
       g_assert_no_error (error);
 
+      /* and now start message processing */
+      g_dbus_connection_start_message_processing (connection);
+
       g_main_loop_run (loop);
 
       g_assert_not_reached ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]