Prevent force_stop state being set in a service that has already
authorDavin McCall <davmac@davmac.org>
Tue, 29 Dec 2015 09:16:40 +0000 (09:16 +0000)
committerDavin McCall <davmac@davmac.org>
Tue, 29 Dec 2015 09:16:40 +0000 (09:16 +0000)
stopped.

service.cc

index 705bb440127651bdf83bffe6f9ee59eafb73300c..2fa88e284953126efb903c88dd56f0b8a658c08c 100644 (file)
@@ -407,12 +407,15 @@ bool ServiceRecord::start_ps_process(const std::vector<std::string> &pargs) noex
 // Mark this and all dependent services as force-stopped.
 void ServiceRecord::forceStop() noexcept
 {
-    force_stop = true;
-    stop();
-    for (sr_iter i = dependents.begin(); i != dependents.end(); i++) {
-        (*i)->forceStop();
+    if (service_state != ServiceState::STOPPED) {
+        force_stop = true;
+        for (sr_iter i = dependents.begin(); i != dependents.end(); i++) {
+            (*i)->forceStop();
+        }
+        stop();
+        
+        // We don't want to force stop soft dependencies, however.
     }
-    // We don't want to force stop soft dependencies, however.
 }
 
 // A dependency of this service failed to start.
@@ -545,14 +548,12 @@ void ServiceRecord::allDepsStopped()
 
 void ServiceRecord::pinStart() noexcept
 {
-    pinned_stopped = false;
     start();
     pinned_started = true;
 }
 
 void ServiceRecord::pinStop() noexcept
 {
-    pinned_started = false;
     stop();
     pinned_stopped = true;
 }