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
613201e9
Commit
613201e9
authored
Sep 22, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add reader.deleted().
parent
ba5ecac5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
0 deletions
+87
-0
README.rst
README.rst
+22
-0
info.vtc
src/tests/info.vtc
+37
-0
vmod_file.c
src/vmod_file.c
+9
-0
vmod_file.vcc
src/vmod_file.vcc
+19
-0
No files found.
README.rst
View file @
613201e9
...
@@ -306,6 +306,28 @@ Example::
...
@@ -306,6 +306,28 @@ Example::
call do_file_error_handling;
call do_file_error_handling;
}
}
.. _.deleted():
.. _xreader.deleted():
BOOL xreader.deleted()
----------------------
Return true if and only if the file was found to have been deleted the
last time the file was checked.
As discussed in `File deletion and file updates`_ above, this is not
an error condition, if the file had been previously mapped. Then the
previously cached contents continue to be valid.
Example::
import std;
if (rdr.deleted()) {
std.log("file deleted, continuing with the current cached contents");
}
.. _xreader.size():
.. _xreader.size():
BYTES xreader.size()
BYTES xreader.size()
...
...
src/tests/info.vtc
View file @
613201e9
...
@@ -17,6 +17,7 @@ varnish v1 -vcl {
...
@@ -17,6 +17,7 @@ varnish v1 -vcl {
set req.http.Mtime = rdr.mtime();
set req.http.Mtime = rdr.mtime();
set req.http.Delta-Mtime = now - rdr.mtime();
set req.http.Delta-Mtime = now - rdr.mtime();
set req.http.Next-Check = rdr.next_check();
set req.http.Next-Check = rdr.next_check();
set req.http.Deleted = rdr.deleted();
return (synth(200));
return (synth(200));
}
}
...
@@ -25,6 +26,7 @@ varnish v1 -vcl {
...
@@ -25,6 +26,7 @@ varnish v1 -vcl {
set resp.http.Mtime = req.http.Mtime;
set resp.http.Mtime = req.http.Mtime;
set resp.http.Delta-Mtime = req.http.Delta-Mtime;
set resp.http.Delta-Mtime = req.http.Delta-Mtime;
set resp.http.Next-Check = req.http.Next-Check;
set resp.http.Next-Check = req.http.Next-Check;
set resp.http.Deleted = req.http.Deleted;
return (deliver);
return (deliver);
}
}
} -start
} -start
...
@@ -40,6 +42,7 @@ client c1 {
...
@@ -40,6 +42,7 @@ client c1 {
expect resp.http.Delta-Mtime < 1
expect resp.http.Delta-Mtime < 1
expect resp.http.Next-Check >= 0
expect resp.http.Next-Check >= 0
expect resp.http.Next-Check <= 0.1
expect resp.http.Next-Check <= 0.1
expect resp.http.Deleted == "false"
} -run
} -run
shell {echo -n "foo" > ${tmpdir}/sz}
shell {echo -n "foo" > ${tmpdir}/sz}
...
@@ -55,6 +58,7 @@ client c1 {
...
@@ -55,6 +58,7 @@ client c1 {
expect resp.http.Delta-Mtime < 1
expect resp.http.Delta-Mtime < 1
expect resp.http.Next-Check >= 0
expect resp.http.Next-Check >= 0
expect resp.http.Next-Check <= 0.1
expect resp.http.Next-Check <= 0.1
expect resp.http.Deleted == "false"
} -run
} -run
shell {chmod a-r ${tmpdir}/sz}
shell {chmod a-r ${tmpdir}/sz}
...
@@ -141,3 +145,36 @@ client c1 {
...
@@ -141,3 +145,36 @@ client c1 {
expect resp.http.Next-Check >= 0
expect resp.http.Next-Check >= 0
expect resp.http.Next-Check <= 0.1
expect resp.http.Next-Check <= 0.1
} -run
} -run
shell {touch ${tmpdir}/deleteme}
varnish v1 -vcl {
import ${vmod_file};
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new rdr = file.reader("${tmpdir}/deleteme", ttl=0.1s);
}
sub vcl_recv {
return (synth(200));
}
sub vcl_synth {
set resp.http.Error = rdr.error();
set resp.http.Deleted = rdr.deleted();
return (deliver);
}
}
shell {rm -f ${tmpdir}/deleteme}
delay .1
# .error() == false, since deleted files are not considered in error.
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.Error == "false"
expect resp.http.Deleted == "true"
} -run
src/vmod_file.c
View file @
613201e9
...
@@ -565,6 +565,15 @@ vmod_reader_errmsg(VRT_CTX, struct VPFX(file_reader) *rdr)
...
@@ -565,6 +565,15 @@ vmod_reader_errmsg(VRT_CTX, struct VPFX(file_reader) *rdr)
return
(
rdr
->
errbuf
);
return
(
rdr
->
errbuf
);
}
}
VCL_BOOL
vmod_reader_deleted
(
VRT_CTX
,
struct
VPFX
(
file_reader
)
*
rdr
)
{
CHECK_OBJ_NOTNULL
(
rdr
,
FILE_READER_MAGIC
);
(
void
)
ctx
;
return
(
rdr
->
flags
&
RDR_DELETED
);
}
VCL_BYTES
VCL_BYTES
vmod_reader_size
(
VRT_CTX
,
struct
VPFX
(
file_reader
)
*
rdr
)
vmod_reader_size
(
VRT_CTX
,
struct
VPFX
(
file_reader
)
*
rdr
)
{
{
...
...
src/vmod_file.vcc
View file @
613201e9
...
@@ -280,6 +280,25 @@ Example::
...
@@ -280,6 +280,25 @@ Example::
call do_file_error_handling;
call do_file_error_handling;
}
}
.. _.deleted():
$Method BOOL .deleted()
Return true if and only if the file was found to have been deleted the
last time the file was checked.
As discussed in `File deletion and file updates`_ above, this is not
an error condition, if the file had been previously mapped. Then the
previously cached contents continue to be valid.
Example::
import std;
if (rdr.deleted()) {
std.log("file deleted, continuing with the current cached contents");
}
$Method BYTES .size()
$Method BYTES .size()
Return the size of the file as currently cached. Invokes VCL failure
Return the size of the file as currently cached. Invokes VCL failure
...
...
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