cgroup: change unfreeze_fromhandler to return bool

To be more consistent with other cgroup_ops methods, in the hopes
of having less return-value-related mixups.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
Serge Hallyn 2014-01-30 14:19:41 +00:00 committed by Stéphane Graber
parent c476bdce46
commit ecfcb3f00a
4 changed files with 11 additions and 13 deletions

View File

@ -570,7 +570,7 @@ static inline bool cgm_init(struct lxc_handler *handler)
return collect_subsytems();
}
static int cgm_unfreeze_fromhandler(struct lxc_handler *handler)
static bool cgm_unfreeze_fromhandler(struct lxc_handler *handler)
{
char *cgroup_path = handler->cgroup_info->data;
@ -581,9 +581,9 @@ static int cgm_unfreeze_fromhandler(struct lxc_handler *handler)
ERROR("call to cgmanager_set_value_sync failed: %s", nerr->message);
nih_free(nerr);
ERROR("Error unfreezing %s", cgroup_path);
return -1;
return false;
}
return 0;
return true;
}
static bool setup_limits(struct lxc_handler *h, bool do_devices)

View File

@ -2279,7 +2279,7 @@ static char *cgfs_get_cgroup(struct lxc_handler *handler, const char *subsystem)
return lxc_cgroup_get_hierarchy_path_handler(subsystem, handler);
}
static int cgfs_unfreeze_fromhandler(struct lxc_handler *handler)
static bool cgfs_unfreeze_fromhandler(struct lxc_handler *handler)
{
char *cgabspath, *cgrelpath;
int ret;
@ -2287,11 +2287,11 @@ static int cgfs_unfreeze_fromhandler(struct lxc_handler *handler)
cgrelpath = lxc_cgroup_get_hierarchy_path_handler("freezer", handler);
cgabspath = lxc_cgroup_find_abs_path("freezer", cgrelpath, true, NULL);
if (!cgabspath)
return -1;
return false;
ret = do_cgroup_set(cgabspath, "freezer.state", "THAWED");
free(cgabspath);
return ret;
return ret == 0;
}
bool cgroupfs_setup_limits(struct lxc_handler *h, bool with_devices)
@ -2431,7 +2431,7 @@ int lxc_cgroup_get(const char *filename, char *value, size_t len, const char *na
return active_cg_ops->get(filename, value, len, name, lxcpath);
}
int lxc_unfreeze_fromhandler(struct lxc_handler *handler)
bool lxc_unfreeze_fromhandler(struct lxc_handler *handler)
{
return active_cg_ops->unfreeze_fromhandler(handler);
}

View File

@ -192,7 +192,7 @@ struct cgroup_ops {
char *(*get_cgroup)(struct lxc_handler *handler, const char *subsystem);
int (*set)(const char *filename, const char *value, const char *name, const char *lxcpath);
int (*get)(const char *filename, char *value, size_t len, const char *name, const char *lxcpath);
int (*unfreeze_fromhandler)(struct lxc_handler *handler);
bool (*unfreeze_fromhandler)(struct lxc_handler *handler);
bool (*setup_limits)(struct lxc_handler *handler, bool with_devices);
bool (*chown)(struct lxc_handler *handler);
bool (*attach)(const char *name, const char *lxcpath, pid_t pid);
@ -220,8 +220,8 @@ extern bool cgroup_create_legacy(struct lxc_handler *handler);
extern char *cgroup_get_cgroup(struct lxc_handler *handler, const char *subsystem);
extern bool lxc_cgroup_attach(const char *name, const char *lxcpath, pid_t pid);
extern bool lxc_setup_mount_cgroup(const char *root, struct lxc_cgroup_info *cgroup_info, int type);
extern bool lxc_unfreeze_fromhandler(struct lxc_handler *handler);
extern int lxc_cgroup_set(const char *filename, const char *value, const char *name, const char *lxcpath);
extern int lxc_cgroup_get(const char *filename, char *value, size_t len, const char *name, const char *lxcpath);
extern int lxc_unfreeze_fromhandler(struct lxc_handler *handler);
#endif

View File

@ -583,7 +583,6 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req,
struct lxc_handler *handler)
{
struct lxc_cmd_rsp rsp;
int ret;
int stopsignal = SIGKILL;
if (handler->conf->stopsignal)
@ -591,11 +590,10 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req,
memset(&rsp, 0, sizeof(rsp));
rsp.ret = kill(handler->pid, stopsignal);
if (!rsp.ret) {
ret = lxc_unfreeze_fromhandler(handler);
if (!ret)
if (lxc_unfreeze_fromhandler(handler))
return 0;
ERROR("Failed to unfreeze %s:%s", handler->lxcpath, handler->name);
rsp.ret = ret;
rsp.ret = -1;
}
return lxc_cmd_rsp_send(fd, &rsp);