[master] 3e4b829 Push struct session out of all the vfp's in one go.

Poul-Henning Kamp phk at varnish-cache.org
Mon Oct 24 16:26:18 CEST 2011


commit 3e4b82917f6c17672dbfd192dd0bc41c04180b31
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 24 14:25:52 2011 +0000

    Push struct session out of all the vfp's in one go.

diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index 08ba997..85f5d5f 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -110,6 +110,7 @@ struct vef_priv;
 struct vrt_backend;
 struct vsb;
 struct waitinglist;
+struct worker;
 
 #define DIGEST_LEN		32
 
@@ -226,9 +227,9 @@ struct dstat {
 
 /* Fetch processors --------------------------------------------------*/
 
-typedef void vfp_begin_f(struct sess *, size_t );
-typedef int vfp_bytes_f(struct sess *, struct http_conn *, ssize_t);
-typedef int vfp_end_f(struct sess *sp);
+typedef void vfp_begin_f(struct worker *, size_t );
+typedef int vfp_bytes_f(struct worker *, struct http_conn *, ssize_t);
+typedef int vfp_end_f(struct worker *);
 
 struct vfp {
 	vfp_begin_f	*begin;
@@ -703,7 +704,7 @@ int EXP_NukeOne(struct worker *w, struct lru *lru);
 /* cache_fetch.c */
 struct storage *FetchStorage(struct worker *w, ssize_t sz);
 int FetchHdr(struct sess *sp);
-int FetchBody(struct sess *sp, struct object *obj);
+int FetchBody(const struct sess *sp, struct object *obj);
 int FetchReqBody(struct sess *sp);
 void Fetch_Init(void);
 
diff --git a/bin/varnishd/cache_esi_fetch.c b/bin/varnishd/cache_esi_fetch.c
index fab6513..1713004 100644
--- a/bin/varnishd/cache_esi_fetch.c
+++ b/bin/varnishd/cache_esi_fetch.c
@@ -34,6 +34,7 @@
 
 #include "cache.h"
 
+#include "cache_backend.h"		// for w->vbc
 #include "cache_esi.h"
 
 /*---------------------------------------------------------------------
@@ -62,26 +63,26 @@ vef_read(struct http_conn *htc, void *buf, ssize_t buflen, ssize_t bytes)
  * We receive a ungzip'ed object, and want to store it ungzip'ed.
  */
 
-static int __match_proto__()
-vfp_esi_bytes_uu(struct sess *sp, struct http_conn *htc, ssize_t bytes)
+static int
+vfp_esi_bytes_uu(struct worker *w, struct http_conn *htc, ssize_t bytes)
 {
-	ssize_t w;
+	ssize_t wl;
 	struct storage *st;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
 
 	while (bytes > 0) {
-		st = FetchStorage(sp->wrk, 0);
+		st = FetchStorage(w, 0);
 		if (st == NULL)
 			return (-1);
-		w = vef_read(htc,
+		wl = vef_read(htc,
 		    st->ptr + st->len, st->space - st->len, bytes);
-		if (w <= 0)
-			return (w);
-		VEP_Parse(sp->wrk, (const char *)st->ptr + st->len, w);
-		st->len += w;
-		sp->obj->len += w;
-		bytes -= w;
+		if (wl <= 0)
+			return (wl);
+		VEP_Parse(w, (const char *)st->ptr + st->len, wl);
+		st->len += wl;
+		w->fetch_obj->len += wl;
+		bytes -= wl;
 	}
 	return (1);
 }
@@ -90,33 +91,33 @@ vfp_esi_bytes_uu(struct sess *sp, struct http_conn *htc, ssize_t bytes)
  * We receive a gzip'ed object, and want to store it ungzip'ed.
  */
 
-static int __match_proto__()
-vfp_esi_bytes_gu(struct sess *sp, struct http_conn *htc, ssize_t bytes)
+static int
+vfp_esi_bytes_gu(struct worker *w, struct http_conn *htc, ssize_t bytes)
 {
 	struct vgz *vg;
-	ssize_t w;
+	ssize_t wl;
 	uint8_t	ibuf[params->gzip_stack_buffer];
 	int i;
 	size_t dl;
 	const void *dp;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	vg = sp->wrk->vgz_rx;
+	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
+	vg = w->vgz_rx;
 
 	while (bytes > 0) {
 		if (VGZ_IbufEmpty(vg) && bytes > 0) {
-			w = vef_read(htc, ibuf, sizeof ibuf, bytes);
-			if (w <= 0)
-				return (w);
-			VGZ_Ibuf(vg, ibuf, w);
-			bytes -= w;
+			wl = vef_read(htc, ibuf, sizeof ibuf, bytes);
+			if (wl <= 0)
+				return (wl);
+			VGZ_Ibuf(vg, ibuf, wl);
+			bytes -= wl;
 		}
-		if (VGZ_ObufStorage(sp->wrk, vg))
+		if (VGZ_ObufStorage(w, vg))
 			return (-1);
 		i = VGZ_Gunzip(vg, &dp, &dl);
 		xxxassert(i == VGZ_OK || i == VGZ_END);
-		VEP_Parse(sp->wrk, dp, dl);
-		sp->obj->len += dl;
+		VEP_Parse(w, dp, dl);
+		w->fetch_obj->len += dl;
 	}
 	return (1);
 }
@@ -202,34 +203,34 @@ vfp_vep_callback(struct worker *w, ssize_t l, enum vgz_flag flg)
 	return (vef->tot);
 }
 
-static int __match_proto__()
-vfp_esi_bytes_ug(struct sess *sp, struct http_conn *htc, ssize_t bytes)
+static int
+vfp_esi_bytes_ug(const struct worker *w, struct http_conn *htc, ssize_t bytes)
 {
-	ssize_t w;
+	ssize_t wl;
 	char ibuf[params->gzip_stack_buffer];
 	struct vef_priv *vef;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	vef = sp->wrk->vef_priv;
+	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
+	vef = w->vef_priv;
 	CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
 
 	while (bytes > 0) {
-		w = vef_read(htc, ibuf, sizeof ibuf, bytes);
-		if (w <= 0)
-			return (w);
-		bytes -= w;
+		wl = vef_read(htc, ibuf, sizeof ibuf, bytes);
+		if (wl <= 0)
+			return (wl);
+		bytes -= wl;
 		vef->bufp = ibuf;
-		VEP_Parse(sp->wrk, ibuf, w);
-		assert(vef->bufp >= ibuf && vef->bufp <= ibuf + w);
+		VEP_Parse(w, ibuf, wl);
+		assert(vef->bufp >= ibuf && vef->bufp <= ibuf + wl);
 		if (vef->error) {
 			errno = vef->error;
 			return (-1);
 		}
-		if (vef->bufp < ibuf + w) {
-			w = (ibuf + w) - vef->bufp;
-			assert(w + vef->npend < sizeof vef->pending);
-			memmove(vef->pending + vef->npend, vef->bufp, w);
-			vef->npend += w;
+		if (vef->bufp < ibuf + wl) {
+			wl = (ibuf + wl) - vef->bufp;
+			assert(wl + vef->npend < sizeof vef->pending);
+			memmove(vef->pending + vef->npend, vef->bufp, wl);
+			vef->npend += wl;
 		}
 	}
 	return (1);
@@ -239,10 +240,10 @@ vfp_esi_bytes_ug(struct sess *sp, struct http_conn *htc, ssize_t bytes)
  * We receive a gzip'ed object, and want to store it gzip'ed.
  */
 
-static int __match_proto__()
-vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
+static int 
+vfp_esi_bytes_gg(const struct worker *w, struct http_conn *htc, size_t bytes)
 {
-	ssize_t w;
+	ssize_t wl;
 	char ibuf[params->gzip_stack_buffer];
 	char ibuf2[params->gzip_stack_buffer];
 	struct vef_priv *vef;
@@ -250,28 +251,28 @@ vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
 	const void *dp;
 	int i;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	vef = sp->wrk->vef_priv;
+	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
+	vef = w->vef_priv;
 	CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
 	assert(sizeof ibuf >= 1024);
 	ibuf2[0] = 0; /* For Flexelint */
 
 	while (bytes > 0) {
-		w = vef_read(htc, ibuf, sizeof ibuf, bytes);
-		if (w <= 0)
-			return (w);
-		bytes -= w;
+		wl = vef_read(htc, ibuf, sizeof ibuf, bytes);
+		if (wl <= 0)
+			return (wl);
+		bytes -= wl;
 
 		vef->bufp = ibuf;
-		VGZ_Ibuf(sp->wrk->vgz_rx, ibuf, w);
+		VGZ_Ibuf(w->vgz_rx, ibuf, wl);
 		do {
-			VGZ_Obuf(sp->wrk->vgz_rx, ibuf2, sizeof ibuf2);
-			i = VGZ_Gunzip(sp->wrk->vgz_rx, &dp, &dl);
+			VGZ_Obuf(w->vgz_rx, ibuf2, sizeof ibuf2);
+			i = VGZ_Gunzip(w->vgz_rx, &dp, &dl);
 			/* XXX: check i */
 			assert(i >= VGZ_OK);
 			vef->bufp = ibuf2;
 			if (dl > 0)
-				VEP_Parse(sp->wrk, ibuf2, dl);
+				VEP_Parse(w, ibuf2, dl);
 			if (vef->error) {
 				errno = vef->error;
 				return (-1);
@@ -283,7 +284,7 @@ vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
 				    vef->bufp, dl);
 				vef->npend += dl;
 			}
-		} while (!VGZ_IbufEmpty(sp->wrk->vgz_rx));
+		} while (!VGZ_IbufEmpty(w->vgz_rx));
 	}
 	return (1);
 }
@@ -292,96 +293,96 @@ vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
 /*---------------------------------------------------------------------*/
 
 static void __match_proto__()
-vfp_esi_begin(struct sess *sp, size_t estimate)
+vfp_esi_begin(struct worker *w, size_t estimate)
 {
 	struct vef_priv *vef;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
 	/* XXX: snapshot WS's ? We'll need the space */
 
-	AZ(sp->wrk->vgz_rx);
-	if (sp->wrk->is_gzip && sp->wrk->do_gunzip) {
-		sp->wrk->vgz_rx = VGZ_NewUngzip(sp->wrk, sp->vsl_id, "U F E");
-		VEP_Init(sp->wrk, NULL);
-	} else if (sp->wrk->is_gunzip && sp->wrk->do_gzip) {
+	AZ(w->vgz_rx);
+	if (w->is_gzip && w->do_gunzip) {
+		w->vgz_rx = VGZ_NewUngzip(w, w->vbc->vsl_id, "U F E");
+		VEP_Init(w, NULL);
+	} else if (w->is_gunzip && w->do_gzip) {
 		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->wrk, sp->vsl_id, "G F E");
-		AZ(sp->wrk->vef_priv);
-		sp->wrk->vef_priv = vef;
-		VEP_Init(sp->wrk, vfp_vep_callback);
-	} else if (sp->wrk->is_gzip) {
-		sp->wrk->vgz_rx = VGZ_NewUngzip(sp->wrk, sp->vsl_id, "U F E");
+		vef->vgz = VGZ_NewGzip(w, w->vbc->vsl_id, "G F E");
+		AZ(w->vef_priv);
+		w->vef_priv = vef;
+		VEP_Init(w, vfp_vep_callback);
+	} else if (w->is_gzip) {
+		w->vgz_rx = VGZ_NewUngzip(w, w->vbc->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->wrk, sp->vsl_id, "G F E");
-		AZ(sp->wrk->vef_priv);
-		sp->wrk->vef_priv = vef;
-		VEP_Init(sp->wrk, vfp_vep_callback);
+		vef->vgz = VGZ_NewGzip(w, w->vbc->vsl_id, "G F E");
+		AZ(w->vef_priv);
+		w->vef_priv = vef;
+		VEP_Init(w, vfp_vep_callback);
 	} else {
-		AZ(sp->wrk->vef_priv);
-		VEP_Init(sp->wrk, NULL);
+		AZ(w->vef_priv);
+		VEP_Init(w, NULL);
 	}
 
 	(void)estimate;
-	AN(sp->wrk->vep);
+	AN(w->vep);
 }
 
 static int __match_proto__()
-vfp_esi_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
+vfp_esi_bytes(struct worker *w, struct http_conn *htc, ssize_t bytes)
 {
 	int i;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	AN(sp->wrk->vep);
-	if (sp->wrk->is_gzip && sp->wrk->do_gunzip)
-		i = vfp_esi_bytes_gu(sp, htc, bytes);
-	else if (sp->wrk->is_gunzip && sp->wrk->do_gzip)
-		i = vfp_esi_bytes_ug(sp, htc, bytes);
-	else if (sp->wrk->is_gzip)
-		i = vfp_esi_bytes_gg(sp, htc, bytes);
+	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
+	AN(w->vep);
+	if (w->is_gzip && w->do_gunzip)
+		i = vfp_esi_bytes_gu(w, htc, bytes);
+	else if (w->is_gunzip && w->do_gzip)
+		i = vfp_esi_bytes_ug(w, htc, bytes);
+	else if (w->is_gzip)
+		i = vfp_esi_bytes_gg(w, htc, bytes);
 	else
-		i = vfp_esi_bytes_uu(sp, htc, bytes);
-	AN(sp->wrk->vep);
+		i = vfp_esi_bytes_uu(w, htc, bytes);
+	AN(w->vep);
 	return (i);
 }
 
 static int __match_proto__()
-vfp_esi_end(struct sess *sp)
+vfp_esi_end(struct worker *w)
 {
 	struct vsb *vsb;
 	struct vef_priv *vef;
 	ssize_t l;
 
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	AN(sp->wrk->vep);
+	CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
+	AN(w->vep);
 
-	vsb = VEP_Finish(sp->wrk);
+	vsb = VEP_Finish(w);
 
 	if (vsb != NULL) {
 		l = VSB_len(vsb);
 		assert(l > 0);
 		/* XXX: This is a huge waste of storage... */
-		sp->obj->esidata = STV_alloc(sp->wrk, l);
-		XXXAN(sp->obj->esidata);
-		memcpy(sp->obj->esidata->ptr, VSB_data(vsb), l);
-		sp->obj->esidata->len = l;
+		w->fetch_obj->esidata = STV_alloc(w, l);
+		XXXAN(w->fetch_obj->esidata);
+		memcpy(w->fetch_obj->esidata->ptr, VSB_data(vsb), l);
+		w->fetch_obj->esidata->len = l;
 		VSB_delete(vsb);
 	}
-	if (sp->wrk->vgz_rx != NULL)
-		VGZ_Destroy(&sp->wrk->vgz_rx);
+	if (w->vgz_rx != NULL)
+		VGZ_Destroy(&w->vgz_rx);
 
-	if (sp->wrk->vef_priv != NULL) {
-		vef = sp->wrk->vef_priv;
+	if (w->vef_priv != NULL) {
+		vef = w->vef_priv;
 		CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
-		sp->wrk->vef_priv = NULL;
-		VGZ_UpdateObj(vef->vgz, sp->obj);
+		w->vef_priv = NULL;
+		VGZ_UpdateObj(vef->vgz, w->fetch_obj);
 		VGZ_Destroy(&vef->vgz);
 		XXXAZ(vef->error);
 		FREE_OBJ(vef);
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index 08dd99c..1769d3a 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -58,15 +58,15 @@ static unsigned fetchfrag;
  * as seen on the socket, or zero if unknown.
  */
 static void __match_proto__()
-vfp_nop_begin(struct sess *sp, size_t estimate)
+vfp_nop_begin(struct worker *w, size_t estimate)
 {
 
 	if (fetchfrag > 0) {
 		estimate = fetchfrag;
-		WSP(sp, SLT_Debug, "Fetch %d byte segments:", fetchfrag);
+		WSLB(w, SLT_Debug, "Fetch %d byte segments:", fetchfrag);
 	}
 	if (estimate > 0)
-		(void)FetchStorage(sp->wrk, estimate);
+		(void)FetchStorage(w, estimate);
 }
 
 /*--------------------------------------------------------------------
@@ -80,13 +80,13 @@ vfp_nop_begin(struct sess *sp, size_t estimate)
  */
 
 static int __match_proto__()
-vfp_nop_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
+vfp_nop_bytes(struct worker *w, struct http_conn *htc, ssize_t bytes)
 {
-	ssize_t l, w;
+	ssize_t l, wl;
 	struct storage *st;
 
 	while (bytes > 0) {
-		st = FetchStorage(sp->wrk, 0);
+		st = FetchStorage(w, 0);
 		if (st == NULL) {
 			htc->error = "Could not get storage";
 			return (-1);
@@ -94,14 +94,14 @@ vfp_nop_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
 		l = st->space - st->len;
 		if (l > bytes)
 			l = bytes;
-		w = HTC_Read(htc, st->ptr + st->len, l);
-		if (w <= 0)
-			return (w);
-		st->len += w;
-		sp->obj->len += w;
-		bytes -= w;
-		if (sp->wrk->do_stream)
-			RES_StreamPoll(sp->wrk);
+		wl = HTC_Read(htc, st->ptr + st->len, l);
+		if (wl <= 0)
+			return (wl);
+		st->len += wl;
+		w->fetch_obj->len += wl;
+		bytes -= wl;
+		if (w->do_stream)
+			RES_StreamPoll(w);
 	}
 	return (1);
 }
@@ -116,16 +116,16 @@ vfp_nop_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
  */
 
 static int __match_proto__()
-vfp_nop_end(struct sess *sp)
+vfp_nop_end(struct worker *w)
 {
 	struct storage *st;
 
-	st = VTAILQ_LAST(&sp->obj->store, storagehead);
+	st = VTAILQ_LAST(&w->fetch_obj->store, storagehead);
 	if (st == NULL)
 		return (0);
 
 	if (st->len == 0) {
-		VTAILQ_REMOVE(&sp->obj->store, st, list);
+		VTAILQ_REMOVE(&w->fetch_obj->store, st, list);
 		STV_free(st);
 		return (0);
 	}
@@ -198,7 +198,7 @@ fetch_number(const char *nbr, int radix)
 /*--------------------------------------------------------------------*/
 
 static int
-fetch_straight(struct sess *sp, struct http_conn *htc, const char *b)
+fetch_straight(const struct sess *sp, struct http_conn *htc, const char *b)
 {
 	int i;
 	ssize_t cl;
@@ -206,14 +206,14 @@ fetch_straight(struct sess *sp, struct http_conn *htc, const char *b)
 	assert(sp->wrk->body_status == BS_LENGTH);
 
 	cl = fetch_number(b, 10);
-	sp->wrk->vfp->begin(sp, cl > 0 ? cl : 0);
+	sp->wrk->vfp->begin(sp->wrk, cl > 0 ? cl : 0);
 	if (cl < 0) {
 		WSP(sp, SLT_FetchError, "straight length field bogus");
 		return (-1);
 	} else if (cl == 0)
 		return (0);
 
-	i = sp->wrk->vfp->bytes(sp, htc, cl);
+	i = sp->wrk->vfp->bytes(sp->wrk, htc, cl);
 	if (i <= 0) {
 		WSP(sp, SLT_FetchError, "straight read_error: %d %d (%s)",
 		    i, errno, htc->error);
@@ -235,14 +235,14 @@ fetch_straight(struct sess *sp, struct http_conn *htc, const char *b)
 	} while (0)
 
 static int
-fetch_chunked(struct sess *sp, struct http_conn *htc)
+fetch_chunked(const struct sess *sp, struct http_conn *htc)
 {
 	int i;
 	char buf[20];		/* XXX: 20 is arbitrary */
 	unsigned u;
 	ssize_t cl;
 
-	sp->wrk->vfp->begin(sp, 0);
+	sp->wrk->vfp->begin(sp->wrk, 0);
 	assert(sp->wrk->body_status == BS_CHUNKED);
 	do {
 		/* Skip leading whitespace */
@@ -283,7 +283,7 @@ fetch_chunked(struct sess *sp, struct http_conn *htc)
 			WSP(sp, SLT_FetchError,	"chunked header nbr syntax");
 			return (-1);
 		} else if (cl > 0) {
-			i = sp->wrk->vfp->bytes(sp, htc, cl);
+			i = sp->wrk->vfp->bytes(sp->wrk, htc, cl);
 			CERR();
 		}
 		i = HTC_Read(htc, buf, 1);
@@ -305,13 +305,13 @@ fetch_chunked(struct sess *sp, struct http_conn *htc)
 /*--------------------------------------------------------------------*/
 
 static int
-fetch_eof(struct sess *sp, struct http_conn *htc)
+fetch_eof(const struct sess *sp, struct http_conn *htc)
 {
 	int i;
 
 	assert(sp->wrk->body_status == BS_EOF);
-	sp->wrk->vfp->begin(sp, 0);
-	i = sp->wrk->vfp->bytes(sp, htc, SSIZE_MAX);
+	sp->wrk->vfp->begin(sp->wrk, 0);
+	i = sp->wrk->vfp->bytes(sp->wrk, htc, SSIZE_MAX);
 	if (i < 0) {
 		WSP(sp, SLT_FetchError, "eof read_error: %d (%s)",
 		    errno, htc->error);
@@ -480,7 +480,7 @@ FetchHdr(struct sess *sp)
 /*--------------------------------------------------------------------*/
 
 int
-FetchBody(struct sess *sp, struct object *obj)
+FetchBody(const struct sess *sp, struct object *obj)
 {
 	int cls;
 	struct storage *st;
@@ -518,17 +518,17 @@ FetchBody(struct sess *sp, struct object *obj)
 		cls = fetch_straight(sp, w->htc,
 		    w->h_content_length);
 		mklen = 1;
-		XXXAZ(w->vfp->end(sp));
+		XXXAZ(w->vfp->end(sp->wrk));
 		break;
 	case BS_CHUNKED:
 		cls = fetch_chunked(sp, w->htc);
 		mklen = 1;
-		XXXAZ(w->vfp->end(sp));
+		XXXAZ(w->vfp->end(sp->wrk));
 		break;
 	case BS_EOF:
 		cls = fetch_eof(sp, w->htc);
 		mklen = 1;
-		XXXAZ(w->vfp->end(sp));
+		XXXAZ(w->vfp->end(sp->wrk));
 		break;
 	case BS_ERROR:
 		cls = 1;
@@ -546,7 +546,7 @@ FetchBody(struct sess *sp, struct object *obj)
 	 * sitting on w->storage, we will always call vfp_nop_end()
 	 * to get it trimmed or thrown out if empty.
 	 */
-	AZ(vfp_nop_end(sp));
+	AZ(vfp_nop_end(sp->wrk));
 
 	w->fetch_obj = NULL;
 
diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c
index 81c2475..541d30e 100644
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -71,6 +71,7 @@
 
 #include "cache.h"
 
+#include "cache_backend.h"	// for w->vbc
 #include "vgz.h"
 
 struct vgz {
@@ -434,24 +435,24 @@ VGZ_Destroy(struct vgz **vgp)
  */
 
 static void __match_proto__()
-vfp_gunzip_begin(struct sess *sp, size_t estimate)
+vfp_gunzip_begin(struct worker *w, size_t estimate)
 {
 	(void)estimate;
-	AZ(sp->wrk->vgz_rx);
-	sp->wrk->vgz_rx = VGZ_NewUngzip(sp->wrk, sp->vsl_id, "U F -");
+	AZ(w->vgz_rx);
+	w->vgz_rx = VGZ_NewUngzip(w, w->vbc->vsl_id, "U F -");
 }
 
 static int __match_proto__()
-vfp_gunzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
+vfp_gunzip_bytes(struct worker *w, struct http_conn *htc, ssize_t bytes)
 {
 	struct vgz *vg;
-	ssize_t l, w;
+	ssize_t l, wl;
 	int i = -100;
 	uint8_t	ibuf[params->gzip_stack_buffer];
 	size_t dl;
 	const void *dp;
 
-	vg = sp->wrk->vgz_rx;
+	vg = w->vgz_rx;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	AZ(vg->vz.avail_in);
 	while (bytes > 0 || vg->vz.avail_in > 0) {
@@ -459,37 +460,37 @@ vfp_gunzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
 			l = sizeof ibuf;
 			if (l > bytes)
 				l = bytes;
-			w = HTC_Read(htc, ibuf, l);
-			if (w <= 0)
-				return (w);
-			VGZ_Ibuf(vg, ibuf, w);
-			bytes -= w;
+			wl = HTC_Read(htc, ibuf, l);
+			if (wl <= 0)
+				return (wl);
+			VGZ_Ibuf(vg, ibuf, wl);
+			bytes -= wl;
 		}
 
-		if (VGZ_ObufStorage(sp->wrk, vg)) {
+		if (VGZ_ObufStorage(w, vg)) {
 			htc->error = "Could not get storage";
 			return (-1);
 		}
 		i = VGZ_Gunzip(vg, &dp, &dl);
 		assert(i == VGZ_OK || i == VGZ_END);
-		sp->obj->len += dl;
-		if (sp->wrk->do_stream)
-			RES_StreamPoll(sp->wrk);
+		w->fetch_obj->len += dl;
+		if (w->do_stream)
+			RES_StreamPoll(w);
 	}
 	if (i == Z_OK || i == Z_STREAM_END)
 		return (1);
 	htc->error = "See other message";
-	WSP(sp, SLT_FetchError, "Gunzip trouble (%d)", i);
+	WSLB(w, SLT_FetchError, "Gunzip trouble (%d)", i);
 	return (-1);
 }
 
 static int __match_proto__()
-vfp_gunzip_end(struct sess *sp)
+vfp_gunzip_end(struct worker *w)
 {
 	struct vgz *vg;
 
-	vg = sp->wrk->vgz_rx;
-	sp->wrk->vgz_rx = NULL;
+	vg = w->vgz_rx;
+	w->vgz_rx = NULL;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	VGZ_Destroy(&vg);
 	return (0);
@@ -509,25 +510,25 @@ struct vfp vfp_gunzip = {
  */
 
 static void __match_proto__()
-vfp_gzip_begin(struct sess *sp, size_t estimate)
+vfp_gzip_begin(struct worker *w, size_t estimate)
 {
 	(void)estimate;
 
-	AZ(sp->wrk->vgz_rx);
-	sp->wrk->vgz_rx = VGZ_NewGzip(sp->wrk, sp->vsl_id, "G F -");
+	AZ(w->vgz_rx);
+	w->vgz_rx = VGZ_NewGzip(w, w->vbc->vsl_id, "G F -");
 }
 
 static int __match_proto__()
-vfp_gzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
+vfp_gzip_bytes(struct worker *w, struct http_conn *htc, ssize_t bytes)
 {
 	struct vgz *vg;
-	ssize_t l, w;
+	ssize_t l, wl;
 	int i = -100;
 	uint8_t ibuf[params->gzip_stack_buffer];
 	size_t dl;
 	const void *dp;
 
-	vg = sp->wrk->vgz_rx;
+	vg = w->vgz_rx;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	AZ(vg->vz.avail_in);
 	while (bytes > 0 || !VGZ_IbufEmpty(vg)) {
@@ -535,46 +536,46 @@ vfp_gzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
 			l = sizeof ibuf;
 			if (l > bytes)
 				l = bytes;
-			w = HTC_Read(htc, ibuf, l);
-			if (w <= 0)
-				return (w);
-			VGZ_Ibuf(vg, ibuf, w);
-			bytes -= w;
+			wl = HTC_Read(htc, ibuf, l);
+			if (wl <= 0)
+				return (wl);
+			VGZ_Ibuf(vg, ibuf, wl);
+			bytes -= wl;
 		}
-		if (VGZ_ObufStorage(sp->wrk, vg)) {
+		if (VGZ_ObufStorage(w, vg)) {
 			htc->error = "Could not get storage";
 			return (-1);
 		}
 		i = VGZ_Gzip(vg, &dp, &dl, VGZ_NORMAL);
 		assert(i == Z_OK);
-		sp->obj->len += dl;
-		if (sp->wrk->do_stream)
-			RES_StreamPoll(sp->wrk);
+		w->fetch_obj->len += dl;
+		if (w->do_stream)
+			RES_StreamPoll(w);
 	}
 	return (1);
 }
 
 static int __match_proto__()
-vfp_gzip_end(struct sess *sp)
+vfp_gzip_end(struct worker *w)
 {
 	struct vgz *vg;
 	size_t dl;
 	const void *dp;
 	int i;
 
-	vg = sp->wrk->vgz_rx;
-	sp->wrk->vgz_rx = NULL;
+	vg = w->vgz_rx;
+	w->vgz_rx = NULL;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	do {
 		VGZ_Ibuf(vg, "", 0);
-		if (VGZ_ObufStorage(sp->wrk, vg))
+		if (VGZ_ObufStorage(w, vg))
 			return (-1);
 		i = VGZ_Gzip(vg, &dp, &dl, VGZ_FINISH);
-		sp->obj->len += dl;
+		w->fetch_obj->len += dl;
 	} while (i != Z_STREAM_END);
-	if (sp->wrk->do_stream)
-		RES_StreamPoll(sp->wrk);
-	VGZ_UpdateObj(vg, sp->obj);
+	if (w->do_stream)
+		RES_StreamPoll(w);
+	VGZ_UpdateObj(vg, w->fetch_obj);
 	VGZ_Destroy(&vg);
 	return (0);
 }
@@ -593,29 +594,29 @@ struct vfp vfp_gzip = {
  */
 
 static void __match_proto__()
-vfp_testgzip_begin(struct sess *sp, size_t estimate)
+vfp_testgzip_begin(struct worker *w, size_t estimate)
 {
 	(void)estimate;
-	sp->wrk->vgz_rx = VGZ_NewUngzip(sp->wrk, sp->vsl_id, "u F -");
-	CHECK_OBJ_NOTNULL(sp->wrk->vgz_rx, VGZ_MAGIC);
+	w->vgz_rx = VGZ_NewUngzip(w, w->vbc->vsl_id, "u F -");
+	CHECK_OBJ_NOTNULL(w->vgz_rx, VGZ_MAGIC);
 }
 
 static int __match_proto__()
-vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
+vfp_testgzip_bytes(struct worker *w, struct http_conn *htc, ssize_t bytes)
 {
 	struct vgz *vg;
-	ssize_t l, w;
+	ssize_t l, wl;
 	int i = -100;
 	uint8_t	obuf[params->gzip_stack_buffer];
 	size_t dl;
 	const void *dp;
 	struct storage *st;
 
-	vg = sp->wrk->vgz_rx;
+	vg = w->vgz_rx;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	AZ(vg->vz.avail_in);
 	while (bytes > 0) {
-		st = FetchStorage(sp->wrk, 0);
+		st = FetchStorage(w, 0);
 		if (st == NULL) {
 			htc->error = "Could not get storage";
 			return (-1);
@@ -623,15 +624,15 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
 		l = st->space - st->len;
 		if (l > bytes)
 			l = bytes;
-		w = HTC_Read(htc, st->ptr + st->len, l);
-		if (w <= 0)
-			return (w);
-		bytes -= w;
-		VGZ_Ibuf(vg, st->ptr + st->len, w);
-		st->len += w;
-		sp->obj->len += w;
-		if (sp->wrk->do_stream)
-			RES_StreamPoll(sp->wrk);
+		wl = HTC_Read(htc, st->ptr + st->len, l);
+		if (wl <= 0)
+			return (wl);
+		bytes -= wl;
+		VGZ_Ibuf(vg, st->ptr + st->len, wl);
+		st->len += wl;
+		w->fetch_obj->len += wl;
+		if (w->do_stream)
+			RES_StreamPoll(w);
 
 		while (!VGZ_IbufEmpty(vg)) {
 			VGZ_Obuf(vg, obuf, sizeof obuf);
@@ -642,7 +643,7 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
 			}
 			if (i != VGZ_OK && i != VGZ_END) {
 				htc->error = "See other message";
-				WSP(sp, SLT_FetchError,
+				WSLB(w, SLT_FetchError,
 				    "Invalid Gzip data: %s", vg->vz.msg);
 				return (-1);
 			}
@@ -651,19 +652,19 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
 	if (i == VGZ_OK || i == VGZ_END)
 		return (1);
 	htc->error = "See other message";
-	WSP(sp, SLT_FetchError, "Gunzip trouble (%d)", i);
+	WSLB(w, SLT_FetchError, "Gunzip trouble (%d)", i);
 	return (-1);
 }
 
 static int __match_proto__()
-vfp_testgzip_end(struct sess *sp)
+vfp_testgzip_end(struct worker *w)
 {
 	struct vgz *vg;
 
-	vg = sp->wrk->vgz_rx;
-	sp->wrk->vgz_rx = NULL;
+	vg = w->vgz_rx;
+	w->vgz_rx = NULL;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
-	VGZ_UpdateObj(vg, sp->obj);
+	VGZ_UpdateObj(vg, w->fetch_obj);
 	VGZ_Destroy(&vg);
 	return (0);
 }



More information about the varnish-commit mailing list