summaryrefslogtreecommitdiff
path: root/src/socket.c
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2012-03-05 22:47:54 +0100
committerMichal Schmidt <mschmidt@redhat.com>2012-03-05 22:47:54 +0100
commitc2f3480897b51dd9b2137f1eeddb4c851e9c6e3b (patch)
tree0b67acba3f0705b4e78c1d1643785ea6b223d56d /src/socket.c
parent82bdec0d65e38333286ae025e5d1aae29b8463f5 (diff)
socket: fail the socket if the service keeps dying on start
If the service reaches the start limit, mark the sockets that activate it as failed (with the result code 'service-broken'). This way the sockets won't act as tarpits for clients connecting to them.
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/socket.c b/src/socket.c
index 15a517bed7..6bcc1297f0 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -2038,7 +2038,7 @@ int socket_collect_fds(Socket *s, int **fds, unsigned *n_fds) {
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!
@@ -2047,8 +2047,11 @@ void socket_notify_service_dead(Socket *s) {
* 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);
}
}
@@ -2156,7 +2159,8 @@ static const char* const socket_result_table[_SOCKET_RESULT_MAX] = {
[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);