From: Arran Cudbard-Bell Date: Fri, 27 Aug 2021 23:00:58 +0000 (-0500) Subject: Deal with EWOULDBLOCK gracefully in log_request_fd_event X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f4cc2b92978184ead732548fd9ab20ae25e903f;p=thirdparty%2Ffreeradius-server.git Deal with EWOULDBLOCK gracefully in log_request_fd_event --- diff --git a/src/lib/server/log.c b/src/lib/server/log.c index ff123ad7724..f35a760a132 100644 --- a/src/lib/server/log.c +++ b/src/lib/server/log.c @@ -972,6 +972,20 @@ void log_request_fd_event(UNUSED fr_event_list_t *el, int fd, UNUSED int flags, ssize_t slen; slen = read(fd, fr_sbuff_current(&m_end), fr_sbuff_remaining(&m_end)); + if (slen < 0) { + if (errno == EINTR) continue; + + /* + * This can happen if the I/O handler is + * manually called to clear out any pending + * data, and we're using a nonblocking FD. + * + * This can happen with the exec code if + * the EVFILT_PROC event gets passed before + * the EVFILT_READ event. + */ + if (errno == EWOULDBLOCK) slen = 0; + } if ((slen < 0) && (errno == EINTR)) continue; if (slen > 0) fr_sbuff_advance(&m_end, slen);