From 5da6e12be566f9f45006d3f9522ce4f74de81a61 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Mon, 11 Jan 2016 23:46:00 +0000 Subject: [PATCH] Fix stop(). Give it a boolean argument for 2 modes of operation: 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 | 11 ++++++----- src/service.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/service.cc b/src/service.cc index 4be3c52..2be1d21 100644 --- a/src/service.cc +++ b/src/service.cc @@ -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 diff --git a/src/service.h b/src/service.h index 3c527b6..1817db4 100644 --- a/src/service.h +++ b/src/service.h @@ -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 -- 2.25.1