From 9348a2c28fcb873916684ef0a2b7ea889f974d82 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Fri, 1 Jan 2016 04:01:34 +0000 Subject: [PATCH] Fix another hanging state: "internal" services can be stopped while they are starting and immediately transition from STARTING to STOPPED. If this is not allowed, they hang in STARTING state. (Other service types eventually start due to an external event, and can then stop). --- service.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/service.cc b/service.cc index a0651f1..0638819 100644 --- a/service.cc +++ b/service.cc @@ -479,7 +479,7 @@ void ServiceRecord::stop(bool unpinned) noexcept notifyListeners(ServiceEvent::STARTCANCELLED); } - if (desired_state == ServiceState::STOPPED && !unpinned) return; + if (desired_state == ServiceState::STOPPED && service_state != ServiceState::STARTED) return; desired_state = ServiceState::STOPPED; @@ -491,7 +491,13 @@ void ServiceRecord::stop(bool unpinned) noexcept // starting, but we don't want any dependents to think that // they are still waiting to start. // Make sure they remain stopped: - stopDependents(); + if (stopDependents()) { + if (service_type == ServiceType::INTERNAL) { + // Internal services can go straight from STARTING to STOPPED. + allDepsStopped(); + // (Other types have to finish starting first). + } + } } // If we're starting we need to wait for that to complete. -- 2.25.1