[master] 349269f Centralize obj->gzipped setting and get it right up front.
Poul-Henning Kamp
phk at varnish-cache.org
Mon May 2 14:32:50 CEST 2011
commit 349269f15403ca5f616bd49677e3882126918c1f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon May 2 12:05:42 2011 +0000
Centralize obj->gzipped setting and get it right up front.
Edging closer to streap+gunzip
diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index 4383292..b42385f 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -264,12 +264,11 @@ struct stream_ctx {
unsigned magic;
#define STREAM_CTX_MAGIC 0x8213728b
-#if 0
struct vgz *vgz;
void *obuf;
ssize_t obuf_len;
ssize_t obuf_ptr;
-#endif
+
/* Next byte we will take from storage */
ssize_t stream_next;
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 36fe329..4514346 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -414,6 +414,7 @@ cnt_error(struct sess *sp)
EXP_Clr(&w->exp);
sp->obj = STV_NewObject(sp, NULL, 1024, &w->exp,
params->http_max_hdr);
+ XXXAN(sp->obj);
sp->obj->xid = sp->xid;
sp->obj->entered = sp->t_req;
} else {
@@ -754,8 +755,8 @@ cnt_fetchbody(struct sess *sp)
sp->wrk->storage_hint = NULL;
- /* VFP will update as needed */
- sp->obj->gziped = sp->wrk->is_gzip;
+ if (sp->wrk->do_gzip || (sp->wrk->is_gzip && !sp->wrk->do_gunzip))
+ sp->obj->gziped = 1;
if (vary != NULL) {
sp->obj->vary =
@@ -840,13 +841,20 @@ cnt_streambody(struct sess *sp)
{
int i;
struct stream_ctx sctx;
-
+ uint8_t obuf[sp->wrk->res_mode & RES_GUNZIP ?
+ params->gzip_stack_buffer : 1];
memset(&sctx, 0, sizeof sctx);
sctx.magic = STREAM_CTX_MAGIC;
AZ(sp->wrk->sctx);
sp->wrk->sctx = &sctx;
+ if (sp->wrk->res_mode & RES_GUNZIP) {
+ sctx.vgz = VGZ_NewUngzip(sp, "U S -");
+ sctx.obuf = obuf;
+ sctx.obuf_len = sizeof (obuf);
+ }
+
RES_StreamStart(sp);
/* Use unmodified headers*/
diff --git a/bin/varnishd/cache_esi_fetch.c b/bin/varnishd/cache_esi_fetch.c
index 9dbb501..58b3852 100644
--- a/bin/varnishd/cache_esi_fetch.c
+++ b/bin/varnishd/cache_esi_fetch.c
@@ -386,10 +386,7 @@ vfp_esi_end(struct sess *sp)
VGZ_UpdateObj(vef->vgz, sp->obj);
VGZ_Destroy(&vef->vgz);
XXXAZ(vef->error);
- sp->obj->gziped = 1;
FREE_OBJ(vef);
- } else {
- sp->obj->gziped = 0;
}
return (0);
}
diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c
index 0c29293..2239884 100644
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -491,7 +491,6 @@ vfp_gunzip_end(struct sess *sp)
sp->wrk->vgz_rx = NULL;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
VGZ_Destroy(&vg);
- sp->obj->gziped = 0;
return (0);
}
@@ -572,7 +571,6 @@ vfp_gzip_end(struct sess *sp)
} while (i != Z_STREAM_END);
VGZ_UpdateObj(vg, sp->obj);
VGZ_Destroy(&vg);
- sp->obj->gziped = 1;
return (0);
}
@@ -653,7 +651,6 @@ vfp_testgzip_end(struct sess *sp)
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
VGZ_UpdateObj(vg, sp->obj);
VGZ_Destroy(&vg);
- sp->obj->gziped = 1;
return (0);
}
More information about the varnish-commit
mailing list