Commit e2a3fcc6 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Emit a "Gzip" VSL record on each gzip operation.

Remember to free vgz structures again in ESI fetching
parent e1a2c7fe
...@@ -638,8 +638,8 @@ void Fetch_Init(void); ...@@ -638,8 +638,8 @@ void Fetch_Init(void);
struct vgz; struct vgz;
enum vgz_flag { VGZ_NORMAL, VGZ_ALIGN, VGZ_RESET, VGZ_FINISH }; enum vgz_flag { VGZ_NORMAL, VGZ_ALIGN, VGZ_RESET, VGZ_FINISH };
struct vgz *VGZ_NewUngzip(struct sess *sp); struct vgz *VGZ_NewUngzip(struct sess *sp, const char *id);
struct vgz *VGZ_NewGzip(struct sess *sp); struct vgz *VGZ_NewGzip(struct sess *sp, const char *id);
void VGZ_Ibuf(struct vgz *, const void *, ssize_t len); void VGZ_Ibuf(struct vgz *, const void *, ssize_t len);
int VGZ_IbufEmpty(const struct vgz *vg); int VGZ_IbufEmpty(const struct vgz *vg);
void VGZ_Obuf(struct vgz *, const void *, ssize_t len); void VGZ_Obuf(struct vgz *, const void *, ssize_t len);
......
...@@ -431,8 +431,7 @@ cnt_error(struct sess *sp) ...@@ -431,8 +431,7 @@ cnt_error(struct sess *sp)
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
* We have fetched the headers from the backend, ask the VCL code what * Fetch an object from the backend, either for pass or for caching.
* to do next, then head off in that direction.
* *
DOT subgraph xcluster_fetch { DOT subgraph xcluster_fetch {
DOT fetch [ DOT fetch [
......
...@@ -274,7 +274,7 @@ ESI_Deliver(struct sess *sp) ...@@ -274,7 +274,7 @@ ESI_Deliver(struct sess *sp)
} }
if (isgzip && !sp->wrk->gzip_resp) { if (isgzip && !sp->wrk->gzip_resp) {
vgz = VGZ_NewUngzip(sp); vgz = VGZ_NewUngzip(sp, "U D E");
obufl = 0; obufl = 0;
} }
......
...@@ -305,24 +305,24 @@ vfp_esi_begin(struct sess *sp, size_t estimate) ...@@ -305,24 +305,24 @@ vfp_esi_begin(struct sess *sp, size_t estimate)
/* XXX: snapshot WS's ? We'll need the space */ /* XXX: snapshot WS's ? We'll need the space */
if (sp->wrk->is_gzip && sp->wrk->do_gunzip) { 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); VEP_Init(sp, NULL);
} else if (sp->wrk->is_gunzip && sp->wrk->do_gzip) { } else if (sp->wrk->is_gunzip && sp->wrk->do_gzip) {
vef = (void*)WS_Alloc(sp->ws, sizeof *vef); vef = (void*)WS_Alloc(sp->ws, sizeof *vef);
AN(vef); AN(vef);
memset(vef, 0, sizeof *vef); memset(vef, 0, sizeof *vef);
vef->magic = VEF_MAGIC; vef->magic = VEF_MAGIC;
vef->vgz = VGZ_NewGzip(sp); vef->vgz = VGZ_NewGzip(sp, "G F E");
AZ(sp->wrk->vef_priv); AZ(sp->wrk->vef_priv);
sp->wrk->vef_priv = vef; sp->wrk->vef_priv = vef;
VEP_Init(sp, vfp_vep_callback); VEP_Init(sp, vfp_vep_callback);
} else if (sp->wrk->is_gzip) { } 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); vef = (void*)WS_Alloc(sp->ws, sizeof *vef);
AN(vef); AN(vef);
memset(vef, 0, sizeof *vef); memset(vef, 0, sizeof *vef);
vef->magic = VEF_MAGIC; vef->magic = VEF_MAGIC;
vef->vgz = VGZ_NewGzip(sp); vef->vgz = VGZ_NewGzip(sp, "G F E");
AZ(sp->wrk->vef_priv); AZ(sp->wrk->vef_priv);
sp->wrk->vef_priv = vef; sp->wrk->vef_priv = vef;
VEP_Init(sp, vfp_vep_callback); VEP_Init(sp, vfp_vep_callback);
...@@ -373,12 +373,15 @@ vfp_esi_end(struct sess *sp) ...@@ -373,12 +373,15 @@ vfp_esi_end(struct sess *sp)
sp->obj->esidata->len = l; sp->obj->esidata->len = l;
vsb_delete(vsb); vsb_delete(vsb);
} }
if (sp->wrk->vgz_rx != NULL)
VGZ_Destroy(&sp->wrk->vgz_rx);
if (sp->wrk->vef_priv != NULL) { if (sp->wrk->vef_priv != NULL) {
vef = sp->wrk->vef_priv; vef = sp->wrk->vef_priv;
VGZ_UpdateObj(vef->vgz, sp->obj);
sp->wrk->vef_priv = NULL;
CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
sp->wrk->vef_priv = NULL;
VGZ_UpdateObj(vef->vgz, sp->obj);
VGZ_Destroy(&vef->vgz);
XXXAZ(vef->error); XXXAZ(vef->error);
sp->obj->gziped = 1; sp->obj->gziped = 1;
} else { } else {
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#include "svnid.h" #include "svnid.h"
SVNID("$Id$") SVNID("$Id$")
#include "vsl.h"
#include "cache.h" #include "cache.h"
#include "stevedore.h" #include "stevedore.h"
...@@ -79,6 +80,8 @@ SVNID("$Id$") ...@@ -79,6 +80,8 @@ SVNID("$Id$")
struct vgz { struct vgz {
unsigned magic; unsigned magic;
#define VGZ_MAGIC 0x162df0cb #define VGZ_MAGIC 0x162df0cb
struct sess *sess;
const char *id;
struct ws *tmp; struct ws *tmp;
char *tmp_snapshot; char *tmp_snapshot;
...@@ -113,7 +116,7 @@ vgz_free(voidpf opaque, voidpf address) ...@@ -113,7 +116,7 @@ vgz_free(voidpf opaque, voidpf address)
*/ */
static struct vgz * static struct vgz *
vgz_alloc_vgz(struct sess *sp) vgz_alloc_vgz(struct sess *sp, const char *id)
{ {
struct vgz *vg; struct vgz *vg;
struct ws *ws = sp->wrk->ws; struct ws *ws = sp->wrk->ws;
...@@ -123,6 +126,8 @@ vgz_alloc_vgz(struct sess *sp) ...@@ -123,6 +126,8 @@ vgz_alloc_vgz(struct sess *sp)
AN(vg); AN(vg);
memset(vg, 0, sizeof *vg); memset(vg, 0, sizeof *vg);
vg->magic = VGZ_MAGIC; vg->magic = VGZ_MAGIC;
vg->sess = sp;
vg->id = id;
switch (params->gzip_tmp_space) { switch (params->gzip_tmp_space) {
case 0: case 0:
...@@ -149,12 +154,12 @@ vgz_alloc_vgz(struct sess *sp) ...@@ -149,12 +154,12 @@ vgz_alloc_vgz(struct sess *sp)
} }
struct vgz * struct vgz *
VGZ_NewUngzip(struct sess *sp) VGZ_NewUngzip(struct sess *sp, const char *id)
{ {
struct vgz *vg; struct vgz *vg;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
vg = vgz_alloc_vgz(sp); vg = vgz_alloc_vgz(sp, id);
/* /*
* Max memory usage according to zonf.h: * Max memory usage according to zonf.h:
...@@ -167,13 +172,13 @@ VGZ_NewUngzip(struct sess *sp) ...@@ -167,13 +172,13 @@ VGZ_NewUngzip(struct sess *sp)
} }
struct vgz * struct vgz *
VGZ_NewGzip(struct sess *sp) VGZ_NewGzip(struct sess *sp, const char *id)
{ {
struct vgz *vg; struct vgz *vg;
int i; int i;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
vg = vgz_alloc_vgz(sp); vg = vgz_alloc_vgz(sp, id);
/* /*
* From zconf.h: * From zconf.h:
...@@ -353,13 +358,23 @@ VGZ_UpdateObj(const struct vgz *vg, struct object *obj) ...@@ -353,13 +358,23 @@ VGZ_UpdateObj(const struct vgz *vg, struct object *obj)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
void void
VGZ_Destroy(struct vgz **vg) VGZ_Destroy(struct vgz **vgp)
{ {
struct vgz *vg;
CHECK_OBJ_NOTNULL(*vg, VGZ_MAGIC); vg = *vgp;
if ((*vg)->tmp != NULL) CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
WS_Reset((*vg)->tmp, (*vg)->tmp_snapshot); *vgp = NULL;
*vg = 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__() ...@@ -372,7 +387,7 @@ static void __match_proto__()
vfp_gunzip_begin(struct sess *sp, size_t estimate) vfp_gunzip_begin(struct sess *sp, size_t estimate)
{ {
(void)estimate; (void)estimate;
sp->wrk->vgz_rx = VGZ_NewUngzip(sp); sp->wrk->vgz_rx = VGZ_NewUngzip(sp, "U F -");
} }
static int __match_proto__() static int __match_proto__()
...@@ -441,7 +456,7 @@ vfp_gzip_begin(struct sess *sp, size_t estimate) ...@@ -441,7 +456,7 @@ vfp_gzip_begin(struct sess *sp, size_t estimate)
{ {
(void)estimate; (void)estimate;
sp->wrk->vgz_rx = VGZ_NewGzip(sp); sp->wrk->vgz_rx = VGZ_NewGzip(sp, "G F -");
} }
static int __match_proto__() static int __match_proto__()
...@@ -517,7 +532,7 @@ static void __match_proto__() ...@@ -517,7 +532,7 @@ static void __match_proto__()
vfp_testgzip_begin(struct sess *sp, size_t estimate) vfp_testgzip_begin(struct sess *sp, size_t estimate)
{ {
(void)estimate; (void)estimate;
sp->wrk->vgz_rx = VGZ_NewUngzip(sp); sp->wrk->vgz_rx = VGZ_NewUngzip(sp, "u F -");
} }
static int __match_proto__() static int __match_proto__()
......
...@@ -253,7 +253,7 @@ res_WriteGunzipObj(struct sess *sp) ...@@ -253,7 +253,7 @@ res_WriteGunzipObj(struct sess *sp)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
vg = VGZ_NewUngzip(sp); vg = VGZ_NewUngzip(sp, "U R -");
VTAILQ_FOREACH(st, &sp->obj->store, list) { VTAILQ_FOREACH(st, &sp->obj->store, list) {
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
......
...@@ -98,3 +98,5 @@ SLTM(Hash) ...@@ -98,3 +98,5 @@ SLTM(Hash)
SLTM(Backend_health) SLTM(Backend_health)
SLTM(VCL_Log) SLTM(VCL_Log)
SLTM(Gzip)
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