service_record: add boolean issue_stop parameter to release function.
authorDavin McCall <davmac@davmac.org>
Mon, 15 Jan 2018 22:38:10 +0000 (22:38 +0000)
committerDavin McCall <davmac@davmac.org>
Mon, 15 Jan 2018 22:38:10 +0000 (22:38 +0000)
Most calls of release() either did not require do_stop to be called (or
were otherwise handling the stop themselves anyway).

src/includes/service.h
src/service.cc

index 7e21821d1b3b6c5d27150a60fe7f8b53b1b97fa0..47aae1ba9c73a376b784e7f4f4e2fb11a1491317 100644 (file)
@@ -373,7 +373,7 @@ class service_record
     bool stop_dependents() noexcept;
     
     void require() noexcept;
-    void release() noexcept;
+    void release(bool issue_stop = true) noexcept;
     void release_dependencies() noexcept;
     
     // Check if service is, fundamentally, stopped.
index c8e5f56f919e79fc1e788125d4c88d22915fcb89..f5e3575c6fc3d6a2e42892d158b30f648465d071 100644 (file)
@@ -122,7 +122,7 @@ void service_record::emergency_stop() noexcept
 {
     if (! do_auto_restart() && start_explicit) {
         start_explicit = false;
-        release();
+        release(false);
     }
     forced_stop();
     stop_dependents();
@@ -139,7 +139,7 @@ void service_record::require() noexcept
     }
 }
 
-void service_record::release() noexcept
+void service_record::release(bool issue_stop) noexcept
 {
     if (--required_by == 0) {
         desired_state = service_state_t::STOPPED;
@@ -153,7 +153,7 @@ void service_record::release() noexcept
         if (service_state == service_state_t::STOPPED) {
             services->service_inactive(this);
         }
-        else {
+        else if (issue_stop) {
             do_stop();
         }
     }
@@ -473,7 +473,7 @@ void service_record::failed_to_start(bool depfailed) noexcept
     service_state = service_state_t::STOPPED;
     if (start_explicit) {
         start_explicit = false;
-        release();
+        release(false);
     }
     notify_listeners(service_event_t::FAILEDSTART);
     
@@ -542,8 +542,7 @@ void service_record::do_stop() noexcept
 
     if (start_explicit && ! do_auto_restart()) {
         start_explicit = false;
-        release();
-        if (required_by == 0) return; // release will re-call us anyway
+        release(false);
     }
 
     bool all_deps_stopped = stop_dependents();