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);
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);
......
......@@ -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 [
......
......@@ -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;
}
......
......@@ -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 {
......
......@@ -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__()
......
......@@ -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);
......
......@@ -98,3 +98,5 @@ SLTM(Hash)
SLTM(Backend_health)
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