[master] e2a3fcc Emit a "Gzip" VSL record on each gzip operation.
Poul-Henning Kamp
phk at varnish-cache.org
Mon Jan 31 10:07:03 CET 2011
commit e2a3fcc6927e61a98d136d853bd7306f2335c4fb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jan 31 09:06:05 2011 +0000
Emit a "Gzip" VSL record on each gzip operation.
Remember to free vgz structures again in ESI fetching
diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index f997341..fdd0308 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -638,8 +638,8 @@ void Fetch_Init(void);
struct vgz;
enum vgz_flag { VGZ_NORMAL, VGZ_ALIGN, VGZ_RESET, VGZ_FINISH };
-struct vgz *VGZ_NewUngzip(struct sess *sp);
-struct vgz *VGZ_NewGzip(struct sess *sp);
+struct vgz *VGZ_NewUngzip(struct sess *sp, const char *id);
+struct vgz *VGZ_NewGzip(struct sess *sp, const char *id);
void VGZ_Ibuf(struct vgz *, const void *, ssize_t len);
int VGZ_IbufEmpty(const struct vgz *vg);
void VGZ_Obuf(struct vgz *, const void *, ssize_t len);
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 6595a98..25d57cb 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -431,8 +431,7 @@ cnt_error(struct sess *sp)
}
/*--------------------------------------------------------------------
- * We have fetched the headers from the backend, ask the VCL code what
- * to do next, then head off in that direction.
+ * Fetch an object from the backend, either for pass or for caching.
*
DOT subgraph xcluster_fetch {
DOT fetch [
diff --git a/bin/varnishd/cache_esi_deliver.c b/bin/varnishd/cache_esi_deliver.c
index 9c5b0cf..a8050de 100644
--- a/bin/varnishd/cache_esi_deliver.c
+++ b/bin/varnishd/cache_esi_deliver.c
@@ -274,7 +274,7 @@ ESI_Deliver(struct sess *sp)
}
if (isgzip && !sp->wrk->gzip_resp) {
- vgz = VGZ_NewUngzip(sp);
+ vgz = VGZ_NewUngzip(sp, "U D E");
obufl = 0;
}
diff --git a/bin/varnishd/cache_esi_fetch.c b/bin/varnishd/cache_esi_fetch.c
index 9369d0a..34d98a4 100644
--- a/bin/varnishd/cache_esi_fetch.c
+++ b/bin/varnishd/cache_esi_fetch.c
@@ -305,24 +305,24 @@ vfp_esi_begin(struct sess *sp, size_t estimate)
/* XXX: snapshot WS's ? We'll need the space */
if (sp->wrk->is_gzip && sp->wrk->do_gunzip) {
- sp->wrk->vgz_rx = VGZ_NewUngzip(sp);
+ sp->wrk->vgz_rx = VGZ_NewUngzip(sp, "U F E");
VEP_Init(sp, NULL);
} else if (sp->wrk->is_gunzip && sp->wrk->do_gzip) {
vef = (void*)WS_Alloc(sp->ws, sizeof *vef);
AN(vef);
memset(vef, 0, sizeof *vef);
vef->magic = VEF_MAGIC;
- vef->vgz = VGZ_NewGzip(sp);
+ vef->vgz = VGZ_NewGzip(sp, "G F E");
AZ(sp->wrk->vef_priv);
sp->wrk->vef_priv = vef;
VEP_Init(sp, vfp_vep_callback);
} else if (sp->wrk->is_gzip) {
- sp->wrk->vgz_rx = VGZ_NewUngzip(sp);
+ sp->wrk->vgz_rx = VGZ_NewUngzip(sp, "U F E");
vef = (void*)WS_Alloc(sp->ws, sizeof *vef);
AN(vef);
memset(vef, 0, sizeof *vef);
vef->magic = VEF_MAGIC;
- vef->vgz = VGZ_NewGzip(sp);
+ vef->vgz = VGZ_NewGzip(sp, "G F E");
AZ(sp->wrk->vef_priv);
sp->wrk->vef_priv = vef;
VEP_Init(sp, vfp_vep_callback);
@@ -373,12 +373,15 @@ vfp_esi_end(struct sess *sp)
sp->obj->esidata->len = l;
vsb_delete(vsb);
}
+ if (sp->wrk->vgz_rx != NULL)
+ VGZ_Destroy(&sp->wrk->vgz_rx);
if (sp->wrk->vef_priv != NULL) {
vef = sp->wrk->vef_priv;
- VGZ_UpdateObj(vef->vgz, sp->obj);
- sp->wrk->vef_priv = NULL;
CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
+ sp->wrk->vef_priv = NULL;
+ VGZ_UpdateObj(vef->vgz, sp->obj);
+ VGZ_Destroy(&vef->vgz);
XXXAZ(vef->error);
sp->obj->gziped = 1;
} else {
diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c
index 5177d01..7ff3895 100644
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -71,6 +71,7 @@
#include "svnid.h"
SVNID("$Id$")
+#include "vsl.h"
#include "cache.h"
#include "stevedore.h"
@@ -79,6 +80,8 @@ SVNID("$Id$")
struct vgz {
unsigned magic;
#define VGZ_MAGIC 0x162df0cb
+ struct sess *sess;
+ const char *id;
struct ws *tmp;
char *tmp_snapshot;
@@ -113,7 +116,7 @@ vgz_free(voidpf opaque, voidpf address)
*/
static struct vgz *
-vgz_alloc_vgz(struct sess *sp)
+vgz_alloc_vgz(struct sess *sp, const char *id)
{
struct vgz *vg;
struct ws *ws = sp->wrk->ws;
@@ -123,6 +126,8 @@ vgz_alloc_vgz(struct sess *sp)
AN(vg);
memset(vg, 0, sizeof *vg);
vg->magic = VGZ_MAGIC;
+ vg->sess = sp;
+ vg->id = id;
switch (params->gzip_tmp_space) {
case 0:
@@ -149,12 +154,12 @@ vgz_alloc_vgz(struct sess *sp)
}
struct vgz *
-VGZ_NewUngzip(struct sess *sp)
+VGZ_NewUngzip(struct sess *sp, const char *id)
{
struct vgz *vg;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- vg = vgz_alloc_vgz(sp);
+ vg = vgz_alloc_vgz(sp, id);
/*
* Max memory usage according to zonf.h:
@@ -167,13 +172,13 @@ VGZ_NewUngzip(struct sess *sp)
}
struct vgz *
-VGZ_NewGzip(struct sess *sp)
+VGZ_NewGzip(struct sess *sp, const char *id)
{
struct vgz *vg;
int i;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- vg = vgz_alloc_vgz(sp);
+ vg = vgz_alloc_vgz(sp, id);
/*
* From zconf.h:
@@ -353,13 +358,23 @@ VGZ_UpdateObj(const struct vgz *vg, struct object *obj)
/*--------------------------------------------------------------------*/
void
-VGZ_Destroy(struct vgz **vg)
+VGZ_Destroy(struct vgz **vgp)
{
+ struct vgz *vg;
- CHECK_OBJ_NOTNULL(*vg, VGZ_MAGIC);
- if ((*vg)->tmp != NULL)
- WS_Reset((*vg)->tmp, (*vg)->tmp_snapshot);
- *vg = NULL;
+ vg = *vgp;
+ CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
+ *vgp = NULL;
+
+ WSP(vg->sess, SLT_Gzip, "%s %jd %jd %jd %jd %jd",
+ vg->id,
+ (intmax_t)vg->vz.total_in,
+ (intmax_t)vg->vz.total_out,
+ (intmax_t)vg->vz.start_bit,
+ (intmax_t)vg->vz.last_bit,
+ (intmax_t)vg->vz.stop_bit);
+ if (vg->tmp != NULL)
+ WS_Reset(vg->tmp, vg->tmp_snapshot);
}
/*--------------------------------------------------------------------
@@ -372,7 +387,7 @@ static void __match_proto__()
vfp_gunzip_begin(struct sess *sp, size_t estimate)
{
(void)estimate;
- sp->wrk->vgz_rx = VGZ_NewUngzip(sp);
+ sp->wrk->vgz_rx = VGZ_NewUngzip(sp, "U F -");
}
static int __match_proto__()
@@ -441,7 +456,7 @@ vfp_gzip_begin(struct sess *sp, size_t estimate)
{
(void)estimate;
- sp->wrk->vgz_rx = VGZ_NewGzip(sp);
+ sp->wrk->vgz_rx = VGZ_NewGzip(sp, "G F -");
}
static int __match_proto__()
@@ -517,7 +532,7 @@ static void __match_proto__()
vfp_testgzip_begin(struct sess *sp, size_t estimate)
{
(void)estimate;
- sp->wrk->vgz_rx = VGZ_NewUngzip(sp);
+ sp->wrk->vgz_rx = VGZ_NewUngzip(sp, "u F -");
}
static int __match_proto__()
diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c
index 18c2612..94f2dd4 100644
--- a/bin/varnishd/cache_response.c
+++ b/bin/varnishd/cache_response.c
@@ -253,7 +253,7 @@ res_WriteGunzipObj(struct sess *sp)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- vg = VGZ_NewUngzip(sp);
+ vg = VGZ_NewUngzip(sp, "U R -");
VTAILQ_FOREACH(st, &sp->obj->store, list) {
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
diff --git a/include/vsl_tags.h b/include/vsl_tags.h
index 7a59d55..6a28832 100644
--- a/include/vsl_tags.h
+++ b/include/vsl_tags.h
@@ -98,3 +98,5 @@ SLTM(Hash)
SLTM(Backend_health)
SLTM(VCL_Log)
+
+SLTM(Gzip)
More information about the varnish-commit
mailing list