Fix stop(). Give it a boolean argument for 2 modes of operation:
authorDavin McCall <davmac@davmac.org>
Mon, 11 Jan 2016 23:46:00 +0000 (23:46 +0000)
committerDavin McCall <davmac@davmac.org>
Mon, 11 Jan 2016 23:46:00 +0000 (23:46 +0000)
One, release the service if it was explicitly started (which will
 bring it down only if it is no longer needed by any active service)
Two, release the service and bring it down (which will also bring
 down any dependent services).

src/service.cc
src/service.h

index 4be3c52b61542c35fabca8015d68dba571beb457..2be1d212bf3db2bdf8b3995258f97af9ad306ae0 100644 (file)
@@ -722,16 +722,17 @@ void ServiceRecord::dependentStopped() noexcept
     }
 }
 
-void ServiceRecord::stop() noexcept
+void ServiceRecord::stop(bool bring_down) noexcept
 {
-    if (desired_state == ServiceState::STOPPED && service_state != ServiceState::STARTED) return;
-    
-    desired_state = ServiceState::STOPPED;
-    
     if (start_explicit) {
         start_explicit = false;
         release();
     }
+    
+    if (bring_down) {
+        desired_state = ServiceState::STOPPED;
+        do_stop();
+    }
 }
 
 void ServiceRecord::do_stop() noexcept
index 3c527b69027e2c529b08a82ff16f38cbca9bb794..1817db453e4ecf5950428ad88a4174c20cb87d8b 100644 (file)
@@ -432,7 +432,7 @@ class ServiceRecord
     ServiceState getState() const noexcept { return service_state; }
     
     void start(bool activate = true) noexcept;  // start the service
-    void stop() noexcept;   // stop the service
+    void stop(bool bring_down = true) noexcept;   // stop the service
     
     void forceStop() noexcept; // force-stop this service and all dependents