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
e8c074b9
Commit
e8c074b9
authored
Jan 10, 2017
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restrict return(vcl) to before any restart, and reset the req.http
to avoid any memory leaks. Closes #2177
parent
275b0076
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
2 deletions
+70
-2
cache_req_fsm.c
bin/varnishd/cache/cache_req_fsm.c
+6
-2
r02177.vtc
bin/varnishtest/tests/r02177.vtc
+64
-0
No files found.
bin/varnishd/cache/cache_req_fsm.c
View file @
e8c074b9
...
@@ -691,8 +691,10 @@ cnt_recv(struct worker *wrk, struct req *req)
...
@@ -691,8 +691,10 @@ cnt_recv(struct worker *wrk, struct req *req)
}
}
VCL_recv_method
(
req
->
vcl
,
wrk
,
req
,
NULL
,
NULL
);
VCL_recv_method
(
req
->
vcl
,
wrk
,
req
,
NULL
,
NULL
);
if
(
wrk
->
handling
==
VCL_RET_VCL
)
{
if
(
wrk
->
handling
==
VCL_RET_VCL
&&
req
->
restarts
==
0
)
{
req
->
director_hint
=
VCL_DefaultDirector
(
req
->
vcl
);
req
->
director_hint
=
VCL_DefaultDirector
(
req
->
vcl
);
HTTP_Copy
(
req
->
http
,
req
->
http0
);
WS_Reset
(
req
->
ws
,
req
->
ws_req
);
AN
(
req
->
director_hint
);
AN
(
req
->
director_hint
);
VCL_recv_method
(
req
->
vcl
,
wrk
,
req
,
NULL
,
NULL
);
VCL_recv_method
(
req
->
vcl
,
wrk
,
req
,
NULL
,
NULL
);
}
}
...
@@ -724,7 +726,9 @@ cnt_recv(struct worker *wrk, struct req *req)
...
@@ -724,7 +726,9 @@ cnt_recv(struct worker *wrk, struct req *req)
switch
(
recv_handling
)
{
switch
(
recv_handling
)
{
case
VCL_RET_VCL
:
case
VCL_RET_VCL
:
VSLb
(
req
->
vsl
,
SLT_VCL_Error
,
VSLb
(
req
->
vsl
,
SLT_VCL_Error
,
"return(vcl) only allowed from active (top) VCL."
);
"Illegal return(vcl): %s"
,
req
->
restarts
?
"Not after restarts"
:
"Only from active VCL"
);
req
->
err_code
=
503
;
req
->
err_code
=
503
;
req
->
req_step
=
R_STP_SYNTH
;
req
->
req_step
=
R_STP_SYNTH
;
return
(
REQ_FSM_MORE
);
return
(
REQ_FSM_MORE
);
...
...
bin/varnishtest/tests/r02177.vtc
0 → 100644
View file @
e8c074b9
varnishtest "restart then switch to label"
server s1 {
rxreq
txresp
} -start
server s2 {
rxreq
txresp -status 404
} -start
varnish v1 -vcl {
backend s1 { .host="${s1_addr}"; .port="${s1_port}"; }
} -start
varnish v1 -cli "vcl.label lbl1 vcl1"
varnish v1 -vcl {
backend s1 { .host="${s1_addr}"; .port="${s1_port}"; }
sub vcl_recv {
return (vcl(lbl1));
}
}
varnish v1 -cli "vcl.label lbl2 vcl2"
varnish v1 -vcl {
backend s2 { .host="${s2_addr}"; .port="${s2_port}"; }
sub vcl_recv {
if (req.restarts > 0) {
return (vcl(lbl1));
}
if (req.http.restart) {
return (vcl(lbl2));
}
}
sub vcl_miss {
return (restart);
}
}
varnish v1 -cliok "vcl.list"
logexpect l1 -v v1 -g raw {
expect * * VCL_Error "Illegal return.vcl.: Not after restarts"
expect * * VCL_Error "Illegal return.vcl.: Only from active VCL"
} -start
client c1 {
txreq
rxresp
expect resp.status == 503
txreq -hdr "restart: yes"
rxresp
expect resp.status == 503
} -run
logexpect l1 -wait
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