Fix reload of stopped service
authorDavin McCall <davmac@davmac.org>
Thu, 5 Dec 2019 13:45:45 +0000 (23:45 +1000)
committerDavin McCall <davmac@davmac.org>
Thu, 5 Dec 2019 13:45:45 +0000 (23:45 +1000)
src/control.cc
src/includes/service.h

index 0ef1a997f7b417219d1b48c353b996c0f839f528..f9354c55b53717f52c084fe5f58b0a564fca09cc 100644 (file)
@@ -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 {
index c4f8dcf5b5eb6f189a5cae3cfd8c12b5edf902e5..eeb6a1925188dd3216c6b11f69c675e0ca5435cd 100644 (file)
@@ -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<service_record *> &list_services() noexcept
     {