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
716a307a
Commit
716a307a
authored
Apr 19, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
We will have to maintain the filter list per VCL, so move the
stuff there.
parent
48a57371
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
112 additions
and
82 deletions
+112
-82
cache_fetch_proc.c
bin/varnishd/cache/cache_fetch_proc.c
+0
-80
cache_filter.h
bin/varnishd/cache/cache_filter.h
+2
-2
cache_main.c
bin/varnishd/cache/cache_main.c
+1
-0
cache_varnishd.h
bin/varnishd/cache/cache_varnishd.h
+3
-0
cache_vcl.c
bin/varnishd/cache/cache_vcl.c
+1
-0
cache_vcl.h
bin/varnishd/cache/cache_vcl.h
+8
-0
cache_vcl_vrt.c
bin/varnishd/cache/cache_vcl_vrt.c
+97
-0
No files found.
bin/varnishd/cache/cache_fetch_proc.c
View file @
716a307a
...
...
@@ -223,81 +223,6 @@ VFP_Push(struct vfp_ctx *vc, const struct vfp *vfp)
return
(
vfe
);
}
/*--------------------------------------------------------------------
*/
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_filter
*
vp
;
VSLb
(
vc
->
wrk
->
vsl
,
SLT_Filters
,
"%s"
,
fl
);
for
(
p
=
fl
;
*
p
;
p
=
q
)
{
if
(
vct_isspace
(
*
p
))
{
q
=
p
+
1
;
continue
;
}
for
(
q
=
p
;
*
q
;
q
++
)
if
(
vct_isspace
(
*
q
))
break
;
VTAILQ_FOREACH
(
vp
,
&
vfp_filters
,
list
)
{
if
(
vp
->
nlen
!=
q
-
p
)
continue
;
if
(
!
memcmp
(
p
,
vp
->
filter
->
name
,
vp
->
nlen
))
break
;
}
if
(
vp
==
NULL
)
return
(
VFP_Error
(
vc
,
"Filter '%.*s' not found"
,
(
int
)(
q
-
p
),
p
));
if
(
VFP_Push
(
vc
,
vp
->
filter
)
==
NULL
)
return
(
-
1
);
}
return
(
0
);
}
/*--------------------------------------------------------------------
* Debugging aids
*/
...
...
@@ -324,9 +249,4 @@ 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 @
716a307a
...
...
@@ -89,8 +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
*
);
void
VFP_AddFilter
(
struct
vcl
*
,
const
struct
vfp
*
);
void
VFP_RemoveFilter
(
struct
vcl
*
,
const
struct
vfp
*
);
/* Deliver processors ------------------------------------------------*/
...
...
bin/varnishd/cache/cache_main.c
View file @
716a307a
...
...
@@ -351,6 +351,7 @@ child_main(int sigmagic, size_t altstksz)
ObjInit
();
VCL_Init
();
VCL_VRT_Init
();
HTTP_Init
();
...
...
bin/varnishd/cache/cache_varnishd.h
View file @
716a307a
...
...
@@ -405,6 +405,9 @@ typedef int vcl_be_func(struct cli *, struct director *, void *);
int
VCL_IterDirector
(
struct
cli
*
,
const
char
*
,
vcl_be_func
*
,
void
*
);
/* cache_vcl_vrt.c */
void
VCL_VRT_Init
(
void
);
/* cache_vrt.c */
void
VRTPRIV_init
(
struct
vrt_privs
*
privs
);
void
VRTPRIV_dynamic_kill
(
struct
vrt_privs
*
privs
,
uintptr_t
id
);
...
...
bin/varnishd/cache/cache_vcl.c
View file @
716a307a
...
...
@@ -526,6 +526,7 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx,
XXXAN
(
vcl
->
loaded_name
);
VTAILQ_INIT
(
&
vcl
->
director_list
);
VTAILQ_INIT
(
&
vcl
->
ref_list
);
VTAILQ_INIT
(
&
vcl
->
vfps
);
vcl
->
temp
=
VCL_TEMP_INIT
;
...
...
bin/varnishd/cache/cache_vcl.h
View file @
716a307a
...
...
@@ -26,8 +26,15 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* NB: This is a private .h file for cache_vcl*.c
* NB: No other code should include this file.
*
*/
struct
vfp_filter
;
VTAILQ_HEAD
(
vfp_filter_head
,
vfp_filter
);
struct
vcl
{
unsigned
magic
;
#define VCL_MAGIC 0x214188f2
...
...
@@ -45,6 +52,7 @@ struct vcl {
int
nrefs
;
struct
vcl
*
label
;
int
nlabels
;
struct
vfp_filter_head
vfps
;
};
struct
vclref
{
...
...
bin/varnishd/cache/cache_vcl_vrt.c
View file @
716a307a
...
...
@@ -37,9 +37,11 @@
#include "cache_varnishd.h"
#include "vcl.h"
#include "vct.h"
#include "cache_director.h"
#include "cache_vcl.h"
#include "cache_filter.h"
/*--------------------------------------------------------------------*/
...
...
@@ -413,3 +415,98 @@ VCL_##func##_method(struct vcl *vcl, struct worker *wrk, \
}
#include "tbl/vcl_returns.h"
/*--------------------------------------------------------------------
*/
struct
vfp_filter
{
unsigned
magic
;
#define VFP_FILTER_MAGIC 0xd40894e9
const
struct
vfp
*
filter
;
int
nlen
;
VTAILQ_ENTRY
(
vfp_filter
)
list
;
};
static
struct
vfp_filter_head
vfp_filters
=
VTAILQ_HEAD_INITIALIZER
(
vfp_filters
);
void
VFP_AddFilter
(
struct
vcl
*
vcl
,
const
struct
vfp
*
filter
)
{
struct
vfp_filter
*
vp
;
struct
vfp_filter_head
*
hd
=
&
vfp_filters
;
VTAILQ_FOREACH
(
vp
,
hd
,
list
)
{
xxxassert
(
vp
->
filter
!=
filter
);
xxxassert
(
strcasecmp
(
vp
->
filter
->
name
,
filter
->
name
));
}
if
(
vcl
!=
NULL
)
{
hd
=
&
vcl
->
vfps
;
VTAILQ_FOREACH
(
vp
,
hd
,
list
)
{
xxxassert
(
vp
->
filter
!=
filter
);
xxxassert
(
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
(
hd
,
vp
,
list
);
}
void
VFP_RemoveFilter
(
struct
vcl
*
vcl
,
const
struct
vfp
*
filter
)
{
struct
vfp_filter
*
vp
;
struct
vfp_filter_head
*
hd
=
&
vcl
->
vfps
;
AN
(
vcl
);
VTAILQ_FOREACH
(
vp
,
hd
,
list
)
{
if
(
vp
->
filter
==
filter
)
break
;
}
XXXAN
(
vp
);
VTAILQ_REMOVE
(
hd
,
vp
,
list
);
FREE_OBJ
(
vp
);
}
int
VFP_FilterList
(
struct
vfp_ctx
*
vc
,
const
char
*
fl
)
{
const
char
*
p
,
*
q
;
const
struct
vfp_filter
*
vp
;
VSLb
(
vc
->
wrk
->
vsl
,
SLT_Filters
,
"%s"
,
fl
);
for
(
p
=
fl
;
*
p
;
p
=
q
)
{
if
(
vct_isspace
(
*
p
))
{
q
=
p
+
1
;
continue
;
}
for
(
q
=
p
;
*
q
;
q
++
)
if
(
vct_isspace
(
*
q
))
break
;
VTAILQ_FOREACH
(
vp
,
&
vfp_filters
,
list
)
{
if
(
vp
->
nlen
!=
q
-
p
)
continue
;
if
(
!
memcmp
(
p
,
vp
->
filter
->
name
,
vp
->
nlen
))
break
;
}
if
(
vp
==
NULL
)
return
(
VFP_Error
(
vc
,
"Filter '%.*s' not found"
,
(
int
)(
q
-
p
),
p
));
if
(
VFP_Push
(
vc
,
vp
->
filter
)
==
NULL
)
return
(
-
1
);
}
return
(
0
);
}
void
VCL_VRT_Init
(
void
)
{
VFP_AddFilter
(
NULL
,
&
VFP_testgunzip
);
VFP_AddFilter
(
NULL
,
&
VFP_gunzip
);
VFP_AddFilter
(
NULL
,
&
VFP_gzip
);
VFP_AddFilter
(
NULL
,
&
VFP_esi
);
VFP_AddFilter
(
NULL
,
&
VFP_esi_gzip
);
}
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