service_unregister(): Refactor, simplify and set #ifdef correctly

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2018-10-05 08:57:01 +02:00
1 parent 7d444e07a5
commit 1269f082de
1 file changed
+13 -8
+13 -8
View File
@@ -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);
}