]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup: allow parsing to be called several times
authorJan Safranek <jsafrane@redhat.com>
Fri, 23 Sep 2011 11:53:06 +0000 (13:53 +0200)
committerJan Safranek <jsafrane@redhat.com>
Thu, 3 Nov 2011 09:12:46 +0000 (10:12 +0100)
cgroup_parse_config() should properly initialize its global variables, so
it can be called several times safely, i.e. several config files can be
parsed in sequence. The call to cgroup_parse_config() *rewrites* previous
result, it does not *add* new groups/mounts to global tables.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
src/config.c

index 726affcb65c3e51ebb404ac1117d6b881ce3235a..38f8b9258624dfc13bb8ba5f20390ab199b8c4f2 100644 (file)
@@ -749,7 +749,13 @@ static int cgroup_parse_config(const char *pathname)
                goto err;
        }
 
+       /* Clear all internal variables so this function can be called twice. */
        init_cgroup_table(config_cgroup_table, MAX_CGROUPS);
+       memset(config_namespace_table, 0, sizeof(config_namespace_table));
+       memset(config_mount_table, 0, sizeof(config_mount_table));
+       config_table_index = 0;
+       namespace_table_index = 0;
+       cgroup_table_index = 0;
 
        /*
         * Parser calls longjmp() on really fatal error (like out-of-memory).