From 345e28b6b552c29ae4f15d510efd0e674cf0639c Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Thu, 16 Jun 2016 08:26:09 +0100 Subject: [PATCH] Use the start queue instead of starting services immediately. --- src/service.cc | 7 +++++-- src/service.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/service.cc b/src/service.cc index a7799c6..746a3b6 100644 --- a/src/service.cc +++ b/src/service.cc @@ -51,6 +51,7 @@ void ServiceSet::startService(const char *name) ServiceRecord *record = loadServiceRecord(name); record->start(); + processQueues(true); } void ServiceSet::stopService(const std::string & name) noexcept @@ -85,7 +86,7 @@ void ServiceRecord::stopped() noexcept if (will_restart) { // Desired state is "started". - do_start(); + service_set->addToStartQueue(this); } else { if (socket_fd != -1) { @@ -326,7 +327,7 @@ void ServiceRecord::start(bool activate) noexcept } desired_state = ServiceState::STARTED; - do_start(); + service_set->addToStartQueue(this); } void ServiceRecord::do_start() noexcept @@ -898,12 +899,14 @@ void ServiceRecord::unpin() noexcept pinned_started = false; if (desired_state == ServiceState::STOPPED) { do_stop(); + service_set->processQueues(false); } } if (pinned_stopped) { pinned_stopped = false; if (desired_state == ServiceState::STARTED) { do_start(); + service_set->processQueues(true); } } } diff --git a/src/service.h b/src/service.h index 8b93080..7c4ca90 100644 --- a/src/service.h +++ b/src/service.h @@ -729,6 +729,7 @@ class ServiceSet (*i)->stop(false); (*i)->unpin(); } + processQueues(false); } void set_auto_restart(bool restart) noexcept -- 2.25.1