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
af71e479
Commit
af71e479
authored
Apr 18, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an internal API to register/remove a VFP
parent
05c74b99
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
16 deletions
+52
-16
cache_fetch_proc.c
bin/varnishd/cache/cache_fetch_proc.c
+50
-16
cache_filter.h
bin/varnishd/cache/cache_filter.h
+2
-0
No files found.
bin/varnishd/cache/cache_fetch_proc.c
View file @
af71e479
...
...
@@ -226,21 +226,52 @@ VFP_Push(struct vfp_ctx *vc, const struct vfp *vfp)
/*--------------------------------------------------------------------
*/
static
const
struct
vfp
*
vfplist
[]
=
{
&
VFP_testgunzip
,
&
VFP_gunzip
,
&
VFP_gzip
,
&
VFP_esi
,
&
VFP_esi_gzip
,
NULL
,
struct
vfp_filter
{
unsigned
magic
;
#define VFP_FILTER_MAGIC 0xd40894e9
const
struct
vfp
*
filter
;
int
nlen
;
VTAILQ_ENTRY
(
vfp_filter
)
list
;
};
static
VTAILQ_HEAD
(,
vfp_filter
)
vfp_filters
=
VTAILQ_HEAD_INITIALIZER
(
vfp_filters
);
void
VFP_AddFilter
(
const
struct
vfp
*
filter
)
{
struct
vfp_filter
*
vp
;
VTAILQ_FOREACH
(
vp
,
&
vfp_filters
,
list
)
{
assert
(
vp
->
filter
!=
filter
);
assert
(
strcasecmp
(
vp
->
filter
->
name
,
filter
->
name
));
}
ALLOC_OBJ
(
vp
,
VFP_FILTER_MAGIC
);
AN
(
vp
);
vp
->
filter
=
filter
;
vp
->
nlen
=
strlen
(
filter
->
name
);
VTAILQ_INSERT_TAIL
(
&
vfp_filters
,
vp
,
list
);
}
void
VFP_RemoveFilter
(
const
struct
vfp
*
filter
)
{
struct
vfp_filter
*
vp
;
VTAILQ_FOREACH
(
vp
,
&
vfp_filters
,
list
)
{
if
(
vp
->
filter
==
filter
)
break
;
}
AN
(
vp
);
VTAILQ_REMOVE
(
&
vfp_filters
,
vp
,
list
);
FREE_OBJ
(
vp
);
}
int
VFP_FilterList
(
struct
vfp_ctx
*
vc
,
const
char
*
fl
)
{
const
char
*
p
,
*
q
;
const
struct
vfp
**
vp
;
int
l
;
const
struct
vfp_filter
*
vp
;
VSLb
(
vc
->
wrk
->
vsl
,
SLT_Filters
,
"%s"
,
fl
);
...
...
@@ -252,23 +283,21 @@ VFP_FilterList(struct vfp_ctx *vc, const char *fl)
for
(
q
=
p
;
*
q
;
q
++
)
if
(
vct_isspace
(
*
q
))
break
;
for
(
vp
=
vfplist
;
*
vp
!=
NULL
;
vp
++
)
{
l
=
strlen
((
*
vp
)
->
name
);
if
(
l
!=
q
-
p
)
VTAILQ_FOREACH
(
vp
,
&
vfp_filters
,
list
)
{
if
(
vp
->
nlen
!=
q
-
p
)
continue
;
if
(
!
memcmp
(
p
,
(
*
vp
)
->
name
,
l
))
if
(
!
memcmp
(
p
,
vp
->
filter
->
name
,
vp
->
nlen
))
break
;
}
if
(
*
vp
==
NULL
)
if
(
vp
==
NULL
)
return
(
VFP_Error
(
vc
,
"Filter '%.*s' not found"
,
(
int
)(
q
-
p
),
p
));
if
(
VFP_Push
(
vc
,
*
vp
)
==
NULL
)
if
(
VFP_Push
(
vc
,
vp
->
filter
)
==
NULL
)
return
(
-
1
);
}
return
(
0
);
}
/*--------------------------------------------------------------------
* Debugging aids
*/
...
...
@@ -295,4 +324,9 @@ VFP_Init(void)
{
CLI_AddFuncs
(
debug_cmds
);
VFP_AddFilter
(
&
VFP_testgunzip
);
VFP_AddFilter
(
&
VFP_gunzip
);
VFP_AddFilter
(
&
VFP_gzip
);
VFP_AddFilter
(
&
VFP_esi
);
VFP_AddFilter
(
&
VFP_esi_gzip
);
}
bin/varnishd/cache/cache_filter.h
View file @
af71e479
...
...
@@ -89,6 +89,8 @@ enum vfp_status VFP_Suck(struct vfp_ctx *, void *p, ssize_t *lp);
enum
vfp_status
VFP_Error
(
struct
vfp_ctx
*
,
const
char
*
fmt
,
...)
v_printflike_
(
2
,
3
);
int
VFP_FilterList
(
struct
vfp_ctx
*
,
const
char
*
);
void
VFP_AddFilter
(
const
struct
vfp
*
);
void
VFP_RemoveFilter
(
const
struct
vfp
*
);
/* Deliver processors ------------------------------------------------*/
...
...
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