[master] 01b6669 Record the positions of gzip start, last and stop bits in objects when we know them.

Poul-Henning Kamp phk at project.varnish-software.com
Sat Jan 22 17:53:24 CET 2011


commit 01b66692d2cb7b2be5e587afb3062ed86e0fb1f7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sat Jan 22 15:57:17 2011 +0000

    Record the positions of gzip start, last and stop bits in
    objects when we know them.
    
    For now: use malloc for gzip instead of running out of workspace.

diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index a2ed4cc..2779a00 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -433,6 +433,10 @@ struct object {
 	/* XXX: make bitmap */
 	unsigned		cacheable;
 	unsigned		gziped;
+	/* Bit positions in the gzip stream */
+	ssize_t			gzip_start;
+	ssize_t			gzip_last;
+	ssize_t			gzip_stop;
 
 	ssize_t			len;
 
@@ -643,6 +647,7 @@ int VGZ_ObufStorage(const struct sess *sp, 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);
 void VGZ_Destroy(struct vgz **);
+void VGZ_UpdateObj(const struct vgz*, struct object *);
 
 /* cache_http.c */
 unsigned HTTP_estimate(unsigned nhttp);
diff --git a/bin/varnishd/cache_esi_fetch.c b/bin/varnishd/cache_esi_fetch.c
index fe802f1..3e05d7c 100644
--- a/bin/varnishd/cache_esi_fetch.c
+++ b/bin/varnishd/cache_esi_fetch.c
@@ -270,6 +270,7 @@ vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
 			VGZ_Obuf(sp->wrk->vgz_rx, ibuf2, sizeof ibuf2);
 			i = VGZ_Gunzip(sp->wrk->vgz_rx, &dp, &dl);
 			/* XXX: check i */
+			assert(i >= 0);
 			vef->bufp = ibuf2;
 			if (dl > 0)
 				VEP_parse(sp, ibuf2, dl);
@@ -371,6 +372,7 @@ vfp_esi_end(struct sess *sp)
 
 	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);
 		XXXAZ(vef->error);
diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c
index 189b62e..6e929e9 100644
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -148,6 +148,11 @@ VGZ_NewUngzip(const struct sess *sp, struct ws *tmp)
 	 * Since we don't control windowBits, we have to assume
 	 * it is 15, so 34-35KB or so.
 	 */
+#if 1
+	vg->vz.zalloc = NULL;
+	vg->vz.zfree = NULL;
+	vg->vz.opaque = NULL;
+#endif
 	assert(Z_OK == inflateInit2(&vg->vz, 31));
 	return (vg);
 }
@@ -176,6 +181,11 @@ VGZ_NewGzip(const struct sess *sp, struct ws *tmp)
 	 * XXX: It may be more efficent to malloc them, rather than have
 	 * XXX: too many worker threads grow the stacks.
 	 */
+#if 1
+	vg->vz.zalloc = NULL;
+	vg->vz.zfree = NULL;
+	vg->vz.opaque = NULL;
+#endif
 	i = deflateInit2(&vg->vz,
 	    0,				/* Level */
 	    Z_DEFLATED,			/* Method */
@@ -271,6 +281,7 @@ VGZ_Gunzip(struct vgz *vg, const void **pptr, size_t *plen)
 		return (1);
 	if (i == Z_BUF_ERROR)
 		return (2);
+printf("INFLATE=%d\n", i);
 	return (-1);
 }
 
@@ -318,6 +329,18 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags)
 /*--------------------------------------------------------------------*/
 
 void
+VGZ_UpdateObj(const struct vgz *vg, struct object *obj)
+{
+
+	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
+	obj->gzip_start	= vg->vz.start_bit;
+	obj->gzip_last	= vg->vz.last_bit;
+	obj->gzip_stop	= vg->vz.stop_bit;
+}
+
+/*--------------------------------------------------------------------*/
+
+void
 VGZ_Destroy(struct vgz **vg)
 {
 
@@ -458,6 +481,7 @@ vfp_gzip_end(struct sess *sp)
 		i = VGZ_Gzip(vg, &dp, &dl, VGZ_FINISH);
 		sp->obj->len += dl;
 	} while (i != Z_STREAM_END);
+	VGZ_UpdateObj(vg, sp->obj);
 	VGZ_Destroy(&vg);
 	sp->obj->gziped = 1;
 	return (0);



More information about the varnish-commit mailing list