]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Deal with EWOULDBLOCK gracefully in log_request_fd_event
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 27 Aug 2021 23:00:58 +0000 (18:00 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 27 Aug 2021 23:02:22 +0000 (18:02 -0500)
src/lib/server/log.c

index ff123ad7724e9d511a2d69e50b7bf8f54cf5126e..f35a760a132727d0ad96a508cd1776fb713e6888 100644 (file)
@@ -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);