From fe03c5b5edfb228c2b634ce2a865a91b44009e1d Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Thu, 7 Sep 2017 20:05:39 +0100 Subject: [PATCH] Improve a test (and make it pass). When a service is unpinned from pinned start, it needs to check force_stop and stop if set. --- src/service.cc | 2 +- src/tests/tests.cc | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/service.cc b/src/service.cc index c170dad..e2ba251 100644 --- a/src/service.cc +++ b/src/service.cc @@ -1284,7 +1284,7 @@ void service_record::unpin() noexcept { if (pinned_started) { pinned_started = false; - if (desired_state == service_state_t::STOPPED) { + if (desired_state == service_state_t::STOPPED || force_stop) { do_stop(); services->process_queues(); } diff --git a/src/tests/tests.cc b/src/tests/tests.cc index 7110292..26f5613 100644 --- a/src/tests/tests.cc +++ b/src/tests/tests.cc @@ -210,6 +210,14 @@ void test6() assert(s3->get_state() == service_state_t::STARTED); assert(s2->get_state() == service_state_t::STOPPING); assert(s1->get_state() == service_state_t::STARTED); + + // 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); } // Test 7: stopping a soft dependency doesn't cause the dependent to stop. -- 2.25.1