mirror of
https://github.com/troglobit/finit.git
synced 2026-11-03 13:28:27 +00: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:
1 parent
dcf8fbe235
commit
bc35b42bd2
1 file changed
+5
-2
+5
-2
@@ -334,6 +334,11 @@ int inetd_start(inetd_t *inetd)
|
|||||||
|
|
||||||
void inetd_stop(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) {
|
if (inetd->watcher.fd != -1) {
|
||||||
_d("Stopping %s socket watcher ...", inetd->svc->cmd);
|
_d("Stopping %s socket watcher ...", inetd->svc->cmd);
|
||||||
uev_io_stop(&inetd->watcher);
|
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! */
|
* and halt the watcher, so don't close the socket! */
|
||||||
if (!svc_is_busy(inetd->svc)) {
|
if (!svc_is_busy(inetd->svc)) {
|
||||||
_d("Shutting down inet socket %d ...", inetd->watcher.fd);
|
_d("Shutting down inet socket %d ...", inetd->watcher.fd);
|
||||||
if (inetd->type == SOCK_STREAM)
|
|
||||||
shutdown(inetd->watcher.fd, SHUT_RDWR);
|
|
||||||
close(inetd->watcher.fd);
|
close(inetd->watcher.fd);
|
||||||
inetd->watcher.fd = -1;
|
inetd->watcher.fd = -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user