On Tue, Apr 21, 2009 at 02:13:36PM +0530, Balbir Singh wrote: > * Dhaval Giani <[email protected]> [2009-04-21 12:05:55]: > > > On Tue, Apr 21, 2009 at 11:57:34AM +0530, Balbir Singh wrote: > > > * Dhaval Giani <[email protected]> [2009-04-20 19:27:36]: > > > > > > > Add new APIs to iterate through the tasks file to get > > > > the list of all the tasks in a cgroup. > > > > > > > > Signed-off-by: Dhaval Giani <[email protected]> > > > > > > > > --- > > > > include/libcgroup.h | 4 ++ > > > > src/api.c | 88 > > > > ++++++++++++++++++++++++++++++++++++++++++++++++++++ > > > > src/libcgroup.map | 6 +++ > > > > 3 files changed, 98 insertions(+) > > > > > > > > Index: libcg/include/libcgroup.h > > > > =================================================================== > > > > --- libcg.orig/include/libcgroup.h > > > > +++ libcg/include/libcgroup.h > > > > @@ -274,6 +274,10 @@ int cgroup_read_stats_next(void **handle > > > > > > > > int cgroup_read_stats_end(void **handle); > > > > > > > > +int cgroup_get_task_begin(char *cgroup, char *controller, void > > > > **handle, > > > > + pid_t > > > > *pid); > > > > +int cgroup_get_task_next(void **handle, pid_t *pid); > > > > +int cgroup_get_task_end(void **handle); > > > > > > I want to see docbook style comments for each function with each > > > parameter documented. > > > > > > > Will do. Would you prefer a delta, or a respin? > > > > Respin, please > > > > > /* The wrappers for filling libcg structures */ > > > > > > > > struct cgroup *cgroup_new_cgroup(const char *name); > > > > Index: libcg/src/api.c > > > > =================================================================== > > > > --- libcg.orig/src/api.c > > > > +++ libcg/src/api.c > > > > @@ -2407,3 +2407,91 @@ int cgroup_read_stats_begin(char *contro > > > > *handle = fp; > > > > return ret; > > > > } > > > > + > > > > +int cgroup_get_task_end(void **handle) > > > > +{ > > > > + FILE *tasks; > > > > + > > > > + if (!cgroup_initialized) > > > > + return ECGROUPNOTINITIALIZED; > > > > + > > > > > > I think we should encapsulate this in an inline function in the future > > > > > > > + if (!handle) > > > > + return ECGINVAL; > > > > + > > > > + tasks = (FILE *) *handle; > > > ^ > > > Extra space here > > > > hmm. checkpatch did not crib about it. Isn't this more readable? > > > > Not to me.. I like having no space after casts. Coding style is not > clear on that. > > > > > > > > + > > > > + if (!tasks) > > > > + return ECGINVAL; > > > > + > > > > + fclose(tasks); > > > > + tasks = NULL; > > > > + *handle = tasks; > > > > + > > > > + return 0; > > > > +} > > > > + > > > > +int cgroup_get_task_next(void **handle, pid_t *pid) > > > > +{ > > > > + FILE *tasks; > > > > + int ret; > > > > + > > > > + if (!cgroup_initialized) > > > > + return ECGROUPNOTINITIALIZED; > > > > + > > > > + if (!handle) > > > > + return ECGINVAL; > > > > + > > > > + tasks = (FILE *) *handle; > > > > + > > > See above > > > > > > > + if (feof(tasks)) > > > > + return ECGEOF; > > > > + > > > > + ret = fscanf(tasks, "%u", pid); > > > > + > > > > + if (ret != 1) { > > > > + *handle = tasks; > > > > + if (feof(tasks)) > > > > + return ECGEOF; > > > > + last_errno = errno; > > > > + return ECGOTHER; > > > > + } > > > > + > > > > + *handle = tasks; > > > > > > Do we need to do this all the time? Shouldn't doing this at begin be > > > enough? > > > > > > > apparently not. my testing was failing at this very point. So I added > > it. > > Really? Overwriting the handle each time? Something is broken, the > handle should refer to the same pointer, unless the code is doing > something wrong. What problem did you see? >
The pointer not getting set. -- regards, Dhaval ------------------------------------------------------------------------------ Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p _______________________________________________ Libcg-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libcg-devel
