Move processing of start pin in do_stop.
authorDavin McCall <davmac@davmac.org>
Tue, 20 Feb 2018 11:43:51 +0000 (11:43 +0000)
committerDavin McCall <davmac@davmac.org>
Tue, 20 Feb 2018 11:43:51 +0000 (11:43 +0000)
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
src/tests/tests.cc

index 64c39f575e58a75810eae867db32ab04535ac066..aa4f0c0f2d6467b80e774b4458fc3ab487ee6595 100644 (file)
@@ -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) {
index 0fa576467e1abf74e35c9741a5bf69990141ec47..9e049e0a3c9daf335a6864956d64bf48eefa258d 100644 (file)
@@ -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);
 }