From b8bcfeb78d2be05cd1f441f292c808c7c4f4abc2 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 12 Mar 2015 13:42:46 +0100 Subject: core-util: Fix set_nice() to use private bus connections In src/pulsecore/core-util.c:set_nice() we currently use a temporary dbus-connection to set the nice-level via rtkit. However, we never close that connection. This is fine, as the connection is shared and dbus-core will manage it. But no other part of pulseaudio (except set_scheduler()) uses the libdbus1 managed connections. Therefore, we effectively end up with an unused dbus-connection that is not integrated into any main-loop. dbus-daemon will send bus-notifications to the connection (as libdbus1 installs matches for those by default (it has to!)) until the outgoing queue is full. Thus, we waste several KBs (or MBs? I didn't look it up) of memory for a message queue that is never dispatched. Signed-off-by: David Henningsson --- src/pulsecore/core-util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 9b16936c9..b37e450ca 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -860,7 +860,7 @@ static int set_nice(int nice_level) { #ifdef HAVE_DBUS /* Try to talk to RealtimeKit */ - if (!(bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) { + if (!(bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error))) { pa_log("Failed to connect to system bus: %s\n", error.message); dbus_error_free(&error); errno = -EIO; @@ -873,6 +873,7 @@ static int set_nice(int nice_level) { dbus_connection_set_exit_on_disconnect(bus, FALSE); r = rtkit_make_high_priority(bus, 0, nice_level); + dbus_connection_close(bus); dbus_connection_unref(bus); if (r >= 0) { -- cgit v1.2.3