Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
254faf07
Commit
254faf07
authored
Sep 22, 2021
by
Dridi Boukelmoune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: Simply require that SO_???TIMEO are present
Closes #3692 Conflicts: bin/varnishd/cache/cache_acceptor.c
parent
6093812b
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
20 additions
and
146 deletions
+20
-146
cache_acceptor.c
bin/varnishd/cache/cache_acceptor.c
+0
-8
cache_vrt_var.c
bin/varnishd/cache/cache_vrt_var.c
+0
-5
b00020.vtc
bin/varnishtest/tests/b00020.vtc
+0
-2
b00021.vtc
bin/varnishtest/tests/b00021.vtc
+0
-2
b00022.vtc
bin/varnishtest/tests/b00022.vtc
+0
-2
b00023.vtc
bin/varnishtest/tests/b00023.vtc
+0
-2
b00026.vtc
bin/varnishtest/tests/b00026.vtc
+0
-2
s00010.vtc
bin/varnishtest/tests/s00010.vtc
+0
-2
s00012.vtc
bin/varnishtest/tests/s00012.vtc
+0
-2
vtc_misc.c
bin/varnishtest/vtc_misc.c
+0
-9
configure.ac
configure.ac
+16
-83
params.h
include/tbl/params.h
+3
-22
vtcp.c
lib/libvarnish/vtcp.c
+1
-5
No files found.
bin/varnishd/cache/cache_acceptor.c
View file @
254faf07
...
...
@@ -100,12 +100,8 @@ static struct sock_opt {
SOCK_OPT
(
SOL_SOCKET
,
SO_LINGER
,
struct
linger
)
SOCK_OPT
(
SOL_SOCKET
,
SO_KEEPALIVE
,
int
)
#ifdef SO_SNDTIMEO_WORKS
SOCK_OPT
(
SOL_SOCKET
,
SO_SNDTIMEO
,
struct
timeval
)
#endif
#ifdef SO_RCVTIMEO_WORKS
SOCK_OPT
(
SOL_SOCKET
,
SO_RCVTIMEO
,
struct
timeval
)
#endif
SOCK_OPT
(
IPPROTO_TCP
,
TCP_NODELAY
,
int
)
#ifdef HAVE_TCP_KEEP
...
...
@@ -204,14 +200,10 @@ vca_sock_opt_init(void)
SET_VAL
(
SO_LINGER
,
so
,
lg
,
disable_so_linger
);
SET_VAL
(
SO_KEEPALIVE
,
so
,
i
,
enable_so_keepalive
);
#ifdef SO_SNDTIMEO_WORKS
NEW_VAL
(
SO_SNDTIMEO
,
so
,
tv
,
VTIM_timeval
(
cache_param
->
idle_send_timeout
));
#endif
#ifdef SO_RCVTIMEO_WORKS
NEW_VAL
(
SO_RCVTIMEO
,
so
,
tv
,
VTIM_timeval
(
cache_param
->
timeout_idle
));
#endif
SET_VAL
(
TCP_NODELAY
,
so
,
i
,
enable_tcp_nodelay
);
#ifdef HAVE_TCP_KEEP
NEW_VAL
(
TCP_KEEPIDLE
,
so
,
i
,
...
...
bin/varnishd/cache/cache_vrt_var.c
View file @
254faf07
...
...
@@ -1000,14 +1000,9 @@ HTTP_VAR(beresp)
static
inline
void
set_idle_send_timeout
(
const
struct
sess
*
sp
,
VCL_DURATION
d
)
{
#ifdef SO_SNDTIMEO_WORKS
struct
timeval
tv
=
VTIM_timeval
(
d
);
VTCP_Assert
(
setsockopt
(
sp
->
fd
,
SOL_SOCKET
,
SO_SNDTIMEO
,
&
tv
,
sizeof
tv
));
#else
(
void
)
sp
;
(
void
)
d
;
#endif
}
#define SESS_VAR_DUR(x, setter) \
...
...
bin/varnishtest/tests/b00020.vtc
View file @
254faf07
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"
...
...
bin/varnishtest/tests/b00021.vtc
View file @
254faf07
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"
...
...
bin/varnishtest/tests/b00022.vtc
View file @
254faf07
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"
...
...
bin/varnishtest/tests/b00023.vtc
View file @
254faf07
varnishtest "Check that the first_byte_timeout works"
feature SO_RCVTIMEO_WORKS
# From VCL
server s1 {
...
...
bin/varnishtest/tests/b00026.vtc
View file @
254faf07
varnishtest "Check the precedence for timeouts"
feature SO_RCVTIMEO_WORKS
server s1 {
rxreq
expect req.url == "from_backend"
...
...
bin/varnishtest/tests/s00010.vtc
View file @
254faf07
...
...
@@ -3,8 +3,6 @@ varnishtest "client h1 send timeouts - tcp"
# XXX See https://github.com/varnishcache/varnish-cache/pull/2980#issuecomment-486214661
feature cmd {test $(uname) != "SunOS" && test $(uname) != "Darwin"}
feature SO_RCVTIMEO_WORKS
barrier b1 cond 2 -cyclic
barrier b2 cond 2 -cyclic
...
...
bin/varnishtest/tests/s00012.vtc
View file @
254faf07
...
...
@@ -2,8 +2,6 @@ varnishtest "client h1 send timeouts - uds"
feature cmd {test $(uname) != "SunOS"}
feature SO_RCVTIMEO_WORKS
server s1 {
rxreq
txresp -bodylen 100000
...
...
bin/varnishtest/vtc_misc.c
View file @
254faf07
...
...
@@ -410,8 +410,6 @@ addr_no_randomize_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
* ipv4
...
...
@@ -508,12 +506,6 @@ static const unsigned with_persistent_storage = 1;
static
const
unsigned
with_persistent_storage
=
0
;
#endif
#ifdef SO_RCVTIMEO_WORKS
static
const
unsigned
so_rcvtimeo_works
=
1
;
#else
static
const
unsigned
so_rcvtimeo_works
=
0
;
#endif
void
v_matchproto_
(
cmd_f
)
cmd_feature
(
CMD_ARGS
)
{
...
...
@@ -566,7 +558,6 @@ cmd_feature(CMD_ARGS)
FEATURE
(
"tsan"
,
tsan
);
FEATURE
(
"ubsan"
,
ubsan
);
FEATURE
(
"sanitizer"
,
sanitizer
);
FEATURE
(
"SO_RCVTIMEO_WORKS"
,
so_rcvtimeo_works
);
FEATURE
(
"workspace_emulator"
,
workspace_emulator
);
if
(
!
strcmp
(
feat
,
"cmd"
))
{
...
...
configure.ac
View file @
254faf07
...
...
@@ -532,91 +532,24 @@ AC_CHECK_MEMBER([struct sockaddr.sa_len],
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 denial-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}"
...
...
include/tbl/params.h
View file @
254faf07
...
...
@@ -610,11 +610,6 @@ PARAM_SIMPLE(
"of that the response is allowed to take up."
)
#if defined(SO_SNDTIMEO_WORKS)
# define PLATFORM_FLAGS DELAYED_EFFECT
#else
# define PLATFORM_FLAGS NOT_IMPLEMENTED
#endif
PARAM_SIMPLE
(
/* name */
idle_send_timeout
,
/* type */
timeout
,
...
...
@@ -628,9 +623,8 @@ PARAM_SIMPLE(
"When this timeout is hit, the session is closed.
\n\n
"
"See the man page for `setsockopt(2)` or `socket(7)` under"
" ``SO_SNDTIMEO`` for more information."
,
/* flags */
PLATFORM_DEPENDENT
|
PLATFORM_FLAGS
/* flags */
DELAYED_EFFECT
)
#undef PLATFORM_FLAGS
PARAM_SIMPLE
(
/* name */
listen_depth
,
...
...
@@ -781,11 +775,6 @@ PARAM_SIMPLE(
/* flags */
EXPERIMENTAL
)
#if defined(SO_SNDTIMEO_WORKS)
# define PLATFORM_FLAGS DELAYED_EFFECT
#else
# define PLATFORM_FLAGS NOT_IMPLEMENTED
#endif
PARAM_SIMPLE
(
/* name */
send_timeout
,
/* type */
timeout
,
...
...
@@ -800,9 +789,8 @@ PARAM_SIMPLE(
" timeout is extended unless the total time already taken for sending"
" the response in its entirety exceeds this many seconds.
\n\n
"
"When this timeout is hit, the session is closed"
,
/* flags */
PLATFORM_DEPENDENT
|
PLATFORM_FLAGS
/* flags */
DELAYED_EFFECT
)
#undef PLATFORM_FLAGS
PARAM_SIMPLE
(
/* name */
shortlived
,
...
...
@@ -914,11 +902,6 @@ PARAM_SIMPLE(
)
#undef PLATFORM_FLAGS
#if defined(SO_RCVTIMEO_WORKS)
# define PLATFORM_FLAGS 0
#else
# define PLATFORM_FLAGS NOT_IMPLEMENTED
#endif
PARAM_SIMPLE
(
/* name */
timeout_idle
,
/* type */
timeout
,
...
...
@@ -932,10 +915,8 @@ PARAM_SIMPLE(
" request headers.
\n\n
"
"This parameter is particularly relevant for HTTP1 keepalive "
" connections which are closed unless the next request is received"
" before this timeout is reached."
,
/* flags */
PLATFORM_DEPENDENT
|
PLATFORM_FLAGS
" before this timeout is reached."
)
#undef PLATFORM_FLAGS
PARAM_SIMPLE
(
/* name */
timeout_linger
,
...
...
lib/libvarnish/vtcp.c
View file @
254faf07
...
...
@@ -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
}
/*--------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment