]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup: Fix the delete API
authorDhaval Giani <dhaval@linux.vnet.ibm.com>
Thu, 14 Aug 2008 11:10:23 +0000 (11:10 +0000)
committerDhaval Giani <dhaval@linux.vnet.ibm.com>
Thu, 14 Aug 2008 11:10:23 +0000 (11:10 +0000)
The delete call was returning a wrong value even on success.
The reason was because in the fallback path, we try to delete
all the groups again. Now it is possible that a group might
have already been deleted and we return a wrong value.

Change the API to check if the group exists before trying to rmdir
it in the error path.

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@145 4f4bb910-9a46-0410-90c8-c897d4f1cd53

api.c

diff --git a/api.c b/api.c
index a6918a8d12d2079b477edef71d5de8b9120c7c7f..56d9af8eafdfb246f6ff01aa219013c5d7afeb6c 100644 (file)
--- a/api.c
+++ b/api.c
@@ -691,8 +691,13 @@ base_open_err:
                                                cgroup->controller[i]->name))
                                continue;
                        error = rmdir(path);
+                       if (error < 0 && errno == ENOENT)
+                               error = 0;
                }
        }
+       if (error)
+               return ECGOTHER;
+
        return error;
 }