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
05f673a9
Commit
05f673a9
authored
Mar 10, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Withdraw backend VSC counters when VCL is cold
parent
ab9af460
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
17 deletions
+63
-17
cache_backend.c
bin/varnishd/cache/cache_backend.c
+12
-0
cache_backend_cfg.c
bin/varnishd/cache/cache_backend_cfg.c
+1
-3
cache_backend_poll.c
bin/varnishd/cache/cache_backend_poll.c
+4
-1
v00043.vcl
bin/varnishtest/tests/v00043.vcl
+46
-13
No files found.
bin/varnishd/cache/cache_backend.c
View file @
05f673a9
...
...
@@ -332,10 +332,22 @@ VRT_event_vbe(VRT_CTX, enum vcl_event_e ev, const struct director *d,
assert
(
d
->
priv2
==
vrt
);
CAST_OBJ_NOTNULL
(
be
,
d
->
priv
,
BACKEND_MAGIC
);
if
(
ev
==
VCL_EVENT_WARM
)
{
be
->
vsc
=
VSM_Alloc
(
sizeof
*
be
->
vsc
,
VSC_CLASS
,
VSC_type_vbe
,
be
->
display_name
);
AN
(
be
->
vsc
);
}
if
(
be
->
probe
!=
NULL
&&
ev
==
VCL_EVENT_WARM
)
VBP_Control
(
be
,
0
);
if
(
be
->
probe
!=
NULL
&&
ev
==
VCL_EVENT_COLD
)
VBP_Control
(
be
,
1
);
if
(
ev
==
VCL_EVENT_COLD
)
{
VSM_Free
(
be
->
vsc
);
be
->
vsc
=
NULL
;
}
}
void
...
...
bin/varnishd/cache/cache_backend_cfg.c
View file @
05f673a9
...
...
@@ -66,7 +66,7 @@ VBE_DeleteBackend(struct backend *b)
free
(
b
->
ipv4
);
free
(
b
->
ipv6
);
free
(
b
->
display_name
);
VSM_Free
(
b
->
vsc
);
AZ
(
b
->
vsc
);
VBT_Rel
(
&
b
->
tcp_pool
);
Lck_Delete
(
&
b
->
mtx
);
FREE_OBJ
(
b
);
...
...
@@ -97,8 +97,6 @@ VBE_AddBackend(const char *vcl, const struct vrt_backend *vb)
bprintf
(
buf
,
"%s.%s"
,
vcl
,
vb
->
vcl_name
);
REPLACE
(
b
->
display_name
,
buf
);
b
->
vsc
=
VSM_Alloc
(
sizeof
*
b
->
vsc
,
VSC_CLASS
,
VSC_type_vbe
,
buf
);
b
->
vcl_name
=
vb
->
vcl_name
;
b
->
ipv4_addr
=
vb
->
ipv4_addr
;
b
->
ipv6_addr
=
vb
->
ipv6_addr
;
...
...
bin/varnishd/cache/cache_backend_poll.c
View file @
05f673a9
...
...
@@ -260,8 +260,10 @@ vbp_has_poked(struct vbp_target *vt)
vt
->
backend
->
vcl_name
,
logmsg
,
bits
,
vt
->
good
,
vt
->
probe
.
threshold
,
vt
->
probe
.
window
,
vt
->
last
,
vt
->
avg
,
vt
->
resp_buf
);
if
(
!
vt
->
disable
)
if
(
!
vt
->
disable
)
{
AN
(
vt
->
backend
->
vsc
);
vt
->
backend
->
vsc
->
happy
=
vt
->
happy
;
}
}
Lck_Unlock
(
&
vt
->
mtx
);
}
...
...
@@ -457,6 +459,7 @@ VBP_Insert(struct backend *b, const struct vrt_backend_probe *p,
b
->
probe
=
vt
;
VTAILQ_INSERT_TAIL
(
&
vbp_list
,
vt
,
list
);
Lck_New
(
&
vt
->
mtx
,
lck_backend
);
vt
->
disable
=
1
;
vt
->
tcp_pool
=
VBT_Ref
(
b
->
ipv4
,
b
->
ipv6
);
AN
(
vt
->
tcp_pool
);
...
...
bin/varnishtest/tests/v00043.vcl
View file @
05f673a9
varnishtest "vcl.state coverage tests"
server s1 {
server s1
-repeat 20
{
rxreq
txresp
delay .2
close
} -start
varnish v1 -vcl+backend {} -start
varnish v1 -vcl+backend {}
varnish v1 -vcl {
backend default {
.host = "${s1_addr}";
.probe = { .interval = 1s; .initial = 1;}
}
} -start
varnish v1 -cliok "param.set vcl_cooldown
5
"
varnish v1 -cliok "param.set vcl_cooldown
3
"
varnish v1 -cliok "vcl.list"
varnish v1 -cliok "vcl.use vcl2"
varnish v1 -cliok "vcl.list"
delay 5
varnish v1 -cliok "vcl.list"
varnish v1 -cliok "vcl.state vcl1 warm"
varnish v1 -cliok "vcl.list"
# We only have one vcl yet
varnish v1 -expect VBE.vcl1.default.happy > 0
varnish v1 -expect !VBE.vcl2.default.happy
varnish v1 -cliok "backend.list -p *.*"
varnish v1 -vcl {
backend default {
.host = "${s1_addr}";
.probe = { .interval = 1s; .initial = 1;}
}
}
# Now we have two vcls (and run on the latest loaded)
varnish v1 -expect VBE.vcl1.default.happy > 0
varnish v1 -expect VBE.vcl2.default.happy > 0
# Freeze the first VCL
varnish v1 -cliok "vcl.state vcl1 cold"
varnish v1 -expect !VBE.vcl1.default.happy
# Set it auto should be a no-op
varnish v1 -cliok "vcl.state vcl1 auto"
varnish v1 -expect !VBE.vcl1.default.happy
# Use it, and it should come alive
varnish v1 -cliok "vcl.use vcl1"
varnish v1 -expect VBE.vcl1.default.happy > 0
varnish v1 -expect VBE.vcl2.default.happy > 0
# and the unused one should go cold
delay 4
varnish v1 -expect !VBE.vcl2.default.happy
# Mark the used warm and use it the other
varnish v1 -cliok "vcl.state vcl1 warm"
varnish v1 -cliok "vcl.use vcl2"
delay
5
varnish v1 -
cliok "vcl.list"
delay
4
varnish v1 -
expect VBE.vcl2.default.happy > 0
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