[master] b8ceaaa Various polishing of the ESI deliver code.
Poul-Henning Kamp
phk at varnish-cache.org
Fri Apr 29 11:38:43 CEST 2011
commit b8ceaaa8bea843e378d4fe87851e6122c03754ab
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Apr 20 14:21:34 2011 +0000
Various polishing of the ESI deliver code.
diff --git a/bin/varnishd/cache_esi_deliver.c b/bin/varnishd/cache_esi_deliver.c
index c06679e..33ce9b8 100644
--- a/bin/varnishd/cache_esi_deliver.c
+++ b/bin/varnishd/cache_esi_deliver.c
@@ -253,7 +253,7 @@ ESI_Deliver(struct sess *sp)
if (isgzip && !(sp->wrk->res_mode & RES_GUNZIP)) {
assert(sizeof gzip_hdr == 10);
/* Send out the gzip header */
- WRW_Write(sp->wrk, gzip_hdr, 10);
+ (void)WRW_Write(sp->wrk, gzip_hdr, 10);
sp->wrk->l_crc = 0;
sp->wrk->gzip_resp = 1;
sp->wrk->crc = crc32(0L, Z_NULL, 0);
@@ -311,7 +311,7 @@ ESI_Deliver(struct sess *sp)
* We have a gzip'ed VEC and delivers
* a gzip'ed ESI response.
*/
- WRW_Write(sp->wrk, st->ptr + off, l2);
+ (void)WRW_Write(sp->wrk, st->ptr + off, l2);
} else if (sp->wrk->gzip_resp) {
/*
* A gzip'ed ESI response, but the VEC
@@ -338,7 +338,7 @@ ESI_Deliver(struct sess *sp)
/*
* Ungzip'ed VEC, ungzip'ed ESI response
*/
- WRW_Write(sp->wrk, st->ptr + off, l2);
+ (void)WRW_Write(sp->wrk, st->ptr + off, l2);
}
off += l2;
if (off == st->len) {
@@ -377,7 +377,7 @@ ESI_Deliver(struct sess *sp)
r = (void*)strchr((const char*)q, '\0');
AN(r);
if (obufl > 0) {
- WRW_Write(sp->wrk, obuf, obufl);
+ (void)WRW_Write(sp->wrk, obuf, obufl);
obufl = 0;
}
if (WRW_Flush(sp->wrk)) {
@@ -397,7 +397,7 @@ ESI_Deliver(struct sess *sp)
}
if (vgz != NULL) {
if (obufl > 0)
- WRW_Write(sp->wrk, obuf, obufl);
+ (void)WRW_Write(sp->wrk, obuf, obufl);
VGZ_Destroy(&vgz);
}
if (sp->wrk->gzip_resp && sp->esi_level == 0) {
@@ -414,7 +414,7 @@ ESI_Deliver(struct sess *sp)
/* MOD(2^32) length */
vle32enc(tailbuf + 9, sp->wrk->l_crc);
- WRW_Write(sp->wrk, tailbuf, 13);
+ (void)WRW_Write(sp->wrk, tailbuf, 13);
}
(void)WRW_Flush(sp->wrk);
}
@@ -454,7 +454,7 @@ ved_deliver_byterange(const struct sess *sp, ssize_t low, ssize_t high)
//printf("[2-] %jd %jd\n", lx, lx + l);
assert(lx >= low && lx + l <= high);
if (l != 0)
- WRW_Write(sp->wrk, p, l);
+ (void)WRW_Write(sp->wrk, p, l);
if (lx + st->len > high)
return(p[l]);
lx += st->len;
@@ -506,7 +506,7 @@ ESI_DeliverChild(const struct sess *sp)
*/
*dbits = ved_deliver_byterange(sp, start/8, last/8);
*dbits &= ~(1U << (last & 7));
- WRW_Write(sp->wrk, dbits, 1);
+ (void)WRW_Write(sp->wrk, dbits, 1);
cc = ved_deliver_byterange(sp, 1 + last/8, stop/8);
switch((int)(stop & 7)) {
case 0: /* xxxxxxxx */
@@ -550,7 +550,7 @@ ESI_DeliverChild(const struct sess *sp)
INCOMPL();
}
if (lpad > 0)
- WRW_Write(sp->wrk, dbits + 1, lpad);
+ (void)WRW_Write(sp->wrk, dbits + 1, lpad);
st = VTAILQ_LAST(&sp->obj->store, storagehead);
assert(st->len > 8);
diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c
index 60e296d..0c29293 100644
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -378,7 +378,7 @@ VGZ_WrwGunzip(struct sess *sp, struct vgz *vg, void *ibuf, ssize_t ibufl,
return (-1);
}
if (obufl == *obufp || i == VGZ_STUCK) {
- WRW_Write(sp->wrk, obuf, *obufp);
+ (void)WRW_Write(sp->wrk, obuf, *obufp);
if (WRW_Flush(sp->wrk))
return (VGZ_SOCKET);
*obufp = 0;
diff --git a/bin/varnishd/cache_wrw.c b/bin/varnishd/cache_wrw.c
index 10fe645..688a5a0 100644
--- a/bin/varnishd/cache_wrw.c
+++ b/bin/varnishd/cache_wrw.c
@@ -203,6 +203,13 @@ WRW_Chunked(struct worker *w)
assert(wrw->ciov < wrw->siov);
}
+/*
+ * XXX: It is not worth the complexity to attempt to get the
+ * XXX: end of chunk into the WRW_Flush(), because most of the time
+ * XXX: if not always, that is a no-op anyway, because the calling
+ * XXX: code already called WRW_Flush() to release local storage.
+ */
+
void
WRW_EndChunk(struct worker *w)
{
@@ -214,9 +221,9 @@ WRW_EndChunk(struct worker *w)
assert(wrw->ciov < wrw->siov);
(void)WRW_Flush(w);
wrw->ciov = wrw->siov;
- (void)WRW_Flush(w);
+ wrw->niov = 0;
wrw->cliov = 0;
- WRW_Write(w, "0\r\n\r\n", -1);
+ (void)WRW_Write(w, "0\r\n\r\n", -1);
}
More information about the varnish-commit
mailing list