]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
This patch fixes file handle leaks as noticed by Paul Menage.
authorBalbir Singh <balbir@linux.vnet.ibm.com>
Thu, 10 Apr 2008 11:37:35 +0000 (11:37 +0000)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Thu, 10 Apr 2008 11:37:35 +0000 (11:37 +0000)
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/branches/balbir@8 4f4bb910-9a46-0410-90c8-c897d4f1cd53

api.c

diff --git a/api.c b/api.c
index 756a3315627cd93740fbeefc8a8d35e67e06d94f..df594ea8efe4e3dd1fc82ce59dc4049fea40ef02 100644 (file)
--- a/api.c
+++ b/api.c
@@ -48,6 +48,7 @@ int cg_init()
                        return ECGROUPNOTMOUNTED;
        }
        strcpy(MOUNT_POINT, ent->mnt_dir);
+       fclose(proc_mount);
        return 0;
 }
 
@@ -67,6 +68,7 @@ static int cg_test_mounted_fs()
                if (ent == NULL)
                        return 0;
        }
+       fclose(proc_mount);
        return 1;
 }
 
@@ -114,6 +116,7 @@ int cg_attach_task_pid(struct cgroup *cgroup, pid_t tid)
                }
        }
        fprintf(tasks, "%d", tid);
+       fclose(tasks);
 
        return 0;
 
@@ -196,11 +199,13 @@ static int cg_set_control_value(char *path, char *val)
                                if (errno == ENOENT)
                                        return ECGROUPSUBSYSNOTMOUNTED;
                        }
+                       fclose(control_file);
                        return ECGROUPNOTALLOWED;
                }
        }
 
        fprintf(control_file, "%s", val);
+       fclose(control_file);
        return 0;
 }
 
@@ -242,27 +247,10 @@ err:
 
 }
 
-/*
- * WARNING: This API is not final. It WILL change format to use
- * struct cgroup. This API will then become internal and be called something
- * else.
- *
- * I am still not happy with how the data structure is looking at the moment,
- * plus there are a couple of additional details to be worked out. Please
- * do not rely on this API.
- *
- * Be prepared to change the implementation later once it shifts to
- * struct cgroup in the real alpha release.
- *
- * The final version is expected to be
+/** create_cgroup creates a new control group.
+ * struct cgroup *cgroup: The control group to be created
  *
- * int create_cgroup(struct cgroup *group);
- *
- * where group is the group to be created
- *
- * Also this version is still at one level since we do not have
- * multi-hierarchy support in kernel. The real alpha release should have this
- * issue sorted out as well.
+ * returns 0 on success.
  */
 int cg_create_cgroup(struct cgroup *cgroup)
 {