[master] f8a8b362e Make VTCP_Check() accept EAGAIN/EWOULDBLOCK as acceptable errno
Martin Blix Grydeland
martin at varnish-software.com
Mon Nov 9 15:13:08 UTC 2020
commit f8a8b362eef918e6211427ec2f6b814410041f61
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Wed Oct 7 14:56:38 2020 +0200
Make VTCP_Check() accept EAGAIN/EWOULDBLOCK as acceptable errno
When a socket timeout is set on a socket and the timeout expires, read()
and write() calls on that socket will return (-1) with errno set to
EAGAIN/EWOULDBLOCK.
diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c
index 45f1c98b7..53335aedf 100644
--- a/lib/libvarnish/vtcp.c
+++ b/lib/libvarnish/vtcp.c
@@ -564,6 +564,14 @@ VTCP_Check(int a)
return (1);
if (errno == ECONNRESET || errno == ENOTCONN || errno == EPIPE)
return (1);
+ /* Accept EAGAIN (and EWOULDBLOCK in case they are not the same)
+ * as errno values. Even though our sockets are all non-blocking,
+ * when a SO_{SND|RCV}TIMEO expires, read() or write() on the
+ * socket will return (-1) and errno set to EAGAIN. (This is not
+ * documented in the read(2) and write(2) manpages, but is
+ * described in the socket(7) manpage.) */
+ if (errno == EAGAIN || errno == EWOULDBLOCK)
+ return (1);
#if (defined (__SVR4) && defined (__sun))
if (errno == EPROTO)
return (1);
More information about the varnish-commit
mailing list