Commit 7c9a9995 by Serge Hallyn

cgmanager: tell dbus to do locking

Thanks to S.Çağlar for figuring out that we needed this! Also fix a memory leak found by coverity. Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent b711e4af
...@@ -79,6 +79,7 @@ static bool cgm_keep_connection = false; ...@@ -79,6 +79,7 @@ static bool cgm_keep_connection = false;
static struct cgroup_ops cgmanager_ops; static struct cgroup_ops cgmanager_ops;
static int nr_subsystems; static int nr_subsystems;
static char **subsystems; static char **subsystems;
static bool dbus_threads_initialized = false;
static void cgm_dbus_disconnect(void) static void cgm_dbus_disconnect(void)
{ {
...@@ -95,6 +96,13 @@ static void cgm_dbus_disconnect(void) ...@@ -95,6 +96,13 @@ static void cgm_dbus_disconnect(void)
static bool do_cgm_dbus_connect(void) static bool do_cgm_dbus_connect(void)
{ {
DBusError dbus_error; DBusError dbus_error;
if (!dbus_threads_initialized) {
// tell dbus to do struct locking for thread safety
dbus_threads_init_default();
dbus_threads_initialized = true;
}
dbus_error_init(&dbus_error); dbus_error_init(&dbus_error);
connection = nih_dbus_connect(CGMANAGER_DBUS_SOCK, NULL); connection = nih_dbus_connect(CGMANAGER_DBUS_SOCK, NULL);
...@@ -935,6 +943,7 @@ static bool cgm_attach(const char *name, const char *lxcpath, pid_t pid) ...@@ -935,6 +943,7 @@ static bool cgm_attach(const char *name, const char *lxcpath, pid_t pid)
} }
if (!cgm_dbus_connect()) { if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager"); ERROR("Error connecting to cgroup manager");
lxc_container_put(c);
return false; return false;
} }
// cgm_create makes sure that we have the same cgroup name for all // cgm_create makes sure that we have the same cgroup name for all
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment