Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-file
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-file
Commits
fd557aa1
Commit
fd557aa1
authored
Sep 22, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add reader.next_check().
parent
d735accc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
0 deletions
+71
-0
README.rst
README.rst
+9
-0
info.vtc
src/tests/info.vtc
+39
-0
vmod_file.c
src/vmod_file.c
+17
-0
vmod_file.vcc
src/vmod_file.vcc
+6
-0
No files found.
README.rst
View file @
fd557aa1
...
...
@@ -117,6 +117,15 @@ recently checked.
XXX ...
.. _xreader.next_check():
DURATION xreader.next_check()
-----------------------------
Returns the time remaining until the next check will be performed.
XXX ...
.. _file.version():
STRING version()
...
...
src/tests/info.vtc
View file @
fd557aa1
...
...
@@ -16,6 +16,7 @@ varnish v1 -vcl {
set req.http.Size = rdr.size();
set req.http.Mtime = rdr.mtime();
set req.http.Delta-Mtime = now - rdr.mtime();
set req.http.Next-Check = rdr.next_check();
return (synth(200));
}
...
...
@@ -23,6 +24,7 @@ varnish v1 -vcl {
set resp.http.Size = req.http.Size;
set resp.http.Mtime = req.http.Mtime;
set resp.http.Delta-Mtime = req.http.Delta-Mtime;
set resp.http.Next-Check = req.http.Next-Check;
return (deliver);
}
} -start
...
...
@@ -36,6 +38,8 @@ client c1 {
expect resp.http.Mtime ~ "GMT$"
expect resp.http.Delta-Mtime > 0
expect resp.http.Delta-Mtime < 1
expect resp.http.Next-Check >= 0
expect resp.http.Next-Check <= 0.1
} -run
shell {echo -n "foo" > ${tmpdir}/sz}
...
...
@@ -49,6 +53,8 @@ client c1 {
expect resp.http.Mtime ~ "GMT$"
expect resp.http.Delta-Mtime > 0
expect resp.http.Delta-Mtime < 1
expect resp.http.Next-Check >= 0
expect resp.http.Next-Check <= 0.1
} -run
shell {rm -f ${tmpdir}/sz}
...
...
@@ -100,3 +106,36 @@ logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" {
client c1 -run
logexpect l1 -wait
shell {touch ${tmpdir}/nxtchk}
varnish v1 -vcl {
import ${vmod_file};
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new rdr = file.reader("${tmpdir}/nxtchk", ttl=0.1s);
}
sub vcl_recv {
set req.http.Next-Check = rdr.next_check();
return (synth(200));
}
sub vcl_synth {
set resp.http.Next-Check = req.http.Next-Check;
return (deliver);
}
}
shell {rm -f ${tmpdir}/nxtchk}
delay .1
# next_check() is not affected by errors.
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.Next-Check >= 0
expect resp.http.Next-Check <= 0.1
} -run
src/vmod_file.c
View file @
fd557aa1
...
...
@@ -560,6 +560,23 @@ vmod_reader_mtime(VRT_CTX, struct VPFX(file_reader) *rdr)
return
(
secs
+
nsecs
*
1e-9
);
}
VCL_DURATION
vmod_reader_next_check
(
VRT_CTX
,
struct
VPFX
(
file_reader
)
*
rdr
)
{
struct
itimerspec
t
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
rdr
,
FILE_READER_MAGIC
);
errno
=
0
;
if
(
timer_gettime
(
rdr
->
timerid
,
&
t
)
!=
0
)
{
VRT_fail
(
ctx
,
"%s.next_check(): timer read failed: %s"
,
rdr
->
vcl_name
,
vstrerror
(
errno
));
return
(
0
.);
}
return
(
t
.
it_value
.
tv_sec
+
1e-9
*
t
.
it_value
.
tv_nsec
);
}
VCL_STRING
vmod_version
(
VRT_CTX
)
{
...
...
src/vmod_file.vcc
View file @
fd557aa1
...
...
@@ -85,6 +85,12 @@ recently checked.
XXX ...
$Method DURATION .next_check()
Returns the time remaining until the next check will be performed.
XXX ...
$Function STRING version()
Return the version string for this VMOD.
...
...
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