]> git.proxmox.com Git - mirror_lxc.git/commitdiff
re-open cgmanager socket after fork in daemonized start
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 14 Feb 2014 23:16:58 +0000 (00:16 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Sat, 15 Feb 2014 00:12:32 +0000 (19:12 -0500)
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/cgmanager.c
src/lxc/cgroup.c
src/lxc/cgroup.h
src/lxc/lxccontainer.c

index e4bd7349cd606d5c4fe9d3d8c859356bb36fdd48..d683bdedb5a38d6f0705c6c669c5c7bfbcb68627 100644 (file)
@@ -114,7 +114,8 @@ static bool cgm_dbus_connect(void)
 
 static void cgm_dbus_disconnect(void)
 {
-       nih_free(cgroup_manager);
+       if (cgroup_manager)
+               nih_free(cgroup_manager);
        cgroup_manager = NULL;
 }
 
@@ -886,5 +887,6 @@ static struct cgroup_ops cgmanager_ops = {
        .attach = cgm_attach,
        .mount_cgroup = cgm_mount_cgroup,
        .nrtasks = cgm_get_nrtasks,
+       .disconnect = cgm_dbus_disconnect,
 };
 #endif
index b03f69de6f4868e77f6c50256e30a5754312dcdb..d931520b26228bf3856342bb2fa27f767d6bcb76 100644 (file)
@@ -167,3 +167,11 @@ int lxc_cgroup_get(const char *filename, char *value, size_t len, const char *na
                return ops->get(filename, value, len, name, lxcpath);
        return -1;
 }
+
+void restart_cgroups(void)
+{
+       if (ops && ops->disconnect)
+               ops->disconnect();
+       ops = NULL;
+       cgroup_ops_init();
+}
index 6f9e5f64508b1782f146dbfa5e7b75f524f12a51..e3cf6e0ff60c41151f739dc2bf6a3fda4dd4637a 100644 (file)
@@ -49,6 +49,7 @@ struct cgroup_ops {
        bool (*attach)(const char *name, const char *lxcpath, pid_t pid);
        bool (*mount_cgroup)(void *hdata, const char *root, int type);
        int (*nrtasks)(void *hdata);
+       void (*disconnect)(void);
 };
 
 extern bool cgroup_attach(const char *name, const char *lxcpath, pid_t pid);
@@ -64,5 +65,6 @@ extern bool cgroup_create_legacy(struct lxc_handler *handler);
 extern int cgroup_nrtasks(struct lxc_handler *handler);
 extern const char *cgroup_get_cgroup(struct lxc_handler *handler, const char *subsystem);
 extern bool cgroup_unfreeze(struct lxc_handler *handler);
+extern void restart_cgroups(void);
 
 #endif
index ee7d4059c308229372906cf2ba1d65f495d8dc8b..2e9798f128d39fe058c1c59100c80c5e4abd1b0b 100644 (file)
@@ -637,6 +637,7 @@ static bool lxcapi_start(struct lxc_container *c, int useinit, char * const argv
                open("/dev/null", O_RDWR);
                open("/dev/null", O_RDWR);
                setsid();
+               restart_cgroups();
        } else {
                if (!am_single_threaded()) {
                        ERROR("Cannot start non-daemonized container when threaded");