From 4415b965ed001b8bd911d9568c0ee04517119c3f Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Thu, 5 Dec 2019 23:45:45 +1000 Subject: [PATCH] Fix reload of stopped service --- src/control.cc | 2 +- src/includes/service.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/control.cc b/src/control.cc index 0ef1a99..f9354c5 100644 --- a/src/control.cc +++ b/src/control.cc @@ -470,7 +470,7 @@ bool control_conn_t::process_reload_service() auto *new_service = services->reload_service(service); if (new_service != service) { service->prepare_for_unload(); - services->remove_service(service); + services->replace_service(service, new_service); delete service; } else { diff --git a/src/includes/service.h b/src/includes/service.h index c4f8dcf..eeb6a19 100644 --- a/src/includes/service.h +++ b/src/includes/service.h @@ -813,6 +813,12 @@ class service_set records.erase(std::find(records.begin(), records.end(), svc)); } + void replace_service(service_record *orig, service_record *replacement) + { + auto i = std::find(records.begin(), records.end(), orig); + *i = replacement; + } + // Get the list of all loaded services. const std::list &list_services() noexcept { -- 2.25.1