sleep,home: always initialize UnitFreezer if used
Previously, unit_freezer_new_freeze() would only return UnitFreezer object if FreezeUnit() succeeds. This is not ideal though, as a failed bus call doesn't mean the action actually failed. E.g. a timeout might occur because pid1 is waiting for cgroup event from kernel, while the bus call timeout was exceeded (#33269). In such a case, ThawUnit() will never be called, resulting in frozen units remain that way after resuming from sleep. Therefore, let's get rid of unit_freezer_new_freeze(), and make sure as long as unit freezer is involved, we'll call ThawUnit() when we're done. This should make things a lot more robust.
This commit is contained in:
@@ -3025,22 +3025,3 @@ int unit_freezer_freeze(UnitFreezer *f) {
|
||||
int unit_freezer_thaw(UnitFreezer *f) {
|
||||
return unit_freezer_action(f, false);
|
||||
}
|
||||
|
||||
int unit_freezer_new_freeze(const char *name, UnitFreezer **ret) {
|
||||
_cleanup_(unit_freezer_freep) UnitFreezer *f = NULL;
|
||||
int r;
|
||||
|
||||
assert(name);
|
||||
assert(ret);
|
||||
|
||||
r = unit_freezer_new(name, &f);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = unit_freezer_freeze(f);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = TAKE_PTR(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -45,5 +45,3 @@ int unit_freezer_new(const char *name, UnitFreezer **ret);
|
||||
|
||||
int unit_freezer_freeze(UnitFreezer *f);
|
||||
int unit_freezer_thaw(UnitFreezer *f);
|
||||
|
||||
int unit_freezer_new_freeze(const char *name, UnitFreezer **ret);
|
||||
|
||||
Reference in New Issue
Block a user