From: Davin McCall Date: Thu, 5 Dec 2019 13:45:45 +0000 (+1000) Subject: Fix reload of stopped service X-Git-Tag: v0.8.0~10 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4415b965ed001b8bd911d9568c0ee04517119c3f;p=oweals%2Fdinit.git Fix reload of stopped service --- 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 {