]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
If cgconfigparser fails, it tries to delete created groups. But if they are
authorJan Safranek <jsafrane@redhat.com>
Tue, 5 Oct 2010 07:51:10 +0000 (13:21 +0530)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Tue, 5 Oct 2010 07:51:10 +0000 (13:21 +0530)
in the config file in wrong order, it tries to remove a parent group before
its children are destroyed, resulting into error.

The roll back should use recursive delete. And in addition, it should
delete as much as possible, not to stop on first error.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Reviewed-By: Ivana Hutarova Varekova <varekova@redhat.com>
Tested-By: Ivana Hutarova Varekova <varekova@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
src/config.c

index abf90e71433c6a8ecfa25126dcfbdb98305d8099..c38b69ecc193cca5230d8af1ea2b95a24210d49d 100644 (file)
@@ -442,16 +442,20 @@ static int cgroup_config_create_groups(void)
  */
 static int cgroup_config_destroy_groups(void)
 {
-       int error = 0;
+       int error = 0, ret = 0;
        int i;
 
        for (i = 0; i < cgroup_table_index; i++) {
                struct cgroup *cgroup = &config_cgroup_table[i];
-               error = cgroup_delete_cgroup(cgroup, 0);
-               if (error)
-                       return error;
+               error = cgroup_delete_cgroup_ext(cgroup,
+                               CGFLAG_DELETE_RECURSIVE
+                               | CGFLAG_DELETE_IGNORE_MIGRATION);
+               if (error) {
+                       /* store the error, but continue deleting the rest */
+                       ret = error;
+               }
        }
-       return error;
+       return ret;
 }
 
 /*