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
@@ -898,7 +898,7 @@ static void path_reset_failed(Unit *u) {
|
||||
p->result = PATH_SUCCESS;
|
||||
}
|
||||
|
||||
static int path_can_start(Unit *u) {
|
||||
static int path_test_startable(Unit *u) {
|
||||
Path *p = ASSERT_PTR(PATH(u));
|
||||
int r;
|
||||
|
||||
@@ -908,7 +908,7 @@ static int path_can_start(Unit *u) {
|
||||
return r;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void activation_details_path_done(ActivationDetails *details) {
|
||||
@@ -1042,7 +1042,7 @@ const UnitVTable path_vtable = {
|
||||
|
||||
.bus_set_property = bus_path_set_property,
|
||||
|
||||
.can_start = path_can_start,
|
||||
.test_startable = path_test_startable,
|
||||
};
|
||||
|
||||
const ActivationDetailsVTable activation_details_path_vtable = {
|
||||
|
||||
Reference in New Issue
Block a user