Bug 932728: Use private DBus connection, r=qdot
authorThomas Zimmermann <tdz@users.sourceforge.net>
Tue, 29 Oct 2013 16:03:40 +0100
changeset 160139 93089287545bf81c60670d4620a848636b33bb05
parent 160138 905ce734b772a657ede8c05f4a5213bb0bd766f9
child 160140 0ddb34970ecb74ec84e58dfe8ca8e95bc70a9bf8
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersqdot
bugs932728
milestone29.0a1
Bug 932728: Use private DBus connection, r=qdot Using a private DBus connection gives each of its users, such as Bluetooth, its own connection to the DBus server. This simplifies the use of DBusWatch structures and ensures that all resources of a connection are free'd when the connection gets closed.
ipc/dbus/RawDBusConnection.cpp
--- a/ipc/dbus/RawDBusConnection.cpp
+++ b/ipc/dbus/RawDBusConnection.cpp
@@ -197,28 +197,29 @@ nsresult RawDBusConnection::EstablishDBu
 {
   if (!sDBusIsInit) {
     dbus_bool_t success = dbus_threads_init_default();
     NS_ENSURE_TRUE(success == TRUE, NS_ERROR_FAILURE);
     sDBusIsInit = true;
   }
   DBusError err;
   dbus_error_init(&err);
-  mConnection = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+  mConnection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
   if (dbus_error_is_set(&err)) {
     dbus_error_free(&err);
     return NS_ERROR_FAILURE;
   }
   dbus_connection_set_exit_on_disconnect(mConnection, FALSE);
   return NS_OK;
 }
 
 void RawDBusConnection::ScopedDBusConnectionPtrTraits::release(DBusConnection* ptr)
 {
   if (ptr) {
+    dbus_connection_close(ptr);
     dbus_connection_unref(ptr);
   }
 }
 
 bool RawDBusConnection::Send(DBusMessage* aMessage)
 {
   nsRefPtr<DBusConnectionSendRunnable> t(
     new DBusConnectionSendRunnable(mConnection, aMessage));