Bug 830290: Replace calls to dbus_connection_send_with_reply_and_block r=bent,qdot
authorThomas Zimmermann <tdz@users.sourceforge.net>
Mon, 11 Mar 2013 15:22:50 +0100
changeset 133796 41fbfc8a1d2995388822c6d2ff93f63f3ec8bc9c
parent 133795 a4a9e95ef22a9e2de07a623fdcf3df22cfaff7f1
child 133797 93044ea22c6d1c38323898e80cc56200b1361e28
push id28905
push userryanvm@gmail.com
push dateMon, 03 Jun 2013 15:58:12 +0000
treeherdermozilla-inbound@d2eabe8e27b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent, qdot
bugs830290
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 830290: Replace calls to dbus_connection_send_with_reply_and_block r=bent,qdot There is one call to dbus_connection_send_with_reply_and_block in the Bluetooth code. This patch replaces the call by a call to the helper function dbus_func_send_and_block, which executes the DBus operation within the DBus thread.
dom/bluetooth/linux/BluetoothDBusService.cpp
--- a/dom/bluetooth/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/linux/BluetoothDBusService.cpp
@@ -684,38 +684,35 @@ RegisterLocalAgent(const char* adapterPa
   if (!dbus_message_append_args(msg,
                                 DBUS_TYPE_OBJECT_PATH, &agentPath,
                                 DBUS_TYPE_STRING, &capabilities,
                                 DBUS_TYPE_INVALID)) {
     BT_WARNING("%s: Couldn't append arguments to dbus message.", __FUNCTION__);
     return false;
   }
 
-  DBusError err;
-  dbus_error_init(&err);
-
-  DBusMessage* reply =
-    dbus_connection_send_with_reply_and_block(gThreadConnection->GetConnection(),
-                                              msg, -1, &err);
-  dbus_message_unref(msg);
-
-  if (!reply) {
+  DBusError err = DBUS_ERROR_INIT;
+  DBusMessage* reply;
+
+  dbus_bool_t success = dbus_func_send_and_block(gThreadConnection->GetConnection(),
+                                                 -1, &reply, &err, msg);
+  if (!success) {
     if (dbus_error_is_set(&err)) {
       if (!strcmp(err.name, "org.bluez.Error.AlreadyExists")) {
         LOG_AND_FREE_DBUS_ERROR(&err);
 #ifdef DEBUG
         BT_WARNING("Agent already registered, still returning true");
 #endif
       } else {
         LOG_AND_FREE_DBUS_ERROR(&err);
         BT_WARNING("%s: Can't register agent!", __FUNCTION__);
         return false;
       }
     }
-  } else {
+  } else if (reply) {
     dbus_message_unref(reply);
   }
 
   dbus_connection_flush(gThreadConnection->GetConnection());
   return true;
 }
 
 static bool