From 20ddac74899c4720378d36cab860d9a7cf89de8e Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Tue, 20 Feb 2018 11:43:51 +0000 Subject: [PATCH] Move processing of start pin in do_stop. The pin should prevent the process from stopping, but not from any other effects on dependencies. This change makes dependencies of a start-pinned service potentially go into STOPPING state, if the pinned service is issued a stop. --- src/service.cc | 4 ++-- src/tests/tests.cc | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/service.cc b/src/service.cc index 64c39f5..aa4f0c0 100644 --- a/src/service.cc +++ b/src/service.cc @@ -445,8 +445,6 @@ void service_record::stop(bool bring_down) noexcept void service_record::do_stop() noexcept { - if (pinned_started) return; - // A service that does actually stop for any reason should have its explicit activation released, unless // it will restart: if (start_explicit && ! do_auto_restart()) { @@ -490,6 +488,8 @@ void service_record::do_stop() noexcept } } + if (pinned_started) return; + service_state = service_state_t::STOPPING; waiting_for_deps = true; if (all_deps_stopped) { diff --git a/src/tests/tests.cc b/src/tests/tests.cc index 0fa5764..9e049e0 100644 --- a/src/tests/tests.cc +++ b/src/tests/tests.cc @@ -210,17 +210,16 @@ void test_pin1() s2->stop(true); sset.process_queues(); - // s3 should remain started: + // s3 should remain started due to pin: assert(s3->get_state() == service_state_t::STARTED); assert(s2->get_state() == service_state_t::STOPPING); - assert(s1->get_state() == service_state_t::STARTED); + assert(s1->get_state() == service_state_t::STOPPING); // If we now unpin, s3 should stop: s3->unpin(); sset.process_queues(); assert(s3->get_state() == service_state_t::STOPPED); assert(s2->get_state() == service_state_t::STOPPED); - // s1 will stop because it is no longer required: assert(s1->get_state() == service_state_t::STOPPED); } -- 2.25.1