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
f2caddcf
Commit
f2caddcf
authored
Aug 28, 2014
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bug in setting *.ttl variables from VCL and go over
testcases at the same time. Spotted by: UPLEX
parent
0c6ef776
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
20 deletions
+35
-20
cache_vrt_var.c
bin/varnishd/cache/cache_vrt_var.c
+22
-11
c00060.vtc
bin/varnishtest/tests/c00060.vtc
+2
-0
r00956.vtc
bin/varnishtest/tests/r00956.vtc
+6
-4
r01578.vtc
bin/varnishtest/tests/r01578.vtc
+5
-5
No files found.
bin/varnishd/cache/cache_vrt_var.c
View file @
f2caddcf
...
@@ -483,17 +483,23 @@ VRT_r_bereq_retries(const struct vrt_ctx *ctx)
...
@@ -483,17 +483,23 @@ VRT_r_bereq_retries(const struct vrt_ctx *ctx)
}
}
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
* NB: TTL is relative to when object was created, whereas grace and
* In exp.*:
* keep are relative to ttl.
* t_origin is absolute
* ttl is relative to t_origin
* grace&keep are relative to ttl
* In VCL:
* ttl is relative to now
* grace&keep are relative to ttl
*/
*/
#define VRT_DO_EXP_L(which, sexp, fld
)
\
#define VRT_DO_EXP_L(which, sexp, fld
, offset)
\
\
\
void \
void \
VRT_l_##which##_##fld(const struct vrt_ctx *ctx, double a) \
VRT_l_##which##_##fld(const struct vrt_ctx *ctx, double a) \
{ \
{ \
\
\
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
a += (offset); \
if (a < 0.0) \
if (a < 0.0) \
a = 0.0; \
a = 0.0; \
sexp.fld = a; \
sexp.fld = a; \
...
@@ -506,23 +512,28 @@ VRT_l_##which##_##fld(const struct vrt_ctx *ctx, double a) \
...
@@ -506,23 +512,28 @@ VRT_l_##which##_##fld(const struct vrt_ctx *ctx, double a) \
double \
double \
VRT_r_##which##_##fld(const struct vrt_ctx *ctx) \
VRT_r_##which##_##fld(const struct vrt_ctx *ctx) \
{ \
{ \
double d; \
\
\
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
if (sexp.fld > 0.0) \
d = sexp.fld; \
return(sexp.fld - offset); \
if (d <= 0.0) \
return(0.0); \
d = 0.0; \
d -= (offset); \
return(d); \
}
}
VRT_DO_EXP_R
(
obj
,
ctx
->
req
->
objcore
->
exp
,
ttl
,
VRT_DO_EXP_R
(
obj
,
ctx
->
req
->
objcore
->
exp
,
ttl
,
(
ctx
->
req
->
t_req
-
ctx
->
req
->
objcore
->
exp
.
t_origin
)
)
ctx
->
now
-
ctx
->
req
->
objcore
->
exp
.
t_origin
)
VRT_DO_EXP_R
(
obj
,
ctx
->
req
->
objcore
->
exp
,
grace
,
0
)
VRT_DO_EXP_R
(
obj
,
ctx
->
req
->
objcore
->
exp
,
grace
,
0
)
VRT_DO_EXP_R
(
obj
,
ctx
->
req
->
objcore
->
exp
,
keep
,
0
)
VRT_DO_EXP_R
(
obj
,
ctx
->
req
->
objcore
->
exp
,
keep
,
0
)
VRT_DO_EXP_L
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
ttl
)
VRT_DO_EXP_L
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
ttl
,
VRT_DO_EXP_R
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
ttl
,
0
)
ctx
->
now
-
ctx
->
bo
->
fetch_objcore
->
exp
.
t_origin
)
VRT_DO_EXP_L
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
grace
)
VRT_DO_EXP_R
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
ttl
,
ctx
->
now
-
ctx
->
bo
->
fetch_objcore
->
exp
.
t_origin
)
VRT_DO_EXP_L
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
grace
,
0
)
VRT_DO_EXP_R
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
grace
,
0
)
VRT_DO_EXP_R
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
grace
,
0
)
VRT_DO_EXP_L
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
keep
)
VRT_DO_EXP_L
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
keep
,
0
)
VRT_DO_EXP_R
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
keep
,
0
)
VRT_DO_EXP_R
(
beresp
,
ctx
->
bo
->
fetch_objcore
->
exp
,
keep
,
0
)
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
...
...
bin/varnishtest/tests/c00060.vtc
View file @
f2caddcf
...
@@ -11,6 +11,7 @@ server s1 {
...
@@ -11,6 +11,7 @@ server s1 {
txresp -status "304" \
txresp -status "304" \
-hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
-hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
-hdr "Snafu: 2" \
-hdr "Snafu: 2" \
-hdr "Grifle: 3" \
-nolen
-nolen
} -start
} -start
...
@@ -40,6 +41,7 @@ client c1 {
...
@@ -40,6 +41,7 @@ client c1 {
rxresp
rxresp
expect resp.bodylen == 13
expect resp.bodylen == 13
expect resp.http.foobar == foo0
expect resp.http.foobar == foo0
expect resp.http.grifle == 3
expect resp.http.snafu == 2a
expect resp.http.snafu == 2a
} -run
} -run
bin/varnishtest/tests/r00956.vtc
View file @
f2caddcf
...
@@ -7,6 +7,7 @@ server s1 {
...
@@ -7,6 +7,7 @@ server s1 {
varnish v1 -vcl+backend {
varnish v1 -vcl+backend {
sub vcl_backend_response {
sub vcl_backend_response {
set beresp.http.fooA = beresp.ttl;
set beresp.ttl = 10s;
set beresp.ttl = 10s;
set beresp.http.fooB = beresp.ttl;
set beresp.http.fooB = beresp.ttl;
}
}
...
@@ -22,21 +23,22 @@ client c1 {
...
@@ -22,21 +23,22 @@ client c1 {
txreq
txreq
rxresp
rxresp
expect resp.bodylen == 40
expect resp.bodylen == 40
expect resp.http.fooA == 19.000
expect resp.http.fooB == 10.000
expect resp.http.fooB == 10.000
delay 2
delay 2
txreq
txreq
rxresp
rxresp
expect resp.bodylen == 40
expect resp.bodylen == 40
# XXX: should be: < 8
expect resp.http.fooA == 19.000
expect resp.http.fooB == 10.000
expect resp.http.fooB == 10.000
expect resp.http.foo != 10.000
expect resp.http.foo <= 8.000
expect resp.http.foo != 9.000
delay 2
delay 2
txreq
txreq
rxresp
rxresp
expect resp.bodylen == 40
expect resp.bodylen == 40
expect resp.http.fooA == 19.000
expect resp.http.fooB == 10.000
expect resp.http.fooB == 10.000
expect resp.http.foo <=
5
.000
expect resp.http.foo <=
6
.000
} -run
} -run
bin/varnishtest/tests/r01578.vtc
View file @
f2caddcf
...
@@ -21,7 +21,7 @@ client c1 {
...
@@ -21,7 +21,7 @@ client c1 {
txreq
txreq
rxresp
rxresp
expect resp.bodylen == 40
expect resp.bodylen == 40
expect resp.http.x-ttl ==
23
.000
expect resp.http.x-ttl ==
19
.000
expect resp.http.Age == 4
expect resp.http.Age == 4
...
@@ -29,13 +29,13 @@ client c1 {
...
@@ -29,13 +29,13 @@ client c1 {
txreq
txreq
rxresp
rxresp
expect resp.bodylen == 40
expect resp.bodylen == 40
expect resp.http.x-ttl ==
23
.000
expect resp.http.x-ttl ==
19
.000
expect resp.http.x-remaining-ttl
~ ^17\.0|^16\.[89]
expect resp.http.x-remaining-ttl
<= 17.000
delay 2
delay 2
txreq
txreq
rxresp
rxresp
expect resp.bodylen == 40
expect resp.bodylen == 40
expect resp.http.x-ttl ==
23
.000
expect resp.http.x-ttl ==
19
.000
expect resp.http.x-remaining-ttl
~ ^15\.0|^14\.[89]
expect resp.http.x-remaining-ttl
<= 15.000
} -run
} -run
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