lib/libvarnish/vtcp.c
int
VTCP_Check(ssize_t a)
{
	if (a == 0)
		return (1);
	if (a > 0)
		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);
	/* tcp(7): The other end didn't acknowledge retransmitted data after
	 * some time. */
	if (errno == ETIMEDOUT)
		return (1);
	/* #3539 various errnos documented on linux as POSIX.1 */
	if (errno == ENETDOWN || errno == ENETUNREACH || errno == ENETRESET ||
	    errno == ECONNABORTED || /* ECONNRESET see above */
	    errno == EHOSTUNREACH || errno == EHOSTDOWN) {
		return (1);
	}

#if (defined (__SVR4) && defined (__sun))
	if (errno == ECONNREFUSED)	// in r02702.vtc
		return (1);
	if (errno == EPROTO)
		return (1);
#endif
#if (defined (__SVR4) && defined (__sun)) ||		\
    defined (__NetBSD__) ||				\
    defined (__APPLE__)
	/*
	 * Solaris and MacOS returns EINVAL if the other end unexpectedly reset
	 * the connection.
	 *
	 * On NetBSD it is documented behaviour.
	 */
	if (errno == EINVAL)
		return (1);
#endif
#if defined(ENABLE_SANITIZER)
	if (errno == EINTR)
		return (1);
#endif
	return (0);
}
/*--------------------------------------------------------------------
 * Check if a TCP syscall return value is fatal
 */
Check if a TCP syscall return value is fatal
Check if a TCP syscall return value is fatal
int
VTCP_Check(ssize_t a)
{
	if (a == 0)
		return (1);
	if (a > 0)
		return (1);
	if (errno == ECONNRESET || errno == ENOTCONN || errno == EPIPE)
		return (1);
	if (errno == EAGAIN || errno == EWOULDBLOCK)
		return (1);
	if (errno == ETIMEDOUT)
		return (1);
	if (errno == ENETDOWN || errno == ENETUNREACH || errno == ENETRESET ||
	    errno == ECONNABORTED || 
	    errno == EHOSTUNREACH || errno == EHOSTDOWN) {
		return (1);
	}
#if (defined (__SVR4) && defined (__sun))
	if (errno == ECONNREFUSED)	
		return (1);
	if (errno == EPROTO)
		return (1);
#endif
#if (defined (__SVR4) && defined (__sun)) ||		\
    defined (__NetBSD__) ||				\
    defined (__APPLE__)
	if (errno == EINVAL)
		return (1);
#endif
#if defined(ENABLE_SANITIZER)
	if (errno == EINTR)
		return (1);
#endif
	return (0);
}
int VTCP_Check ( ssize_t a ) { if ( a == 0 ) return ( 1 ) ; if ( a > 0 ) return ( 1 ) ; if ( errno == ECONNRESET || errno == ENOTCONN || errno == EPIPE ) return ( 1 ) ; if ( errno == EAGAIN || errno == EWOULDBLOCK ) return ( 1 ) ; if ( errno == ETIMEDOUT ) return ( 1 ) ; if ( errno == ENETDOWN || errno == ENETUNREACH || errno == ENETRESET || errno == ECONNABORTED || errno == EHOSTUNREACH || errno == EHOSTDOWN ) { return ( 1 ) ; } #if ( defined ( __SVR4 ) && defined ( __sun ) ) if ( errno == ECONNREFUSED ) return ( 1 ) ; if ( errno == EPROTO ) return ( 1 ) ; #endif #if ( defined ( __SVR4 ) && defined ( __sun ) ) || defined ( __NetBSD__ ) || defined ( __APPLE__ ) if ( errno == EINVAL ) return ( 1 ) ; #endif #if defined ( ENABLE_SANITIZER ) if ( errno == EINTR ) return ( 1 ) ; #endif return ( 0 ) ; }
Check if a TCP syscall return value is fatal
Check if a TCP syscall return value is fatal
/* 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.) */ /* tcp(7): The other end didn't acknowledge retransmitted data after
	 * some time. */ /* #3539 various errnos documented on linux as POSIX.1 */ /* ECONNRESET see above */ // in r02702.vtc /*
	 * Solaris and MacOS returns EINVAL if the other end unexpectedly reset
	 * the connection.
	 *
	 * On NetBSD it is documented behaviour.
	 */