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
618908db
Commit
618908db
authored
Sep 25, 2013
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable taglists in VSL query expressions
parent
24ad8224
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
19 deletions
+62
-19
l00001.vtc
bin/varnishtest/tests/l00001.vtc
+7
-0
vsl_api.h
lib/libvarnishapi/vsl_api.h
+2
-0
vsl_arg.c
lib/libvarnishapi/vsl_arg.c
+2
-2
vsl_query.c
lib/libvarnishapi/vsl_query.c
+3
-3
vxp.h
lib/libvarnishapi/vxp.h
+3
-3
vxp_parse.c
lib/libvarnishapi/vxp_parse.c
+45
-11
No files found.
bin/varnishtest/tests/l00001.vtc
View file @
618908db
...
@@ -172,3 +172,10 @@ logexpect l1 -d 1 -g vxid -q "RespHeader[2] == 123" {
...
@@ -172,3 +172,10 @@ logexpect l1 -d 1 -g vxid -q "RespHeader[2] == 123" {
expect * = ReqEnd
expect * = ReqEnd
expect * = End
expect * = End
} -run
} -run
# Test taglists
logexpect l1 -d 1 -g vxid -q "Debug,Resp* == 200" {
expect 0 * Begin req
expect * = ReqEnd
expect * = End
} -run
lib/libvarnishapi/vsl_api.h
View file @
618908db
...
@@ -40,6 +40,8 @@
...
@@ -40,6 +40,8 @@
int
vsl_diag
(
struct
VSL_data
*
vsl
,
const
char
*
fmt
,
...)
int
vsl_diag
(
struct
VSL_data
*
vsl
,
const
char
*
fmt
,
...)
__printflike
(
2
,
3
);
__printflike
(
2
,
3
);
int
vsl_skip
(
struct
VSL_cursor
*
c
,
ssize_t
words
);
int
vsl_skip
(
struct
VSL_cursor
*
c
,
ssize_t
words
);
void
vsl_vbm_bitset
(
int
bit
,
void
*
priv
);
void
vsl_vbm_bitclr
(
int
bit
,
void
*
priv
);
typedef
void
vslc_delete_f
(
struct
VSL_cursor
*
);
typedef
void
vslc_delete_f
(
struct
VSL_cursor
*
);
typedef
int
vslc_next_f
(
struct
VSL_cursor
*
);
typedef
int
vslc_next_f
(
struct
VSL_cursor
*
);
...
...
lib/libvarnishapi/vsl_arg.c
View file @
618908db
...
@@ -212,14 +212,14 @@ VSLQ_Name2Grouping(const char *name, int l)
...
@@ -212,14 +212,14 @@ VSLQ_Name2Grouping(const char *name, int l)
return
(
n
);
return
(
n
);
}
}
static
void
void
__match_proto__
(
VSL_tagfind_f
)
vsl_vbm_bitset
(
int
bit
,
void
*
priv
)
vsl_vbm_bitset
(
int
bit
,
void
*
priv
)
{
{
vbit_set
((
struct
vbitmap
*
)
priv
,
bit
);
vbit_set
((
struct
vbitmap
*
)
priv
,
bit
);
}
}
static
void
void
__match_proto__
(
VSL_tagfind_f
)
vsl_vbm_bitclr
(
int
bit
,
void
*
priv
)
vsl_vbm_bitclr
(
int
bit
,
void
*
priv
)
{
{
...
...
lib/libvarnishapi/vsl_query.c
View file @
618908db
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
#include "miniobj.h"
#include "miniobj.h"
#include "vre.h"
#include "vre.h"
#include "vsb.h"
#include "vsb.h"
#include "vbm.h"
#include "vapi/vsl.h"
#include "vapi/vsl.h"
#include "vsl_api.h"
#include "vsl_api.h"
...
@@ -187,6 +188,7 @@ vslq_test(const struct vex *vex, struct VSL_transaction * const ptrans[])
...
@@ -187,6 +188,7 @@ vslq_test(const struct vex *vex, struct VSL_transaction * const ptrans[])
CHECK_OBJ_NOTNULL
(
vex
,
VEX_MAGIC
);
CHECK_OBJ_NOTNULL
(
vex
,
VEX_MAGIC
);
CHECK_OBJ_NOTNULL
(
vex
->
lhs
,
VEX_LHS_MAGIC
);
CHECK_OBJ_NOTNULL
(
vex
->
lhs
,
VEX_LHS_MAGIC
);
AN
(
vex
->
lhs
->
tags
);
CHECK_OBJ_NOTNULL
(
vex
->
rhs
,
VEX_RHS_MAGIC
);
CHECK_OBJ_NOTNULL
(
vex
->
rhs
,
VEX_RHS_MAGIC
);
for
(
t
=
ptrans
[
0
];
t
!=
NULL
;
t
=
*++
ptrans
)
{
for
(
t
=
ptrans
[
0
];
t
!=
NULL
;
t
=
*++
ptrans
)
{
...
@@ -200,14 +202,12 @@ vslq_test(const struct vex *vex, struct VSL_transaction * const ptrans[])
...
@@ -200,14 +202,12 @@ vslq_test(const struct vex *vex, struct VSL_transaction * const ptrans[])
assert
(
i
==
1
);
assert
(
i
==
1
);
AN
(
t
->
c
->
rec
.
ptr
);
AN
(
t
->
c
->
rec
.
ptr
);
if
(
vex
->
lhs
->
tag
!=
VSL_TAG
(
t
->
c
->
rec
.
ptr
))
if
(
!
vbit_test
(
vex
->
lhs
->
tags
,
VSL_TAG
(
t
->
c
->
rec
.
ptr
)
))
continue
;
continue
;
i
=
vslq_test_rec
(
vex
,
&
t
->
c
->
rec
);
i
=
vslq_test_rec
(
vex
,
&
t
->
c
->
rec
);
if
(
i
)
if
(
i
)
return
(
i
);
return
(
i
);
}
}
}
}
...
...
lib/libvarnishapi/vxp.h
View file @
618908db
...
@@ -35,8 +35,8 @@
...
@@ -35,8 +35,8 @@
#include "vxp_tokens.h"
#include "vxp_tokens.h"
#define isword(c) \
#define isword(c)
(isalpha(c) || isdigit(c) || (c) == '_' || (c) == '-' ||
\
(isalpha(c) || isdigit(c) || (c) == '_' || (c) == '-' || (c) == '.
')
(c) == '.' || (c) == '*' || (c) == ',
')
#define PF(t) (int)((t)->e - (t)->b), (t)->b
#define PF(t) (int)((t)->e - (t)->b), (t)->b
...
@@ -82,7 +82,7 @@ struct vex_lhs {
...
@@ -82,7 +82,7 @@ struct vex_lhs {
expression should be applied to */
expression should be applied to */
unsigned
magic
;
unsigned
magic
;
#define VEX_LHS_MAGIC 0x1AD3D78D
#define VEX_LHS_MAGIC 0x1AD3D78D
int
tag
;
struct
vbitmap
*
tags
;
int
field
;
int
field
;
int
level_min
;
int
level_min
;
int
level_max
;
int
level_max
;
...
...
lib/libvarnishapi/vxp_parse.c
View file @
618908db
...
@@ -40,8 +40,10 @@
...
@@ -40,8 +40,10 @@
#include "vas.h"
#include "vas.h"
#include "vsb.h"
#include "vsb.h"
#include "vbm.h"
#include "miniobj.h"
#include "miniobj.h"
#include "vapi/vsl.h"
#include "vapi/vsl.h"
#include "vsl_api.h"
#include "vxp.h"
#include "vxp.h"
...
@@ -51,29 +53,36 @@ static void
...
@@ -51,29 +53,36 @@ static void
vxp_expr_lhs
(
struct
vxp
*
vxp
,
struct
vex_lhs
**
plhs
)
vxp_expr_lhs
(
struct
vxp
*
vxp
,
struct
vex_lhs
**
plhs
)
{
{
char
*
p
;
char
*
p
;
int
i
;
/* XXX: Tag wildcards */
AN
(
plhs
);
AN
(
plhs
);
AZ
(
*
plhs
);
AZ
(
*
plhs
);
if
(
vxp
->
t
->
tok
!=
VAL
)
{
if
(
vxp
->
t
->
tok
!=
VAL
)
{
VSB_printf
(
vxp
->
sb
,
"Expected VSL tag got '%.*s' "
,
PF
(
vxp
->
t
));
VSB_printf
(
vxp
->
sb
,
"Expected VSL taglist got '%.*s' "
,
PF
(
vxp
->
t
));
vxp_ErrWhere
(
vxp
,
vxp
->
t
,
-
1
);
vxp_ErrWhere
(
vxp
,
vxp
->
t
,
-
1
);
return
;
return
;
}
}
ALLOC_OBJ
(
*
plhs
,
VEX_LHS_MAGIC
);
ALLOC_OBJ
(
*
plhs
,
VEX_LHS_MAGIC
);
AN
(
*
plhs
);
AN
(
*
plhs
);
(
*
plhs
)
->
tag
=
VSL_Name2Tag
(
vxp
->
t
->
dec
,
-
1
);
(
*
plhs
)
->
tag
s
=
vbit_init
(
SLT__MAX
);
i
f
((
*
plhs
)
->
tag
==
-
1
)
{
i
=
VSL_List2Tags
(
vxp
->
t
->
dec
,
-
1
,
vsl_vbm_bitset
,
(
*
plhs
)
->
tags
);
VSB_printf
(
vxp
->
sb
,
"Could not match '%.*s' to any tag "
,
if
(
i
==
-
1
)
{
PF
(
vxp
->
t
)
);
VSB_printf
(
vxp
->
sb
,
"Taglist matches zero tags"
);
vxp_ErrWhere
(
vxp
,
vxp
->
t
,
-
1
);
vxp_ErrWhere
(
vxp
,
vxp
->
t
,
-
1
);
return
;
return
;
}
else
if
((
*
plhs
)
->
tag
==
-
2
)
{
}
VSB_printf
(
vxp
->
sb
,
"'%.*s' matches multiple tags "
,
if
(
i
==
-
2
)
{
PF
(
vxp
->
t
));
VSB_printf
(
vxp
->
sb
,
"Taglist is ambiguous"
);
vxp_ErrWhere
(
vxp
,
vxp
->
t
,
-
1
);
return
;
}
if
(
i
==
-
3
)
{
VSB_printf
(
vxp
->
sb
,
"Syntax error in taglist"
);
vxp_ErrWhere
(
vxp
,
vxp
->
t
,
-
1
);
vxp_ErrWhere
(
vxp
,
vxp
->
t
,
-
1
);
return
;
return
;
}
}
assert
(
i
>
0
);
vxp_NextToken
(
vxp
);
vxp_NextToken
(
vxp
);
if
(
vxp
->
t
->
tok
==
'['
)
{
if
(
vxp
->
t
->
tok
==
'['
)
{
...
@@ -422,8 +431,11 @@ void
...
@@ -422,8 +431,11 @@ void
vex_Free
(
struct
vex
**
pvex
)
vex_Free
(
struct
vex
**
pvex
)
{
{
if
((
*
pvex
)
->
lhs
!=
NULL
)
if
((
*
pvex
)
->
lhs
!=
NULL
)
{
if
((
*
pvex
)
->
lhs
->
tags
!=
NULL
)
vbit_destroy
((
*
pvex
)
->
lhs
->
tags
);
FREE_OBJ
((
*
pvex
)
->
lhs
);
FREE_OBJ
((
*
pvex
)
->
lhs
);
}
if
((
*
pvex
)
->
rhs
!=
NULL
)
{
if
((
*
pvex
)
->
rhs
!=
NULL
)
{
if
((
*
pvex
)
->
rhs
->
val_string
)
if
((
*
pvex
)
->
rhs
->
val_string
)
free
((
*
pvex
)
->
rhs
->
val_string
);
free
((
*
pvex
)
->
rhs
->
val_string
);
...
@@ -472,6 +484,25 @@ vex_print_rhs(const struct vex_rhs *rhs)
...
@@ -472,6 +484,25 @@ vex_print_rhs(const struct vex_rhs *rhs)
}
}
}
}
static
void
vex_print_tags
(
const
struct
vbitmap
*
vbm
)
{
int
i
;
int
first
=
1
;
for
(
i
=
0
;
i
<
SLT__MAX
;
i
++
)
{
if
(
VSL_tags
[
i
]
==
NULL
)
continue
;
if
(
!
vbit_test
(
vbm
,
i
))
continue
;
if
(
first
)
first
=
0
;
else
fprintf
(
stderr
,
","
);
fprintf
(
stderr
,
"%s"
,
VSL_tags
[
i
]);
}
}
static
void
static
void
vex_print
(
const
struct
vex
*
vex
,
int
indent
)
vex_print
(
const
struct
vex
*
vex
,
int
indent
)
{
{
...
@@ -480,7 +511,10 @@ vex_print(const struct vex *vex, int indent)
...
@@ -480,7 +511,10 @@ vex_print(const struct vex *vex, int indent)
fprintf
(
stderr
,
"%*s%s"
,
indent
,
""
,
vxp_tnames
[
vex
->
tok
]);
fprintf
(
stderr
,
"%*s%s"
,
indent
,
""
,
vxp_tnames
[
vex
->
tok
]);
if
(
vex
->
lhs
!=
NULL
)
{
if
(
vex
->
lhs
!=
NULL
)
{
CHECK_OBJ_NOTNULL
(
vex
->
lhs
,
VEX_LHS_MAGIC
);
CHECK_OBJ_NOTNULL
(
vex
->
lhs
,
VEX_LHS_MAGIC
);
fprintf
(
stderr
,
" tag=%s"
,
VSL_tags
[
vex
->
lhs
->
tag
]);
AN
(
vex
->
lhs
->
tags
);
fprintf
(
stderr
,
" lhs=("
);
vex_print_tags
(
vex
->
lhs
->
tags
);
fprintf
(
stderr
,
")"
);
if
(
vex
->
lhs
->
field
>=
0
)
if
(
vex
->
lhs
->
field
>=
0
)
fprintf
(
stderr
,
"[%d]"
,
vex
->
lhs
->
field
);
fprintf
(
stderr
,
"[%d]"
,
vex
->
lhs
->
field
);
}
}
...
...
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