diff --git a/src/core/automount.c b/src/core/automount.c index 5ee0937fa7..0c92616575 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -325,6 +325,9 @@ static void automount_enter_dead(Automount *a, AutomountResult f) { if (a->result == AUTOMOUNT_SUCCESS) a->result = f; + if (a->result != AUTOMOUNT_SUCCESS) + log_unit_warning(UNIT(a), "Failed with result '%s'.", automount_result_to_string(a->result)); + automount_set_state(a, a->result != AUTOMOUNT_SUCCESS ? AUTOMOUNT_FAILED : AUTOMOUNT_DEAD); } diff --git a/src/core/mount.c b/src/core/mount.c index 22b3608a2f..903b3a9c1b 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -796,6 +796,9 @@ static void mount_enter_dead(Mount *m, MountResult f) { if (m->result == MOUNT_SUCCESS) m->result = f; + if (m->result != MOUNT_SUCCESS) + log_unit_warning(UNIT(m), "Failed with result '%s'.", mount_result_to_string(m->result)); + mount_set_state(m, m->result != MOUNT_SUCCESS ? MOUNT_FAILED : MOUNT_DEAD); exec_runtime_destroy(m->exec_runtime); diff --git a/src/core/path.c b/src/core/path.c index 83f794be89..7092ed13ba 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -457,6 +457,9 @@ static void path_enter_dead(Path *p, PathResult f) { if (p->result == PATH_SUCCESS) p->result = f; + if (p->result != PATH_SUCCESS) + log_unit_warning(UNIT(p), "Failed with result '%s'.", path_result_to_string(p->result)); + path_set_state(p, p->result != PATH_SUCCESS ? PATH_FAILED : PATH_DEAD); } diff --git a/src/core/scope.c b/src/core/scope.c index 8f9df3b9b7..9670228694 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -253,6 +253,9 @@ static void scope_enter_dead(Scope *s, ScopeResult f) { if (s->result == SCOPE_SUCCESS) s->result = f; + if (s->result != SCOPE_SUCCESS) + log_unit_warning(UNIT(s), "Failed with result '%s'.", scope_result_to_string(s->result)); + scope_set_state(s, s->result != SCOPE_SUCCESS ? SCOPE_FAILED : SCOPE_DEAD); } diff --git a/src/core/service.c b/src/core/service.c index 47fecfb34f..1a4455bd22 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -1512,12 +1512,13 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart) if (s->result == SERVICE_SUCCESS) s->result = f; + if (s->result != SERVICE_SUCCESS) + log_unit_warning(UNIT(s), "Failed with result '%s'.", service_result_to_string(s->result)); + service_set_state(s, s->result != SERVICE_SUCCESS ? SERVICE_FAILED : SERVICE_DEAD); - if (s->result != SERVICE_SUCCESS) { - log_unit_warning(UNIT(s), "Failed with result '%s'.", service_result_to_string(s->result)); + if (s->result != SERVICE_SUCCESS) emergency_action(UNIT(s)->manager, s->emergency_action, UNIT(s)->reboot_arg, "service failed"); - } if (allow_restart && service_shall_restart(s)) { diff --git a/src/core/socket.c b/src/core/socket.c index 3b84ffa2a7..fa93101e52 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -1983,6 +1983,9 @@ static void socket_enter_dead(Socket *s, SocketResult f) { if (s->result == SOCKET_SUCCESS) s->result = f; + if (s->result != SOCKET_SUCCESS) + log_unit_warning(UNIT(s), "Failed with result '%s'.", socket_result_to_string(s->result)); + socket_set_state(s, s->result != SOCKET_SUCCESS ? SOCKET_FAILED : SOCKET_DEAD); exec_runtime_destroy(s->exec_runtime); diff --git a/src/core/swap.c b/src/core/swap.c index 6db1c0df69..f475755572 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -665,6 +665,9 @@ static void swap_enter_dead(Swap *s, SwapResult f) { if (s->result == SWAP_SUCCESS) s->result = f; + if (s->result != SWAP_SUCCESS) + log_unit_warning(UNIT(s), "Failed with result '%s'.", swap_result_to_string(s->result)); + swap_set_state(s, s->result != SWAP_SUCCESS ? SWAP_FAILED : SWAP_DEAD); exec_runtime_destroy(s->exec_runtime); diff --git a/src/core/timer.c b/src/core/timer.c index 3032a237b1..a34bc7b14e 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -296,6 +296,9 @@ static void timer_enter_dead(Timer *t, TimerResult f) { if (t->result == TIMER_SUCCESS) t->result = f; + if (t->result != TIMER_SUCCESS) + log_unit_warning(UNIT(t), "Failed with result '%s'.", timer_result_to_string(t->result)); + timer_set_state(t, t->result != TIMER_SUCCESS ? TIMER_FAILED : TIMER_DEAD); } diff --git a/src/core/unit.c b/src/core/unit.c index c31ddd771e..60cf30ea3a 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2272,7 +2272,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su check_unneeded_dependencies(u); if (ns != os && ns == UNIT_FAILED) { - log_unit_notice(u, "Unit entered failed state."); + log_unit_debug(u, "Unit entered failed state."); unit_start_on_failure(u); } }