int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
_cleanup_free_ char *path = NULL;
FreezerState target, kernel = _FREEZER_STATE_INVALID;
- int r;
+ int r, ret;
assert(u);
assert(IN_SET(action, FREEZER_FREEZE, FREEZER_THAW));
if (target == kernel) {
u->freezer_state = target;
- return 0;
- }
+ if (action == FREEZER_FREEZE)
+ return 0;
+ ret = 0;
+ } else
+ ret = 1;
r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, "cgroup.freeze", &path);
if (r < 0)
log_unit_debug(u, "%s unit.", action == FREEZER_FREEZE ? "Freezing" : "Thawing");
- if (action == FREEZER_FREEZE)
- u->freezer_state = FREEZER_FREEZING;
- else
- u->freezer_state = FREEZER_THAWING;
+ if (target != kernel) {
+ if (action == FREEZER_FREEZE)
+ u->freezer_state = FREEZER_FREEZING;
+ else
+ u->freezer_state = FREEZER_THAWING;
+ }
r = write_string_file(path, one_zero(action == FREEZER_FREEZE), WRITE_STRING_FILE_DISABLE_BUFFER);
if (r < 0)
return r;
- return 1;
+ return ret;
}
int unit_get_cpuset(Unit *u, CPUSet *cpus, const char *name) {