core: increment start limit counter only when we can start the unit
Otherwise, e.g. requesting to start a unit that is under stopping may enter the failed state. This makes - rename .can_start() -> .test_startable(), and make it allow to return boolean and refuse to start units when it returns false, - refuse earlier to start units that are in the deactivating state, so several redundant conditions in .start() can be dropped, - move checks for unit states mapped to UNIT_ACTIVATING from .start() to .test_startable(). Fixes #39247.
This commit is contained in:
+3
-3
@@ -906,7 +906,7 @@ static int timer_can_clean(Unit *u, ExecCleanMask *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int timer_can_start(Unit *u) {
|
||||
static int timer_test_startable(Unit *u) {
|
||||
Timer *t = ASSERT_PTR(TIMER(u));
|
||||
int r;
|
||||
|
||||
@@ -916,7 +916,7 @@ static int timer_can_start(Unit *u) {
|
||||
return r;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void activation_details_timer_serialize(const ActivationDetails *details, FILE *f) {
|
||||
@@ -1093,7 +1093,7 @@ const UnitVTable timer_vtable = {
|
||||
|
||||
.bus_set_property = bus_timer_set_property,
|
||||
|
||||
.can_start = timer_can_start,
|
||||
.test_startable = timer_test_startable,
|
||||
};
|
||||
|
||||
const ActivationDetailsVTable activation_details_timer_vtable = {
|
||||
|
||||
Reference in New Issue
Block a user