Check for state STARTING before calling started() when process status
authorDavin McCall <davmac@davmac.org>
Wed, 9 Nov 2016 15:17:54 +0000 (15:17 +0000)
committerDavin McCall <davmac@davmac.org>
Wed, 9 Nov 2016 15:17:54 +0000 (15:17 +0000)
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

index 4df414d92c1bb4cc0a8b1ef058412a1a59edae7c..4a5bcec90f9709b00f3fd9552bcf82420cc4acff 100644 (file)
@@ -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();
             }
         }