From: Davin McCall Date: Mon, 15 Jan 2018 22:38:10 +0000 (+0000) Subject: service_record: add boolean issue_stop parameter to release function. X-Git-Tag: v0.08~31 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0747492dfb73ed9c0422c3abd5cd9fe3cd64cada;p=oweals%2Fdinit.git service_record: add boolean issue_stop parameter to release function. Most calls of release() either did not require do_stop to be called (or were otherwise handling the stop themselves anyway). --- diff --git a/src/includes/service.h b/src/includes/service.h index 7e21821..47aae1b 100644 --- a/src/includes/service.h +++ b/src/includes/service.h @@ -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. diff --git a/src/service.cc b/src/service.cc index c8e5f56..f5e3575 100644 --- a/src/service.cc +++ b/src/service.cc @@ -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();