Commit a475d980 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune Committed by Martin Blix Grydeland

build: Simply require that SO_???TIMEO are present

Closes #3692
parent 9b2fbebf
......@@ -95,14 +95,8 @@ static struct tcp_opt {
TCPO(SOL_SOCKET, SO_LINGER, struct linger, 0)
TCPO(SOL_SOCKET, SO_KEEPALIVE, int, 0)
TCPO(IPPROTO_TCP, TCP_NODELAY, int, 1)
#ifdef SO_SNDTIMEO_WORKS
TCPO(SOL_SOCKET, SO_SNDTIMEO, struct timeval, 0)
#endif
#ifdef SO_RCVTIMEO_WORKS
TCPO(SOL_SOCKET, SO_RCVTIMEO, struct timeval, 0)
#endif
#ifdef HAVE_TCP_KEEP
TCPO(IPPROTO_TCP, TCP_KEEPIDLE, int, 1)
......@@ -194,16 +188,12 @@ vca_tcp_opt_init(void)
} \
} while (0)
#ifdef SO_SNDTIMEO_WORKS
} else if (!strcmp(to->strname, "SO_SNDTIMEO")) {
tv = VTIM_timeval(cache_param->idle_send_timeout);
NEW_VAL(to, tv);
#endif
#ifdef SO_RCVTIMEO_WORKS
} else if (!strcmp(to->strname, "SO_RCVTIMEO")) {
tv = VTIM_timeval(cache_param->timeout_idle);
NEW_VAL(to, tv);
#endif
#ifdef HAVE_TCP_KEEP
} else if (!strcmp(to->strname, "TCP_KEEPIDLE")) {
x = (int)(cache_param->tcp_keepalive_time);
......
varnishtest "Check that between_bytes_timeout behaves from parameters"
feature SO_RCVTIMEO_WORKS
server s1 {
rxreq
send "HTTP/1.0 200 OK\r\nConnection: close\r\n\r\n"
......
varnishtest "Check the between_bytes_timeout behaves from vcl"
feature SO_RCVTIMEO_WORKS
server s1 {
rxreq
send "HTTP/1.0 200 OK\r\nConnection: close\r\n\r\n"
......
varnishtest "Check the between_bytes_timeout behaves from backend definition"
feature SO_RCVTIMEO_WORKS
server s1 {
rxreq
send "HTTP/1.0 200 OK\r\nConnection: close\r\n\r\n"
......
varnishtest "Check that the first_byte_timeout works"
feature SO_RCVTIMEO_WORKS
# From VCL
server s1 {
......
varnishtest "Check the precedence for timeouts"
feature SO_RCVTIMEO_WORKS
server s1 {
rxreq
expect req.url == "from_backend"
......
......@@ -368,8 +368,6 @@ dns_works(void)
* the test otherwise; or change the interpretation of the test, as
* documented below. feature takes any number of arguments from this list:
*
* SO_RCVTIMEO_WORKS
* The SO_RCVTIMEO socket option is working
* 64bit
* The environment is 64 bits
* !OSX
......@@ -431,13 +429,6 @@ cmd_feature(CMD_ARGS)
for (av++; *av != NULL; av++) {
good = 0;
if (!strcmp(*av, "SO_RCVTIMEO_WORKS")) {
#ifdef SO_RCVTIMEO_WORKS
good = 1;
#else
vtc_stop = 2;
#endif
}
if (!strcmp(*av, "!OSX")) {
#if !defined(__APPLE__) || !defined(__MACH__)
......
......@@ -491,91 +491,24 @@ AM_MISSING_HAS_RUN
AC_CHECK_DECL([SO_ACCEPTFILTER],
AC_DEFINE(HAVE_ACCEPT_FILTERS,1,[Define to 1 if you have accept filters]),
,
[
#include <sys/types.h>
#include <sys/socket.h>
]
)
# Older Solaris versions define SO_{RCV,SND}TIMEO, but do not
# implement them.
#
# Varnish will build and run without these, but connections will not
# time out, which may leave Varnish vulnerable to denail-of-service
# attacks which would not be possible on other platforms.
#
# Newer Solaris releases with the Volo framework (Solaris 11,
# Opensolaris starting with onnv_106) do support SO_{RCV,SND}TIMEO
# (see PSARC 2007/587, initially committed into onnv-gate /
# OpenSolaris 8348:4137e18bfaf0 Thu Dec 11 20:04:13 2008)
save_LIBS="${LIBS}"
LIBS="${LIBS} ${NET_LIBS}"
AC_CACHE_CHECK([whether SO_RCVTIMEO works],
[ac_cv_so_rcvtimeo_works],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <errno.h>
]],[[
int s = socket(AF_INET, SOCK_STREAM, 0);
struct timeval tv = { 1, 0 };
if (s < 0 && errno == EPROTONOSUPPORT)
s = socket(AF_INET6, SOCK_STREAM, 0);
if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv) == 0) {
socklen_t l = sizeof tv;
if (getsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, &l) == 0) {
return (l != sizeof tv);
}
}
return 1;
]])],
[ac_cv_so_rcvtimeo_works=yes],
[ac_cv_so_rcvtimeo_works=no])
])
if test "$ac_cv_so_rcvtimeo_works" = yes; then
AC_DEFINE([SO_RCVTIMEO_WORKS], [1], [Define if SO_RCVTIMEO works])
fi
LIBS="${save_LIBS}"
[], [
#include <sys/types.h>
#include <sys/socket.h>
])
save_LIBS="${LIBS}"
LIBS="${LIBS} ${NET_LIBS}"
AC_CACHE_CHECK([whether SO_SNDTIMEO works],
[ac_cv_so_sndtimeo_works],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <errno.h>
]],[[
int s = socket(AF_INET, SOCK_STREAM, 0);
struct timeval tv = { 1, 0 };
if (s < 0 && errno == EPROTONOSUPPORT)
s = socket(AF_INET6, SOCK_STREAM, 0);
if (setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv) == 0) {
socklen_t l = sizeof tv;
if (getsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &tv, &l) == 0) {
return (l != sizeof tv);
}
}
return 1;
]])],
[ac_cv_so_sndtimeo_works=yes],
[ac_cv_so_sndtimeo_works=no])
])
if test "$ac_cv_so_sndtimeo_works" = yes; then
AC_DEFINE([SO_SNDTIMEO_WORKS], [1], [Define if SO_SNDTIMEO works])
fi
AC_CHECK_DECL([SO_RCVTIMEO],
[],
AC_MSG_ERROR([SO_RCVTIMEO is needed to build Varnish.]), [
#include <sys/types.h>
#include <sys/socket.h>
])
if test "$ac_cv_so_rcvtimeo_works" = no ||
test "$ac_cv_so_sndtimeo_works" = no; then
AC_MSG_WARN([connection timeouts will not work])
fi
LIBS="${save_LIBS}"
AC_CHECK_DECL([SO_SNDTIMEO],
[],
AC_MSG_ERROR([SO_SNDTIMEO is needed to build Varnish.]), [
#include <sys/types.h>
#include <sys/socket.h>
])
# Check if the OS supports TCP_KEEP(CNT|IDLE|INTVL) socket options
save_LIBS="${LIBS}"
......
......@@ -746,15 +746,6 @@ PARAM(
/* func */ NULL
)
#if defined(XYZZY)
#error "Temporary macro XYZZY already defined"
#endif
#if defined(SO_SNDTIMEO_WORKS)
#define XYZZY DELAYED_EFFECT
#else
#define XYZZY NOT_IMPLEMENTED
#endif
PARAM(
/* name */ idle_send_timeout,
/* typ */ timeout,
......@@ -762,7 +753,7 @@ PARAM(
/* max */ NULL,
/* default */ "60.000",
/* units */ "seconds",
/* flags */ XYZZY,
/* flags */ DELAYED_EFFECT,
/* s-text */
"Send timeout for individual pieces of data on client connections."
" May get extended if 'send_timeout' applies.\n\n"
......@@ -772,7 +763,6 @@ PARAM(
/* l-text */ "",
/* func */ NULL
)
#undef XYZZY
PARAM(
/* name */ listen_depth,
......@@ -1010,15 +1000,6 @@ PARAM(
/* func */ NULL
)
#if defined(XYZZY)
#error "Temporary macro XYZZY already defined"
#endif
#if defined(SO_SNDTIMEO_WORKS)
#define XYZZY DELAYED_EFFECT
#else
#define XYZZY NOT_IMPLEMENTED
#endif
PARAM(
/* name */ send_timeout,
/* typ */ timeout,
......@@ -1026,7 +1007,7 @@ PARAM(
/* max */ NULL,
/* default */ "600.000",
/* units */ "seconds",
/* flags */ XYZZY,
/* flags */ DELAYED_EFFECT,
/* s-text */
"Total timeout for ordinary HTTP1 responses. Does not apply to some"
" internally generated errors and pipe mode.\n\n"
......@@ -1037,7 +1018,6 @@ PARAM(
/* l-text */ "",
/* func */ NULL
)
#undef XYZZY
#if 0
/* actual location mgt_param_tbl.c */
......@@ -1100,6 +1080,9 @@ PARAM(
/* func */ NULL
)
#if defined(XYZZY)
#error "Temporary macro XYZZY already defined"
#endif
#if defined(HAVE_TCP_FASTOPEN)
#define XYZZY MUST_RESTART
#else
......@@ -1425,15 +1408,6 @@ PARAM(
)
#endif
#if defined(XYZZY)
#error "Temporary macro XYZZY already defined"
#endif
#if defined(SO_RCVTIMEO_WORKS)
#define XYZZY 0
#else
#define XYZZY NOT_IMPLEMENTED
#endif
PARAM(
/* name */ timeout_idle,
/* typ */ timeout,
......@@ -1441,7 +1415,7 @@ PARAM(
/* max */ NULL,
/* default */ "5.000",
/* units */ "seconds",
/* flags */ XYZZY,
/* flags */ 0,
/* s-text */
"Idle timeout for client connections.\n\n"
"A connection is considered idle until we have received the full"
......@@ -1452,7 +1426,6 @@ PARAM(
/* l-text */ "",
/* func */ NULL
)
#undef XYZZY
PARAM(
/* name */ timeout_linger,
......
......@@ -349,8 +349,8 @@ VTCP_close(int *s)
void
VTCP_set_read_timeout(int s, vtim_dur seconds)
{
#ifdef SO_RCVTIMEO_WORKS
struct timeval timeout = VTIM_timeval(seconds);
/*
* Solaris bug (present at least in snv_151 and older): If this fails
* with EINVAL, the socket is half-closed (SS_CANTSENDMORE) and the
......@@ -359,10 +359,6 @@ VTCP_set_read_timeout(int s, vtim_dur seconds)
*/
VTCP_Assert(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,
&timeout, sizeof timeout));
#else
(void)s;
(void)seconds;
#endif
}
/*--------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment