mirror of
https://github.com/troglobit/finit.git
synced 2026-10-18 10:59:34 +00:00
Check return value from fcntl() on inetd server socket
Setting O_NONBLOCK on an inetd server socket may fail, we must check for this or the event loop may stall and block Finit completely. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
33ccff7733
commit
ef7f0b100b
1 file changed
+5
-2
@@ -262,10 +262,13 @@ int inetd_start(inetd_t *inetd)
|
|||||||
/* Read anything lingering, or clean up socket after failure */
|
/* Read anything lingering, or clean up socket after failure */
|
||||||
len = recv(sd, buf, sizeof(buf), MSG_DONTWAIT);
|
len = recv(sd, buf, sizeof(buf), MSG_DONTWAIT);
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
_d("Read %zd lingering bytes from socket before restarting %s ...", len, inetd->svc->cmd);
|
_d("Read %zd lingering bytes from socket before (re)starting %s ...", len, inetd->svc->cmd);
|
||||||
|
|
||||||
/* Restore O_NONBLOCK for socket */
|
/* Restore O_NONBLOCK for socket */
|
||||||
fcntl(sd, F_SETFL, fcntl(sd, F_GETFL, 0) | O_NONBLOCK);
|
if (fcntl(sd, F_SETFL, fcntl(sd, F_GETFL, 0) | O_NONBLOCK)) {
|
||||||
|
FLOG_PERROR("Cannot safely (re)start %s inetd service", inetd->svc->cmd);
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
|
|
||||||
_d("Re-starting %s socket watcher ...", inetd->svc->cmd);
|
_d("Re-starting %s socket watcher ...", inetd->svc->cmd);
|
||||||
uev_io_start(&inetd->watcher);
|
uev_io_start(&inetd->watcher);
|
||||||
|
|||||||
Reference in new issue
Block a user