[experimental-ims] 5e673e1 Start to push struct sess out of the "fetch non-esi body from backend" code path, to pave the road for Martins streaming code.

Geoff Simmons geoff at varnish-cache.org
Mon Jan 9 21:52:25 CET 2012


commit 5e673e14c020a4cf3ce2f246268a0fbfd0de7bfb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 24 09:50:18 2011 +0000

    Start to push struct sess out of the "fetch non-esi body from backend"
    code path, to pave the road for Martins streaming code.

diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index e94180a..018355e 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -710,8 +710,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, const char *id);
-struct vgz *VGZ_NewGzip(struct sess *sp, const char *id);
+struct vgz *VGZ_NewUngzip(struct worker *wrk, int vsl_id, const char *id);
+struct vgz *VGZ_NewGzip(struct worker *wrk, int vsl_id, 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 *, void *, ssize_t len);
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index fd3238d..d60f17e 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -901,7 +901,7 @@ cnt_streambody(struct sess *sp)
 	sp->wrk->sctx = &sctx;
 
 	if (sp->wrk->res_mode & RES_GUNZIP) {
-		sctx.vgz = VGZ_NewUngzip(sp, "U S -");
+		sctx.vgz = VGZ_NewUngzip(sp->wrk, sp->vsl_id, "U S -");
 		sctx.obuf = obuf;
 		sctx.obuf_len = sizeof (obuf);
 	}
diff --git a/bin/varnishd/cache_esi_deliver.c b/bin/varnishd/cache_esi_deliver.c
index f7daeeb..aaf5f7a 100644
--- a/bin/varnishd/cache_esi_deliver.c
+++ b/bin/varnishd/cache_esi_deliver.c
@@ -267,7 +267,7 @@ ESI_Deliver(struct sess *sp)
 	}
 
 	if (isgzip && !sp->wrk->gzip_resp) {
-		vgz = VGZ_NewUngzip(sp, "U D E");
+		vgz = VGZ_NewUngzip(sp->wrk, sp->vsl_id, "U D E");
 
 		/* Feed a gzip header to gunzip to make it happy */
 		VGZ_Ibuf(vgz, gzip_hdr, sizeof gzip_hdr);
diff --git a/bin/varnishd/cache_esi_fetch.c b/bin/varnishd/cache_esi_fetch.c
index 1db5259..f69e900 100644
--- a/bin/varnishd/cache_esi_fetch.c
+++ b/bin/varnishd/cache_esi_fetch.c
@@ -301,7 +301,7 @@ vfp_esi_begin(struct sess *sp, size_t estimate)
 
 	AZ(sp->wrk->vgz_rx);
 	if (sp->wrk->is_gzip && sp->wrk->do_gunzip) {
-		sp->wrk->vgz_rx = VGZ_NewUngzip(sp, "U F E");
+		sp->wrk->vgz_rx = VGZ_NewUngzip(sp->wrk, sp->vsl_id, "U F E");
 		VEP_Init(sp, NULL);
 	} else if (sp->wrk->is_gunzip && sp->wrk->do_gzip) {
 		ALLOC_OBJ(vef, VEF_MAGIC);
@@ -309,18 +309,18 @@ vfp_esi_begin(struct sess *sp, size_t estimate)
 		//vef = (void*)WS_Alloc(sp->ws, sizeof *vef);
 		//memset(vef, 0, sizeof *vef);
 		//vef->magic = VEF_MAGIC;
-		vef->vgz = VGZ_NewGzip(sp, "G F E");
+		vef->vgz = VGZ_NewGzip(sp->wrk, sp->vsl_id, "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, "U F E");
+		sp->wrk->vgz_rx = VGZ_NewUngzip(sp->wrk, sp->vsl_id, "U F E");
 		ALLOC_OBJ(vef, VEF_MAGIC);
 		AN(vef);
 		//vef = (void*)WS_Alloc(sp->ws, sizeof *vef);
 		//memset(vef, 0, sizeof *vef);
 		//vef->magic = VEF_MAGIC;
-		vef->vgz = VGZ_NewGzip(sp, "G F E");
+		vef->vgz = VGZ_NewGzip(sp->wrk, sp->vsl_id, "G F E");
 		AZ(sp->wrk->vef_priv);
 		sp->wrk->vef_priv = vef;
 		VEP_Init(sp, vfp_vep_callback);
diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c
index 156ac52..787ff16 100644
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -77,7 +77,8 @@ struct vgz {
 	unsigned		magic;
 #define VGZ_MAGIC		0x162df0cb
 	enum {VGZ_GZ,VGZ_UN}	dir;
-	struct sess		*sess;
+	struct worker		*wrk;
+	int			vsl_id;
 	const char		*id;
 	struct ws		*tmp;
 	char			*tmp_snapshot;
@@ -113,11 +114,13 @@ vgz_free(voidpf opaque, voidpf address)
  */
 
 static struct vgz *
-vgz_alloc_vgz(struct sess *sp, const char *id)
+vgz_alloc_vgz(struct worker *wrk, int vsl_id, const char *id)
 {
 	struct vgz *vg;
-	struct ws *ws = sp->wrk->ws;
+	struct ws *ws;
 
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+	ws = wrk->ws;
 	WS_Assert(ws);
 	// XXX: we restore workspace in esi:include
 	// vg = (void*)WS_Alloc(ws, sizeof *vg);
@@ -125,22 +128,17 @@ vgz_alloc_vgz(struct sess *sp, const char *id)
 	AN(vg);
 	memset(vg, 0, sizeof *vg);
 	vg->magic = VGZ_MAGIC;
-	vg->sess = sp;
+	vg->wrk = wrk;
+	vg->vsl_id = vsl_id;
 	vg->id = id;
 
 	switch (params->gzip_tmp_space) {
 	case 0:
-		/* malloc, the default */
-		break;
 	case 1:
-		vg->tmp = sp->ws;
-		vg->tmp_snapshot = WS_Snapshot(vg->tmp);
-		vg->vz.zalloc = vgz_alloc;
-		vg->vz.zfree = vgz_free;
-		vg->vz.opaque = vg;
+		/* malloc, the default */
 		break;
 	case 2:
-		vg->tmp = sp->wrk->ws;
+		vg->tmp = wrk->ws;
 		vg->tmp_snapshot = WS_Snapshot(vg->tmp);
 		vg->vz.zalloc = vgz_alloc;
 		vg->vz.zfree = vgz_free;
@@ -153,12 +151,12 @@ vgz_alloc_vgz(struct sess *sp, const char *id)
 }
 
 struct vgz *
-VGZ_NewUngzip(struct sess *sp, const char *id)
+VGZ_NewUngzip(struct worker *wrk, int vsl_id, const char *id)
 {
 	struct vgz *vg;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	vg = vgz_alloc_vgz(sp, id);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+	vg = vgz_alloc_vgz(wrk, vsl_id, id);
 	vg->dir = VGZ_UN;
 	VSC_C_main->n_gunzip++;
 
@@ -173,13 +171,13 @@ VGZ_NewUngzip(struct sess *sp, const char *id)
 }
 
 struct vgz *
-VGZ_NewGzip(struct sess *sp, const char *id)
+VGZ_NewGzip(struct worker *wrk, int vsl_id, const char *id)
 {
 	struct vgz *vg;
 	int i;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	vg = vgz_alloc_vgz(sp, id);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+	vg = vgz_alloc_vgz(wrk, vsl_id, id);
 	vg->dir = VGZ_GZ;
 	VSC_C_main->n_gzip++;
 
@@ -413,7 +411,7 @@ VGZ_Destroy(struct vgz **vgp)
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	*vgp = NULL;
 
-	WSP(vg->sess, SLT_Gzip, "%s %jd %jd %jd %jd %jd",
+	WSL(vg->wrk, SLT_Gzip, vg->vsl_id, "%s %jd %jd %jd %jd %jd",
 	    vg->id,
 	    (intmax_t)vg->vz.total_in,
 	    (intmax_t)vg->vz.total_out,
@@ -440,7 +438,7 @@ vfp_gunzip_begin(struct sess *sp, size_t estimate)
 {
 	(void)estimate;
 	AZ(sp->wrk->vgz_rx);
-	sp->wrk->vgz_rx = VGZ_NewUngzip(sp, "U F -");
+	sp->wrk->vgz_rx = VGZ_NewUngzip(sp->wrk, sp->vsl_id, "U F -");
 }
 
 static int __match_proto__()
@@ -516,7 +514,7 @@ vfp_gzip_begin(struct sess *sp, size_t estimate)
 	(void)estimate;
 
 	AZ(sp->wrk->vgz_rx);
-	sp->wrk->vgz_rx = VGZ_NewGzip(sp, "G F -");
+	sp->wrk->vgz_rx = VGZ_NewGzip(sp->wrk, sp->vsl_id, "G F -");
 }
 
 static int __match_proto__()
@@ -598,7 +596,7 @@ static void __match_proto__()
 vfp_testgzip_begin(struct sess *sp, size_t estimate)
 {
 	(void)estimate;
-	sp->wrk->vgz_rx = VGZ_NewUngzip(sp, "u F -");
+	sp->wrk->vgz_rx = VGZ_NewUngzip(sp->wrk, sp->vsl_id, "u F -");
 	CHECK_OBJ_NOTNULL(sp->wrk->vgz_rx, VGZ_MAGIC);
 }
 
diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c
index 4f0334b..5521bc0 100644
--- a/bin/varnishd/cache_response.c
+++ b/bin/varnishd/cache_response.c
@@ -151,7 +151,7 @@ RES_BuildHttp(const struct sess *sp)
  */
 
 static void
-res_WriteGunzipObj(struct sess *sp)
+res_WriteGunzipObj(const struct sess *sp)
 {
 	struct storage *st;
 	unsigned u = 0;
@@ -162,7 +162,7 @@ res_WriteGunzipObj(struct sess *sp)
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 
-	vg = VGZ_NewUngzip(sp, "U D -");
+	vg = VGZ_NewUngzip(sp->wrk, sp->vsl_id, "U D -");
 
 	VGZ_Obuf(vg, obuf, sizeof obuf);
 	VTAILQ_FOREACH(st, &sp->obj->store, list) {
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index 1ca6a74..8665ff5 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -882,7 +882,6 @@ static const struct parspec input_parspec[] = {
 	{ "gzip_tmp_space", tweak_uint, &master.gzip_tmp_space, 0, 2,
 		"Where temporary space for gzip/gunzip is allocated:\n"
 		"  0 - malloc\n"
-		"  1 - session workspace\n"
 		"  2 - thread workspace\n"
 		"If you have much gzip/gunzip activity, it may be an"
 		" advantage to use workspace for these allocations to reduce"



More information about the varnish-commit mailing list