From: Davin McCall Date: Wed, 9 Nov 2016 15:17:54 +0000 (+0000) Subject: Check for state STARTING before calling started() when process status X-Git-Tag: v0.04~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=bb6855c2457607fa3f4191324a44176e9892df09;p=oweals%2Fdinit.git 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. --- 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(); } }