From 1269f082de5d1deb7067b70a1013f5ca0b440b12 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Fri, 5 Oct 2018 08:57:01 +0200 Subject: [PATCH] service_unregister(): Refactor, simplify and set #ifdef correctly Signed-off-by: Joachim Nilsson --- src/service.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/service.c b/src/service.c index e26e73c7..005006a5 100644 --- a/src/service.c +++ b/src/service.c @@ -897,21 +897,26 @@ void service_unregister(svc_t *svc) * Only try stopping @svc if it's *not* an inetd connection. * Prevents infinite recursion when called from service_step() */ - if (!svc_is_inetd_conn(svc)) - service_stop(svc); - else { + switch (svc->type) { +#ifdef INETD_ENABLED + case SVC_TYPE_INETD: + inetd_del(&svc->inetd); + break; + + case SVC_TYPE_INETD_CONN: /* inetd connection, if UDP unblock parent */ if (svc_is_busy(svc->inetd.svc)) { svc_unblock(svc->inetd.svc); service_step(svc->inetd.svc); } - } - -#ifdef INETD_ENABLED - if (svc_is_inetd(svc)) - inetd_del(&svc->inetd); + break; #endif + default: + service_stop(svc); + break; + } + svc_del(svc); }