Dispatch dbus messages after method calls when no main loop running
authorMike Gorse <mgorse@linux-sh69.site>
Wed, 21 Aug 2013 19:33:18 +0000 (14:33 -0500)
committerMike Gorse <mgorse@linux-sh69.site>
Wed, 21 Aug 2013 19:33:18 +0000 (14:33 -0500)
If no main loop is running, then the dbus connection's incoming message
queue was never emptied, so with, eg, dogtail,
dbus_connection_send_with_reply_and_block would take longer and longer
to look through the message queue to find a reply. This also effectively
led to a memory leak.

https://bugzilla.gnome.org/show_bug.cgi?id=701145

atspi/atspi-misc.c
dbind/dbind.c

index 17f9bb2..190a3eb 100644 (file)
@@ -1518,6 +1518,8 @@ get_accessibility_bus_address_dbus (void)
                                                     message,
                                                     -1,
                                                     &error);
+  if (g_main_depth () == 0)
+    while (dbus_connection_dispatch (session_bus) == DBUS_DISPATCH_DATA_REMAINS);
   dbus_message_unref (message);
 
   if (!reply)
index b83071a..f10b9cd 100644 (file)
@@ -71,7 +71,13 @@ dbind_send_and_allow_reentry (DBusConnection * bus, DBusMessage * message, DBusE
 
   if (unique_name && destination &&
       strcmp (destination, unique_name) != 0)
-    return dbus_connection_send_with_reply_and_block (bus, message, dbind_timeout, error);
+    {
+      ret = dbus_connection_send_with_reply_and_block (bus, message,
+                                                       dbind_timeout, error);
+      if (g_main_depth () == 0)
+      while (dbus_connection_dispatch (bus) == DBUS_DISPATCH_DATA_REMAINS);
+      return ret;
+    }
 
   closure = g_new0 (SpiReentrantCallClosure, 1);
   closure->reply = NULL;