Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvdfp-pipe
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
libvdfp-pipe
Commits
b68b1451
Commit
b68b1451
authored
Aug 07, 2020
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the timeout parameter to the VDP object.
parent
f7640fe5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
129 additions
and
13 deletions
+129
-13
README.rst
README.rst
+8
-3
Makefile.am
src/Makefile.am
+1
-0
slow.sh
src/tests/slow.sh
+9
-0
timeout.vtc
src/tests/timeout.vtc
+102
-0
vdfp_pipe.c
src/vdfp_pipe.c
+8
-9
vdfp_pipe.vcc
src/vdfp_pipe.vcc
+1
-1
No files found.
README.rst
View file @
b68b1451
...
...
@@ -56,12 +56,17 @@ XXX ...
.. _pipe.vdp():
new xvdp = pipe.vdp(STRING path, STRING name, BYTES bufsz)
----------------------------------------------------------
new xvdp = pipe.vdp(STRING path, STRING name, BYTES bufsz
, DURATION timeout
)
----------------------------------------------------------
------------------
::
new xvdp = pipe.vdp(STRING path, STRING name=0, BYTES bufsz=0)
new xvdp = pipe.vdp(
STRING path,
STRING name=0,
BYTES bufsz=0,
DURATION timeout=60
)
XXX ...
...
...
src/Makefile.am
View file @
b68b1451
...
...
@@ -70,6 +70,7 @@ endif
EXTRA_DIST
=
\
vdfp_pipe.vcc
\
$(srcdir)
/tests/slow.sh
\
$(VMOD_TESTS)
CLEANFILES
=
\
...
...
src/tests/slow.sh
0 → 100755
View file @
b68b1451
#! /bin/sh
while
read
line
do
sleep
1
echo
$line
done
exit
0
src/tests/timeout.vtc
0 → 100644
View file @
b68b1451
# looks like -*- vcl -*-
varnishtest "vdp timeouts"
server s1 {
rxreq
txresp -body {foo bar baz quux
foo bar baz quux
}
} -start
varnish v1 -vcl+backend {
import ${vmod_pipe};
sub vcl_init {
new slow = pipe.vdp(path="${testdir}/slow.sh", timeout=0.5s);
}
sub vcl_deliver {
set resp.filters = "slow";
}
} -start
client c1 {
txreq
rxresp -no_obj
expect resp.status == 200
} -run
logexpect l1 -v v1 -g vxid -d 1 -q {Notice ~ "^vdfp_pipe: vdp slow:" or Error ~ "^vdfp_pipe: vdp slow:"} {
expect 0 * Begin {^req \d+ rxreq$}
expect * = Notice {^vdfp_pipe: vdp slow: exec'd .+/slow.sh as pid \d+$}
expect * = Error {^vdfp_pipe: vdp slow: timeout waiting for .+/slow.sh$}
expect * = Notice {^vdfp_pipe: vdp slow: .+/slow.sh exited with status 0$}
expect * = End
} -run
varnish v1 -vcl+backend {
import ${vmod_pipe};
sub vcl_init {
new slow = pipe.vdp(path="${testdir}/slow.sh", timeout=2s);
}
sub vcl_deliver {
set resp.filters = "slow";
}
}
logexpect l1 -v v1 -g vxid -d 0 -q {Notice ~ "^vdfp_pipe: vdp slow:" or Error ~ "^vdfp_pipe: vdp slow:"} {
expect 0 * Begin {^req \d+ rxreq$}
expect * = Notice {^vdfp_pipe: vdp slow: exec'd .+/slow.sh as pid \d+$}
expect * = Notice {^vdfp_pipe: vdp slow: .+/slow.sh exited with status 0$}
expect * = End
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.body == {foo bar baz quux
foo bar baz quux
}
} -run
logexpect l1 -wait
varnish v1 -vcl+backend {
import ${vmod_pipe};
sub vcl_init {
new slow = pipe.vdp(path="${testdir}/slow.sh", timeout=0s);
}
sub vcl_deliver {
set resp.filters = "slow";
}
}
logexpect l1 -start
client c1 -run
logexpect l1 -wait
varnish v1 -vcl+backend {
import ${vmod_pipe};
sub vcl_init {
new slow = pipe.vdp(path="${testdir}/slow.sh", timeout=-1s);
}
sub vcl_deliver {
set resp.filters = "slow";
}
}
logexpect l1 -start
client c1 -run
logexpect l1 -wait
src/vdfp_pipe.c
View file @
b68b1451
...
...
@@ -53,10 +53,6 @@
#define VDPFAIL(ctx, fmt, ...) \
VFAIL((ctx), "vdp", fmt, __VA_ARGS__)
/* == default first_byte_ and between_bytes_timeout (in ms) */
#define TIMEOUT_MS 60000
/* XXX make bufsz configurable per object (and at runtime?) */
#ifdef PIPE_BUF
#define DEFAULT_BUFSZ ((size_t)PIPE_BUF)
#else
...
...
@@ -72,6 +68,7 @@ struct VPFX(pipe_vdp) {
char
**
argv
;
size_t
bufsz
;
int
argc
;
int
tmo_ms
;
};
struct
vdp_map
{
...
...
@@ -356,18 +353,18 @@ vdp_bytes(struct req *req, enum vdp_action act, void **priv, const void *ptr,
fds
[
STDERR_FILENO
].
revents
=
0
;
errno
=
0
;
retval
=
poll
(
fds
,
3
,
TIMEOUT_MS
);
retval
=
poll
(
fds
,
3
,
obj
->
tmo_ms
);
if
(
retval
<
0
)
{
assert
(
errno
==
EINTR
);
continue
;
}
if
(
retval
==
0
&&
len
>
0
)
{
if
(
retval
==
0
)
{
if
(
obj
->
tmo_ms
==
0
)
continue
;
VSLb
(
req
->
vsl
,
SLT_Error
,
"vdfp_pipe: vdp %s: timeout "
"waiting for %s"
,
obj
->
name
,
obj
->
path
);
return
(
-
1
);
}
else
if
(
retval
==
0
)
continue
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
if
(
fds
[
i
].
revents
==
0
)
...
...
@@ -530,7 +527,8 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
VCL_VOID
vmod_vdp__init
(
VRT_CTX
,
struct
VPFX
(
pipe_vdp
)
**
vdpp
,
const
char
*
obj_name
,
VCL_STRING
path
,
VCL_STRING
vdp_name
,
VCL_BYTES
bufsz
)
VCL_STRING
path
,
VCL_STRING
vdp_name
,
VCL_BYTES
bufsz
,
VCL_DURATION
timeout
)
{
struct
VPFX
(
pipe_vdp
)
*
vdp_obj
;
struct
vdp
*
vdp
;
...
...
@@ -585,6 +583,7 @@ vmod_vdp__init(VRT_CTX, struct VPFX(pipe_vdp) **vdpp, const char *obj_name,
vdp_obj
->
name
=
strdup
(
obj_name
);
vdp_obj
->
path
=
strdup
(
path
);
vdp_obj
->
bufsz
=
bufsz
;
vdp_obj
->
tmo_ms
=
timeout
*
1000
;
errno
=
0
;
vdp
=
malloc
(
sizeof
(
*
vdp
));
...
...
src/vdfp_pipe.vcc
View file @
b68b1451
...
...
@@ -50,7 +50,7 @@ external commands.
XXX ...
$Object vdp(STRING path, STRING name=0, BYTES bufsz=0)
$Object vdp(STRING path, STRING name=0, BYTES bufsz=0
, DURATION timeout=60
)
XXX ...
...
...
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