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
97e8a9f5
Commit
97e8a9f5
authored
May 11, 2020
by
Poul-Henning Kamp
Committed by
Nils Goroll
May 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make .resolve() a type specific method of BACKEND
This is an alternative implementation of #2680
parent
0c9c3851
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
15 deletions
+46
-15
cache_director.c
bin/varnishd/cache/cache_director.c
+17
-12
d00021.vtc
bin/varnishtest/tests/d00021.vtc
+27
-3
vrt.h
include/vrt.h
+1
-0
vcc_expr.c
lib/libvcc/vcc_expr.c
+1
-0
No files found.
bin/varnishd/cache/cache_director.c
View file @
97e8a9f5
...
...
@@ -80,27 +80,32 @@ VDI_Ahealth(const struct director *d)
/* Resolve director --------------------------------------------------*/
VCL_BACKEND
VRT_VDI_Resolve
(
VRT_CTX
,
VCL_BACKEND
d
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
while
(
d
!=
NULL
)
{
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
AN
(
d
->
vdir
);
if
(
d
->
vdir
->
methods
->
resolve
==
NULL
)
break
;
d
=
d
->
vdir
->
methods
->
resolve
(
ctx
,
d
);
CHECK_OBJ_ORNULL
(
d
,
DIRECTOR_MAGIC
);
}
return
(
d
);
}
static
VCL_BACKEND
VDI_Resolve
(
VRT_CTX
)
{
const
struct
director
*
d
;
const
struct
director
*
d2
;
struct
busyobj
*
bo
;
bo
=
ctx
->
bo
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_ORNULL
(
bo
->
director_req
,
DIRECTOR_MAGIC
);
for
(
d
=
bo
->
director_req
;
d
!=
NULL
&&
d
->
vdir
->
methods
->
resolve
!=
NULL
;
d
=
d2
)
{
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
AN
(
d
->
vdir
);
d2
=
d
->
vdir
->
methods
->
resolve
(
ctx
,
d
);
if
(
d2
==
NULL
)
VSLb
(
bo
->
vsl
,
SLT_FetchError
,
"Director %s returned no backend"
,
d
->
vcl_name
);
}
d
=
VRT_VDI_Resolve
(
ctx
,
bo
->
director_req
);
CHECK_OBJ_ORNULL
(
d
,
DIRECTOR_MAGIC
);
if
(
d
==
NULL
)
{
VSLb
(
bo
->
vsl
,
SLT_FetchError
,
"No backend"
);
...
...
bin/varnishtest/tests/d00021.vtc
View file @
97e8a9f5
varnishtest "shard director LAZY and layering"
server s1 -repeat
2
{
server s1 -repeat
3
{
rxreq
txresp -body "ech3Ooj"
} -start
server s2 -repeat
2
{
server s2 -repeat
3
{
rxreq
txresp -body "ieQu2qua"
} -start
server s3 -repeat
2
{
server s3 -repeat
3
{
rxreq
txresp -body "xiuFi3Pe"
} -start
...
...
@@ -88,6 +88,9 @@ varnish v1 -vcl+backend {
sub vcl_backend_fetch {
if (bereq.http.layered) {
call backend_fetch_layered;
} else if (bereq.http.resolve) {
call backend_fetch_layered;
set bereq.backend = bereq.backend.resolve();
} else {
call backend_fetch_direct;
}
...
...
@@ -148,4 +151,25 @@ client c1 {
expect resp.http.healthy == "true"
expect resp.http.director == "ll"
expect resp.http.backend == "s3"
txreq -url /1 -hdr "resolve: true"
rxresp
expect resp.body == "ech3Ooj"
expect resp.http.healthy == "true"
expect resp.http.director == "s1"
expect resp.http.backend == "s1"
txreq -url /2 -hdr "resolve: true"
rxresp
expect resp.body == "ieQu2qua"
expect resp.http.healthy == "true"
expect resp.http.director == "s2"
expect resp.http.backend == "s2"
txreq -url /3 -hdr "resolve: true"
rxresp
expect resp.body == "xiuFi3Pe"
expect resp.http.healthy == "true"
expect resp.http.director == "s3"
expect resp.http.backend == "s3"
} -run
include/vrt.h
View file @
97e8a9f5
...
...
@@ -435,6 +435,7 @@ struct vrt_backend_probe {
VRT_BACKEND_PROBE_FIELDS
(
const
)
};
VCL_BACKEND
VRT_VDI_Resolve
(
VRT_CTX
,
VCL_BACKEND
);
/***********************************************************************
* Implementation details of ACLs
...
...
lib/libvcc/vcc_expr.c
View file @
97e8a9f5
...
...
@@ -839,6 +839,7 @@ static const struct vcc_methods {
{
STRINGS
,
STRING
,
"upper"
,
"VRT_UpperLowerStrands(ctx,
\v
T, 1)"
,
1
},
{
STRINGS
,
STRING
,
"lower"
,
"VRT_UpperLowerStrands(ctx,
\v
T, 0)"
,
1
},
{
BACKEND
,
BACKEND
,
"resolve"
,
"VRT_VDI_Resolve(ctx,
\v
1)"
,
1
},
{
NULL
,
NULL
,
NULL
,
NULL
},
};
...
...
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