During shutdown, let process attrition occur naturally, instead of forcing
authorDavin McCall <davmac@davmac.org>
Tue, 12 Jan 2016 00:58:55 +0000 (00:58 +0000)
committerDavin McCall <davmac@davmac.org>
Tue, 12 Jan 2016 00:58:55 +0000 (00:58 +0000)
the services down early.

Also, don't restart a service which has desired_state = STARTED if auto-restart
is disabled.

src/service.cc
src/service.h

index 2be1d212bf3db2bdf8b3995258f97af9ad306ae0..f810b04c7f6ddd34db9b667d1ccd992c831d0e15 100644 (file)
@@ -74,7 +74,7 @@ void ServiceRecord::stopped() noexcept
         dependency->dependentStopped();
     }
     
-    if (desired_state == ServiceState::STARTED) {
+    if (desired_state == ServiceState::STARTED && service_set->get_auto_restart()) {
         // Desired state is "started".
         do_start();
     }
@@ -144,7 +144,8 @@ void ServiceRecord::handle_exit_status() noexcept
         }
         
         if (need_stop) {
-            if (! do_auto_restart()) desired_state = ServiceState::STOPPED;
+            // Failed startup: no auto-restart.
+            desired_state = ServiceState::STOPPED;
             do_stop();
         }
         
index 1817db453e4ecf5950428ad88a4174c20cb87d8b..64ae15c1d5bd0acffba8f24f06c20257c2bb9c4a 100644 (file)
@@ -545,7 +545,7 @@ class ServiceSet
         restart_enabled = false;
         shutdown_type = type;
         for (std::list<ServiceRecord *>::iterator i = records.begin(); i != records.end(); ++i) {
-            (*i)->stop();
+            (*i)->stop(false);
             (*i)->unpin();
         }
     }