core/cgroup: also assume cgroup.events frozen attr is available

Follow-up for 3c86a935ad
This commit is contained in:
Mike Yuan
2025-05-19 21:01:39 +02:00
parent 791847ea64
commit 88f4bf8a8b
+7 -11
View File
@@ -3176,7 +3176,7 @@ static int unit_check_cgroup_events(Unit *u) {
if (!crt || !crt->cgroup_path)
return 0;
r = cg_get_keyed_attribute_graceful(
r = cg_get_keyed_attribute(
SYSTEMD_CGROUP_CONTROLLER,
crt->cgroup_path,
"cgroup.events",
@@ -3188,22 +3188,18 @@ static int unit_check_cgroup_events(Unit *u) {
/* The cgroup.events notifications can be merged together so act as we saw the given state for the
* first time. The functions we call to handle given state are idempotent, which makes them
* effectively remember the previous state. */
if (values[0]) {
if (streq(values[0], "1"))
unit_remove_from_cgroup_empty_queue(u);
else
unit_add_to_cgroup_empty_queue(u);
}
if (streq(values[0], "1"))
unit_remove_from_cgroup_empty_queue(u);
else
unit_add_to_cgroup_empty_queue(u);
/* Disregard freezer state changes due to operations not initiated by us.
* See: https://github.com/systemd/systemd/pull/13512/files#r416469963 and
* https://github.com/systemd/systemd/pull/13512#issuecomment-573007207 */
if (values[1] && IN_SET(u->freezer_state, FREEZER_FREEZING, FREEZER_FREEZING_BY_PARENT, FREEZER_THAWING))
if (IN_SET(u->freezer_state, FREEZER_FREEZING, FREEZER_FREEZING_BY_PARENT, FREEZER_THAWING))
unit_freezer_complete(u, streq(values[1], "0") ? FREEZER_RUNNING : FREEZER_FROZEN);
free(values[0]);
free(values[1]);
free_many_charp(values, ELEMENTSOF(values));
return 0;
}