manager/service: when we have multiple candidates to handle, warn

This would be very confusing to users, so let's warn if they configured the
same handler for multiple units and we're not running it as expected.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2022-03-10 14:51:28 +00:00
committed by Luca Boccassi
parent edbf8984a4
commit 7a5049c780
+9 -10
View File
@@ -1462,24 +1462,23 @@ static Service *service_get_triggering_service(Service *s) {
* one to propagate the exit status. */
UNIT_FOREACH_DEPENDENCY(other, UNIT(s), UNIT_ATOM_ON_FAILURE_OF) {
if (candidate) {
log_unit_debug(UNIT(s), "multiple trigger source candidates for exit status propagation, skipping.");
return NULL;
}
if (candidate)
goto have_other;
candidate = other;
}
UNIT_FOREACH_DEPENDENCY(other, UNIT(s), UNIT_ATOM_ON_SUCCESS_OF) {
if (candidate) {
log_unit_debug(UNIT(s), "multiple trigger source candidates for exit status propagation, skipping.");
return NULL;
}
if (candidate)
goto have_other;
candidate = other;
}
return SERVICE(candidate);
have_other:
log_unit_warning(UNIT(s), "multiple trigger source candidates for exit status propagation (%s, %s), skipping.",
candidate->id, other->id);
return NULL;
}
static int service_spawn_internal(