Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvfp-brotli
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
libvfp-brotli
Commits
e3c28439
Commit
e3c28439
authored
Feb 15, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the decoder.create_stats() method.
parent
d913397b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
23 deletions
+56
-23
README.rst
README.rst
+7
-0
stats.vtc
src/tests/stats.vtc
+11
-7
vfp_brotli.c
src/vfp_brotli.c
+34
-16
vfp_brotli.vcc
src/vfp_brotli.vcc
+4
-0
No files found.
README.rst
View file @
e3c28439
...
...
@@ -105,6 +105,13 @@ new xdecoder = brotli.decoder(STRING name, BYTES buffer, BOOL large_win)
XXX ...
.. _vmod_brotli.decoder.create_stats:
VOID xdecoder.create_stats()
----------------------------
XXX ...
.. _vmod_brotli.encoder_version:
STRING encoder_version()
...
...
src/tests/stats.vtc
View file @
e3c28439
...
...
@@ -44,10 +44,12 @@ varnish v1 -vcl+backend {
sub vcl_init {
new mybr = brotli.encoder("mybr");
mybr.create_stats();
new myunbr = brotli.decoder("myunbr");
myunbr.create_stats();
}
sub vcl_backend_response {
set beresp.filters = "mybr unbr";
set beresp.filters = "mybr
my
unbr";
set beresp.uncacheable = true;
}
}
...
...
@@ -65,25 +67,27 @@ client c1 -run
varnish v1 -vsc BROTLI.*
varnish v1 -expect BROTLI.br.ops == 10
varnish v1 -expect BROTLI.unbr.ops ==
2
0
varnish v1 -expect BROTLI.unbr.ops ==
1
0
varnish v1 -expect BROTLI.vcl2.mybr.ops == 10
varnish v1 -expect BROTLI.vcl2.myunbr.ops == 10
varnish v1 -vcl+backend {}
varnish v1 -cliok "vcl.state vcl2 cold"
# With vcl2 in the cold state, stats for vcl2.
mybr
do not appear.
# With vcl2 in the cold state, stats for vcl2.
*
do not appear.
# This has to be checked manually in the log.
varnish v1 -vsc BROTLI.vcl2.*
varnish v1 -expect BROTLI.br.ops == 10
varnish v1 -expect BROTLI.unbr.ops ==
2
0
varnish v1 -expect BROTLI.unbr.ops ==
1
0
varnish v1 -cliok "vcl.state vcl2 warm"
# With vcl2 back in the warm state, stats for vcl2.
mybr
appear again.
# With vcl2 back in the warm state, stats for vcl2.
*
appear again.
varnish v1 -expect BROTLI.br.ops == 10
varnish v1 -expect BROTLI.unbr.ops ==
2
0
varnish v1 -expect BROTLI.unbr.ops ==
1
0
varnish v1 -expect BROTLI.vcl2.mybr.ops == 10
varnish v1 -expect BROTLI.vcl2.myunbr.ops == 10
varnish v1 -cliok "vcl.state vcl2 cold"
varnish v1 -cliok "vcl.discard vcl2"
...
...
@@ -91,4 +95,4 @@ varnish v1 -cliok "vcl.list"
varnish v1 -vsc BROTLI.*
varnish v1 -expect BROTLI.br.ops == 10
varnish v1 -expect BROTLI.unbr.ops ==
2
0
varnish v1 -expect BROTLI.unbr.ops ==
1
0
src/vfp_brotli.c
View file @
e3c28439
...
...
@@ -95,6 +95,7 @@ struct vmod_brotli_encoder {
struct
vmod_brotli_decoder
{
unsigned
magic
;
#define VMOD_BROTLI_DECODER_MAGIC 0x263b6d01
char
*
vcl_name
;
struct
vfp
*
vfp
;
};
...
...
@@ -709,6 +710,28 @@ coder_init(VRT_CTX, const char *vcl_name, struct vmod_priv *priv,
return
(
0
);
}
static
void
create_stats
(
VRT_CTX
,
const
struct
vfp
*
vfp
,
const
char
*
vcl_name
)
{
struct
vfp_priv
*
vfp_priv
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
vcl_name
);
if
((
ctx
->
method
&
VCL_MET_INIT
)
==
0
)
{
VFAIL
(
ctx
,
"%s.create_stats() may only be called in vcl_init"
,
vcl_name
);
return
;
}
AN
(
vfp
);
CAST_OBJ_NOTNULL
(
vfp_priv
,
TRUST_ME
(
vfp
->
priv1
),
VFP_PRIV_MAGIC
);
vfp_priv
->
stats
=
VSC_brotli_New
(
NULL
,
&
vfp_priv
->
vsc_seg
,
"%s.%s"
,
VCL_Name
(
ctx
->
vcl
),
vcl_name
);
AN
(
vfp_priv
->
stats
);
memset
(
vfp_priv
->
stats
,
0
,
sizeof
(
*
vfp_priv
->
stats
));
}
VCL_VOID
vmod_encoder__init
(
VRT_CTX
,
struct
vmod_brotli_encoder
**
encp
,
const
char
*
vcl_name
,
struct
vmod_priv
*
priv
,
...
...
@@ -785,23 +808,8 @@ vmod_encoder__fini(struct vmod_brotli_encoder **encp)
VCL_VOID
vmod_encoder_create_stats
(
VRT_CTX
,
struct
vmod_brotli_encoder
*
enc
)
{
struct
vfp_priv
*
vfp_priv
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
enc
,
VMOD_BROTLI_ENCODER_MAGIC
);
if
((
ctx
->
method
&
VCL_MET_INIT
)
==
0
)
{
VFAIL
(
ctx
,
"%s.create_stats() may only be called in vcl_init"
,
enc
->
vcl_name
);
return
;
}
AN
(
enc
->
vfp
);
CAST_OBJ_NOTNULL
(
vfp_priv
,
TRUST_ME
(
enc
->
vfp
->
priv1
),
VFP_PRIV_MAGIC
);
vfp_priv
->
stats
=
VSC_brotli_New
(
NULL
,
&
vfp_priv
->
vsc_seg
,
"%s.%s"
,
VCL_Name
(
ctx
->
vcl
),
enc
->
vcl_name
);
AN
(
vfp_priv
->
stats
);
memset
(
vfp_priv
->
stats
,
0
,
sizeof
(
*
vfp_priv
->
stats
));
create_stats
(
ctx
,
enc
->
vfp
,
enc
->
vcl_name
);
}
/* Object decoder */
...
...
@@ -837,6 +845,7 @@ vmod_decoder__init(VRT_CTX, struct vmod_brotli_decoder **decp,
settings
->
which
=
DEC
;
settings
->
large_win
=
large_win
;
dec
->
vfp
=
vfp
;
dec
->
vcl_name
=
strdup
(
vcl_name
);
*
decp
=
dec
;
}
...
...
@@ -853,9 +862,18 @@ vmod_decoder__fini(struct vmod_brotli_decoder **decp)
CHECK_OBJ
(
*
decp
,
VMOD_BROTLI_DECODER_MAGIC
);
dec
=
*
decp
;
*
decp
=
NULL
;
if
(
dec
->
vcl_name
!=
NULL
)
free
(
dec
->
vcl_name
);
FREE_OBJ
(
dec
);
}
VCL_VOID
vmod_decoder_create_stats
(
VRT_CTX
,
struct
vmod_brotli_decoder
*
dec
)
{
CHECK_OBJ_NOTNULL
(
dec
,
VMOD_BROTLI_DECODER_MAGIC
);
create_stats
(
ctx
,
dec
->
vfp
,
dec
->
vcl_name
);
}
/* Version functions */
static
VCL_STRING
...
...
src/vfp_brotli.vcc
View file @
e3c28439
...
...
@@ -75,6 +75,10 @@ $Object decoder(PRIV_VCL, STRING name, BYTES buffer=32768, BOOL large_win=0)
XXX ...
$Method VOID .create_stats()
XXX ...
$Function STRING encoder_version()
Return the version string for the brotli encoder.
...
...
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