[master] da0d1c8 Decouple testing from the gunzip counter
Federico G. Schwindt
fgsch at lodoss.net
Fri Jan 20 10:50:05 CET 2017
commit da0d1c86c7b5348dfb3ed48160ca6dd57c876172
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Wed Jan 18 08:33:52 2017 +0000
Decouple testing from the gunzip counter
Add a new counter, n_test_gunzip to track the former.
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 1860799..deb3b21 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -76,7 +76,7 @@ vgz_msg(const struct vgz *vg)
*/
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;
@@ -84,17 +84,7 @@ vgz_alloc_vgz(struct vsl_log *vsl, const char *id)
AN(vg);
vg->vsl = vsl;
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;
- VSC_C_main->n_gunzip++;
/*
* Max memory usage according to zonf.h:
@@ -106,15 +96,32 @@ VGZ_NewUngzip(struct vsl_log *vsl, const char *id)
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 *
VGZ_NewGzip(struct vsl_log *vsl, const char *id)
{
struct vgz *vg;
int i;
- vg = vgz_alloc_vgz(vsl, id);
- vg->dir = VGZ_GZ;
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:
@@ -293,7 +300,7 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv,
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
if (act == VDP_INIT) {
- vg = VGZ_NewUngzip(req->vsl, "U D -");
+ vg = VGZ_NewGunzip(req->vsl, "U D -");
AN(vg);
if (vgz_getmbuf(vg)) {
(void)VGZ_Destroy(&vg);
@@ -451,7 +458,10 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
} else {
if (!http_HdrIs(vc->http, H_Content_Encoding, "gzip"))
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)
return (VFP_ERROR);
diff --git a/bin/varnishtest/tests/g00001.vtc b/bin/varnishtest/tests/g00001.vtc
index a1343fe..0f84f54 100644
--- a/bin/varnishtest/tests/g00001.vtc
+++ b/bin/varnishtest/tests/g00001.vtc
@@ -43,3 +43,7 @@ client c1 {
expect resp.http.content-length == "26"
expect resp.http.content-encoding == "gzip"
} -run
+
+varnish v1 -expect n_gzip == 0
+varnish v1 -expect n_gunzip == 3
+varnish v1 -expect n_test_gunzip == 1
diff --git a/bin/varnishtest/tests/g00002.vtc b/bin/varnishtest/tests/g00002.vtc
index 1abdd8e..b722617 100644
--- a/bin/varnishtest/tests/g00002.vtc
+++ b/bin/varnishtest/tests/g00002.vtc
@@ -50,3 +50,7 @@ client c1 {
expect resp.http.content-encoding == <undef>
expect resp.bodylen == 4109
} -run
+
+varnish v1 -expect n_gzip == 1
+varnish v1 -expect n_gunzip == 3
+varnish v1 -expect n_test_gunzip == 0
diff --git a/bin/varnishtest/tests/g00003.vtc b/bin/varnishtest/tests/g00003.vtc
index 6fdae5c..ee032e3 100644
--- a/bin/varnishtest/tests/g00003.vtc
+++ b/bin/varnishtest/tests/g00003.vtc
@@ -49,3 +49,7 @@ client c1 {
expect resp.http.content-encoding == <undef>
expect resp.bodylen == 43
} -run
+
+varnish v1 -expect n_gzip == 1
+varnish v1 -expect n_gunzip == 2
+varnish v1 -expect n_test_gunzip == 0
diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h
index 7dbc87d..97e25ef 100644
--- a/include/tbl/vsc_f_main.h
+++ b/include/tbl/vsc_f_main.h
@@ -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,
More information about the varnish-commit
mailing list