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
8c7e9383
Commit
8c7e9383
authored
Oct 28, 2014
by
Dag Haavi Finstad
Committed by
Lasse Karstensen
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer exact matches in varnishadm backend.set_health.
Fixes: #1349
parent
6deca863
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
16 deletions
+93
-16
cache_backend_cfg.c
bin/varnishd/cache/cache_backend_cfg.c
+27
-16
r01349.vtc
bin/varnishtest/tests/r01349.vtc
+66
-0
No files found.
bin/varnishd/cache/cache_backend_cfg.c
View file @
8c7e9383
...
...
@@ -288,7 +288,7 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv)
const
char
*
port_b
=
NULL
;
ssize_t
port_l
=
0
;
int
found
=
0
;
int
i
;
int
i
,
j
;
name_b
=
matcher
;
if
(
matcher
!=
NULL
)
{
...
...
@@ -342,22 +342,33 @@ backend_find(struct cli *cli, const char *matcher, bf_func *func, void *priv)
}
}
}
VTAILQ_FOREACH
(
b
,
&
backends
,
list
)
{
CHECK_OBJ_NOTNULL
(
b
,
BACKEND_MAGIC
);
if
(
port_b
!=
NULL
&&
strncmp
(
b
->
port
,
port_b
,
port_l
)
!=
0
)
continue
;
if
(
name_b
!=
NULL
&&
strncmp
(
b
->
vcl_name
,
name_b
,
name_l
)
!=
0
)
continue
;
if
(
ip_b
!=
NULL
&&
(
b
->
ipv4_addr
==
NULL
||
strncmp
(
b
->
ipv4_addr
,
ip_b
,
ip_l
))
&&
(
b
->
ipv6_addr
==
NULL
||
strncmp
(
b
->
ipv6_addr
,
ip_b
,
ip_l
)))
for
(
j
=
0
;
j
<
2
;
++
j
)
{
if
(
j
==
0
&&
name_b
==
NULL
)
continue
;
found
++
;
i
=
func
(
cli
,
b
,
priv
);
if
(
i
)
return
(
i
);
VTAILQ_FOREACH
(
b
,
&
backends
,
list
)
{
CHECK_OBJ_NOTNULL
(
b
,
BACKEND_MAGIC
);
if
(
port_b
!=
NULL
&&
strncmp
(
b
->
port
,
port_b
,
port_l
)
!=
0
)
continue
;
if
(
name_b
!=
NULL
&&
strncmp
(
b
->
vcl_name
,
name_b
,
name_l
)
!=
0
)
continue
;
if
(
j
==
0
&&
b
->
vcl_name
[
name_l
]
!=
'\0'
)
continue
;
if
(
ip_b
!=
NULL
&&
(
b
->
ipv4_addr
==
NULL
||
strncmp
(
b
->
ipv4_addr
,
ip_b
,
ip_l
))
&&
(
b
->
ipv6_addr
==
NULL
||
strncmp
(
b
->
ipv6_addr
,
ip_b
,
ip_l
)))
continue
;
found
++
;
i
=
func
(
cli
,
b
,
priv
);
if
(
i
)
return
(
i
);
if
(
j
==
0
)
return
(
1
);
}
}
return
(
found
);
}
...
...
bin/varnishtest/tests/r01349.vtc
0 → 100644
View file @
8c7e9383
varnishtest "Exact matching for varnishadm backend.set_health"
server s1 -repeat 2 {
rxreq
txresp -hdr "Backend: b1"
} -start
server s2 -repeat 2 {
rxreq
txresp -hdr "Backend: b"
} -start
varnish v1 -vcl {
backend b1 {
.host = "${s1_addr}";
.port = "${s1_port}";
}
backend b {
.host = "${s2_addr}";
.port = "${s2_port}";
}
sub vcl_recv {
return(pass);
}
sub vcl_backend_fetch {
if (bereq.http.backend == "b1") {
set bereq.backend = b1;
}
else {
set bereq.backend = b;
}
}
} -start
varnish v1 -cliok "backend.list b"
client c1 {
txreq -hdr "Backend: b1"
rxresp
expect resp.status == 200
expect resp.http.backend == "b1"
txreq -hdr "Backend: b"
rxresp
expect resp.status == 200
expect resp.http.backend == "b"
} -run
varnish v1 -cliok "backend.set_health b sick"
client c1 {
txreq -hdr "Backend: b1"
rxresp
expect resp.status == 200
expect resp.http.backend == "b1"
txreq -hdr "Backend: b"
rxresp
expect resp.status == 503
} -run
varnish v1 -clierr 106 "backend.set_health b(1.2.3.4:) healthy"
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