Commit da0d1c86 authored by Federico G. Schwindt's avatar Federico G. Schwindt

Decouple testing from the gunzip counter

Add a new counter, n_test_gunzip to track the former.
parent 13db0ab6
...@@ -76,7 +76,7 @@ vgz_msg(const struct vgz *vg) ...@@ -76,7 +76,7 @@ vgz_msg(const struct vgz *vg)
*/ */
static struct vgz * static struct vgz *
vgz_alloc_vgz(struct vsl_log *vsl, const char *id) vgz_gunzip(struct vsl_log *vsl, const char *id)
{ {
struct vgz *vg; struct vgz *vg;
...@@ -84,17 +84,7 @@ vgz_alloc_vgz(struct vsl_log *vsl, const char *id) ...@@ -84,17 +84,7 @@ vgz_alloc_vgz(struct vsl_log *vsl, const char *id)
AN(vg); AN(vg);
vg->vsl = vsl; vg->vsl = vsl;
vg->id = id; vg->id = id;
return (vg);
}
static struct vgz *
VGZ_NewUngzip(struct vsl_log *vsl, const char *id)
{
struct vgz *vg;
vg = vgz_alloc_vgz(vsl, id);
vg->dir = VGZ_UN; vg->dir = VGZ_UN;
VSC_C_main->n_gunzip++;
/* /*
* Max memory usage according to zonf.h: * Max memory usage according to zonf.h:
...@@ -106,15 +96,32 @@ VGZ_NewUngzip(struct vsl_log *vsl, const char *id) ...@@ -106,15 +96,32 @@ VGZ_NewUngzip(struct vsl_log *vsl, const char *id)
return (vg); return (vg);
} }
static struct vgz *
VGZ_NewGunzip(struct vsl_log *vsl, const char *id)
{
VSC_C_main->n_gunzip++;
return (vgz_gunzip(vsl, id));
}
static struct vgz *
VGZ_NewTestGunzip(struct vsl_log *vsl, const char *id)
{
VSC_C_main->n_test_gunzip++;
return (vgz_gunzip(vsl, id));
}
struct vgz * struct vgz *
VGZ_NewGzip(struct vsl_log *vsl, const char *id) VGZ_NewGzip(struct vsl_log *vsl, const char *id)
{ {
struct vgz *vg; struct vgz *vg;
int i; int i;
vg = vgz_alloc_vgz(vsl, id);
vg->dir = VGZ_GZ;
VSC_C_main->n_gzip++; VSC_C_main->n_gzip++;
ALLOC_OBJ(vg, VGZ_MAGIC);
AN(vg);
vg->vsl = vsl;
vg->id = id;
vg->dir = VGZ_GZ;
/* /*
* From zconf.h: * From zconf.h:
...@@ -293,7 +300,7 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv, ...@@ -293,7 +300,7 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv,
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
if (act == VDP_INIT) { if (act == VDP_INIT) {
vg = VGZ_NewUngzip(req->vsl, "U D -"); vg = VGZ_NewGunzip(req->vsl, "U D -");
AN(vg); AN(vg);
if (vgz_getmbuf(vg)) { if (vgz_getmbuf(vg)) {
(void)VGZ_Destroy(&vg); (void)VGZ_Destroy(&vg);
...@@ -451,7 +458,10 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) ...@@ -451,7 +458,10 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
} else { } else {
if (!http_HdrIs(vc->http, H_Content_Encoding, "gzip")) if (!http_HdrIs(vc->http, H_Content_Encoding, "gzip"))
return (VFP_NULL); return (VFP_NULL);
vg = VGZ_NewUngzip(vc->wrk->vsl, vfe->vfp->priv1); if (vfe->vfp->priv2 == VFP_GUNZIP)
vg = VGZ_NewGunzip(vc->wrk->vsl, vfe->vfp->priv1);
else
vg = VGZ_NewTestGunzip(vc->wrk->vsl, vfe->vfp->priv1);
} }
if (vg == NULL) if (vg == NULL)
return (VFP_ERROR); return (VFP_ERROR);
......
...@@ -43,3 +43,7 @@ client c1 { ...@@ -43,3 +43,7 @@ client c1 {
expect resp.http.content-length == "26" expect resp.http.content-length == "26"
expect resp.http.content-encoding == "gzip" expect resp.http.content-encoding == "gzip"
} -run } -run
varnish v1 -expect n_gzip == 0
varnish v1 -expect n_gunzip == 3
varnish v1 -expect n_test_gunzip == 1
...@@ -50,3 +50,7 @@ client c1 { ...@@ -50,3 +50,7 @@ client c1 {
expect resp.http.content-encoding == <undef> expect resp.http.content-encoding == <undef>
expect resp.bodylen == 4109 expect resp.bodylen == 4109
} -run } -run
varnish v1 -expect n_gzip == 1
varnish v1 -expect n_gunzip == 3
varnish v1 -expect n_test_gunzip == 0
...@@ -49,3 +49,7 @@ client c1 { ...@@ -49,3 +49,7 @@ client c1 {
expect resp.http.content-encoding == <undef> expect resp.http.content-encoding == <undef>
expect resp.bodylen == 43 expect resp.bodylen == 43
} -run } -run
varnish v1 -expect n_gzip == 1
varnish v1 -expect n_gunzip == 2
varnish v1 -expect n_test_gunzip == 0
...@@ -662,6 +662,11 @@ VSC_FF(n_gunzip, uint64_t, 0, 'c', 'i', info, ...@@ -662,6 +662,11 @@ VSC_FF(n_gunzip, uint64_t, 0, 'c', 'i', info,
"" ""
) )
VSC_FF(n_test_gunzip, uint64_t, 0, 'c', 'i', info,
"Test gunzip operations",
""
)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
VSC_FF(vsm_free, uint64_t, 0, 'g', 'B', diag, VSC_FF(vsm_free, uint64_t, 0, 'g', 'B', diag,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment