From 2c904b5b443fe4c62f318c350571ae59a6c85f0e Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Fri, 19 Jan 2018 15:13:08 +0100 Subject: [PATCH] service_unregister(): Also call inetd_del() for inetd services Signed-off-by: Joachim Nilsson --- src/inetd.c | 6 ++++-- src/service.c | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/inetd.c b/src/inetd.c index efd010e5..33627e84 100644 --- a/src/inetd.c +++ b/src/inetd.c @@ -346,8 +346,10 @@ void inetd_stop(inetd_t *inetd) _d("Stopping %s socket watcher ...", inetd->svc->cmd); uev_io_stop(&inetd->watcher); - /* For dgram inetd services we block the parent SVC - * and halt the watcher, so don't close the socket! */ + /* + * For dgram inetd services we block the parent SVC + * and halt the watcher, so don't close the socket! + */ if (!svc_is_busy(inetd->svc)) { _d("Shutting down inet socket %d ...", inetd->watcher.fd); close(inetd->watcher.fd); diff --git a/src/service.c b/src/service.c index 8395da61..00e0f031 100644 --- a/src/service.c +++ b/src/service.c @@ -850,6 +850,18 @@ recreate: void service_unregister(svc_t *svc) { + if (!svc) + return; + + if (svc_is_inetd(svc)) { + if (svc_is_busy(svc->inetd.svc)) { + svc_unblock(svc->inetd.svc); + service_step(svc->inetd.svc); + } + + inetd_del(&svc->inetd); + } + svc_del(svc); } @@ -970,10 +982,6 @@ restart: case SVC_DONE_STATE: #ifdef INETD_ENABLED if (svc_is_inetd_conn(svc)) { - if (svc_is_busy(svc->inetd.svc)) { - svc_unblock(svc->inetd.svc); - service_step(svc->inetd.svc); - } service_unregister(svc); return -1; }