]> git.ipfire.org Git - thirdparty/lxc.git/commit
cgmanager: avoid stray dbus connections
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 11 Mar 2014 02:41:34 +0000 (21:41 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 11 Mar 2014 14:55:44 +0000 (10:55 -0400)
commita2868fe90b37f6d22cae1cff1574bac85d6a9891
tree762b70a194a5e4a0855ec9dee0a691fdda881e36
parent800648d24ad2791bc656e47f3a048c01fbe27587
cgmanager: avoid stray dbus connections

There are two parts to this fix.

First, create a private DBusConnection manually, instead of using
nih_dbus_connect.  The latter always creates a shared connection,
which cannot be closed.  Note: creating an actual shared connection,
mutexing it among all threads, and creating per-thread proxies would
be an alternative - however we don't want long-lived connections as
they tend not to be reliable (especially if cgmanager restarts).

Second, use pthread_setspecific to create per-thread keys which can
be associated with destructors.  Specify a destructor which closes
the dbus connection.  If a thread dies while holding cgmanager,
the connection will be closed.  Otherwise, we close the connection
and unset the key.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/cgmanager.c