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
93b77d9a
Commit
93b77d9a
authored
Dec 24, 2015
by
Dridi Boukelmoune
Committed by
Lasse Karstensen
Jun 14, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Teach vmod-debug how to sync with varnishtest
parent
6a709f87
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
0 deletions
+76
-0
m00024.vtc
bin/varnishtest/tests/m00024.vtc
+39
-0
vmod.vcc
lib/libvmod_debug/vmod.vcc
+4
-0
vmod_debug.c
lib/libvmod_debug/vmod_debug.c
+33
-0
No files found.
bin/varnishtest/tests/m00024.vtc
0 → 100644
View file @
93b77d9a
varnishtest "Test debug.barrier_sync"
barrier b1 sock 2
barrier b2 sock 2
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
import debug;
sub vcl_recv {
if (!debug.barrier_sync("${b1_sock}")) {
return (synth(400));
}
}
sub vcl_backend_response {
if (!debug.barrier_sync("${b2_sock}")) {
return (abandon);
}
}
} -start
varnish v1 -cliok "param.set debug +syncvsl"
client c1 {
txreq
rxresp
expect resp.status == 200
} -start
barrier b1 sync
delay 0.5
barrier b2 sync
client c1 -wait
lib/libvmod_debug/vmod.vcc
View file @
93b77d9a
...
...
@@ -154,3 +154,7 @@ Hold a reference to the VCL when it goes cold for the given delay.
$Function BOOL match_acl(ACL acl, IP ip)
Perform an IP match against a named ACL.
$Function BOOL barrier_sync(STRING)
Synchronize with a varnishtest shared barrier.
lib/libvmod_debug/vmod_debug.c
View file @
93b77d9a
...
...
@@ -28,6 +28,7 @@
#include "config.h"
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
...
...
@@ -38,6 +39,7 @@
#include "vrt.h"
#include "vsa.h"
#include "vsb.h"
#include "vtcp.h"
#include "vtim.h"
#include "vcc_if.h"
...
...
@@ -476,3 +478,34 @@ vmod_match_acl(VRT_CTX, VCL_ACL acl, VCL_IP ip)
return
(
VRT_acl_match
(
ctx
,
acl
,
ip
));
}
VCL_BOOL
vmod_barrier_sync
(
VRT_CTX
,
VCL_STRING
addr
)
{
const
char
*
err
;
char
buf
[
32
];
int
sock
;
ssize_t
sz
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
addr
);
AN
(
*
addr
);
VSLb
(
ctx
->
vsl
,
SLT_VCL_call
,
"barrier_sync(
\"
%s
\"
)"
,
addr
);
sock
=
VTCP_open
(
addr
,
NULL
,
0
.,
&
err
);
if
(
sock
<
0
)
{
VSLb
(
ctx
->
vsl
,
SLT_Error
,
"Barrier connection failed: %s"
,
err
);
return
(
0
);
}
sz
=
read
(
sock
,
buf
,
sizeof
buf
);
if
(
sz
==
0
)
return
(
1
);
if
(
sz
<
0
)
VSLb
(
ctx
->
vsl
,
SLT_Error
,
"Barrier connection failed: %s (errno=%d)"
,
strerror
(
errno
),
errno
);
if
(
sz
>
0
)
VSLb
(
ctx
->
vsl
,
SLT_Error
,
"Barrier unexpected data (%ldB)"
,
sz
);
return
(
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