[master] 4133b27 Push sess out of the stream-polling operation.
Poul-Henning Kamp
phk at varnish-cache.org
Mon Oct 24 16:26:16 CEST 2011
commit 4133b274b11c980b302f4c79716b8083efaf3d83
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Oct 24 14:01:25 2011 +0000
Push sess out of the stream-polling operation.
diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index 298f820..08ba997 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -722,7 +722,7 @@ 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 *);
-int VGZ_WrwGunzip(const struct sess *, struct vgz *, const void *ibuf,
+int VGZ_WrwGunzip(struct worker *w, struct vgz *, const void *ibuf,
ssize_t ibufl, char *obuf, ssize_t obufl, ssize_t *obufp);
/* Return values */
@@ -898,7 +898,7 @@ void RES_BuildHttp(const struct sess *sp);
void RES_WriteObj(struct sess *sp);
void RES_StreamStart(struct sess *sp);
void RES_StreamEnd(struct sess *sp);
-void RES_StreamPoll(const struct sess *sp);
+void RES_StreamPoll(struct worker *);
/* cache_vary.c */
struct vsb *VRY_Create(const struct sess *sp, const struct http *hp);
diff --git a/bin/varnishd/cache_esi_deliver.c b/bin/varnishd/cache_esi_deliver.c
index aaf5f7a..c79da64 100644
--- a/bin/varnishd/cache_esi_deliver.c
+++ b/bin/varnishd/cache_esi_deliver.c
@@ -330,7 +330,7 @@ ESI_Deliver(struct sess *sp)
* response
*/
AN(vgz);
- i = VGZ_WrwGunzip(sp, vgz,
+ i = VGZ_WrwGunzip(sp->wrk, vgz,
st->ptr + off, l2,
obuf, sizeof obuf, &obufl);
if (WRW_Error(sp->wrk)) {
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index d71b2ec..08dd99c 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -101,7 +101,7 @@ vfp_nop_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
sp->obj->len += w;
bytes -= w;
if (sp->wrk->do_stream)
- RES_StreamPoll(sp);
+ RES_StreamPoll(sp->wrk);
}
return (1);
}
diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c
index 68dc04b..81c2475 100644
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -350,7 +350,7 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags)
*/
int
-VGZ_WrwGunzip(const struct sess *sp, struct vgz *vg, const void *ibuf,
+VGZ_WrwGunzip(struct worker *w, struct vgz *vg, const void *ibuf,
ssize_t ibufl, char *obuf, ssize_t obufl, ssize_t *obufp)
{
int i;
@@ -375,9 +375,9 @@ VGZ_WrwGunzip(const struct sess *sp, struct vgz *vg, const void *ibuf,
return (-1);
}
if (obufl == *obufp || i == VGZ_STUCK) {
- sp->wrk->acct_tmp.bodybytes += *obufp;
- (void)WRW_Write(sp->wrk, obuf, *obufp);
- (void)WRW_Flush(sp->wrk);
+ w->acct_tmp.bodybytes += *obufp;
+ (void)WRW_Write(w, obuf, *obufp);
+ (void)WRW_Flush(w);
*obufp = 0;
VGZ_Obuf(vg, obuf + *obufp, obufl - *obufp);
}
@@ -474,7 +474,7 @@ vfp_gunzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
assert(i == VGZ_OK || i == VGZ_END);
sp->obj->len += dl;
if (sp->wrk->do_stream)
- RES_StreamPoll(sp);
+ RES_StreamPoll(sp->wrk);
}
if (i == Z_OK || i == Z_STREAM_END)
return (1);
@@ -549,7 +549,7 @@ vfp_gzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
assert(i == Z_OK);
sp->obj->len += dl;
if (sp->wrk->do_stream)
- RES_StreamPoll(sp);
+ RES_StreamPoll(sp->wrk);
}
return (1);
}
@@ -573,7 +573,7 @@ vfp_gzip_end(struct sess *sp)
sp->obj->len += dl;
} while (i != Z_STREAM_END);
if (sp->wrk->do_stream)
- RES_StreamPoll(sp);
+ RES_StreamPoll(sp->wrk);
VGZ_UpdateObj(vg, sp->obj);
VGZ_Destroy(&vg);
return (0);
@@ -631,7 +631,7 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
st->len += w;
sp->obj->len += w;
if (sp->wrk->do_stream)
- RES_StreamPoll(sp);
+ RES_StreamPoll(sp->wrk);
while (!VGZ_IbufEmpty(vg)) {
VGZ_Obuf(vg, obuf, sizeof obuf);
diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c
index 5521bc0..ecc9839 100644
--- a/bin/varnishd/cache_response.c
+++ b/bin/varnishd/cache_response.c
@@ -172,7 +172,7 @@ res_WriteGunzipObj(const struct sess *sp)
VSC_C_main->n_objwrite++;
- i = VGZ_WrwGunzip(sp, vg,
+ i = VGZ_WrwGunzip(sp->wrk, vg,
st->ptr, st->len,
obuf, sizeof obuf, &obufl);
/* XXX: error check */
@@ -354,50 +354,52 @@ RES_StreamStart(struct sess *sp)
}
void
-RES_StreamPoll(const struct sess *sp)
+RES_StreamPoll(struct worker *w)
{
struct stream_ctx *sctx;
struct storage *st;
ssize_t l, l2;
void *ptr;
- sctx = sp->wrk->sctx;
+ CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
+ CHECK_OBJ_NOTNULL(w->fetch_obj, OBJECT_MAGIC);
+ sctx = w->sctx;
CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC);
- if (sp->obj->len == sctx->stream_next)
+ if (w->fetch_obj->len == sctx->stream_next)
return;
- assert(sp->obj->len > sctx->stream_next);
+ assert(w->fetch_obj->len > sctx->stream_next);
l = sctx->stream_front;
- VTAILQ_FOREACH(st, &sp->obj->store, list) {
+ VTAILQ_FOREACH(st, &w->fetch_obj->store, list) {
if (st->len + l <= sctx->stream_next) {
l += st->len;
continue;
}
l2 = st->len + l - sctx->stream_next;
ptr = st->ptr + (sctx->stream_next - l);
- if (sp->wrk->res_mode & RES_GUNZIP) {
- (void)VGZ_WrwGunzip(sp, sctx->vgz, ptr, l2,
+ if (w->res_mode & RES_GUNZIP) {
+ (void)VGZ_WrwGunzip(w, sctx->vgz, ptr, l2,
sctx->obuf, sctx->obuf_len, &sctx->obuf_ptr);
} else {
- (void)WRW_Write(sp->wrk, ptr, l2);
+ (void)WRW_Write(w, ptr, l2);
}
l += st->len;
sctx->stream_next += l2;
}
- if (!(sp->wrk->res_mode & RES_GUNZIP))
- (void)WRW_Flush(sp->wrk);
+ if (!(w->res_mode & RES_GUNZIP))
+ (void)WRW_Flush(w);
- if (sp->obj->objcore == NULL ||
- (sp->obj->objcore->flags & OC_F_PASS)) {
+ if (w->fetch_obj->objcore == NULL ||
+ (w->fetch_obj->objcore->flags & OC_F_PASS)) {
/*
* This is a pass object, release storage as soon as we
* have delivered it.
*/
while (1) {
- st = VTAILQ_FIRST(&sp->obj->store);
+ st = VTAILQ_FIRST(&w->fetch_obj->store);
if (st == NULL ||
sctx->stream_front + st->len > sctx->stream_next)
break;
- VTAILQ_REMOVE(&sp->obj->store, st, list);
+ VTAILQ_REMOVE(&w->fetch_obj->store, st, list);
sctx->stream_front += st->len;
STV_free(st);
}
More information about the varnish-commit
mailing list