From: Davin McCall Date: Mon, 11 Jan 2016 23:46:00 +0000 (+0000) Subject: Fix stop(). Give it a boolean argument for 2 modes of operation: X-Git-Tag: v0.01~36 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5da6e12be566f9f45006d3f9522ce4f74de81a61;p=oweals%2Fdinit.git 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). --- 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