mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07: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:
@@ -262,10 +262,13 @@ int inetd_start(inetd_t *inetd)
|
||||
/* Read anything lingering, or clean up socket after failure */
|
||||
len = recv(sd, buf, sizeof(buf), MSG_DONTWAIT);
|
||||
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 */
|
||||
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);
|
||||
uev_io_start(&inetd->watcher);
|
||||
|
||||
Reference in New Issue
Block a user