mirror of
https://github.com/troglobit/finit.git
synced 2026-10-03 06:23:11 +07:00
inet_stop(): Check argument and skip shutdown(), just close() socket
- Validate function argument - Skip¹ shutdown() when closing a TCP socket, not needed ___ ¹ also, shutdown() segfaults a late shutdown/reboot Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
+5
-2
@@ -334,6 +334,11 @@ int inetd_start(inetd_t *inetd)
|
||||
|
||||
void inetd_stop(inetd_t *inetd)
|
||||
{
|
||||
if (!inetd || !inetd->svc) {
|
||||
_e("Invalid inetd, cannot stop it...");
|
||||
return;
|
||||
}
|
||||
|
||||
if (inetd->watcher.fd != -1) {
|
||||
_d("Stopping %s socket watcher ...", inetd->svc->cmd);
|
||||
uev_io_stop(&inetd->watcher);
|
||||
@@ -342,8 +347,6 @@ void inetd_stop(inetd_t *inetd)
|
||||
* 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);
|
||||
if (inetd->type == SOCK_STREAM)
|
||||
shutdown(inetd->watcher.fd, SHUT_RDWR);
|
||||
close(inetd->watcher.fd);
|
||||
inetd->watcher.fd = -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user