From ba3e67a78564bf25c5af97ffe2e1a122b193a9cb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 13 Jul 2010 00:27:27 +0200 Subject: [PATCH] socket: when the socket is supposed to stop, don't accept any connections anymore --- src/automount.c | 7 +++++++ src/path.c | 4 ++++ src/socket.c | 7 +++++++ src/timer.c | 4 ++++ 4 files changed, 22 insertions(+) diff --git a/src/automount.c b/src/automount.c index 00f3736b2..e685c96a7 100644 --- a/src/automount.c +++ b/src/automount.c @@ -568,6 +568,13 @@ static void automount_enter_runnning(Automount *a) { dbus_error_init(&error); + /* We don't take mount requests anymore if we are supposed to + * shut down anyway */ + if (a->meta.job && a->meta.job->type == JOB_STOP) { + automount_send_ready(a, -EHOSTDOWN); + return; + } + mkdir_p(a->where, a->directory_mode); /* Before we do anything, let's see if somebody is playing games with us? */ diff --git a/src/path.c b/src/path.c index 27c454472..2ae6e569c 100644 --- a/src/path.c +++ b/src/path.c @@ -304,6 +304,10 @@ static void path_enter_running(Path *p) { assert(p); dbus_error_init(&error); + /* Don't start job if we are supposed to go down */ + if (p->meta.job && p->meta.job->type == JOB_STOP) + return; + if ((r = manager_add_job(p->meta.manager, JOB_START, p->unit, JOB_REPLACE, true, &error, NULL)) < 0) goto fail; diff --git a/src/socket.c b/src/socket.c index 2d113aef3..f998cada2 100644 --- a/src/socket.c +++ b/src/socket.c @@ -1030,6 +1030,13 @@ static void socket_enter_running(Socket *s, int cfd) { assert(s); dbus_error_init(&error); + /* We don't take connections anymore if we are supposed to + * shut down anyway */ + if (s->meta.job && s->meta.job->type == JOB_STOP) { + close_nointr_nofail(cfd); + return; + } + if (cfd < 0) { if ((r = manager_add_job(s->meta.manager, JOB_START, UNIT(s->service), JOB_REPLACE, true, &error, NULL)) < 0) goto fail; diff --git a/src/timer.c b/src/timer.c index 1c7010d12..0d4ed27bb 100644 --- a/src/timer.c +++ b/src/timer.c @@ -268,6 +268,10 @@ static void timer_enter_running(Timer *t) { assert(t); dbus_error_init(&error); + /* Don't start job if we are supposed to go down */ + if (t->meta.job && t->meta.job->type == JOB_STOP) + return; + if ((r = manager_add_job(t->meta.manager, JOB_START, t->unit, JOB_REPLACE, true, &error, NULL)) < 0) goto fail; -- 2.30.2