mirror of
https://github.com/troglobit/finit.git
synced 2026-10-31 13:00:32 +00:00
Handle type change from inetd to service
When a service changes type from inetd to a regular daemon we must make sure to first deregister the currently running inetd service properly. Example: a system boots up with httpd.conf as an inetd service, so Finit opens a socket 0.0.0.0:80 pending connections to start `httpd -i`. After a while a user changes httpd.conf to be a regular service and calls `initctl reload`. Without this patch the socket will remain open and prevent httpd from opening and binding to the same port. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
448a9e1198
commit
df1fbbc996
1 file changed
+8
@@ -616,6 +616,7 @@ int service_register(int type, char *line, time_t mtime, char *username)
|
|||||||
|
|
||||||
id = svc_next_id(cmd);
|
id = svc_next_id(cmd);
|
||||||
}
|
}
|
||||||
|
recreate:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
svc = svc_find(cmd, id);
|
svc = svc_find(cmd, id);
|
||||||
@@ -626,6 +627,13 @@ int service_register(int type, char *line, time_t mtime, char *username)
|
|||||||
_e("Out of memory, cannot register service %s", cmd);
|
_e("Out of memory, cannot register service %s", cmd);
|
||||||
return errno = ENOMEM;
|
return errno = ENOMEM;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (svc_is_inetd(svc) && type != SVC_TYPE_INETD) {
|
||||||
|
_d("Service was previously inetd, deregistering ...");
|
||||||
|
inetd_del(&svc->inetd);
|
||||||
|
svc_del(svc);
|
||||||
|
goto recreate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desc)
|
if (desc)
|
||||||
|
|||||||
Reference in new issue
Block a user