Bug 89532

Summary: [PATCH] dbus I/O is not dispatched
Product: PulseAudio Reporter: David Herrmann <dh.herrmann>
Component: coreAssignee: pulseaudio-bugs
Status: RESOLVED FIXED QA Contact: pulseaudio-bugs
Severity: normal    
Priority: medium CC: lennart
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Fix set_nice() to use private bus connections

Description David Herrmann 2015-03-11 12:37:24 UTC
Created attachment 114218 [details]
Fix set_nice() to use private bus connections

Hi

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 (with one exception, see below) 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.

If you look at set_scheduler() in the same file, you see the only other user of libdbus1 without pa_dbus. However, it correctly uses a private bus connection via dbus_get_bus_private(). It also correctly closes _and_ unref's it after it's done.

Note that you cannot call dbus_connection_close() on shared connections. Therefore, I recommend fixing set_nice() to work exactly like set_scheduler(). An untested patch is attached. I don't have any clue what the rtkit stuff does, so I cannot really test it. I hope you guys can give it a try.

Thanks
David
Comment 1 David Henningsson 2015-03-12 12:45:30 UTC
Thanks! Pushed to git master.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.