From f349b88170c934728f525db439079d3c1da9e13a Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Sun, 9 Feb 2025 20:42:47 +1000 Subject: [PATCH] Avoid check of service type in process_service::exec_succeeded The only subclass is bgproc_service, and we can just override the function - so do that instead. --- src/includes/proc-service.h | 1 + src/proc-service.cc | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/includes/proc-service.h b/src/includes/proc-service.h index a516bb04..40ca5296 100644 --- a/src/includes/proc-service.h +++ b/src/includes/proc-service.h @@ -834,6 +834,7 @@ class process_service : public base_process_service class bgproc_service : public process_service { virtual void handle_exit_status() noexcept override; + virtual void exec_succeeded() noexcept override; virtual void exec_failed(run_proc_err errcode) noexcept override; enum class pid_result_t { diff --git a/src/proc-service.cc b/src/proc-service.cc index a0bb69b0..6b9ec214 100644 --- a/src/proc-service.cc +++ b/src/proc-service.cc @@ -44,10 +44,6 @@ std::vector separate_args(ha_string &s, void process_service::exec_succeeded() noexcept { - if (get_type() != service_type_t::PROCESS) { - return; - } - tracking_child = true; // This could be a smooth recovery (state already STARTED). No need to do anything here in @@ -83,6 +79,12 @@ void process_service::exec_succeeded() noexcept } } +void bgproc_service::exec_succeeded() noexcept +{ + // For bgproc service, unlike regular process service, successful execution doesn't mean much; + // the process has to terminate (after forking) before we consider it started. +} + void scripted_service::exec_succeeded() noexcept { // For a scripted service, this means nothing other than that the start/stop