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
43da3e4a
Commit
43da3e4a
authored
Apr 23, 2019
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add VRT_VCL_Busy() and VRT_VCL_Unbusy() so VMODs can prevent
their VCL from going cold. One half of #2471
parent
f58469a7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
0 deletions
+115
-0
cache_vrt_vcl.c
bin/varnishd/cache/cache_vrt_vcl.c
+22
-0
r02471.vtc
bin/varnishtest/tests/r02471.vtc
+63
-0
vrt.h
include/vrt.h
+8
-0
vmod.vcc
lib/libvmod_debug/vmod.vcc
+8
-0
vmod_debug.c
lib/libvmod_debug/vmod_debug.c
+14
-0
No files found.
bin/varnishd/cache/cache_vrt_vcl.c
View file @
43da3e4a
...
...
@@ -144,6 +144,28 @@ VCL_Rel(struct vcl **vcc)
/*--------------------------------------------------------------------*/
void
VRT_VCL_Busy
(
VRT_CTX
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
vcl
,
VCL_MAGIC
);
VCL_Ref
(
ctx
->
vcl
);
}
void
VRT_VCL_Unbusy
(
VRT_CTX
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
struct
vcl
*
vcl
;
CHECK_OBJ_NOTNULL
(
ctx
->
vcl
,
VCL_MAGIC
);
vcl
=
ctx
->
vcl
;
VCL_Rel
(
&
vcl
);
}
/*--------------------------------------------------------------------*/
VCL_BACKEND
VRT_AddDirector
(
VRT_CTX
,
const
struct
vdi_methods
*
m
,
void
*
priv
,
const
char
*
fmt
,
...)
...
...
bin/varnishtest/tests/r02471.vtc
0 → 100644
View file @
43da3e4a
varnishtest "test VRT_VCL_(Un)Busy()"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
import debug;
sub vcl_recv {
if (req.url == "/hold") {
debug.hold_vcl_busy();
} else if (req.url == "/release") {
debug.release_vcl_busy();
}
return (synth(200));
}
} -start
varnish v1 -vcl+backend {}
varnish v1 -cliok "vcl.state vcl1 cold"
# Nothing holds vcl1, so it should go gold.
varnish v1 -cliexpect "cold cold 0 vcl1" "vcl.list"
# Grab hold of vcl1
varnish v1 -cliok "vcl.use vcl1"
client c1 {
txreq -url "/hold"
rxresp
} -run
# Flush worker threads hold
varnish v1 -cliok "vcl.use vcl2"
client c1 {
txreq
rxresp
} -run
# There should still be a single busy hold on vcl1
varnish v1 -cliok "vcl.state vcl1 cold"
varnish v1 -cliexpect "cold busy 1 vcl1" "vcl.list"
# Release hold on vcl1
varnish v1 -cliok "vcl.use vcl1"
client c1 {
txreq -url "/release"
rxresp
} -run
# Flush worker threads hold
varnish v1 -cliok "vcl.use vcl2"
client c1 {
txreq
rxresp
} -run
# Nothing holds vcl1, so it should go gold.
varnish v1 -cliok "vcl.state vcl1 cold"
varnish v1 -cliexpect "cold cold 0 vcl1" "vcl.list"
include/vrt.h
View file @
43da3e4a
...
...
@@ -52,6 +52,7 @@
* binary/load-time compatible, increment MAJOR version
*
* unreleased (planned for 2019-09-15)
* VRT_VCL_Busy() and VRT_VCL_Unbusy() added.
* VRT_vcl_get moved to vcc_interface.h
* VRT_vcl_rel emoved to vcc_interface.h
* VRT_vcl_select emoved to vcc_interface.h
...
...
@@ -575,3 +576,10 @@ void VRT_VSC_Destroy(const char *, struct vsc_seg *);
void
VRT_VSC_Hide
(
const
struct
vsc_seg
*
);
void
VRT_VSC_Reveal
(
const
struct
vsc_seg
*
);
size_t
VRT_VSC_Overhead
(
size_t
);
/*
* API to prevent VCL from going cold
*/
void
VRT_VCL_Busy
(
VRT_CTX
);
void
VRT_VCL_Unbusy
(
VRT_CTX
);
lib/libvmod_debug/vmod.vcc
View file @
43da3e4a
...
...
@@ -243,3 +243,11 @@ This function is by no means guaranteed to work cross platform and
should now only be used for diagnostic purposes.
0B is returned if no sensible value can be determined.
$Function VOID hold_vcl_busy()
Prevent VCL from going cold
$Function VOID release_vcl_busy()
Allow VCL to go cold
lib/libvmod_debug/vmod_debug.c
View file @
43da3e4a
...
...
@@ -793,3 +793,17 @@ xyzzy_stk(VRT_CTX)
return
(
0
);
}
VCL_VOID
xyzzy_hold_vcl_busy
(
VRT_CTX
)
{
VRT_VCL_Busy
(
ctx
);
}
VCL_VOID
xyzzy_release_vcl_busy
(
VRT_CTX
)
{
VRT_VCL_Unbusy
(
ctx
);
}
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