return 0;
}
-static void service_notify_sockets_dead(Service *s) {
+static void service_notify_sockets_dead(Service *s, bool broken) {
Iterator i;
Unit *u;
SET_FOREACH(u, UNIT(s)->dependencies[UNIT_TRIGGERED_BY], i)
if (u->type == UNIT_SOCKET)
- socket_notify_service_dead(SOCKET(u));
+ socket_notify_service_dead(SOCKET(u), broken);
return;
}
state == SERVICE_FINAL_SIGKILL ||
state == SERVICE_FAILED ||
state == SERVICE_AUTO_RESTART)
- service_notify_sockets_dead(s);
+ service_notify_sockets_dead(s, false);
if (state != SERVICE_START_PRE &&
state != SERVICE_START &&
/* Make sure we don't enter a busy loop of some kind. */
r = service_start_limit_test(s);
- if (r < 0)
+ if (r < 0) {
+ service_notify_sockets_dead(s, true);
return r;
+ }
s->result = SERVICE_SUCCESS;
s->reload_result = SERVICE_SUCCESS;
return 0;
}
-void socket_notify_service_dead(Socket *s) {
+void socket_notify_service_dead(Socket *s, bool broken) {
assert(s);
/* The service is dead. Dang!
* services. */
if (s->state == SOCKET_RUNNING) {
- log_debug("%s got notified about service death.", UNIT(s)->id);
- socket_enter_listening(s);
+ log_debug("%s got notified about service death (broken: %s)", UNIT(s)->id, yes_no(broken));
+ if (broken)
+ socket_enter_stop_pre(s, SOCKET_FAILURE_SERVICE_BROKEN);
+ else
+ socket_enter_listening(s);
}
}
[SOCKET_FAILURE_TIMEOUT] = "timeout",
[SOCKET_FAILURE_EXIT_CODE] = "exit-code",
[SOCKET_FAILURE_SIGNAL] = "signal",
- [SOCKET_FAILURE_CORE_DUMP] = "core-dump"
+ [SOCKET_FAILURE_CORE_DUMP] = "core-dump",
+ [SOCKET_FAILURE_SERVICE_BROKEN] = "service-broken"
};
DEFINE_STRING_TABLE_LOOKUP(socket_result, SocketResult);
SOCKET_FAILURE_EXIT_CODE,
SOCKET_FAILURE_SIGNAL,
SOCKET_FAILURE_CORE_DUMP,
+ SOCKET_FAILURE_SERVICE_BROKEN,
_SOCKET_RESULT_MAX,
_SOCKET_RESULT_INVALID = -1
} SocketResult;
int socket_collect_fds(Socket *s, int **fds, unsigned *n_fds);
/* Called from the service when it shut down */
-void socket_notify_service_dead(Socket *s);
+void socket_notify_service_dead(Socket *s, bool broken);
/* Called from the mount code figure out if a mount is a dependency of
* any of the sockets of this socket */