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 <david.henningsson@canonical.com>
This commit is contained in:
David Herrmann 2015-03-12 13:42:46 +01:00 committed by David Henningsson
parent a13b6f001d
commit b8bcfeb78d

View file

@ -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) {