summaryrefslogtreecommitdiff
path: root/src/service.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/service.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/service.c')
-rw-r--r--src/service.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/service.c b/src/service.c
index ec2725a7ba..5764f5f842 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1436,7 +1436,7 @@ static int service_search_main_pid(Service *s) {
return 0;
}
-static void service_notify_sockets_dead(Service *s) {
+static void service_notify_sockets_dead(Service *s, bool broken) {
Iterator i;
Unit *u;
@@ -1449,7 +1449,7 @@ static void service_notify_sockets_dead(Service *s) {
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;
}
@@ -1511,7 +1511,7 @@ static void service_set_state(Service *s, ServiceState state) {
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 &&
@@ -2402,8 +2402,10 @@ static int service_start(Unit *u) {
/* 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;