[experimental-ims] bd9df97 The VGZ api does not need a worker, it just needs a vsl_log

Geoff Simmons geoff at varnish-cache.org
Fri Feb 17 13:58:53 CET 2012


commit bd9df9772158d3d7078243e211113551ecbcc292
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Feb 15 11:02:18 2012 +0000

    The VGZ api does not need a worker, it just needs a vsl_log

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 62b1202..a76cc45 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -768,8 +768,8 @@ void Fetch_Init(void);
 struct vgz;
 
 enum vgz_flag { VGZ_NORMAL, VGZ_ALIGN, VGZ_RESET, VGZ_FINISH };
-struct vgz *VGZ_NewUngzip(struct worker *wrk, const char *id);
-struct vgz *VGZ_NewGzip(struct worker *wrk, const char *id);
+struct vgz *VGZ_NewUngzip(struct vsl_log *vsl, const char *id);
+struct vgz *VGZ_NewGzip(struct vsl_log *vsl, 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);
@@ -777,7 +777,7 @@ int VGZ_ObufFull(const struct vgz *vg);
 int VGZ_ObufStorage(struct worker *w, struct vgz *vg);
 int VGZ_Gzip(struct vgz *, const void **, size_t *len, enum vgz_flag);
 int VGZ_Gunzip(struct vgz *, const void **, size_t *len);
-int VGZ_Destroy(struct vgz **, int vsl_id);
+int VGZ_Destroy(struct vgz **);
 void VGZ_UpdateObj(const struct vgz*, struct object *);
 
 int VGZ_WrwInit(struct vgz *vg);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 360a70f..54302c8 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -258,7 +258,7 @@ ESI_Deliver(struct sess *sp)
 	}
 
 	if (isgzip && !sp->req->gzip_resp) {
-		vgz = VGZ_NewUngzip(sp->wrk, "U D E");
+		vgz = VGZ_NewUngzip(sp->wrk->vsl, "U D E");
 		AZ(VGZ_WrwInit(vgz));
 
 		/* Feed a gzip header to gunzip to make it happy */
@@ -390,7 +390,7 @@ ESI_Deliver(struct sess *sp)
 	}
 	if (vgz != NULL) {
 		VGZ_WrwFlush(sp->wrk, vgz);
-		(void)VGZ_Destroy(&vgz, sp->vsl_id);
+		(void)VGZ_Destroy(&vgz);
 	}
 	if (sp->req->gzip_resp && sp->req->esi_level == 0) {
 		/* Emit a gzip literal block with finish bit set */
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index 45bfa86..c3ca15e 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -313,16 +313,16 @@ vfp_esi_begin(struct worker *wrk, size_t estimate)
 
 	AZ(bo->vgz_rx);
 	if (bo->is_gzip && bo->do_gunzip) {
-		bo->vgz_rx = VGZ_NewUngzip(wrk, "U F E");
+		bo->vgz_rx = VGZ_NewUngzip(wrk->vsl, "U F E");
 		VEP_Init(wrk, NULL);
 		vef->ibuf_sz = cache_param->gzip_buffer;
 	} else if (bo->is_gunzip && bo->do_gzip) {
-		vef->vgz = VGZ_NewGzip(wrk, "G F E");
+		vef->vgz = VGZ_NewGzip(wrk->vsl, "G F E");
 		VEP_Init(wrk, vfp_vep_callback);
 		vef->ibuf_sz = cache_param->gzip_buffer;
 	} else if (bo->is_gzip) {
-		bo->vgz_rx = VGZ_NewUngzip(wrk, "U F E");
-		vef->vgz = VGZ_NewGzip(wrk, "G F E");
+		bo->vgz_rx = VGZ_NewUngzip(wrk->vsl, "U F E");
+		vef->vgz = VGZ_NewGzip(wrk->vsl, "G F E");
 		VEP_Init(wrk, vfp_vep_callback);
 		vef->ibuf_sz = cache_param->gzip_buffer;
 		vef->ibuf2_sz = cache_param->gzip_buffer;
@@ -386,7 +386,7 @@ vfp_esi_end(struct worker *wrk)
 
 	retval = bo->fetch_failed;
 
-	if (bo->vgz_rx != NULL && VGZ_Destroy(&bo->vgz_rx, -1) != VGZ_END)
+	if (bo->vgz_rx != NULL && VGZ_Destroy(&bo->vgz_rx) != VGZ_END)
 		retval = FetchError(bo, "Gunzip+ESI Failed at the very end");
 
 	vsb = VEP_Finish(wrk);
@@ -414,7 +414,7 @@ vfp_esi_end(struct worker *wrk)
 	CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
 	if (vef->vgz != NULL) {
 		VGZ_UpdateObj(vef->vgz, bo->fetch_obj);
-		if (VGZ_Destroy(&vef->vgz,  -1) != VGZ_END)
+		if (VGZ_Destroy(&vef->vgz) != VGZ_END)
 			retval = FetchError(bo,
 			    "ESI+Gzip Failed at the very end");
 	}
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index c4eab44..38c323f 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -49,7 +49,7 @@ struct vgz {
 	unsigned		magic;
 #define VGZ_MAGIC		0x162df0cb
 	enum {VGZ_GZ,VGZ_UN}	dir;
-	struct worker		*wrk;
+	struct vsl_log		*vsl;
 	const char		*id;
 	struct ws		*tmp;
 	char			*tmp_snapshot;
@@ -70,25 +70,23 @@ struct vgz {
  */
 
 static struct vgz *
-vgz_alloc_vgz(struct worker *wrk, const char *id)
+vgz_alloc_vgz(struct vsl_log *vsl, const char *id)
 {
 	struct vgz *vg;
 
-	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	ALLOC_OBJ(vg, VGZ_MAGIC);
 	AN(vg);
-	vg->wrk = wrk;
+	vg->vsl = vsl;
 	vg->id = id;
 	return (vg);
 }
 
 struct vgz *
-VGZ_NewUngzip(struct worker *wrk, const char *id)
+VGZ_NewUngzip(struct vsl_log *vsl, const char *id)
 {
 	struct vgz *vg;
 
-	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	vg = vgz_alloc_vgz(wrk, id);
+	vg = vgz_alloc_vgz(vsl, id);
 	vg->dir = VGZ_UN;
 	VSC_C_main->n_gunzip++;
 
@@ -103,13 +101,12 @@ VGZ_NewUngzip(struct worker *wrk, const char *id)
 }
 
 struct vgz *
-VGZ_NewGzip(struct worker *wrk, const char *id)
+VGZ_NewGzip(struct vsl_log *vsl, const char *id)
 {
 	struct vgz *vg;
 	int i;
 
-	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	vg = vgz_alloc_vgz(wrk, id);
+	vg = vgz_alloc_vgz(vsl, id);
 	vg->dir = VGZ_GZ;
 	VSC_C_main->n_gzip++;
 
@@ -389,7 +386,7 @@ VGZ_UpdateObj(const struct vgz *vg, struct object *obj)
  */
 
 int
-VGZ_Destroy(struct vgz **vgp, int vsl_id)
+VGZ_Destroy(struct vgz **vgp)
 {
 	struct vgz *vg;
 	int i;
@@ -398,22 +395,13 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id)
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	*vgp = NULL;
 
-	if (vsl_id < 0)
-		VSLB(vg->wrk->busyobj, 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);
-	else
-		WSL(vg->wrk->vsl, SLT_Gzip, vsl_id, "%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);
+	WSL(vg->vsl, SLT_Gzip, -1, "%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);
 	if (vg->dir == VGZ_GZ)
@@ -447,7 +435,7 @@ vfp_gunzip_begin(struct worker *wrk, size_t estimate)
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
 	AZ(wrk->busyobj->vgz_rx);
-	wrk->busyobj->vgz_rx = VGZ_NewUngzip(wrk, "U F -");
+	wrk->busyobj->vgz_rx = VGZ_NewUngzip(wrk->vsl, "U F -");
 	XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx));
 }
 
@@ -502,10 +490,10 @@ vfp_gunzip_end(struct worker *wrk)
 	wrk->busyobj->vgz_rx = NULL;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	if (wrk->busyobj->fetch_failed) {
-		(void)VGZ_Destroy(&vg, -1);
+		(void)VGZ_Destroy(&vg);
 		return(0);
 	}
-	if (VGZ_Destroy(&vg, -1) != VGZ_END)
+	if (VGZ_Destroy(&vg) != VGZ_END)
 		return(FetchError(wrk->busyobj,
 		    "Gunzip error at the very end"));
 	return (0);
@@ -531,7 +519,7 @@ vfp_gzip_begin(struct worker *wrk, size_t estimate)
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
 	AZ(wrk->busyobj->vgz_rx);
-	wrk->busyobj->vgz_rx = VGZ_NewGzip(wrk, "G F -");
+	wrk->busyobj->vgz_rx = VGZ_NewGzip(wrk->vsl, "G F -");
 	XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx));
 }
 
@@ -586,7 +574,7 @@ vfp_gzip_end(struct worker *wrk)
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	wrk->busyobj->vgz_rx = NULL;
 	if (wrk->busyobj->fetch_failed) {
-		(void)VGZ_Destroy(&vg, -1);
+		(void)VGZ_Destroy(&vg);
 		return(0);
 	}
 	do {
@@ -599,7 +587,7 @@ vfp_gzip_end(struct worker *wrk)
 	if (wrk->busyobj->do_stream)
 		RES_StreamPoll(wrk);
 	VGZ_UpdateObj(vg, wrk->busyobj->fetch_obj);
-	if (VGZ_Destroy(&vg, -1) != VGZ_END)
+	if (VGZ_Destroy(&vg) != VGZ_END)
 		return(FetchError(wrk->busyobj, "Gzip error at the very end"));
 	return (0);
 }
@@ -623,7 +611,7 @@ vfp_testgzip_begin(struct worker *wrk, size_t estimate)
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
 	(void)estimate;
-	wrk->busyobj->vgz_rx = VGZ_NewUngzip(wrk, "u F -");
+	wrk->busyobj->vgz_rx = VGZ_NewUngzip(wrk->vsl, "u F -");
 	CHECK_OBJ_NOTNULL(wrk->busyobj->vgz_rx, VGZ_MAGIC);
 	XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx));
 }
@@ -687,11 +675,11 @@ vfp_testgzip_end(struct worker *wrk)
 	wrk->busyobj->vgz_rx = NULL;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	if (wrk->busyobj->fetch_failed) {
-		(void)VGZ_Destroy(&vg, -1);
+		(void)VGZ_Destroy(&vg);
 		return(0);
 	}
 	VGZ_UpdateObj(vg, wrk->busyobj->fetch_obj);
-	if (VGZ_Destroy(&vg, -1) != VGZ_END)
+	if (VGZ_Destroy(&vg) != VGZ_END)
 		return(FetchError(wrk->busyobj,
 		    "TestGunzip error at the very end"));
 	return (0);
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index 148a73c..125440b 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -160,7 +160,7 @@ res_WriteGunzipObj(const struct sess *sp)
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 
-	vg = VGZ_NewUngzip(sp->wrk, "U D -");
+	vg = VGZ_NewUngzip(sp->wrk->vsl, "U D -");
 	AZ(VGZ_WrwInit(vg));
 
 	VTAILQ_FOREACH(st, &sp->req->obj->store, list) {
@@ -175,7 +175,7 @@ res_WriteGunzipObj(const struct sess *sp)
 		(void)i;
 	}
 	VGZ_WrwFlush(sp->wrk, vg);
-	(void)VGZ_Destroy(&vg, sp->vsl_id);
+	(void)VGZ_Destroy(&vg);
 	assert(u == sp->req->obj->len);
 }
 
@@ -325,7 +325,7 @@ RES_StreamStart(struct sess *sp)
 	WRW_Reserve(sp->wrk, &sp->fd);
 
 	if (req->res_mode & RES_GUNZIP) {
-		req->stream_vgz = VGZ_NewUngzip(sp->wrk, "U S -");
+		req->stream_vgz = VGZ_NewUngzip(sp->wrk->vsl, "U S -");
 		AZ(VGZ_WrwInit(req->stream_vgz));
 		http_Unset(req->resp, H_Content_Encoding);
 	}
@@ -407,7 +407,7 @@ RES_StreamEnd(struct sess *sp)
 	if (req->res_mode & RES_GUNZIP) {
 		AN(req->stream_vgz);
 		VGZ_WrwFlush(sp->wrk, req->stream_vgz);
-		(void)VGZ_Destroy(&req->stream_vgz, sp->vsl_id);
+		(void)VGZ_Destroy(&req->stream_vgz);
 	}
 	if (req->res_mode & RES_CHUNKED && !(req->res_mode & RES_ESI_CHILD))
 		WRW_EndChunk(sp->wrk);



More information about the varnish-commit mailing list