From bb6855c2457607fa3f4191324a44176e9892df09 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Wed, 9 Nov 2016 15:17:54 +0000 Subject: [PATCH] Check for state STARTING before calling started() when process status fd closes. A smooth-recovery process should not reported started when it recovers (state is already STARTED). Furthermore, a service could be stopped during smooth recovery, in which case the state will be STOPPING and the service should certainly not transition to STARTED. --- src/service.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/service.cc b/src/service.cc index 4df414d..4a5bcec 100644 --- a/src/service.cc +++ b/src/service.cc @@ -277,7 +277,10 @@ Rearm ServiceIoWatcher::fdEvent(EventLoop_t &loop, int fd, int flags) noexcept else { // exec() succeeded. if (sr->service_type == ServiceType::PROCESS) { - if (sr->service_state != ServiceState::STARTED) { + // This could be a smooth recovery (state already STARTED). Even more, the process + // might be stopped (and killed via a signal) during smooth recovery. We don't to + // process startup again in either case, so we check for state STARTING: + if (sr->service_state == ServiceState::STARTING) { sr->started(); } } -- 2.25.1