On Mon, Jul 5, 2010 at 9:16 PM, Eric Brower <[email protected]> wrote: > Return ECGROUPNOTEQUAL when copying controller parameters fails-- [...]
Let's try this again... Return ECGROUPNOTEQUAL when copying controller parameters fails-- this allows callers to differentiate between cgroup creation failures and controller configuration failures, and makes explicit that this function can return an error code but still have created the cgroup. Callers, such as cgroup_create_cgroup_from_parent(), can now explicitly ignore (the unfortunately expected) controller configuration errors. Signed-off-by: Eric Brower <[email protected]> Acked-by: Balbir Singh <[email protected]> diff -ruPp a/src/api.c b/src/api.c --- a/src/api.c 2010-07-05 09:12:12.116417609 -0700 +++ b/src/api.c 2010-07-05 10:54:45.955407274 -0700 @@ -1310,6 +1310,8 @@ err: * * returns 0 on success. We recommend calling cg_delete_cgroup * if this routine fails. That should do the cleanup operation. + * If ECGROUPNOTEQUAL is returned, the group was created successfully + * but not all controller parameters were successfully set. */ int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership) { @@ -1374,8 +1376,8 @@ int cgroup_create_cgroup(struct cgroup * for (j = 0; j < cgroup->controller[k]->index; j++) { ret = snprintf(path, FILENAME_MAX, "%s%s", base, cgroup->controller[k]->values[j]->name); - cgroup_dbg("setting %s to %s, error %d\n", path, - cgroup->controller[k]->values[j]->name, ret); + cgroup_dbg("setting %s to \"%s\", pathlen %d\n", path, + cgroup->controller[k]->values[j]->value, ret); if (ret < 0 || ret >= FILENAME_MAX) { last_errno = errno; error = ECGOTHER; @@ -1390,10 +1392,15 @@ int cgroup_create_cgroup(struct cgroup * * are only conditionally created in the child. * * A middle ground would be to track that there - * was an error and return that value. + * was an error and return a diagnostic value-- + * callers don't get context for the error, but can + * ignore it specifically if they wish. */ if (error) { - retval = error; + cgroup_dbg("failed to set %s: %s (%d)\n", + path, + cgroup_strerror(error), error); + retval = ECGROUPNOTEQUAL; continue; } } @@ -1508,6 +1515,9 @@ free_parent: * @cgroup: cgroup data structure to be filled with parent values and then * passed down for creation * @ignore_ownership: Ignore doing a chown on the newly created cgroup + * @return 0 on success, > 0 on failure. If ECGROUPNOTEQUAL is returned, + * the group was created successfully, but not all controller parameters + * were copied from the parent successfully; unfortunately, this is expected... */ int cgroup_create_cgroup_from_parent(struct cgroup *cgroup, int ignore_ownership) -- E ------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://ad.doubleclick.net/clk;226879339;13503038;l? http://clk.atdmt.com/CRS/go/247765532/direct/01/ _______________________________________________ Libcg-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libcg-devel
