cgroups/cgfsng: rework cgfsng_monitor_destroy()

parent 1359d223
...@@ -1124,12 +1124,23 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops, ...@@ -1124,12 +1124,23 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops,
struct lxc_handler *handler) struct lxc_handler *handler)
{ {
int len; int len;
struct lxc_conf *conf = handler->conf;
char pidstr[INTTYPE_TO_STRLEN(pid_t)]; char pidstr[INTTYPE_TO_STRLEN(pid_t)];
struct lxc_conf *conf;
if (!ops)
log_error_errno(return, ENOENT, "Called with uninitialized cgroup operations");
if (!ops->hierarchies) if (!ops->hierarchies)
return; return;
if (!handler)
log_error_errno(return, EINVAL, "Called with uninitialized handler");
if (!handler->conf)
log_error_errno(return, EINVAL, "Called with uninitialized conf");
conf = handler->conf;
len = snprintf(pidstr, sizeof(pidstr), "%d", handler->monitor_pid); len = snprintf(pidstr, sizeof(pidstr), "%d", handler->monitor_pid);
if (len < 0 || (size_t)len >= sizeof(pidstr)) if (len < 0 || (size_t)len >= sizeof(pidstr))
return; return;
...@@ -1164,16 +1175,15 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops, ...@@ -1164,16 +1175,15 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops,
* Make sure not to pass in the ro string literal PIVOT_CGROUP * Make sure not to pass in the ro string literal PIVOT_CGROUP
* here. * here.
*/ */
if (!cg_legacy_handle_cpuset_hierarchy(h, pivot_cgroup)) { if (!cg_legacy_handle_cpuset_hierarchy(h, pivot_cgroup))
WARN("Failed to handle legacy cpuset controller"); log_warn_errno(continue,
continue; errno, "Failed to handle legacy cpuset controller");
}
ret = mkdir_p(pivot_path, 0755); ret = mkdir_p(pivot_path, 0755);
if (ret < 0 && errno != EEXIST) { if (ret < 0 && errno != EEXIST)
SYSWARN("Failed to create cgroup \"%s\"\n", pivot_path); log_warn_errno(continue, errno,
continue; "Failed to create cgroup \"%s\"\n",
} pivot_path);
if (chop) if (chop)
*chop = '/'; *chop = '/';
...@@ -1182,10 +1192,10 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops, ...@@ -1182,10 +1192,10 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops,
* cgroup. * cgroup.
*/ */
ret = lxc_write_to_file(pivot_path, pidstr, len, false, 0666); ret = lxc_write_to_file(pivot_path, pidstr, len, false, 0666);
if (ret != 0) { if (ret != 0)
SYSWARN("Failed to move monitor %s to \"%s\"\n", pidstr, pivot_path); log_warn_errno(continue, errno,
continue; "Failed to move monitor %s to \"%s\"\n",
} pidstr, pivot_path);
ret = recursive_destroy(h->monitor_full_path); ret = recursive_destroy(h->monitor_full_path);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment