Skip to content

Commit 4a4e721

Browse files
committed
Refactor: libcrmservices: Unref the dbus connection...
...when we disconnect from the bus. We aren't allowed to close the connection since we acquired it with dbus_bus_get which makes it a shared connection. So, this is the best cleanup we can do.
1 parent 51a93e7 commit 4a4e721

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/services/dbus.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,12 @@ pcmk_dbus_connect(void)
294294
void
295295
pcmk_dbus_disconnect(DBusConnection *connection)
296296
{
297-
/* Per the DBus documentation, connections created with
298-
* dbus_connection_open() are owned by libdbus and should never be closed.
299-
*
300-
* @TODO Should we call dbus_connection_unref() here?
297+
/* We acquire our dbus connection with dbus_bus_get(), which makes it a
298+
* shared connection. Therefore, we can't close or free it here. The
299+
* best we can do is decrement the reference count so dbus knows when
300+
* there are no more clients connected to it.
301301
*/
302-
return;
302+
dbus_connection_unref(connection);
303303
}
304304

305305
// Custom DBus error names to use

0 commit comments

Comments
 (0)