]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
config.c: better detect whether template group already is created
authorIvana Hutarova Varekova <varekova@redhat.com>
Thu, 18 Jul 2013 10:51:41 +0000 (12:51 +0200)
committerIvana Hutarova Varekova <varekova@redhat.com>
Thu, 18 Jul 2013 10:51:41 +0000 (12:51 +0200)
cgroup_config_create_template_group: properly detect whether template group was created

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
src/config.c

index b2b8a13545b05b8cb325da944b35754e11750a9a..06f559befebaf4f6d8a7a6073594f9f3f02bfbea 100644 (file)
@@ -1566,6 +1566,7 @@ int cgroup_config_create_template_group(struct cgroup *cgroup,
        char buffer[FILENAME_MAX];
        struct cgroup *aux_cgroup;
        struct cgroup_controller *cgc;
+       int found;
 
        /*
         * If the user did not ask for cached rules, we must parse the
@@ -1590,6 +1591,7 @@ int cgroup_config_create_template_group(struct cgroup *cgroup,
                /* for each controller we have to add to cgroup structure
                 * either template cgroup or empty controller  */
 
+               found = 0;
                /* look for relevant template - test name x controller pair */
                for (j = 0; j < template_table_index; j++) {
 
@@ -1625,12 +1627,16 @@ int cgroup_config_create_template_group(struct cgroup *cgroup,
                                } else {
                                        /* go to new controller */
                                        j = template_table_index;
+                                       found = 1;
                                        continue;
                                }
 
                        }
                }
 
+               if (found == 1)
+                       continue;
+
                /* no template is present for given name x controller pair
                 * add controller to result cgroup */
                aux_cgroup = cgroup_new_cgroup(cgroup->name);