From lkarsten at varnish-cache.org Mon Feb 6 13:29:58 2012 From: lkarsten at varnish-cache.org (Lasse Karstensen) Date: Mon, 06 Feb 2012 14:29:58 +0100 Subject: [master] f3a85e9 typo Message-ID: commit f3a85e93e690dcac91636d7b9d14af29a233aaab Author: Lasse Karstensen Date: Mon Feb 6 14:29:39 2012 +0100 typo diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 82e53ef..203d76f 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -47,7 +47,7 @@ vcc_Type(enum var_type fmt) #include "tbl/vcc_types.h" #undef VCC_TYPE default: - assert("Unknwon Type"); + assert("Unknown Type"); return(NULL); } } From phk at varnish-cache.org Tue Feb 7 08:49:04 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 07 Feb 2012 09:49:04 +0100 Subject: [master] 512dddc Hindsight is always so glaring sharp... Message-ID: commit 512dddc60ace8c4eaacfde351dfa06756fb32d8d Author: Poul-Henning Kamp Date: Tue Feb 7 08:47:05 2012 +0000 Hindsight is always so glaring sharp... It was a mistake to put the gunzip delivery buffers on the worker stack, given that only a minority of clients (mostly spiders and robots) don't grok "Content-Encoding: gzip". Move them to malloc space. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ad4f426..b89ef23 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -262,9 +262,6 @@ struct stream_ctx { #define STREAM_CTX_MAGIC 0x8213728b struct vgz *vgz; - void *obuf; - ssize_t obuf_len; - ssize_t obuf_ptr; /* Next byte we will take from storage */ ssize_t stream_next; @@ -786,8 +783,12 @@ 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); void VGZ_UpdateObj(const struct vgz*, struct object *); + +int VGZ_WrwInit(struct vgz *vg); int VGZ_WrwGunzip(struct worker *w, struct vgz *, const void *ibuf, - ssize_t ibufl, char *obuf, ssize_t obufl, ssize_t *obufp); + ssize_t ibufl); +void VGZ_WrwFlush(struct worker *wrk, struct vgz *vg); +void VGZ_WrwFinish(struct worker *wrk, struct vgz *vg); /* Return values */ #define VGZ_ERROR -1 diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index c933175..a8148b5 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -941,8 +941,6 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) { int i; struct stream_ctx sctx; - uint8_t obuf[sp->wrk->res_mode & RES_GUNZIP ? - cache_param->gzip_stack_buffer : 1]; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -954,12 +952,6 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) AZ(wrk->sctx); wrk->sctx = &sctx; - if (wrk->res_mode & RES_GUNZIP) { - sctx.vgz = VGZ_NewUngzip(wrk, "U S -"); - sctx.obuf = obuf; - sctx.obuf_len = sizeof (obuf); - } - RES_StreamStart(sp); AssertObjCorePassOrBusy(req->obj->objcore); @@ -985,8 +977,6 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) req->restarts = 0; RES_StreamEnd(sp); - if (wrk->res_mode & RES_GUNZIP) - (void)VGZ_Destroy(&sctx.vgz, sp->vsl_id); wrk->sctx = NULL; assert(WRW_IsReleased(wrk)); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index a7e80cd..0175c3d 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -224,8 +224,6 @@ ESI_Deliver(struct sess *sp) uint8_t tailbuf[8 + 5]; int isgzip; struct vgz *vgz = NULL; - char obuf[cache_param->gzip_stack_buffer]; - ssize_t obufl = 0; size_t dl; const void *dp; int i; @@ -233,9 +231,6 @@ ESI_Deliver(struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); st = sp->req->obj->esidata; AN(st); - assert(sizeof obuf >= 1024); - - obuf[0] = 0; /* For flexelint */ p = st->ptr; e = st->ptr + st->len; @@ -264,16 +259,14 @@ ESI_Deliver(struct sess *sp) if (isgzip && !sp->req->gzip_resp) { vgz = VGZ_NewUngzip(sp->wrk, "U D E"); + AZ(VGZ_WrwInit(vgz)); /* Feed a gzip header to gunzip to make it happy */ VGZ_Ibuf(vgz, gzip_hdr, sizeof gzip_hdr); - VGZ_Obuf(vgz, obuf, sizeof obuf); i = VGZ_Gunzip(vgz, &dp, &dl); assert(i == VGZ_OK); assert(VGZ_IbufEmpty(vgz)); assert(dl == 0); - - obufl = 0; } st = VTAILQ_FIRST(&sp->req->obj->store); @@ -328,8 +321,7 @@ ESI_Deliver(struct sess *sp) */ AN(vgz); i = VGZ_WrwGunzip(sp->wrk, vgz, - st->ptr + off, l2, - obuf, sizeof obuf, &obufl); + st->ptr + off, l2); if (WRW_Error(sp->wrk)) { SES_Close(sp, "remote closed"); p = e; @@ -379,10 +371,8 @@ ESI_Deliver(struct sess *sp) q++; r = (void*)strchr((const char*)q, '\0'); AN(r); - if (obufl > 0) { - (void)WRW_Write(sp->wrk, obuf, obufl); - obufl = 0; - } + if (vgz != NULL) + VGZ_WrwFlush(sp->wrk, vgz); if (WRW_Flush(sp->wrk)) { SES_Close(sp, "remote closed"); p = e; @@ -399,8 +389,7 @@ ESI_Deliver(struct sess *sp) } } if (vgz != NULL) { - if (obufl > 0) - (void)WRW_Write(sp->wrk, obuf, obufl); + VGZ_WrwFinish(sp->wrk, vgz); (void)VGZ_Destroy(&vgz, sp->vsl_id); } if (sp->req->gzip_resp && sp->req->esi_level == 0) { diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 1b732ca..63a18cd 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -83,7 +83,12 @@ struct vgz { char *tmp_snapshot; int last_i; - struct storage *obuf; + struct storage *st_obuf; + + /* Wrw stuff */ + char *wrw_buf; + ssize_t wrw_sz; + ssize_t wrw_len; z_stream vz; }; @@ -260,7 +265,7 @@ VGZ_ObufStorage(struct worker *wrk, struct vgz *vg) if (st == NULL) return (-1); - vg->obuf = st; + vg->st_obuf = st; VGZ_Obuf(vg, st->ptr + st->len, st->space - st->len); return (0); @@ -287,8 +292,8 @@ VGZ_Gunzip(struct vgz *vg, const void **pptr, size_t *plen) *pptr = before; l = (const uint8_t *)vg->vz.next_out - before; *plen = l; - if (vg->obuf != NULL) - vg->obuf->len += l; + if (vg->st_obuf != NULL) + vg->st_obuf->len += l; } vg->last_i = i; if (i == Z_OK) @@ -330,8 +335,8 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags) *pptr = before; l = (const uint8_t *)vg->vz.next_out - before; *plen = l; - if (vg->obuf != NULL) - vg->obuf->len += l; + if (vg->st_obuf != NULL) + vg->st_obuf->len += l; } vg->last_i = i; if (i == Z_OK) @@ -344,41 +349,63 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags) } /*-------------------------------------------------------------------- + */ + +int +VGZ_WrwInit(struct vgz *vg) +{ + + CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); + AZ(vg->wrw_sz); + AZ(vg->wrw_len); + AZ(vg->wrw_buf); + + vg->wrw_sz = cache_param->gzip_stack_buffer; + vg->wrw_buf = malloc(vg->wrw_sz); + if (vg->wrw_buf == NULL) { + vg->wrw_sz = 0; + return (-1); + } + VGZ_Obuf(vg, vg->wrw_buf, vg->wrw_sz); + return (0); +} + +/*-------------------------------------------------------------------- * Gunzip ibuf into outb, if it runs full, emit it with WRW. * Leave flushing to caller, more data may be coming. */ int VGZ_WrwGunzip(struct worker *wrk, struct vgz *vg, const void *ibuf, - ssize_t ibufl, char *obuf, ssize_t obufl, ssize_t *obufp) + ssize_t ibufl) { int i; size_t dl; const void *dp; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - assert(obufl > 16); + AN(vg->wrw_buf); VGZ_Ibuf(vg, ibuf, ibufl); if (ibufl == 0) return (VGZ_OK); - VGZ_Obuf(vg, obuf + *obufp, obufl - *obufp); do { - if (obufl == *obufp) + if (vg->wrw_len == vg->wrw_sz) i = VGZ_STUCK; else { i = VGZ_Gunzip(vg, &dp, &dl); - *obufp += dl; + vg->wrw_len += dl; } if (i < VGZ_OK) { /* XXX: VSL ? */ return (-1); } - if (obufl == *obufp || i == VGZ_STUCK) { - wrk->acct_tmp.bodybytes += *obufp; - (void)WRW_Write(wrk, obuf, *obufp); + if (vg->wrw_len == vg->wrw_sz || i == VGZ_STUCK) { + wrk->acct_tmp.bodybytes += vg->wrw_len; + (void)WRW_Write(wrk, vg->wrw_buf, vg->wrw_len); (void)WRW_Flush(wrk); - *obufp = 0; - VGZ_Obuf(vg, obuf + *obufp, obufl - *obufp); + vg->wrw_len = 0; + VGZ_Obuf(vg, vg->wrw_buf, vg->wrw_sz); } } while (!VGZ_IbufEmpty(vg)); if (i == VGZ_STUCK) @@ -389,6 +416,35 @@ VGZ_WrwGunzip(struct worker *wrk, struct vgz *vg, const void *ibuf, /*--------------------------------------------------------------------*/ void +VGZ_WrwFlush(struct worker *wrk, struct vgz *vg) +{ + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); + + if (vg->wrw_len == 0) + return; + (void)WRW_Write(wrk, vg->wrw_buf, vg->wrw_len); + (void)WRW_Flush(wrk); + vg->wrw_len = 0; +} + +/*--------------------------------------------------------------------*/ + +void +VGZ_WrwFinish(struct worker *wrk, struct vgz *vg) +{ + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); + + VGZ_WrwFlush(wrk, vg); + free(vg->wrw_buf); + vg->wrw_buf = 0; + vg->wrw_sz = 0; +} + +/*--------------------------------------------------------------------*/ + +void VGZ_UpdateObj(const struct vgz *vg, struct object *obj) { @@ -412,6 +468,7 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id) vg = *vgp; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); *vgp = NULL; + AZ(vg->wrw_buf); if (vsl_id < 0) WSLB(vg->wrk, SLT_Gzip, "%s %jd %jd %jd %jd %jd", diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 5724f07..6206c18 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -161,15 +161,13 @@ res_WriteGunzipObj(const struct sess *sp) struct storage *st; unsigned u = 0; struct vgz *vg; - char obuf[cache_param->gzip_stack_buffer]; - ssize_t obufl = 0; int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); vg = VGZ_NewUngzip(sp->wrk, "U D -"); + AZ(VGZ_WrwInit(vg)); - VGZ_Obuf(vg, obuf, sizeof obuf); VTAILQ_FOREACH(st, &sp->req->obj->store, list) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); @@ -177,16 +175,11 @@ res_WriteGunzipObj(const struct sess *sp) VSC_C_main->n_objwrite++; - i = VGZ_WrwGunzip(sp->wrk, vg, - st->ptr, st->len, - obuf, sizeof obuf, &obufl); + i = VGZ_WrwGunzip(sp->wrk, vg, st->ptr, st->len); /* XXX: error check */ (void)i; } - if (obufl) { - (void)WRW_Write(sp->wrk, obuf, obufl); - (void)WRW_Flush(sp->wrk); - } + VGZ_WrwFinish(sp->wrk, vg); (void)VGZ_Destroy(&vg, sp->vsl_id); assert(u == sp->req->obj->len); } @@ -346,11 +339,12 @@ RES_StreamStart(struct sess *sp) AN(sp->req->wantbody); WRW_Reserve(sp->wrk, &sp->fd); - /* - * Always remove C-E if client don't grok it - */ - if (sp->wrk->res_mode & RES_GUNZIP) + + if (sp->wrk->res_mode & RES_GUNZIP) { + sctx->vgz = VGZ_NewUngzip(sp->wrk, "U S -"); + AZ(VGZ_WrwInit(sctx->vgz)); http_Unset(sp->req->resp, H_Content_Encoding); + } if (!(sp->wrk->res_mode & RES_CHUNKED) && sp->wrk->busyobj->h_content_length != NULL) @@ -388,8 +382,7 @@ RES_StreamPoll(struct worker *wrk) l2 = st->len + l - sctx->stream_next; ptr = st->ptr + (sctx->stream_next - l); if (wrk->res_mode & RES_GUNZIP) { - (void)VGZ_WrwGunzip(wrk, sctx->vgz, ptr, l2, - sctx->obuf, sctx->obuf_len, &sctx->obuf_ptr); + (void)VGZ_WrwGunzip(wrk, sctx->vgz, ptr, l2); } else { (void)WRW_Write(wrk, ptr, l2); } @@ -425,8 +418,11 @@ RES_StreamEnd(struct sess *sp) sctx = sp->wrk->sctx; CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); - if (sp->wrk->res_mode & RES_GUNZIP && sctx->obuf_ptr > 0) - (void)WRW_Write(sp->wrk, sctx->obuf, sctx->obuf_ptr); + if (sp->wrk->res_mode & RES_GUNZIP) { + AN(sctx->vgz); + VGZ_WrwFinish(sp->wrk, sctx->vgz); + (void)VGZ_Destroy(&sctx->vgz, sp->vsl_id); + } if (sp->wrk->res_mode & RES_CHUNKED && !(sp->wrk->res_mode & RES_ESI_CHILD)) WRW_EndChunk(sp->wrk); From geoff at varnish-cache.org Tue Feb 7 09:13:13 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 07 Feb 2012 10:13:13 +0100 Subject: [experimental-ims] f3a85e9 typo Message-ID: commit f3a85e93e690dcac91636d7b9d14af29a233aaab Author: Lasse Karstensen Date: Mon Feb 6 14:29:39 2012 +0100 typo diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 82e53ef..203d76f 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -47,7 +47,7 @@ vcc_Type(enum var_type fmt) #include "tbl/vcc_types.h" #undef VCC_TYPE default: - assert("Unknwon Type"); + assert("Unknown Type"); return(NULL); } } From geoff at varnish-cache.org Tue Feb 7 09:13:14 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 07 Feb 2012 10:13:14 +0100 Subject: [experimental-ims] 99f0d07 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache into experimental-ims Message-ID: commit 99f0d076f5e61413ed809060e2941a1e2024f389 Merge: 1f8cdd7 512dddc Author: Geoff Simmons Date: Tue Feb 7 10:07:07 2012 +0100 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache into experimental-ims From geoff at varnish-cache.org Tue Feb 7 09:13:13 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 07 Feb 2012 10:13:13 +0100 Subject: [experimental-ims] 512dddc Hindsight is always so glaring sharp... Message-ID: commit 512dddc60ace8c4eaacfde351dfa06756fb32d8d Author: Poul-Henning Kamp Date: Tue Feb 7 08:47:05 2012 +0000 Hindsight is always so glaring sharp... It was a mistake to put the gunzip delivery buffers on the worker stack, given that only a minority of clients (mostly spiders and robots) don't grok "Content-Encoding: gzip". Move them to malloc space. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ad4f426..b89ef23 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -262,9 +262,6 @@ struct stream_ctx { #define STREAM_CTX_MAGIC 0x8213728b struct vgz *vgz; - void *obuf; - ssize_t obuf_len; - ssize_t obuf_ptr; /* Next byte we will take from storage */ ssize_t stream_next; @@ -786,8 +783,12 @@ 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); void VGZ_UpdateObj(const struct vgz*, struct object *); + +int VGZ_WrwInit(struct vgz *vg); int VGZ_WrwGunzip(struct worker *w, struct vgz *, const void *ibuf, - ssize_t ibufl, char *obuf, ssize_t obufl, ssize_t *obufp); + ssize_t ibufl); +void VGZ_WrwFlush(struct worker *wrk, struct vgz *vg); +void VGZ_WrwFinish(struct worker *wrk, struct vgz *vg); /* Return values */ #define VGZ_ERROR -1 diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index c933175..a8148b5 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -941,8 +941,6 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) { int i; struct stream_ctx sctx; - uint8_t obuf[sp->wrk->res_mode & RES_GUNZIP ? - cache_param->gzip_stack_buffer : 1]; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -954,12 +952,6 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) AZ(wrk->sctx); wrk->sctx = &sctx; - if (wrk->res_mode & RES_GUNZIP) { - sctx.vgz = VGZ_NewUngzip(wrk, "U S -"); - sctx.obuf = obuf; - sctx.obuf_len = sizeof (obuf); - } - RES_StreamStart(sp); AssertObjCorePassOrBusy(req->obj->objcore); @@ -985,8 +977,6 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) req->restarts = 0; RES_StreamEnd(sp); - if (wrk->res_mode & RES_GUNZIP) - (void)VGZ_Destroy(&sctx.vgz, sp->vsl_id); wrk->sctx = NULL; assert(WRW_IsReleased(wrk)); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index a7e80cd..0175c3d 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -224,8 +224,6 @@ ESI_Deliver(struct sess *sp) uint8_t tailbuf[8 + 5]; int isgzip; struct vgz *vgz = NULL; - char obuf[cache_param->gzip_stack_buffer]; - ssize_t obufl = 0; size_t dl; const void *dp; int i; @@ -233,9 +231,6 @@ ESI_Deliver(struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); st = sp->req->obj->esidata; AN(st); - assert(sizeof obuf >= 1024); - - obuf[0] = 0; /* For flexelint */ p = st->ptr; e = st->ptr + st->len; @@ -264,16 +259,14 @@ ESI_Deliver(struct sess *sp) if (isgzip && !sp->req->gzip_resp) { vgz = VGZ_NewUngzip(sp->wrk, "U D E"); + AZ(VGZ_WrwInit(vgz)); /* Feed a gzip header to gunzip to make it happy */ VGZ_Ibuf(vgz, gzip_hdr, sizeof gzip_hdr); - VGZ_Obuf(vgz, obuf, sizeof obuf); i = VGZ_Gunzip(vgz, &dp, &dl); assert(i == VGZ_OK); assert(VGZ_IbufEmpty(vgz)); assert(dl == 0); - - obufl = 0; } st = VTAILQ_FIRST(&sp->req->obj->store); @@ -328,8 +321,7 @@ ESI_Deliver(struct sess *sp) */ AN(vgz); i = VGZ_WrwGunzip(sp->wrk, vgz, - st->ptr + off, l2, - obuf, sizeof obuf, &obufl); + st->ptr + off, l2); if (WRW_Error(sp->wrk)) { SES_Close(sp, "remote closed"); p = e; @@ -379,10 +371,8 @@ ESI_Deliver(struct sess *sp) q++; r = (void*)strchr((const char*)q, '\0'); AN(r); - if (obufl > 0) { - (void)WRW_Write(sp->wrk, obuf, obufl); - obufl = 0; - } + if (vgz != NULL) + VGZ_WrwFlush(sp->wrk, vgz); if (WRW_Flush(sp->wrk)) { SES_Close(sp, "remote closed"); p = e; @@ -399,8 +389,7 @@ ESI_Deliver(struct sess *sp) } } if (vgz != NULL) { - if (obufl > 0) - (void)WRW_Write(sp->wrk, obuf, obufl); + VGZ_WrwFinish(sp->wrk, vgz); (void)VGZ_Destroy(&vgz, sp->vsl_id); } if (sp->req->gzip_resp && sp->req->esi_level == 0) { diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 1b732ca..63a18cd 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -83,7 +83,12 @@ struct vgz { char *tmp_snapshot; int last_i; - struct storage *obuf; + struct storage *st_obuf; + + /* Wrw stuff */ + char *wrw_buf; + ssize_t wrw_sz; + ssize_t wrw_len; z_stream vz; }; @@ -260,7 +265,7 @@ VGZ_ObufStorage(struct worker *wrk, struct vgz *vg) if (st == NULL) return (-1); - vg->obuf = st; + vg->st_obuf = st; VGZ_Obuf(vg, st->ptr + st->len, st->space - st->len); return (0); @@ -287,8 +292,8 @@ VGZ_Gunzip(struct vgz *vg, const void **pptr, size_t *plen) *pptr = before; l = (const uint8_t *)vg->vz.next_out - before; *plen = l; - if (vg->obuf != NULL) - vg->obuf->len += l; + if (vg->st_obuf != NULL) + vg->st_obuf->len += l; } vg->last_i = i; if (i == Z_OK) @@ -330,8 +335,8 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags) *pptr = before; l = (const uint8_t *)vg->vz.next_out - before; *plen = l; - if (vg->obuf != NULL) - vg->obuf->len += l; + if (vg->st_obuf != NULL) + vg->st_obuf->len += l; } vg->last_i = i; if (i == Z_OK) @@ -344,41 +349,63 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags) } /*-------------------------------------------------------------------- + */ + +int +VGZ_WrwInit(struct vgz *vg) +{ + + CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); + AZ(vg->wrw_sz); + AZ(vg->wrw_len); + AZ(vg->wrw_buf); + + vg->wrw_sz = cache_param->gzip_stack_buffer; + vg->wrw_buf = malloc(vg->wrw_sz); + if (vg->wrw_buf == NULL) { + vg->wrw_sz = 0; + return (-1); + } + VGZ_Obuf(vg, vg->wrw_buf, vg->wrw_sz); + return (0); +} + +/*-------------------------------------------------------------------- * Gunzip ibuf into outb, if it runs full, emit it with WRW. * Leave flushing to caller, more data may be coming. */ int VGZ_WrwGunzip(struct worker *wrk, struct vgz *vg, const void *ibuf, - ssize_t ibufl, char *obuf, ssize_t obufl, ssize_t *obufp) + ssize_t ibufl) { int i; size_t dl; const void *dp; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - assert(obufl > 16); + AN(vg->wrw_buf); VGZ_Ibuf(vg, ibuf, ibufl); if (ibufl == 0) return (VGZ_OK); - VGZ_Obuf(vg, obuf + *obufp, obufl - *obufp); do { - if (obufl == *obufp) + if (vg->wrw_len == vg->wrw_sz) i = VGZ_STUCK; else { i = VGZ_Gunzip(vg, &dp, &dl); - *obufp += dl; + vg->wrw_len += dl; } if (i < VGZ_OK) { /* XXX: VSL ? */ return (-1); } - if (obufl == *obufp || i == VGZ_STUCK) { - wrk->acct_tmp.bodybytes += *obufp; - (void)WRW_Write(wrk, obuf, *obufp); + if (vg->wrw_len == vg->wrw_sz || i == VGZ_STUCK) { + wrk->acct_tmp.bodybytes += vg->wrw_len; + (void)WRW_Write(wrk, vg->wrw_buf, vg->wrw_len); (void)WRW_Flush(wrk); - *obufp = 0; - VGZ_Obuf(vg, obuf + *obufp, obufl - *obufp); + vg->wrw_len = 0; + VGZ_Obuf(vg, vg->wrw_buf, vg->wrw_sz); } } while (!VGZ_IbufEmpty(vg)); if (i == VGZ_STUCK) @@ -389,6 +416,35 @@ VGZ_WrwGunzip(struct worker *wrk, struct vgz *vg, const void *ibuf, /*--------------------------------------------------------------------*/ void +VGZ_WrwFlush(struct worker *wrk, struct vgz *vg) +{ + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); + + if (vg->wrw_len == 0) + return; + (void)WRW_Write(wrk, vg->wrw_buf, vg->wrw_len); + (void)WRW_Flush(wrk); + vg->wrw_len = 0; +} + +/*--------------------------------------------------------------------*/ + +void +VGZ_WrwFinish(struct worker *wrk, struct vgz *vg) +{ + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); + + VGZ_WrwFlush(wrk, vg); + free(vg->wrw_buf); + vg->wrw_buf = 0; + vg->wrw_sz = 0; +} + +/*--------------------------------------------------------------------*/ + +void VGZ_UpdateObj(const struct vgz *vg, struct object *obj) { @@ -412,6 +468,7 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id) vg = *vgp; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); *vgp = NULL; + AZ(vg->wrw_buf); if (vsl_id < 0) WSLB(vg->wrk, SLT_Gzip, "%s %jd %jd %jd %jd %jd", diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 5724f07..6206c18 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -161,15 +161,13 @@ res_WriteGunzipObj(const struct sess *sp) struct storage *st; unsigned u = 0; struct vgz *vg; - char obuf[cache_param->gzip_stack_buffer]; - ssize_t obufl = 0; int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); vg = VGZ_NewUngzip(sp->wrk, "U D -"); + AZ(VGZ_WrwInit(vg)); - VGZ_Obuf(vg, obuf, sizeof obuf); VTAILQ_FOREACH(st, &sp->req->obj->store, list) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); @@ -177,16 +175,11 @@ res_WriteGunzipObj(const struct sess *sp) VSC_C_main->n_objwrite++; - i = VGZ_WrwGunzip(sp->wrk, vg, - st->ptr, st->len, - obuf, sizeof obuf, &obufl); + i = VGZ_WrwGunzip(sp->wrk, vg, st->ptr, st->len); /* XXX: error check */ (void)i; } - if (obufl) { - (void)WRW_Write(sp->wrk, obuf, obufl); - (void)WRW_Flush(sp->wrk); - } + VGZ_WrwFinish(sp->wrk, vg); (void)VGZ_Destroy(&vg, sp->vsl_id); assert(u == sp->req->obj->len); } @@ -346,11 +339,12 @@ RES_StreamStart(struct sess *sp) AN(sp->req->wantbody); WRW_Reserve(sp->wrk, &sp->fd); - /* - * Always remove C-E if client don't grok it - */ - if (sp->wrk->res_mode & RES_GUNZIP) + + if (sp->wrk->res_mode & RES_GUNZIP) { + sctx->vgz = VGZ_NewUngzip(sp->wrk, "U S -"); + AZ(VGZ_WrwInit(sctx->vgz)); http_Unset(sp->req->resp, H_Content_Encoding); + } if (!(sp->wrk->res_mode & RES_CHUNKED) && sp->wrk->busyobj->h_content_length != NULL) @@ -388,8 +382,7 @@ RES_StreamPoll(struct worker *wrk) l2 = st->len + l - sctx->stream_next; ptr = st->ptr + (sctx->stream_next - l); if (wrk->res_mode & RES_GUNZIP) { - (void)VGZ_WrwGunzip(wrk, sctx->vgz, ptr, l2, - sctx->obuf, sctx->obuf_len, &sctx->obuf_ptr); + (void)VGZ_WrwGunzip(wrk, sctx->vgz, ptr, l2); } else { (void)WRW_Write(wrk, ptr, l2); } @@ -425,8 +418,11 @@ RES_StreamEnd(struct sess *sp) sctx = sp->wrk->sctx; CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); - if (sp->wrk->res_mode & RES_GUNZIP && sctx->obuf_ptr > 0) - (void)WRW_Write(sp->wrk, sctx->obuf, sctx->obuf_ptr); + if (sp->wrk->res_mode & RES_GUNZIP) { + AN(sctx->vgz); + VGZ_WrwFinish(sp->wrk, sctx->vgz); + (void)VGZ_Destroy(&sctx->vgz, sp->vsl_id); + } if (sp->wrk->res_mode & RES_CHUNKED && !(sp->wrk->res_mode & RES_ESI_CHILD)) WRW_EndChunk(sp->wrk); From phk at varnish-cache.org Tue Feb 7 10:27:55 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 07 Feb 2012 11:27:55 +0100 Subject: [master] a2a2717 Move more gzip buffers off th wrk->stack and into malloc. Message-ID: commit a2a2717f6c8e5a185151343c70532a9615039583 Author: Poul-Henning Kamp Date: Tue Feb 7 10:27:32 2012 +0000 Move more gzip buffers off th wrk->stack and into malloc. diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index d2f4c01..6b2d271 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -37,6 +37,24 @@ #include "cache_esi.h" /*--------------------------------------------------------------------- + */ + +struct vef_priv { + unsigned magic; +#define VEF_MAGIC 0xf104b51f + struct vgz *vgz; + + char *bufp; + ssize_t tot; + int error; + char pending[20]; + ssize_t npend; + + char *ibuf; + ssize_t ibuf_sz; +}; + +/*--------------------------------------------------------------------- * Read some bytes. * * If the esi_syntax&8 bit is set, we read only a couple of bytes at @@ -64,12 +82,14 @@ vef_read(struct worker *wrk, struct http_conn *htc, void *buf, ssize_t buflen, */ static int -vfp_esi_bytes_uu(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +vfp_esi_bytes_uu(struct worker *wrk, const struct vef_priv *vef, + struct http_conn *htc, ssize_t bytes) { ssize_t wl; struct storage *st; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); while (bytes > 0) { st = FetchStorage(wrk, 0); @@ -92,24 +112,25 @@ vfp_esi_bytes_uu(struct worker *wrk, struct http_conn *htc, ssize_t bytes) */ static int -vfp_esi_bytes_gu(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, + struct http_conn *htc, ssize_t bytes) { struct vgz *vg; ssize_t wl; - uint8_t ibuf[cache_param->gzip_stack_buffer]; int i; size_t dl; const void *dp; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); vg = wrk->busyobj->vgz_rx; while (bytes > 0) { if (VGZ_IbufEmpty(vg) && bytes > 0) { - wl = vef_read(wrk, htc, ibuf, sizeof ibuf, bytes); + wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes); if (wl <= 0) return (wl); - VGZ_Ibuf(vg, ibuf, wl); + VGZ_Ibuf(vg, vef->ibuf, wl); bytes -= wl; } if (VGZ_ObufStorage(wrk, vg)) @@ -123,21 +144,6 @@ vfp_esi_bytes_gu(struct worker *wrk, struct http_conn *htc, ssize_t bytes) } /*--------------------------------------------------------------------- - */ - -struct vef_priv { - unsigned magic; -#define VEF_MAGIC 0xf104b51f - struct vgz *vgz; - - char *bufp; - ssize_t tot; - int error; - char pending[20]; - ssize_t npend; -}; - -/*--------------------------------------------------------------------- * We receive a [un]gzip'ed object, and want to store it gzip'ed. */ @@ -205,31 +211,29 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) } static int -vfp_esi_bytes_ug(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef, + struct http_conn *htc, ssize_t bytes) { ssize_t wl; - char ibuf[cache_param->gzip_stack_buffer]; - struct vef_priv *vef; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vef = wrk->busyobj->vef_priv; CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); + CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); while (bytes > 0) { - wl = vef_read(wrk, htc, ibuf, sizeof ibuf, bytes); + wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes); if (wl <= 0) return (wl); bytes -= wl; - vef->bufp = ibuf; - VEP_Parse(wrk, ibuf, wl); - assert(vef->bufp >= ibuf && vef->bufp <= ibuf + wl); + vef->bufp = vef->ibuf; + VEP_Parse(wrk, vef->ibuf, wl); + assert(vef->bufp >= vef->ibuf && vef->bufp <= vef->ibuf + wl); if (vef->error) { errno = vef->error; return (-1); } - if (vef->bufp < ibuf + wl) { - wl = (ibuf + wl) - vef->bufp; + if (vef->bufp < vef->ibuf + wl) { + wl = (vef->ibuf + wl) - vef->bufp; assert(wl + vef->npend < sizeof vef->pending); memmove(vef->pending + vef->npend, vef->bufp, wl); vef->npend += wl; @@ -243,31 +247,28 @@ vfp_esi_bytes_ug(struct worker *wrk, struct http_conn *htc, ssize_t bytes) */ static int -vfp_esi_bytes_gg(struct worker *wrk, struct http_conn *htc, size_t bytes) +vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef, + struct http_conn *htc, size_t bytes) { ssize_t wl; - char ibuf[cache_param->gzip_stack_buffer]; char ibuf2[cache_param->gzip_stack_buffer]; - struct vef_priv *vef; size_t dl; const void *dp; int i; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vef = wrk->busyobj->vef_priv; CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - assert(sizeof ibuf >= 1024); + CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); ibuf2[0] = 0; /* For Flexelint */ while (bytes > 0) { - wl = vef_read(wrk, htc, ibuf, sizeof ibuf, bytes); + wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes); if (wl <= 0) return (wl); bytes -= wl; - vef->bufp = ibuf; - VGZ_Ibuf(wrk->busyobj->vgz_rx, ibuf, wl); + vef->bufp = vef->ibuf; + VGZ_Ibuf(wrk->busyobj->vgz_rx, vef->ibuf, wl); do { VGZ_Obuf(wrk->busyobj->vgz_rx, ibuf2, sizeof ibuf2); i = VGZ_Gunzip(wrk->busyobj->vgz_rx, &dp, &dl); @@ -306,30 +307,32 @@ vfp_esi_begin(struct worker *wrk, size_t estimate) bo = wrk->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + ALLOC_OBJ(vef, VEF_MAGIC); + XXXAN(vef); + AZ(bo->vef_priv); + bo->vef_priv = vef; + AZ(bo->vgz_rx); if (bo->is_gzip && bo->do_gunzip) { bo->vgz_rx = VGZ_NewUngzip(wrk, "U F E"); VEP_Init(wrk, NULL); + vef->ibuf_sz = cache_param->gzip_stack_buffer; } else if (bo->is_gunzip && bo->do_gzip) { - ALLOC_OBJ(vef, VEF_MAGIC); - AN(vef); vef->vgz = VGZ_NewGzip(wrk, "G F E"); - AZ(bo->vef_priv); - bo->vef_priv = vef; VEP_Init(wrk, vfp_vep_callback); + vef->ibuf_sz = cache_param->gzip_stack_buffer; } else if (bo->is_gzip) { bo->vgz_rx = VGZ_NewUngzip(wrk, "U F E"); - ALLOC_OBJ(vef, VEF_MAGIC); - AN(vef); vef->vgz = VGZ_NewGzip(wrk, "G F E"); - AZ(bo->vef_priv); - bo->vef_priv = vef; VEP_Init(wrk, vfp_vep_callback); + vef->ibuf_sz = cache_param->gzip_stack_buffer; } else { - AZ(bo->vef_priv); VEP_Init(wrk, NULL); } - + if (vef->ibuf_sz > 0) { + vef->ibuf = calloc(1L, vef->ibuf_sz); + XXXAN(vef->ibuf); + } AN(bo->vep); } @@ -337,23 +340,26 @@ static int __match_proto__() vfp_esi_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) { struct busyobj *bo; + struct vef_priv *vef; int i; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); bo = wrk->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vef = bo->vef_priv; + CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); AZ(bo->fetch_failed); AN(bo->vep); assert(&bo->htc == htc); if (bo->is_gzip && bo->do_gunzip) - i = vfp_esi_bytes_gu(wrk, htc, bytes); + i = vfp_esi_bytes_gu(wrk, vef, htc, bytes); else if (bo->is_gunzip && bo->do_gzip) - i = vfp_esi_bytes_ug(wrk, htc, bytes); + i = vfp_esi_bytes_ug(wrk, vef, htc, bytes); else if (bo->is_gzip) - i = vfp_esi_bytes_gg(wrk, htc, bytes); + i = vfp_esi_bytes_gg(wrk, vef, htc, bytes); else - i = vfp_esi_bytes_uu(wrk, htc, bytes); + i = vfp_esi_bytes_uu(wrk, vef, htc, bytes); AN(bo->vep); return (i); } @@ -398,15 +404,17 @@ vfp_esi_end(struct worker *wrk) } vef = bo->vef_priv; - if (vef != NULL) { - CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - bo->vef_priv = NULL; + bo->vef_priv = NULL; + 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) retval = FetchError(wrk, "ESI+Gzip Failed at the very end"); - FREE_OBJ(vef); } + if (vef->ibuf != NULL) + free(vef->ibuf); + FREE_OBJ(vef); return (retval); } From phk at varnish-cache.org Tue Feb 7 10:47:37 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 07 Feb 2012 11:47:37 +0100 Subject: [master] da2cdc5 Move the second G-ESI-G buffer away from the stack too. Message-ID: commit da2cdc5d6d89c8533e2acf4ab5f2eeed6b14a40b Author: Poul-Henning Kamp Date: Tue Feb 7 10:47:20 2012 +0000 Move the second G-ESI-G buffer away from the stack too. diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 6b2d271..e5facd7 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -52,6 +52,9 @@ struct vef_priv { char *ibuf; ssize_t ibuf_sz; + + char *ibuf2; + ssize_t ibuf2_sz; }; /*--------------------------------------------------------------------- @@ -251,7 +254,6 @@ vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef, struct http_conn *htc, size_t bytes) { ssize_t wl; - char ibuf2[cache_param->gzip_stack_buffer]; size_t dl; const void *dp; int i; @@ -259,30 +261,30 @@ vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef, CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - ibuf2[0] = 0; /* For Flexelint */ while (bytes > 0) { - wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes); + wl = vef_read(wrk, htc, vef->ibuf2, vef->ibuf2_sz, bytes); if (wl <= 0) return (wl); bytes -= wl; - vef->bufp = vef->ibuf; - VGZ_Ibuf(wrk->busyobj->vgz_rx, vef->ibuf, wl); + vef->bufp = vef->ibuf2; + VGZ_Ibuf(wrk->busyobj->vgz_rx, vef->ibuf2, wl); do { - VGZ_Obuf(wrk->busyobj->vgz_rx, ibuf2, sizeof ibuf2); + VGZ_Obuf(wrk->busyobj->vgz_rx, vef->ibuf, + vef->ibuf_sz); i = VGZ_Gunzip(wrk->busyobj->vgz_rx, &dp, &dl); /* XXX: check i */ assert(i >= VGZ_OK); - vef->bufp = ibuf2; + vef->bufp = vef->ibuf; if (dl > 0) - VEP_Parse(wrk, ibuf2, dl); + VEP_Parse(wrk, vef->ibuf, dl); if (vef->error) { errno = vef->error; return (-1); } - if (vef->bufp < ibuf2 + dl) { - dl = (ibuf2 + dl) - vef->bufp; + if (vef->bufp < vef->ibuf + dl) { + dl = (vef->ibuf + dl) - vef->bufp; assert(dl + vef->npend < sizeof vef->pending); memmove(vef->pending + vef->npend, vef->bufp, dl); @@ -326,6 +328,7 @@ vfp_esi_begin(struct worker *wrk, size_t estimate) vef->vgz = VGZ_NewGzip(wrk, "G F E"); VEP_Init(wrk, vfp_vep_callback); vef->ibuf_sz = cache_param->gzip_stack_buffer; + vef->ibuf2_sz = cache_param->gzip_stack_buffer; } else { VEP_Init(wrk, NULL); } @@ -333,6 +336,10 @@ vfp_esi_begin(struct worker *wrk, size_t estimate) vef->ibuf = calloc(1L, vef->ibuf_sz); XXXAN(vef->ibuf); } + if (vef->ibuf2_sz > 0) { + vef->ibuf2 = calloc(1L, vef->ibuf2_sz); + XXXAN(vef->ibuf2); + } AN(bo->vep); } @@ -414,6 +421,8 @@ vfp_esi_end(struct worker *wrk) } if (vef->ibuf != NULL) free(vef->ibuf); + if (vef->ibuf2 != NULL) + free(vef->ibuf2); FREE_OBJ(vef); return (retval); } From phk at varnish-cache.org Tue Feb 7 13:18:01 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 07 Feb 2012 14:18:01 +0100 Subject: [master] 0eae9d0 Now that we have a input buffer which persists over calls to vfp->bytes, loose the dedicated "pending" buffer and just use the front of the input buffer. This simplifies the code quite a bit. Message-ID: commit 0eae9d0076b419b4d9979cba519f7502e43a6384 Author: Poul-Henning Kamp Date: Tue Feb 7 13:17:07 2012 +0000 Now that we have a input buffer which persists over calls to vfp->bytes, loose the dedicated "pending" buffer and just use the front of the input buffer. This simplifies the code quite a bit. diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index e5facd7..4b9d04d 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -44,13 +44,12 @@ struct vef_priv { #define VEF_MAGIC 0xf104b51f struct vgz *vgz; - char *bufp; ssize_t tot; int error; - char pending[20]; - ssize_t npend; char *ibuf; + char *ibuf_i; + char *ibuf_o; ssize_t ibuf_sz; char *ibuf2; @@ -148,13 +147,46 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, /*--------------------------------------------------------------------- * We receive a [un]gzip'ed object, and want to store it gzip'ed. + * + * This is rather complicated, because the ESI parser does not + * spit out all bytes we feed it right away: Sometimes it needs + * more input to make up its mind. + * + * The inject function feeds uncompressed bytes into the VEP, and + * takes care to keep any bytes VEP didn't decide on intact until + * later. + * + * The callback is called by VEP to dispose of bytes and report + * where to find them again later. */ +static int +vfp_vep_inject(const struct worker *wrk, struct vef_priv *vef, ssize_t wl) +{ + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); + + VEP_Parse(wrk, vef->ibuf_i, wl); + vef->ibuf_i += wl; + assert(vef->ibuf_o >= vef->ibuf && vef->ibuf_o <= vef->ibuf_i); + if (vef->error) { + errno = vef->error; + return (-1); + } + wl = vef->ibuf_i - vef->ibuf_o; + if (wl > 0) + memmove(vef->ibuf, vef->ibuf_o, wl); + vef->ibuf_o = vef->ibuf; + vef->ibuf_i = vef->ibuf + wl; + return (0); +} + static ssize_t vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) { struct vef_priv *vef; - size_t dl, px; + size_t dl; const void *dp; int i; @@ -177,35 +209,20 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) if (l == 0 && flg == VGZ_NORMAL) return (vef->tot); + VGZ_Ibuf(vef->vgz, vef->ibuf_o, l); do { - px = vef->npend; - if (l < px) - px = l; - if (px != 0) { - VGZ_Ibuf(vef->vgz, vef->pending, px); - l -= px; - } else { - VGZ_Ibuf(vef->vgz, vef->bufp, l); - vef->bufp += l; - l = 0; - } - do { - if (VGZ_ObufStorage(wrk, vef->vgz)) { - vef->error = ENOMEM; - vef->tot += l; - return (vef->tot); - } - i = VGZ_Gzip(vef->vgz, &dp, &dl, flg); - vef->tot += dl; - wrk->busyobj->fetch_obj->len += dl; - } while (!VGZ_IbufEmpty(vef->vgz) || - (flg != VGZ_NORMAL && VGZ_ObufFull(vef->vgz))); - if (px != 0) { - memmove(vef->pending, vef->pending + px, - vef->npend - px); - vef->npend -= px; + if (VGZ_ObufStorage(wrk, vef->vgz)) { + vef->error = ENOMEM; + vef->tot += l; + return (vef->tot); } - } while (l > 0); + i = VGZ_Gzip(vef->vgz, &dp, &dl, flg); + vef->tot += dl; + wrk->busyobj->fetch_obj->len += dl; + } while (!VGZ_IbufEmpty(vef->vgz) || + (flg != VGZ_NORMAL && VGZ_ObufFull(vef->vgz))); + assert(VGZ_IbufEmpty(vef->vgz)); + vef->ibuf_o += l; if (flg == VGZ_FINISH) assert(i == 1); /* XXX */ else @@ -213,6 +230,10 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) return (vef->tot); } +/*--------------------------------------------------------------------- + * We receive a gunzip'ed object, and want to store it gzip'ed. + */ + static int vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef, struct http_conn *htc, ssize_t bytes) @@ -224,23 +245,13 @@ vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef, CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); while (bytes > 0) { - wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes); + wl = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf); + wl = vef_read(wrk, htc, vef->ibuf_i, wl, bytes); if (wl <= 0) return (wl); bytes -= wl; - vef->bufp = vef->ibuf; - VEP_Parse(wrk, vef->ibuf, wl); - assert(vef->bufp >= vef->ibuf && vef->bufp <= vef->ibuf + wl); - if (vef->error) { - errno = vef->error; + if (vfp_vep_inject(wrk, vef, wl)) return (-1); - } - if (vef->bufp < vef->ibuf + wl) { - wl = (vef->ibuf + wl) - vef->bufp; - assert(wl + vef->npend < sizeof vef->pending); - memmove(vef->pending + vef->npend, vef->bufp, wl); - vef->npend += wl; - } } return (1); } @@ -268,34 +279,20 @@ vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef, return (wl); bytes -= wl; - vef->bufp = vef->ibuf2; VGZ_Ibuf(wrk->busyobj->vgz_rx, vef->ibuf2, wl); do { - VGZ_Obuf(wrk->busyobj->vgz_rx, vef->ibuf, - vef->ibuf_sz); + wl = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf); + VGZ_Obuf(wrk->busyobj->vgz_rx, vef->ibuf_i, wl); i = VGZ_Gunzip(wrk->busyobj->vgz_rx, &dp, &dl); /* XXX: check i */ assert(i >= VGZ_OK); - vef->bufp = vef->ibuf; - if (dl > 0) - VEP_Parse(wrk, vef->ibuf, dl); - if (vef->error) { - errno = vef->error; + if (dl > 0 && vfp_vep_inject(wrk, vef, dl)) return (-1); - } - if (vef->bufp < vef->ibuf + dl) { - dl = (vef->ibuf + dl) - vef->bufp; - assert(dl + vef->npend < sizeof vef->pending); - memmove(vef->pending + vef->npend, - vef->bufp, dl); - vef->npend += dl; - } } while (!VGZ_IbufEmpty(wrk->busyobj->vgz_rx)); } return (1); } - /*---------------------------------------------------------------------*/ static void __match_proto__() @@ -335,6 +332,8 @@ vfp_esi_begin(struct worker *wrk, size_t estimate) if (vef->ibuf_sz > 0) { vef->ibuf = calloc(1L, vef->ibuf_sz); XXXAN(vef->ibuf); + vef->ibuf_i = vef->ibuf; + vef->ibuf_o = vef->ibuf; } if (vef->ibuf2_sz > 0) { vef->ibuf2 = calloc(1L, vef->ibuf2_sz); From phk at varnish-cache.org Tue Feb 7 13:59:19 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 07 Feb 2012 14:59:19 +0100 Subject: [master] 42f03cc Move the last g(un)zip buffers from the wrk->stack to malloc(3). Message-ID: commit 42f03cc1c580d1acb811eb63284584d98393a171 Author: Poul-Henning Kamp Date: Tue Feb 7 13:57:39 2012 +0000 Move the last g(un)zip buffers from the wrk->stack to malloc(3). Rename the gzip_stack_buffer param to gzip_buffer. Remove the gzip_tmp_space param. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b89ef23..f7bef9d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -788,7 +788,6 @@ int VGZ_WrwInit(struct vgz *vg); int VGZ_WrwGunzip(struct worker *w, struct vgz *, const void *ibuf, ssize_t ibufl); void VGZ_WrwFlush(struct worker *wrk, struct vgz *vg); -void VGZ_WrwFinish(struct worker *wrk, struct vgz *vg); /* Return values */ #define VGZ_ERROR -1 diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 0175c3d..a9bc694 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -389,7 +389,7 @@ ESI_Deliver(struct sess *sp) } } if (vgz != NULL) { - VGZ_WrwFinish(sp->wrk, vgz); + VGZ_WrwFlush(sp->wrk, vgz); (void)VGZ_Destroy(&vgz, sp->vsl_id); } if (sp->req->gzip_resp && sp->req->esi_level == 0) { diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 4b9d04d..64adf51 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -315,17 +315,17 @@ vfp_esi_begin(struct worker *wrk, size_t estimate) if (bo->is_gzip && bo->do_gunzip) { bo->vgz_rx = VGZ_NewUngzip(wrk, "U F E"); VEP_Init(wrk, NULL); - vef->ibuf_sz = cache_param->gzip_stack_buffer; + vef->ibuf_sz = cache_param->gzip_buffer; } else if (bo->is_gunzip && bo->do_gzip) { vef->vgz = VGZ_NewGzip(wrk, "G F E"); VEP_Init(wrk, vfp_vep_callback); - vef->ibuf_sz = cache_param->gzip_stack_buffer; + 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"); VEP_Init(wrk, vfp_vep_callback); - vef->ibuf_sz = cache_param->gzip_stack_buffer; - vef->ibuf2_sz = cache_param->gzip_stack_buffer; + vef->ibuf_sz = cache_param->gzip_buffer; + vef->ibuf2_sz = cache_param->gzip_buffer; } else { VEP_Init(wrk, NULL); } diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 63a18cd..402633f 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -86,34 +86,13 @@ struct vgz { struct storage *st_obuf; /* Wrw stuff */ - char *wrw_buf; - ssize_t wrw_sz; - ssize_t wrw_len; + char *m_buf; + ssize_t m_sz; + ssize_t m_len; z_stream vz; }; -/*--------------------------------------------------------------------*/ - -static voidpf -vgz_alloc(voidpf opaque, uInt items, uInt size) -{ - struct vgz *vg; - - CAST_OBJ_NOTNULL(vg, opaque, VGZ_MAGIC); - - return (WS_Alloc(vg->tmp, items * size)); -} - -static void -vgz_free(voidpf opaque, voidpf address) -{ - struct vgz *vg; - - CAST_OBJ_NOTNULL(vg, opaque, VGZ_MAGIC); - (void)address; -} - /*-------------------------------------------------------------------- * Set up a gunzip instance */ @@ -127,30 +106,10 @@ vgz_alloc_vgz(struct worker *wrk, const char *id) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); ws = wrk->ws; WS_Assert(ws); - // XXX: we restore workspace in esi:include - // vg = (void*)WS_Alloc(ws, sizeof *vg); ALLOC_OBJ(vg, VGZ_MAGIC); AN(vg); - memset(vg, 0, sizeof *vg); - vg->magic = VGZ_MAGIC; vg->wrk = wrk; vg->id = id; - - switch (cache_param->gzip_tmp_space) { - case 0: - case 1: - /* malloc, the default */ - break; - case 2: - vg->tmp = wrk->ws; - vg->tmp_snapshot = WS_Snapshot(vg->tmp); - vg->vz.zalloc = vgz_alloc; - vg->vz.zfree = vgz_free; - vg->vz.opaque = vg; - break; - default: - assert(0 == __LINE__); - } return (vg); } @@ -210,6 +169,27 @@ VGZ_NewGzip(struct worker *wrk, const char *id) return (vg); } +/*-------------------------------------------------------------------- + */ + +static int +vgz_getmbuf(struct vgz *vg) +{ + + CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); + AZ(vg->m_sz); + AZ(vg->m_len); + AZ(vg->m_buf); + + vg->m_sz = cache_param->gzip_buffer; + vg->m_buf = malloc(vg->m_sz); + if (vg->m_buf == NULL) { + vg->m_sz = 0; + return (-1); + } + return (0); +} + /*--------------------------------------------------------------------*/ void @@ -356,17 +336,11 @@ VGZ_WrwInit(struct vgz *vg) { CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - AZ(vg->wrw_sz); - AZ(vg->wrw_len); - AZ(vg->wrw_buf); - - vg->wrw_sz = cache_param->gzip_stack_buffer; - vg->wrw_buf = malloc(vg->wrw_sz); - if (vg->wrw_buf == NULL) { - vg->wrw_sz = 0; + + if (vgz_getmbuf(vg)) return (-1); - } - VGZ_Obuf(vg, vg->wrw_buf, vg->wrw_sz); + + VGZ_Obuf(vg, vg->m_buf, vg->m_sz); return (0); } @@ -385,27 +359,27 @@ VGZ_WrwGunzip(struct worker *wrk, struct vgz *vg, const void *ibuf, CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - AN(vg->wrw_buf); + AN(vg->m_buf); VGZ_Ibuf(vg, ibuf, ibufl); if (ibufl == 0) return (VGZ_OK); do { - if (vg->wrw_len == vg->wrw_sz) + if (vg->m_len == vg->m_sz) i = VGZ_STUCK; else { i = VGZ_Gunzip(vg, &dp, &dl); - vg->wrw_len += dl; + vg->m_len += dl; } if (i < VGZ_OK) { /* XXX: VSL ? */ return (-1); } - if (vg->wrw_len == vg->wrw_sz || i == VGZ_STUCK) { - wrk->acct_tmp.bodybytes += vg->wrw_len; - (void)WRW_Write(wrk, vg->wrw_buf, vg->wrw_len); + if (vg->m_len == vg->m_sz || i == VGZ_STUCK) { + wrk->acct_tmp.bodybytes += vg->m_len; + (void)WRW_Write(wrk, vg->m_buf, vg->m_len); (void)WRW_Flush(wrk); - vg->wrw_len = 0; - VGZ_Obuf(vg, vg->wrw_buf, vg->wrw_sz); + vg->m_len = 0; + VGZ_Obuf(vg, vg->m_buf, vg->m_sz); } } while (!VGZ_IbufEmpty(vg)); if (i == VGZ_STUCK) @@ -421,25 +395,11 @@ VGZ_WrwFlush(struct worker *wrk, struct vgz *vg) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - if (vg->wrw_len == 0) + if (vg->m_len == 0) return; - (void)WRW_Write(wrk, vg->wrw_buf, vg->wrw_len); + (void)WRW_Write(wrk, vg->m_buf, vg->m_len); (void)WRW_Flush(wrk); - vg->wrw_len = 0; -} - -/*--------------------------------------------------------------------*/ - -void -VGZ_WrwFinish(struct worker *wrk, struct vgz *vg) -{ - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - - VGZ_WrwFlush(wrk, vg); - free(vg->wrw_buf); - vg->wrw_buf = 0; - vg->wrw_sz = 0; + vg->m_len = 0; } /*--------------------------------------------------------------------*/ @@ -468,7 +428,6 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id) vg = *vgp; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); *vgp = NULL; - AZ(vg->wrw_buf); if (vsl_id < 0) WSLB(vg->wrk, SLT_Gzip, "%s %jd %jd %jd %jd %jd", @@ -494,6 +453,8 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id) i = inflateEnd(&vg->vz); if (vg->last_i == Z_STREAM_END && i == Z_OK) i = Z_STREAM_END; + if (vg->m_buf) + free(vg->m_buf); FREE_OBJ(vg); if (i == Z_OK) return (VGZ_OK); @@ -518,6 +479,7 @@ vfp_gunzip_begin(struct worker *wrk, size_t estimate) CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(wrk->busyobj->vgz_rx); wrk->busyobj->vgz_rx = VGZ_NewUngzip(wrk, "U F -"); + XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx)); } static int __match_proto__() @@ -526,7 +488,6 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) struct vgz *vg; ssize_t l, wl; int i = -100; - uint8_t ibuf[cache_param->gzip_stack_buffer]; size_t dl; const void *dp; @@ -538,13 +499,13 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) AZ(vg->vz.avail_in); while (bytes > 0 || vg->vz.avail_in > 0) { if (vg->vz.avail_in == 0 && bytes > 0) { - l = sizeof ibuf; + l = vg->m_sz; if (l > bytes) l = bytes; - wl = HTC_Read(wrk, htc, ibuf, l); + wl = HTC_Read(wrk, htc, vg->m_buf, l); if (wl <= 0) return (wl); - VGZ_Ibuf(vg, ibuf, wl); + VGZ_Ibuf(vg, vg->m_buf, wl); bytes -= wl; } @@ -586,7 +547,6 @@ struct vfp vfp_gunzip = { .end = vfp_gunzip_end, }; - /*-------------------------------------------------------------------- * VFP_GZIP * @@ -602,6 +562,7 @@ vfp_gzip_begin(struct worker *wrk, size_t estimate) CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(wrk->busyobj->vgz_rx); wrk->busyobj->vgz_rx = VGZ_NewGzip(wrk, "G F -"); + XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx)); } static int __match_proto__() @@ -610,7 +571,6 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) struct vgz *vg; ssize_t l, wl; int i = -100; - uint8_t ibuf[cache_param->gzip_stack_buffer]; size_t dl; const void *dp; @@ -622,13 +582,13 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) AZ(vg->vz.avail_in); while (bytes > 0 || !VGZ_IbufEmpty(vg)) { if (VGZ_IbufEmpty(vg) && bytes > 0) { - l = sizeof ibuf; + l = vg->m_sz; if (l > bytes) l = bytes; - wl = HTC_Read(wrk, htc, ibuf, l); + wl = HTC_Read(wrk, htc, vg->m_buf, l); if (wl <= 0) return (wl); - VGZ_Ibuf(vg, ibuf, wl); + VGZ_Ibuf(vg, vg->m_buf, wl); bytes -= wl; } if (VGZ_ObufStorage(wrk, vg)) @@ -695,6 +655,7 @@ vfp_testgzip_begin(struct worker *wrk, size_t estimate) (void)estimate; wrk->busyobj->vgz_rx = VGZ_NewUngzip(wrk, "u F -"); CHECK_OBJ_NOTNULL(wrk->busyobj->vgz_rx, VGZ_MAGIC); + XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx)); } static int __match_proto__() @@ -703,7 +664,6 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) struct vgz *vg; ssize_t l, wl; int i = -100; - uint8_t obuf[cache_param->gzip_stack_buffer]; size_t dl; const void *dp; struct storage *st; @@ -732,7 +692,7 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) RES_StreamPoll(wrk); while (!VGZ_IbufEmpty(vg)) { - VGZ_Obuf(vg, obuf, sizeof obuf); + VGZ_Obuf(vg, vg->m_buf, vg->m_sz); i = VGZ_Gunzip(vg, &dp, &dl); if (i == VGZ_END && !VGZ_IbufEmpty(vg)) return(FetchError(wrk, "Junk after gzip data")); diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 6206c18..6c48468 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -179,7 +179,7 @@ res_WriteGunzipObj(const struct sess *sp) /* XXX: error check */ (void)i; } - VGZ_WrwFinish(sp->wrk, vg); + VGZ_WrwFlush(sp->wrk, vg); (void)VGZ_Destroy(&vg, sp->vsl_id); assert(u == sp->req->obj->len); } @@ -420,7 +420,7 @@ RES_StreamEnd(struct sess *sp) if (sp->wrk->res_mode & RES_GUNZIP) { AN(sctx->vgz); - VGZ_WrwFinish(sp->wrk, sctx->vgz); + VGZ_WrwFlush(sp->wrk, sctx->vgz); (void)VGZ_Destroy(&sctx->vgz, sp->vsl_id); } if (sp->wrk->res_mode & RES_CHUNKED && diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 6c1899a..015e5d2 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -181,8 +181,7 @@ struct params { unsigned http_range_support; unsigned http_gzip_support; - unsigned gzip_stack_buffer; - unsigned gzip_tmp_space; + unsigned gzip_buffer; unsigned gzip_level; unsigned gzip_window; unsigned gzip_memlevel; diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index c984aae..60d49f8 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -1084,17 +1084,6 @@ static const struct parspec input_parspec[] = { "Varnish reference.", EXPERIMENTAL, "on", "bool" }, - { "gzip_tmp_space", tweak_uint, &mgt_param.gzip_tmp_space, 0, 2, - "Where temporary space for gzip/gunzip is allocated:\n" - " 0 - malloc\n" - " 2 - thread workspace\n" - "\n" - "If you have much gzip/gunzip activity, it may be an" - " advantage to use workspace for these allocations to reduce" - " malloc activity. Be aware that gzip needs 256+KB and gunzip" - " needs 32+KB of workspace (64+KB if ESI processing).", - EXPERIMENTAL, - "0", "" }, { "gzip_level", tweak_uint, &mgt_param.gzip_level, 0, 9, "Gzip compression level: 0=debug, 1=fast, 9=best", 0, @@ -1109,11 +1098,11 @@ static const struct parspec input_parspec[] = { "Memory impact is 1=1k, 2=2k, ... 9=256k.", 0, "8", ""}, - { "gzip_stack_buffer", - tweak_bytes_u, &mgt_param.gzip_stack_buffer, + { "gzip_buffer", + tweak_bytes_u, &mgt_param.gzip_buffer, 2048, UINT_MAX, - "Size of stack buffer used for gzip processing.\n" - "The stack buffers are used for in-transit data," + "Size of malloc buffer used for gzip processing.\n" + "These buffers are used for in-transit data," " for instance gunzip'ed data being sent to a client." "Making this space to small results in more overhead," " writes to sockets etc, making it too big is probably" diff --git a/bin/varnishtest/tests/e00020.vtc b/bin/varnishtest/tests/e00020.vtc index 5b40c16..f9b73a4 100644 --- a/bin/varnishtest/tests/e00020.vtc +++ b/bin/varnishtest/tests/e00020.vtc @@ -22,7 +22,6 @@ varnish v1 -vcl+backend { varnish v1 -cliok "param.set esi_syntax 4" varnish v1 -cliok "param.set http_gzip_support true" -varnish v1 -cliok "param.set gzip_tmp_space 2" client c1 { txreq diff --git a/bin/varnishtest/tests/e00022.vtc b/bin/varnishtest/tests/e00022.vtc index 897f3ee..1f13cd3 100644 --- a/bin/varnishtest/tests/e00022.vtc +++ b/bin/varnishtest/tests/e00022.vtc @@ -25,7 +25,6 @@ varnish v1 -arg "-p thread_pool_stack=262144" -vcl+backend { varnish v1 -cliok "param.set esi_syntax 0xc" varnish v1 -cliok "param.set http_gzip_support true" -varnish v1 -cliok "param.set gzip_tmp_space 1" varnish v1 -cliok "param.set gzip_window 8" varnish v1 -cliok "param.set gzip_memlevel 1" From phk at varnish-cache.org Tue Feb 7 14:10:17 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 07 Feb 2012 15:10:17 +0100 Subject: [master] 2a5cf8f Remove comment OBE. Message-ID: commit 2a5cf8f7574c92fa7eef4852742f9b25497fed2e Author: Poul-Henning Kamp Date: Tue Feb 7 14:10:06 2012 +0000 Remove comment OBE. diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 402633f..6064f67 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -34,34 +34,6 @@ * The API defined by this file, will also insulate the rest of the code, * should we find a better gzip library at a later date. * - * The absolutely worst case gzip processing path, once we have pipe-lining, - * will be the following, so we need to be a bit careful with the scratch - * space we use: - * - * Backend Tmp Input Output - * | ---------------------- - * v - * gunzip wrk stack ? - * | - * v - * esi - * | - * v - * gzip wrk ? storage - * | - * v - * cache - * | - * v - * gunzip wrk storage stack - * | - * v - * client - * - * XXXX: The two '?' are obviously the same memory, but I have yet to decide - * where it goes. As usual we try to avoid the session->ws if we can but - * I may have to use that. - * */ #include "config.h" From phk at varnish-cache.org Wed Feb 8 22:05:03 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 08 Feb 2012 23:05:03 +0100 Subject: [master] 2362e93 Add a call-back function to memory pools, which can be used to update the desired size of objects from the guard thread. Message-ID: commit 2362e936e03bf3ee2093efe3aa663c9c998b272b Author: Poul-Henning Kamp Date: Wed Feb 8 22:03:39 2012 +0000 Add a call-back function to memory pools, which can be used to update the desired size of objects from the guard thread. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f7bef9d..6338750 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -884,9 +884,10 @@ int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, struct timespec *ts); #undef LOCK /* cache_mempool.c */ +typedef void mpl_poll_f(volatile unsigned *); void MPL_AssertSane(void *item); struct mempool * MPL_New(const char *name, volatile struct poolparam *pp, - volatile unsigned *cur_size); + volatile unsigned *cur_size, mpl_poll_f *poll_f); void MPL_Destroy(struct mempool **mpp); void *MPL_Get(struct mempool *mpl, unsigned *size); void MPL_Free(struct mempool *mpl, void *item); diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index b683300..2610b06 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -519,6 +519,6 @@ void VDI_Init(void) { - vbcpool = MPL_New("vbc", &cache_param->vbc_pool, &vbcps); + vbcpool = MPL_New("vbc", &cache_param->vbc_pool, &vbcps, NULL); AN(vbcpool); } diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 468d5a8..ec0d36b 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -57,6 +57,7 @@ struct mempool { struct lock mtx; volatile struct poolparam *param; volatile unsigned *cur_size; + mpl_poll_f *poll_func; uint64_t live; struct VSC_C_mempool *vsc; unsigned n_pool; @@ -104,6 +105,8 @@ mpl_guard(void *priv) mpl_slp = 0.15; // random while (1) { VTIM_sleep(mpl_slp); + if (mpl->poll_func != NULL) + mpl->poll_func(mpl->cur_size); mpl_slp = 0.814; // random mpl->t_now = VTIM_real(); @@ -224,7 +227,7 @@ mpl_guard(void *priv) struct mempool * MPL_New(const char *name, volatile struct poolparam *pp, - volatile unsigned *cur_size) + volatile unsigned *cur_size, mpl_poll_f *poll_f) { struct mempool *mpl; @@ -233,6 +236,7 @@ MPL_New(const char *name, bprintf(mpl->name, "%s", name); mpl->param = pp; mpl->cur_size = cur_size; + mpl->poll_func = poll_f; VTAILQ_INIT(&mpl->list); VTAILQ_INIT(&mpl->surplus); Lck_New(&mpl->mtx, lck_mempool); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 3e144c1..2e080f1 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -383,9 +383,9 @@ SES_NewPool(struct pool *wp, unsigned pool_no) pp->pool = wp; bprintf(nb, "req%u", pool_no); pp->mpl_req = MPL_New(nb, &cache_param->req_pool, - &cache_param->workspace_client); + &cache_param->workspace_client, NULL); bprintf(nb, "sess%u", pool_no); - pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &ses_size); + pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &ses_size, NULL); return (pp); } From phk at varnish-cache.org Wed Feb 8 22:29:37 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 08 Feb 2012 23:29:37 +0100 Subject: [master] 1366473 Allocate busyobj with a mempool, instead of a private one-item pool. Message-ID: commit 1366473e5a52b2425e6348c395c74fe5381c4140 Author: Poul-Henning Kamp Date: Wed Feb 8 22:28:58 2012 +0000 Allocate busyobj with a mempool, instead of a private one-item pool. diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index ab4db76..51207df 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -38,6 +38,10 @@ #include "cache.h" +static struct mempool *vbopool; + +static volatile unsigned vbosize; + struct vbo { unsigned magic; #define VBO_MAGIC 0xde3d8223 @@ -48,13 +52,35 @@ struct vbo { }; static struct lock vbo_mtx; -static struct vbo *nvbo; + +/*-------------------------------------------------------------------- + */ + +static void +vbo_size_calc(volatile unsigned *u) +{ + uint16_t nhttp; + ssize_t http_space; + + assert(cache_param->http_max_hdr < 65536); + nhttp = (uint16_t)cache_param->http_max_hdr; + + http_space = HTTP_estimate(nhttp); + + *u = sizeof(struct vbo) + http_space * 2L; +} + +/*-------------------------------------------------------------------- + */ void VBO_Init(void) { + + vbopool = MPL_New("vbo", &cache_param->vbo_pool, &vbosize, + vbo_size_calc); + AN(vbopool); Lck_New(&vbo_mtx, lck_busyobj); - nvbo = NULL; } /*-------------------------------------------------------------------- @@ -67,16 +93,19 @@ vbo_New(void) struct vbo *vbo; uint16_t nhttp; ssize_t http_space; + unsigned sz; - assert(cache_param->http_max_hdr < 65536); + vbo = MPL_Get(vbopool, &sz); nhttp = (uint16_t)cache_param->http_max_hdr; - http_space = HTTP_estimate(nhttp); - - vbo = malloc(sizeof *vbo + 2 * http_space); + if (sizeof *vbo + 2 * http_space > sz) { + /* Could be transient, try again */ + MPL_Free(vbopool, vbo); + vbo_size_calc(&vbosize); + vbo = MPL_Get(vbopool, &sz); + assert (sizeof *vbo + 2 * http_space <= sz); + } AN(vbo); - - memset(vbo, 0, sizeof *vbo); vbo->magic = VBO_MAGIC; vbo->nhttp = nhttp; Lck_New(&vbo->mtx, lck_busyobj); @@ -94,7 +123,7 @@ VBO_Free(struct vbo **vbop) CHECK_OBJ_NOTNULL(vbo, VBO_MAGIC); AZ(vbo->refcount); Lck_Delete(&vbo->mtx); - FREE_OBJ(vbo); + MPL_Free(vbopool, vbo); } struct busyobj * @@ -110,21 +139,6 @@ VBO_GetBusyObj(struct worker *wrk) wrk->nvbo = NULL; } - if (vbo == NULL) { - Lck_Lock(&vbo_mtx); - - vbo = nvbo; - nvbo = NULL; - - if (vbo == NULL) - VSC_C_main->busyobj_alloc++; - - Lck_Unlock(&vbo_mtx); - } - - if (vbo != NULL && vbo->nhttp != cache_param->http_max_hdr) - VBO_Free(&vbo); - if (vbo == NULL) vbo = vbo_New(); @@ -181,19 +195,9 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) /* XXX: Sanity checks & cleanup */ memset(&vbo->bo, 0, sizeof vbo->bo); - if (cache_param->bo_cache && wrk->nvbo == NULL) { + if (cache_param->bo_cache && wrk->nvbo == NULL) wrk->nvbo = vbo; - } else { - Lck_Lock(&vbo_mtx); - if (nvbo == NULL) { - nvbo = vbo; - vbo = NULL; - } else - VSC_C_main->busyobj_free++; - Lck_Unlock(&vbo_mtx); - - if (vbo != NULL) - VBO_Free(&vbo); - } + else + VBO_Free(&vbo); } } diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index ec0d36b..4b8ed07 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -237,6 +237,8 @@ MPL_New(const char *name, mpl->param = pp; mpl->cur_size = cur_size; mpl->poll_func = poll_f; + if (poll_f != NULL) + poll_f(mpl->cur_size); VTAILQ_INIT(&mpl->list); VTAILQ_INIT(&mpl->surplus); Lck_New(&mpl->mtx, lck_mempool); diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 015e5d2..40fcf1d 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -201,4 +201,5 @@ struct params { struct poolparam vbc_pool; struct poolparam req_pool; struct poolparam sess_pool; + struct poolparam vbo_pool; }; diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 60d49f8..56c8336 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -662,6 +662,12 @@ tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg) "\nNB: Do not change this parameter, unless a developer tell " \ "you to do so." +#define MEMPOOL_TEXT \ + "The three numbers are:\n" \ + " min_pool -- minimum size of free pool.\n" \ + " max_pool -- maximum size of free pool.\n" \ + " max_age -- max age of free element.\n" + /* * Remember to update varnishd.1 whenever you add / remove a parameter or * change its default value. @@ -1192,27 +1198,23 @@ static const struct parspec input_parspec[] = { { "pool_vbc", tweak_poolparam, &mgt_param.vbc_pool, 0, 10000, "Parameters for backend connection memory pool.\n" - "The three numbers are:\n" - " min_pool -- minimum size of free pool.\n" - " max_pool -- maximum size of free pool.\n" - " max_age -- max age of free element.\n", + MEMPOOL_TEXT, 0, "10,100,10", ""}, { "pool_req", tweak_poolparam, &mgt_param.req_pool, 0, 10000, "Parameters for per worker pool request memory pool.\n" - "The three numbers are:\n" - " min_pool -- minimum size of free pool.\n" - " max_pool -- maximum size of free pool.\n" - " max_age -- max age of free element.\n", + MEMPOOL_TEXT, 0, "10,100,10", ""}, { "pool_sess", tweak_poolparam, &mgt_param.sess_pool, 0, 10000, "Parameters for per worker pool session memory pool.\n" - "The three numbers are:\n" - " min_pool -- minimum size of free pool.\n" - " max_pool -- maximum size of free pool.\n" - " max_age -- max age of free element.\n", + MEMPOOL_TEXT, + 0, + "10,100,10", ""}, + { "pool_vbo", tweak_poolparam, &mgt_param.vbo_pool, 0, 10000, + "Parameters for backend object fetch memory pool.\n" + MEMPOOL_TEXT, 0, "10,100,10", ""}, diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index df7984a..1188903 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -206,20 +206,6 @@ VSC_F(sess_dropped, uint64_t, 0, 'c', " See also param queue_max." ) -/*--------------------------------------------------------------------- - * BusyObj - */ - -VSC_F(busyobj_alloc, uint64_t, 0, 'c', - "Busyobj allocations", - "Number of busyobj structures allocated." -) - -VSC_F(busyobj_free, uint64_t, 0, 'c', - "Busyobj freed", - "Number of busyobj structures freed." -) - /*---------------------------------------------------------------------*/ VSC_F(n_object, uint64_t, 1, 'i', "N struct object", "") From phk at varnish-cache.org Wed Feb 8 23:09:49 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 09 Feb 2012 00:09:49 +0100 Subject: [master] 4d4e9f7 Use the req workspace, not the worker workspace, as we cannot trust that to be the same throughout the request. Message-ID: commit 4d4e9f7f2a079290bad85275ac9146b49df1a32e Author: Poul-Henning Kamp Date: Wed Feb 8 23:09:12 2012 +0000 Use the req workspace, not the worker workspace, as we cannot trust that to be the same throughout the request. diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index b2ab419..e363b2d 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -58,8 +58,8 @@ vmod_updown(struct sess *sp, int up, const char *s, va_list ap) const char *p; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - u = WS_Reserve(sp->wrk->ws, 0); - e = b = sp->wrk->ws->f; + u = WS_Reserve(sp->req->ws, 0); + e = b = sp->req->ws->f; e += u; p = s; while (p != vrt_magic_string_end && b < e) { @@ -76,12 +76,12 @@ vmod_updown(struct sess *sp, int up, const char *s, va_list ap) *b = '\0'; b++; if (b > e) { - WS_Release(sp->wrk->ws, 0); + WS_Release(sp->req->ws, 0); return (NULL); } else { e = b; - b = sp->wrk->ws->f; - WS_Release(sp->wrk->ws, e - b); + b = sp->req->ws->f; + WS_Release(sp->req->ws, e - b); return (b); } } From phk at varnish-cache.org Wed Feb 8 23:43:35 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 09 Feb 2012 00:43:35 +0100 Subject: [master] 5454314 Remove now unused ws variable. Message-ID: commit 54543147bf099e71c9a3094c838911d6d3228c8d Author: Poul-Henning Kamp Date: Wed Feb 8 23:26:19 2012 +0000 Remove now unused ws variable. diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 6064f67..9d81f62 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -73,11 +73,8 @@ static struct vgz * vgz_alloc_vgz(struct worker *wrk, const char *id) { struct vgz *vg; - struct ws *ws; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - ws = wrk->ws; - WS_Assert(ws); ALLOC_OBJ(vg, VGZ_MAGIC); AN(vg); vg->wrk = wrk; From phk at varnish-cache.org Wed Feb 8 23:43:35 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 09 Feb 2012 00:43:35 +0100 Subject: [master] 1cdbbff NB: Major Reorg Commit Message-ID: commit 1cdbbff4dc0c1886e1a3535ea7580f43ea52008d Author: Poul-Henning Kamp Date: Wed Feb 8 23:34:52 2012 +0000 NB: Major Reorg Commit Introduce a new "backend workspace" which is used for the backend transactions (bereq.*, beresp.*) Together with the "client workspace" which holds the client transaction (req.*, resp.*) this should make memory management much simpler to understand. The backend workspace lives in "busyobj" rather than the worker thread, which therefore needs a lot less stack, allowing many more threads in the same space. Experiments with thread_pool_stack are encouraged, I wouldn't be surprised if 32k is now enough. The per-thread workspace is still around, known as the "auxiallary workspace", but it is down to 256 bytes and it is only used to hand the acceptor information off to worker threads. Once the dust settles, I may remove it entirely, but I can see a value of having a small amount of fast memory in a thread, so I may also keep it. No promises. Ohh, and I removed a couple of small memory leaks which were only present in -trunk, as a result of a git-mis-merge. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 6338750..8df9591 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -327,7 +327,11 @@ struct worker { uint32_t *wlb, *wlp, *wle; unsigned wlr; - struct ws ws[1]; + /* + * In practice this workspace is only used for wrk_accept now + * but it might come handy later, so keep it around. For now. + */ + struct ws aws[1]; struct busyobj *busyobj; @@ -502,6 +506,7 @@ struct busyobj { unsigned fetch_failed; struct vgz *vgz_rx; + struct ws ws[1]; struct vbc *vbc; struct http *bereq; struct http *beresp; diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 434b50c..9384d1c 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -228,7 +228,7 @@ VCA_FailSess(struct worker *wrk) struct wrk_accept *wa; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CAST_OBJ_NOTNULL(wa, (void*)wrk->ws->f, WRK_ACCEPT_MAGIC); + CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC); AZ(wrk->sp); AZ(close(wa->acceptsock)); wrk->stats.sess_drop++; @@ -246,7 +246,7 @@ VCA_SetupSess(struct worker *wrk) struct wrk_accept *wa; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CAST_OBJ_NOTNULL(wa, (void*)wrk->ws->f, WRK_ACCEPT_MAGIC); + CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC); sp = wrk->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); sp->fd = wa->acceptsock; diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 51207df..65791e8 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -47,7 +47,7 @@ struct vbo { #define VBO_MAGIC 0xde3d8223 struct lock mtx; unsigned refcount; - uint16_t nhttp; + char *end; struct busyobj bo; }; @@ -67,7 +67,9 @@ vbo_size_calc(volatile unsigned *u) http_space = HTTP_estimate(nhttp); - *u = sizeof(struct vbo) + http_space * 2L; + *u = sizeof(struct vbo) + + http_space * 2L + + cache_param->workspace_backend; } /*-------------------------------------------------------------------- @@ -91,23 +93,12 @@ static struct vbo * vbo_New(void) { struct vbo *vbo; - uint16_t nhttp; - ssize_t http_space; unsigned sz; vbo = MPL_Get(vbopool, &sz); - nhttp = (uint16_t)cache_param->http_max_hdr; - http_space = HTTP_estimate(nhttp); - if (sizeof *vbo + 2 * http_space > sz) { - /* Could be transient, try again */ - MPL_Free(vbopool, vbo); - vbo_size_calc(&vbosize); - vbo = MPL_Get(vbopool, &sz); - assert (sizeof *vbo + 2 * http_space <= sz); - } AN(vbo); vbo->magic = VBO_MAGIC; - vbo->nhttp = nhttp; + vbo->end = (char *)vbo + sz; Lck_New(&vbo->mtx, lck_busyobj); return (vbo); } @@ -130,10 +121,15 @@ struct busyobj * VBO_GetBusyObj(struct worker *wrk) { struct vbo *vbo = NULL; + uint16_t nhttp; + unsigned httpsz; char *p; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + nhttp = (uint16_t)cache_param->http_max_hdr; + httpsz = HTTP_estimate(nhttp); + if (wrk->nvbo != NULL) { vbo = wrk->nvbo; wrk->nvbo = NULL; @@ -151,9 +147,11 @@ VBO_GetBusyObj(struct worker *wrk) vbo->bo.vbo = vbo; p = (void*)(vbo + 1); - vbo->bo.bereq = HTTP_create(p, vbo->nhttp); - p += HTTP_estimate(vbo->nhttp); - vbo->bo.beresp = HTTP_create(p, vbo->nhttp); + vbo->bo.bereq = HTTP_create(p, nhttp); + p += httpsz; + vbo->bo.beresp = HTTP_create(p, nhttp); + p += httpsz; + WS_Init(vbo->bo.ws, "bo", p, vbo->end - p); return (&vbo->bo); } @@ -197,7 +195,7 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) if (cache_param->bo_cache && wrk->nvbo == NULL) wrk->nvbo = vbo; - else + else VBO_Free(&vbo); } } diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index a8148b5..6692491 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -435,9 +435,9 @@ cnt_done(struct sess *sp, struct worker *wrk, struct req *req) if (wrk->stats.client_req >= cache_param->wthread_stats_rate) WRK_SumStat(wrk); - /* Reset the workspace to the session-watermark */ + WS_Reset(req->ws, NULL); - WS_Reset(wrk->ws, NULL); + WS_Reset(wrk->aws, NULL); sp->t_req = sp->t_idle; i = HTC_Reinit(req->htc); @@ -569,7 +569,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) AZ(wrk->busyobj->should_close); AZ(req->storage_hint); - http_Setup(wrk->busyobj->beresp, wrk->ws); + http_Setup(wrk->busyobj->beresp, wrk->busyobj->ws); need_host_hdr = !http_GetHdr(wrk->busyobj->bereq, H_Host, NULL); @@ -1230,9 +1230,8 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(req->obj); - WS_Reset(wrk->ws, NULL); wrk->busyobj = VBO_GetBusyObj(wrk); - http_Setup(wrk->busyobj->bereq, wrk->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); http_FilterReq(sp, HTTPH_R_FETCH); http_ForceGet(wrk->busyobj->bereq); if (cache_param->http_gzip_support) { @@ -1306,9 +1305,7 @@ cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req) AZ(wrk->busyobj); wrk->busyobj = VBO_GetBusyObj(wrk); - WS_Reset(wrk->ws, NULL); - wrk->busyobj = VBO_GetBusyObj(wrk); - http_Setup(wrk->busyobj->bereq, wrk->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); http_FilterReq(sp, HTTPH_R_PASS); VCL_pass_method(sp); @@ -1362,9 +1359,7 @@ cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req) wrk->acct_tmp.pipe++; wrk->busyobj = VBO_GetBusyObj(wrk); - WS_Reset(wrk->ws, NULL); - wrk->busyobj = VBO_GetBusyObj(wrk); - http_Setup(wrk->busyobj->bereq, wrk->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); http_FilterReq(sp, 0); VCL_pipe_method(sp); @@ -1674,7 +1669,7 @@ CNT_Session(struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_ORNULL(wrk->nobjhead, OBJHEAD_MAGIC); - WS_Assert(wrk->ws); + WS_Assert(wrk->aws); switch (sp->step) { #define STEP(l,u,arg) \ @@ -1688,7 +1683,7 @@ CNT_Session(struct sess *sp) default: WRONG("State engine misfire"); } - WS_Assert(wrk->ws); + WS_Assert(wrk->aws); CHECK_OBJ_ORNULL(wrk->nobjhead, OBJHEAD_MAGIC); } WSL_Flush(wrk, 0); diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c index de8265d..dd76c91 100644 --- a/bin/varnishd/cache/cache_cli.c +++ b/bin/varnishd/cache/cache_cli.c @@ -129,6 +129,7 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv) SZOF(struct worker); SZOF(struct wrk_accept); SZOF(struct storage); + SZOF(struct busyobj); SZOF(struct object); SZOF(struct objcore); SZOF(struct objhead); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index a9bc694..9747919 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -67,7 +67,7 @@ ved_include(struct sess *sp, const char *src, const char *host) /* Take a workspace snapshot */ sp_ws_wm = WS_Snapshot(sp->req->ws); - wrk_ws_wm = WS_Snapshot(w->ws); + wrk_ws_wm = WS_Snapshot(w->aws); /* XXX ? */ http_SetH(sp->req->http, HTTP_HDR_URL, src); if (host != NULL && *host != '\0') { @@ -111,7 +111,7 @@ ved_include(struct sess *sp, const char *src, const char *host) /* Reset the workspace */ WS_Reset(sp->req->ws, sp_ws_wm); - WS_Reset(w->ws, wrk_ws_wm); + WS_Reset(w->aws, wrk_ws_wm); /* XXX ? */ WRW_Reserve(sp->wrk, &sp->fd); if (sp->wrk->res_mode & RES_CHUNKED) @@ -476,7 +476,7 @@ ESI_DeliverChild(const struct sess *sp) * padding it, as necessary, to a byte boundary. */ - dbits = (void*)WS_Alloc(sp->wrk->ws, 8); + dbits = (void*)WS_Alloc(sp->req->ws, 8); AN(dbits); obj = sp->req->obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 8352717..1d705b1 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -1004,7 +1004,7 @@ VEP_Init(struct worker *wrk, vep_callback_t *cb) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(wrk->busyobj->vep); - vep = (void*)WS_Alloc(wrk->ws, sizeof *vep); + vep = (void*)WS_Alloc(wrk->busyobj->ws, sizeof *vep); AN(vep); memset(vep, 0, sizeof *vep); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index abef6b1..c4c0718 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -446,7 +446,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) /* Receive response */ - HTC_Init(htc, wrk->ws, vc->fd, vc->vsl_id, + HTC_Init(htc, wrk->busyobj->ws, vc->fd, vc->vsl_id, cache_param->http_resp_size, cache_param->http_resp_hdr_len); diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index d967291..c8cb6cc 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -521,8 +521,8 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace) struct object *o; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); - spc = WS_Reserve(sp->wrk->ws, 0); - ocp = (void*)sp->wrk->ws->f; + spc = WS_Reserve(sp->req->ws, 0); + ocp = (void*)sp->req->ws->f; Lck_Lock(&oh->mtx); assert(oh->refcnt > 0); nobj = 0; @@ -565,7 +565,7 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace) EXP_Rearm(o); (void)HSH_Deref(sp->wrk, NULL, &o); } - WS_Release(sp->wrk->ws, 0); + WS_Release(sp->req->ws, 0); } diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index b09bcb8..5a2a805 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -196,7 +196,7 @@ pan_wrk(const struct worker *wrk) { VSB_printf(pan_vsp, " worker = %p {\n", wrk); - pan_ws(wrk->ws, 4); + pan_ws(wrk->aws, 4); if (wrk->busyobj != NULL && wrk->busyobj->bereq->ws != NULL) pan_http("bereq", wrk->busyobj->bereq, 4); if (wrk->busyobj != NULL && wrk->busyobj->beresp->ws != NULL) @@ -209,6 +209,7 @@ pan_busyobj(const struct busyobj *bo) { VSB_printf(pan_vsp, " busyobj = %p {\n", bo); + pan_ws(bo->ws, 4); if (bo->is_gzip) VSB_printf(pan_vsp, " is_gzip\n"); if (bo->is_gunzip) VSB_printf(pan_vsp, " is_gunzip\n"); if (bo->do_gzip) VSB_printf(pan_vsp, " do_gzip\n"); diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index dab5b11..be4af0a 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -162,8 +162,8 @@ pool_accept(struct worker *wrk, void *arg) CAST_OBJ_NOTNULL(ps, arg, POOLSOCK_MAGIC); CHECK_OBJ_NOTNULL(ps->lsock, LISTEN_SOCK_MAGIC); - assert(sizeof *wa == WS_Reserve(wrk->ws, sizeof *wa)); - wa = (void*)wrk->ws->f; + assert(sizeof *wa == WS_Reserve(wrk->aws, sizeof *wa)); + wa = (void*)wrk->aws->f; while (1) { memset(wa, 0, sizeof *wa); wa->magic = WRK_ACCEPT_MAGIC; @@ -171,7 +171,7 @@ pool_accept(struct worker *wrk, void *arg) if (ps->lsock->sock < 0) { /* Socket Shutdown */ FREE_OBJ(ps); - WS_Release(wrk->ws, 0); + WS_Release(wrk->aws, 0); return; } if (VCA_Accept(ps->lsock, wa) < 0) { @@ -192,8 +192,8 @@ pool_accept(struct worker *wrk, void *arg) } VTAILQ_REMOVE(&pp->idle_queue, &wrk2->task, list); Lck_Unlock(&pp->mtx); - assert(sizeof *wa2 == WS_Reserve(wrk2->ws, sizeof *wa2)); - wa2 = (void*)wrk2->ws->f; + assert(sizeof *wa2 == WS_Reserve(wrk2->aws, sizeof *wa2)); + wa2 = (void*)wrk2->aws->f; memcpy(wa2, wa, sizeof *wa); wrk2->task.func = SES_pool_accept_task; wrk2->task.priv = pp->sesspool; @@ -277,7 +277,7 @@ Pool_Work_Thread(void *priv, struct worker *wrk) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - WS_Reset(wrk->ws, NULL); + WS_Reset(wrk->aws, NULL); tp = VTAILQ_FIRST(&pp->front_queue); if (tp != NULL) { diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 2e080f1..58ff960 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -139,7 +139,7 @@ ses_pool_task(struct worker *wrk, void *arg) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CAST_OBJ_NOTNULL(sp, arg, SESS_MAGIC); - AZ(wrk->ws->r); + AZ(wrk->aws->r); wrk->lastused = NAN; THR_SetSession(sp); if (wrk->sp == NULL) @@ -153,7 +153,7 @@ ses_pool_task(struct worker *wrk, void *arg) /* Cannot access sp now */ THR_SetSession(NULL); wrk->sp = NULL; - WS_Assert(wrk->ws); + WS_Assert(wrk->aws); AZ(wrk->busyobj); AZ(wrk->wrw.wfd); assert(wrk->wlp == wrk->wlb); @@ -177,7 +177,7 @@ SES_pool_accept_task(struct worker *wrk, void *arg) /* Turn accepted socket into a session */ AZ(wrk->sp); - AN(wrk->ws->r); + AN(wrk->aws->r); wrk->sp = ses_new(pp); if (wrk->sp == NULL) { VCA_FailSess(wrk); @@ -185,7 +185,7 @@ SES_pool_accept_task(struct worker *wrk, void *arg) } VCA_SetupSess(wrk); wrk->sp->step = STP_FIRST; - WS_Release(wrk->ws, 0); + WS_Release(wrk->aws, 0); ses_pool_task(wrk, wrk->sp); } diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 2623bcc..643f0a3 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -205,7 +205,7 @@ VRT_WrkString(const struct sess *sp, const char *p, ...) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); va_start(ap, p); - b = VRT_String(sp->wrk->ws, NULL, p, ap); + b = VRT_String(sp->wrk->aws, NULL, p, ap); va_end(ap); return (b); } diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index c4c0c56..ec067a2 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -297,7 +297,7 @@ VRT_l_beresp_storage(struct sess *sp, const char *str, ...) char *b; va_start(ap, str); - b = VRT_String(sp->wrk->ws, NULL, str, ap); + b = VRT_String(sp->wrk->busyobj->ws, NULL, str, ap); va_end(ap); sp->req->storage_hint = b; } diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 6087991..32ad21d 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -152,7 +152,7 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace, w->wrw.ciov = siov; AZ(pthread_cond_init(&w->cond, NULL)); - WS_Init(w->ws, "wrk", ws, sess_workspace); + WS_Init(w->aws, "wrk", ws, sess_workspace); VSL(SLT_WorkThread, 0, "%p start", w); @@ -182,7 +182,7 @@ WRK_thread(void *priv) siov = IOV_MAX; return (wrk_thread_real(priv, cache_param->shm_workspace, - cache_param->wthread_workspace, siov)); + cache_param->workspace_thread, siov)); } void diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 40fcf1d..1e51656 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -70,12 +70,14 @@ struct params { unsigned wthread_purge_delay; unsigned wthread_stats_rate; unsigned wthread_stacksize; - unsigned wthread_workspace; unsigned queue_max; /* Memory allocation hints */ unsigned workspace_client; + unsigned workspace_backend; + unsigned workspace_thread; + unsigned shm_workspace; unsigned http_req_size; unsigned http_req_hdr_len; diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 56c8336..8c7a668 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -662,7 +662,7 @@ tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg) "\nNB: Do not change this parameter, unless a developer tell " \ "you to do so." -#define MEMPOOL_TEXT \ +#define MEMPOOL_TEXT \ "The three numbers are:\n" \ " min_pool -- minimum size of free pool.\n" \ " max_pool -- maximum size of free pool.\n" \ @@ -698,6 +698,18 @@ static const struct parspec input_parspec[] = { "Bytes of HTTP protocol workspace for clients HTTP req/resp.", DELAYED_EFFECT, "64k", "bytes" }, + { "workspace_backend", + tweak_bytes_u, &mgt_param.workspace_backend, 1024, UINT_MAX, + "Bytes of HTTP protocol workspace for backend HTTP req/resp.", + DELAYED_EFFECT, + "64k", "bytes" }, + { "workspace_thread", + tweak_bytes_u, &mgt_param.workspace_thread, 256, 256, + "Bytes of auxillary workspace per thread." + /* XXX: See comment in cache.h */ + "This is not the workspace you are looking for.", + DELAYED_EFFECT, + "256", "bytes" }, { "http_req_hdr_len", tweak_bytes_u, &mgt_param.http_req_hdr_len, 40, UINT_MAX, @@ -1194,7 +1206,7 @@ static const struct parspec input_parspec[] = { "Disable this if you have very high hitrates and want" "to save the memory of one busyobj per worker thread.", 0, - "true", ""}, + "false", ""}, { "pool_vbc", tweak_poolparam, &mgt_param.vbc_pool, 0, 10000, "Parameters for backend connection memory pool.\n" diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index d34eef2..b716937 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -224,16 +224,5 @@ const struct parspec WRK_parspec[] = { "many threads into the limited address space.\n", EXPERIMENTAL, "-1", "bytes" }, - { "thread_pool_workspace", tweak_uint, &mgt_param.wthread_workspace, - 1024, UINT_MAX, - "Bytes of HTTP protocol workspace allocated for worker " - "threads. " - "This space must be big enough for the backend request " - "and responses, and response to the client plus any other " - "memory needs in the VCL code." - "Minimum is 1024 bytes.", - DELAYED_EFFECT, - "65536", - "bytes" }, { NULL, NULL, NULL } }; diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc index a4173b4..ff94c72 100644 --- a/bin/varnishtest/tests/r01038.vtc +++ b/bin/varnishtest/tests/r01038.vtc @@ -45,7 +45,7 @@ server s1 { txresp -body "foo8" } -start -varnish v1 -arg "-p thread_pool_workspace=1024" -vcl+backend { +varnish v1 -arg "-p workspace_backend=1024" -vcl+backend { sub vcl_fetch { set beresp.do_esi = true; } From phk at varnish-cache.org Wed Feb 8 23:43:35 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 09 Feb 2012 00:43:35 +0100 Subject: [master] e88413b Allocate HTTP.status from http's designated workspace. Message-ID: commit e88413bccbd000157da949eedc3ee4b0c6889dec Author: Poul-Henning Kamp Date: Wed Feb 8 23:26:57 2012 +0000 Allocate HTTP.status from http's designated workspace. diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 0b0b926..cdf95f1 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -1069,7 +1069,7 @@ http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, int resp) l = WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], " "); WSLH(w, vsl_id, hp, HTTP_HDR_PROTO); - hp->hd[HTTP_HDR_STATUS].b = WS_Alloc(w->ws, 4); + hp->hd[HTTP_HDR_STATUS].b = WS_Alloc(hp->ws, 4); AN(hp->hd[HTTP_HDR_STATUS].b); sprintf(hp->hd[HTTP_HDR_STATUS].b, "%3d", hp->status); From phk at varnish-cache.org Thu Feb 9 07:48:37 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 09 Feb 2012 08:48:37 +0100 Subject: [master] cd2ce96 Allocate the vbo and http's out of the backend workspace to avoid wasting partial pages with likely parameter values. Message-ID: commit cd2ce96c4d4d6300fb44d526cf2fc0cc9a39db43 Author: Poul-Henning Kamp Date: Thu Feb 9 07:48:04 2012 +0000 Allocate the vbo and http's out of the backend workspace to avoid wasting partial pages with likely parameter values. diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 65791e8..d6074a7 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -40,8 +40,6 @@ static struct mempool *vbopool; -static volatile unsigned vbosize; - struct vbo { unsigned magic; #define VBO_MAGIC 0xde3d8223 @@ -51,27 +49,6 @@ struct vbo { struct busyobj bo; }; -static struct lock vbo_mtx; - -/*-------------------------------------------------------------------- - */ - -static void -vbo_size_calc(volatile unsigned *u) -{ - uint16_t nhttp; - ssize_t http_space; - - assert(cache_param->http_max_hdr < 65536); - nhttp = (uint16_t)cache_param->http_max_hdr; - - http_space = HTTP_estimate(nhttp); - - *u = sizeof(struct vbo) + - http_space * 2L + - cache_param->workspace_backend; -} - /*-------------------------------------------------------------------- */ @@ -79,10 +56,9 @@ void VBO_Init(void) { - vbopool = MPL_New("vbo", &cache_param->vbo_pool, &vbosize, - vbo_size_calc); + vbopool = MPL_New("vbo", &cache_param->vbo_pool, + &cache_param->workspace_backend, NULL); AN(vbopool); - Lck_New(&vbo_mtx, lck_busyobj); } /*-------------------------------------------------------------------- From phk at varnish-cache.org Thu Feb 9 07:49:15 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 09 Feb 2012 08:49:15 +0100 Subject: [master] 8c2fe8d Clarify that certain parameters are likely to be rounded to page-size by the operating system. Message-ID: commit 8c2fe8d056f11f53b3cfd37d52bda3b93ec075f4 Author: Poul-Henning Kamp Date: Thu Feb 9 07:48:53 2012 +0000 Clarify that certain parameters are likely to be rounded to page-size by the operating system. diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 8c7a668..87b57ec 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -695,12 +695,14 @@ static const struct parspec input_parspec[] = { "120", "seconds" }, { "workspace_client", tweak_bytes_u, &mgt_param.workspace_client, 3072, UINT_MAX, - "Bytes of HTTP protocol workspace for clients HTTP req/resp.", + "Bytes of HTTP protocol workspace for clients HTTP req/resp." + " If larger than 4k, use a multiple of 4k for VM efficiency.", DELAYED_EFFECT, "64k", "bytes" }, { "workspace_backend", tweak_bytes_u, &mgt_param.workspace_backend, 1024, UINT_MAX, - "Bytes of HTTP protocol workspace for backend HTTP req/resp.", + "Bytes of HTTP protocol workspace for backend HTTP req/resp." + " If larger than 4k, use a multiple of 4k for VM efficiency.", DELAYED_EFFECT, "64k", "bytes" }, { "workspace_thread", diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index b716937..a6f020c 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -66,7 +66,7 @@ tweak_thread_pool_min(struct cli *cli, const struct parspec *par, /*-------------------------------------------------------------------- * This is utterly ridiculous: POSIX does not guarantee that the * minimum thread stack size is a compile time constant. - * XXX: "32" is a magic marker for 32bit systems. + * XXX: "32bit" is a magic marker for 32bit systems. */ static void @@ -220,6 +220,7 @@ const struct parspec WRK_parspec[] = { { "thread_pool_stack", tweak_stack_size, &mgt_param.wthread_stacksize, 0, UINT_MAX, "Worker thread stack size.\n" + "This is likely rounded up to a multiple of 4k by the kernel.\n" "On 32bit systems you may need to tweak this down to fit " "many threads into the limited address space.\n", EXPERIMENTAL, From phk at varnish-cache.org Thu Feb 9 07:52:15 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 09 Feb 2012 08:52:15 +0100 Subject: [master] fc387c3 Eliminate the mempool poll function again, we don't need it anyway. Message-ID: commit fc387c38ed38ddf3748f26b558a3c2e3589921b4 Author: Poul-Henning Kamp Date: Thu Feb 9 07:51:52 2012 +0000 Eliminate the mempool poll function again, we don't need it anyway. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 8df9591..e376b66 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -889,15 +889,13 @@ int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, struct timespec *ts); #undef LOCK /* cache_mempool.c */ -typedef void mpl_poll_f(volatile unsigned *); void MPL_AssertSane(void *item); struct mempool * MPL_New(const char *name, volatile struct poolparam *pp, - volatile unsigned *cur_size, mpl_poll_f *poll_f); + volatile unsigned *cur_size); void MPL_Destroy(struct mempool **mpp); void *MPL_Get(struct mempool *mpl, unsigned *size); void MPL_Free(struct mempool *mpl, void *item); - /* cache_panic.c */ void PAN_Init(void); diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 2610b06..b683300 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -519,6 +519,6 @@ void VDI_Init(void) { - vbcpool = MPL_New("vbc", &cache_param->vbc_pool, &vbcps, NULL); + vbcpool = MPL_New("vbc", &cache_param->vbc_pool, &vbcps); AN(vbcpool); } diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index d6074a7..3a60bfd 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -57,7 +57,7 @@ VBO_Init(void) { vbopool = MPL_New("vbo", &cache_param->vbo_pool, - &cache_param->workspace_backend, NULL); + &cache_param->workspace_backend); AN(vbopool); } diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 4b8ed07..8906406 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -57,7 +57,6 @@ struct mempool { struct lock mtx; volatile struct poolparam *param; volatile unsigned *cur_size; - mpl_poll_f *poll_func; uint64_t live; struct VSC_C_mempool *vsc; unsigned n_pool; @@ -105,8 +104,6 @@ mpl_guard(void *priv) mpl_slp = 0.15; // random while (1) { VTIM_sleep(mpl_slp); - if (mpl->poll_func != NULL) - mpl->poll_func(mpl->cur_size); mpl_slp = 0.814; // random mpl->t_now = VTIM_real(); @@ -226,8 +223,7 @@ mpl_guard(void *priv) struct mempool * MPL_New(const char *name, - volatile struct poolparam *pp, - volatile unsigned *cur_size, mpl_poll_f *poll_f) + volatile struct poolparam *pp, volatile unsigned *cur_size) { struct mempool *mpl; @@ -236,9 +232,6 @@ MPL_New(const char *name, bprintf(mpl->name, "%s", name); mpl->param = pp; mpl->cur_size = cur_size; - mpl->poll_func = poll_f; - if (poll_f != NULL) - poll_f(mpl->cur_size); VTAILQ_INIT(&mpl->list); VTAILQ_INIT(&mpl->surplus); Lck_New(&mpl->mtx, lck_mempool); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 58ff960..07b5cfb 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -383,9 +383,9 @@ SES_NewPool(struct pool *wp, unsigned pool_no) pp->pool = wp; bprintf(nb, "req%u", pool_no); pp->mpl_req = MPL_New(nb, &cache_param->req_pool, - &cache_param->workspace_client, NULL); + &cache_param->workspace_client); bprintf(nb, "sess%u", pool_no); - pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &ses_size, NULL); + pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &ses_size); return (pp); } From phk at varnish-cache.org Thu Feb 9 07:58:32 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 09 Feb 2012 08:58:32 +0100 Subject: [master] c2a2576 Make sure to free workers cached busyobj when threads are reaped. Message-ID: commit c2a2576ca15d3bdbdf0b151383833332f0be1f22 Author: Poul-Henning Kamp Date: Thu Feb 9 07:58:04 2012 +0000 Make sure to free workers cached busyobj when threads are reaped. diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 32ad21d..c1d20e8 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -163,6 +163,8 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace, if (w->vcl != NULL) VCL_Rel(&w->vcl); AZ(pthread_cond_destroy(&w->cond)); + if (w->nvbo != NULL) + VBO_Free(&w->nvbo); HSH_Cleanup(w); WRK_SumStat(w); return (NULL); From phk at varnish-cache.org Mon Feb 13 09:19:05 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 10:19:05 +0100 Subject: [master] 21eb82b Rename variable to not confuse people on monday mornings. Message-ID: commit 21eb82b4a96e270e12d0aa8b9b95d2c1a31a7fc9 Author: Poul-Henning Kamp Date: Mon Feb 13 09:18:50 2012 +0000 Rename variable to not confuse people on monday mornings. diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index c1d20e8..98de83f 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -131,13 +131,13 @@ WRK_BgThread(pthread_t *thr, const char *name, bgthread_t *func, void *priv) /*--------------------------------------------------------------------*/ static void * -wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace, +wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace, unsigned siov) { struct worker *w, ww; uint32_t wlog[shm_workspace / 4]; /* XXX: can we trust these to be properly aligned ? */ - unsigned char ws[sess_workspace]; + unsigned char ws[thread_workspace]; struct iovec iov[siov]; THR_SetName("cache-worker"); @@ -152,7 +152,7 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace, w->wrw.ciov = siov; AZ(pthread_cond_init(&w->cond, NULL)); - WS_Init(w->aws, "wrk", ws, sess_workspace); + WS_Init(w->aws, "wrk", ws, thread_workspace); VSL(SLT_WorkThread, 0, "%p start", w); From tfheen at varnish-cache.org Mon Feb 13 09:34:23 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 13 Feb 2012 10:34:23 +0100 Subject: [master] 877f011 Wait a bit before trying to start/use varnishd again Message-ID: commit 877f011eda4a1c83f7b5f1fa7e537e16f752e63c Author: Rogier 'DocWilco' Mulhuijzen Date: Wed Jan 18 10:51:16 2012 +0100 Wait a bit before trying to start/use varnishd again diff --git a/bin/varnishtest/tests/p00007.vtc b/bin/varnishtest/tests/p00007.vtc index 78aa8fb..7dc2e68 100644 --- a/bin/varnishtest/tests/p00007.vtc +++ b/bin/varnishtest/tests/p00007.vtc @@ -53,6 +53,8 @@ varnish v1 -cliok "debug.persistent s0 dump" # Panic worker so second segment does not get closed varnish v1 -clierr 400 "debug.panic.worker" +delay 0.5 + # start again varnish v1 -start diff --git a/bin/varnishtest/tests/v00010.vtc b/bin/varnishtest/tests/v00010.vtc index 45dbc79..b44fc13 100644 --- a/bin/varnishtest/tests/v00010.vtc +++ b/bin/varnishtest/tests/v00010.vtc @@ -42,6 +42,8 @@ varnish v1 -cliok "start" varnish v1 -wait-running sema r1 sync 2 +delay 0.5 + client c1 { txreq -url "/" rxresp From tfheen at varnish-cache.org Mon Feb 13 09:34:23 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 13 Feb 2012 10:34:23 +0100 Subject: [master] 646d185 Fixup printf format on 32bit platforms Message-ID: commit 646d185e6bee723a848d315b9729b2997443135e Author: Rogier 'DocWilco' Mulhuijzen Date: Wed Jan 18 10:51:15 2012 +0100 Fixup printf format on 32bit platforms diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index c344f9c..e33be6c 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -163,14 +163,14 @@ WRW_Flush(struct worker *wrk) cache_param->send_timeout) { WSL(wrk, SLT_Debug, *wrw->wfd, "Hit total send timeout, " - "wrote = %ld/%ld; not retrying", + "wrote = %zd/%zd; not retrying", i, wrw->liov); i = -1; break; } WSL(wrk, SLT_Debug, *wrw->wfd, - "Hit send timeout, wrote = %ld/%ld; retrying", + "Hit send timeout, wrote = %zd/%zd; retrying", i, wrw->liov); wrw_prune(wrw, i); From tfheen at varnish-cache.org Mon Feb 13 09:34:23 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 13 Feb 2012 10:34:23 +0100 Subject: [master] 8a75838 Fix up some sess_workspace leftovers Message-ID: commit 8a758381848f885f9f39f963345697359bffc787 Author: Rogier 'DocWilco' Mulhuijzen Date: Wed Jan 18 10:51:14 2012 +0100 Fix up some sess_workspace leftovers Found by: Joakim Berg diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index cc918c1..6405cdd 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -406,7 +406,7 @@ main(int argc, char * const *argv) * Adjust default parameters for 32 bit systems to conserve * VM space. */ - MCF_ParamSet(cli, "sess_workspace", "16384"); + MCF_ParamSet(cli, "workspace_client", "16384"); cli_check(cli); MCF_ParamSet(cli, "thread_pool_workspace", "16384"); diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 87b57ec..ff523b1 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -725,8 +725,8 @@ static const struct parspec input_parspec[] = { "Maximum number of bytes of HTTP client request we will deal " "with. This is a limit on all bytes up to the double blank " "line which ends the HTTP request.\n" - "The memory for the request is allocated from the session " - "workspace (param: sess_workspace) and this parameter limits " + "The memory for the request is allocated from the client " + "workspace (param: workspace_client) and this parameter limits " "how much of that the request is allowed to take up.", 0, "32k", "bytes" }, @@ -744,8 +744,8 @@ static const struct parspec input_parspec[] = { "with. This is a limit on all bytes up to the double blank " "line which ends the HTTP request.\n" "The memory for the request is allocated from the worker " - "workspace (param: sess_workspace) and this parameter limits " - "how much of that the request is allowed to take up.", + "workspace (param: thread_pool_workspace) and this parameter " + "limits how much of that the request is allowed to take up.", 0, "32k", "bytes" }, { "http_max_hdr", tweak_uint, &mgt_param.http_max_hdr, 32, 65535, From tfheen at varnish-cache.org Mon Feb 13 09:48:03 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 13 Feb 2012 10:48:03 +0100 Subject: [master] d119819 32 bit default parameter adjustments Message-ID: commit d1198194c78d204f5eaa4bce3db0d46c1fce2e9d Author: Tollef Fog Heen Date: Mon Feb 13 10:47:04 2012 +0100 32 bit default parameter adjustments thread_pool_workspace is gone, adjust workspace_backend instead diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 6405cdd..e7f1a1c 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -409,7 +409,7 @@ main(int argc, char * const *argv) MCF_ParamSet(cli, "workspace_client", "16384"); cli_check(cli); - MCF_ParamSet(cli, "thread_pool_workspace", "16384"); + MCF_ParamSet(cli, "workspace_backend", "16384"); cli_check(cli); MCF_ParamSet(cli, "http_resp_size", "8192"); From tfheen at varnish-cache.org Mon Feb 13 09:50:57 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 13 Feb 2012 10:50:57 +0100 Subject: [master] b42a6d1 More 32 bit adjustments, now rename gzip_stack_buffer to gzip_buffer Message-ID: commit b42a6d17865d929f3b657d6e0e0516f59583a012 Author: Tollef Fog Heen Date: Mon Feb 13 10:50:54 2012 +0100 More 32 bit adjustments, now rename gzip_stack_buffer to gzip_buffer diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index e7f1a1c..a74fd17 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -421,7 +421,7 @@ main(int argc, char * const *argv) MCF_ParamSet(cli, "thread_pool_stack", "32bit"); cli_check(cli); - MCF_ParamSet(cli, "gzip_stack_buffer", "4096"); + MCF_ParamSet(cli, "gzip_buffer", "4096"); cli_check(cli); } From phk at varnish-cache.org Mon Feb 13 10:00:14 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 11:00:14 +0100 Subject: [master] 866b419 Fix a printf format issue with time_t Message-ID: commit 866b4195e0c0877d16d952949eca1d0ca02aba45 Author: Charlie Root Date: Mon Feb 13 09:59:23 2012 +0000 Fix a printf format issue with time_t diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c index 547061c..0de26b1 100644 --- a/lib/libvarnish/cli_serve.c +++ b/lib/libvarnish/cli_serve.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -107,7 +108,7 @@ VCLS_func_ping(struct cli *cli, const char * const *av, void *priv) (void)priv; (void)av; t = time(NULL); - VCLI_Out(cli, "PONG %ld 1.0", t); + VCLI_Out(cli, "PONG %jd 1.0", (intmax_t)t); } /*--------------------------------------------------------------------*/ From phk at varnish-cache.org Mon Feb 13 10:19:37 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 11:19:37 +0100 Subject: [master] fb3cc4b Make fmt_bytes take an uintmax_t Message-ID: commit fb3cc4b53a61b1ca404eb4885e09f497aee00998 Author: Poul-Henning Kamp Date: Mon Feb 13 10:19:26 2012 +0000 Make fmt_bytes take an uintmax_t diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index ff523b1..f32cc0e 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -283,7 +283,7 @@ tweak_uint(struct cli *cli, const struct parspec *par, const char *arg) /*--------------------------------------------------------------------*/ static void -fmt_bytes(struct cli *cli, ssize_t t) +fmt_bytes(struct cli *cli, uintmax_t t) { const char *p; @@ -298,7 +298,7 @@ fmt_bytes(struct cli *cli, ssize_t t) } t /= 1024; if (t & 0x0ff) { - VCLI_Out(cli, "%zu%c", t, *p); + VCLI_Out(cli, "%ju%c", t, *p); return; } } @@ -324,14 +324,14 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, } if ((uintmax_t)((ssize_t)r) != r || r > max) { VCLI_Out(cli, "Must be no more than "); - fmt_bytes(cli, (ssize_t)max); + fmt_bytes(cli, (uintmax_t)max); VCLI_Out(cli, "\n"); VCLI_SetResult(cli, CLIS_PARAM); return; } if (r < min) { VCLI_Out(cli, "Must be at least "); - fmt_bytes(cli, (ssize_t)min); + fmt_bytes(cli, (uintmax_t)min); VCLI_Out(cli, "\n"); VCLI_SetResult(cli, CLIS_PARAM); return; From phk at varnish-cache.org Mon Feb 13 10:22:44 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 11:22:44 +0100 Subject: [master] b600f1a Don't use HUGE_VAL to signify no upper limit, we run into infinity in conversions to uintmax_t. Use zero to disable upper limit check. Check separately for byte sizes larger than the architecture can do. Message-ID: commit b600f1a1ad5c59ac9e762e1e9530d78b2ef0ea1f Author: Poul-Henning Kamp Date: Mon Feb 13 10:21:56 2012 +0000 Don't use HUGE_VAL to signify no upper limit, we run into infinity in conversions to uintmax_t. Use zero to disable upper limit check. Check separately for byte sizes larger than the architecture can do. diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index f32cc0e..6c24e91 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -322,7 +322,13 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, VCLI_SetResult(cli, CLIS_PARAM); return; } - if ((uintmax_t)((ssize_t)r) != r || r > max) { + if ((uintmax_t)((ssize_t)r) != r) { + fmt_bytes(cli, (uintmax_t)max); + VCLI_Out(cli, " is too large for this architecture.\n"); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + if (max != 0. && r > max) { VCLI_Out(cli, "Must be no more than "); fmt_bytes(cli, (uintmax_t)max); VCLI_Out(cli, "\n"); @@ -859,7 +865,7 @@ static const struct parspec input_parspec[] = { "256m", "bytes" }, #ifdef SENDFILE_WORKS { "sendfile_threshold", - tweak_bytes, &mgt_param.sendfile_threshold, 0, HUGE_VAL, + tweak_bytes, &mgt_param.sendfile_threshold, 0, 0, "The minimum size of objects transmitted with sendfile.", EXPERIMENTAL, "1E", "bytes" }, @@ -1183,7 +1189,7 @@ static const struct parspec input_parspec[] = { "10000", ""}, { "vsl_space", tweak_bytes, - &mgt_param.vsl_space, 1024*1024, HUGE_VAL, + &mgt_param.vsl_space, 1024*1024, 0, "The amount of space to allocate for the VSL fifo buffer" " in the VSM memory segment." " If you make this too small, varnish{ncsa|log} etc will" @@ -1193,7 +1199,7 @@ static const struct parspec input_parspec[] = { "80M", "bytes"}, { "vsm_space", tweak_bytes, - &mgt_param.vsm_space, 1024*1024, HUGE_VAL, + &mgt_param.vsm_space, 1024*1024, 0, "The amount of space to allocate for stats counters" " in the VSM memory segment." " If you make this too small, some counters will be" From phk at varnish-cache.org Mon Feb 13 10:24:41 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 11:24:41 +0100 Subject: [master] 2e8ff87 Print out the right number in our diagnostics Message-ID: commit 2e8ff8776a536a302047881438f4aaca487fd51f Author: Poul-Henning Kamp Date: Mon Feb 13 10:24:29 2012 +0000 Print out the right number in our diagnostics diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 6c24e91..1abb273 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -323,7 +323,7 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, return; } if ((uintmax_t)((ssize_t)r) != r) { - fmt_bytes(cli, (uintmax_t)max); + fmt_bytes(cli, r); VCLI_Out(cli, " is too large for this architecture.\n"); VCLI_SetResult(cli, CLIS_PARAM); return; From phk at varnish-cache.org Mon Feb 13 11:08:32 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 12:08:32 +0100 Subject: [master] 23cffba Check that workspace_backend is big enough, rather than run on the mercy of mallocs rounding algorithm. Message-ID: commit 23cffba4d1fc94bb765c30c6271a52f52691689e Author: Poul-Henning Kamp Date: Mon Feb 13 11:07:55 2012 +0000 Check that workspace_backend is big enough, rather than run on the mercy of mallocs rounding algorithm. Fix overly optimistictest-case. diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 3a60bfd..0252d57 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -127,6 +127,11 @@ VBO_GetBusyObj(struct worker *wrk) p += httpsz; vbo->bo.beresp = HTTP_create(p, nhttp); p += httpsz; + if (p >= vbo->end) { + fprintf(stderr, "workspace_backend is at least %jd to small\n", + (p - vbo->end)); + assert (p < vbo->end); + } WS_Init(vbo->bo.ws, "bo", p, vbo->end - p); return (&vbo->bo); diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc index ff94c72..cecb009 100644 --- a/bin/varnishtest/tests/r01038.vtc +++ b/bin/varnishtest/tests/r01038.vtc @@ -45,7 +45,7 @@ server s1 { txresp -body "foo8" } -start -varnish v1 -arg "-p workspace_backend=1024" -vcl+backend { +varnish v1 -arg "-p workspace_backend=3072" -vcl+backend { sub vcl_fetch { set beresp.do_esi = true; } @@ -54,8 +54,11 @@ varnish v1 -arg "-p workspace_backend=1024" -vcl+backend { client c1 { txreq rxresp + expect resp.bodylen == 42 + txreq rxresp + expect resp.bodylen == 42 } -run varnish v1 -expect losthdr == 0 From phk at varnish-cache.org Mon Feb 13 11:43:17 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 12:43:17 +0100 Subject: [master] d3f869a Remove sendfile(2) support, it doesn't seem to actually make any difference in practice and complicates the code and increases the size of storage data structures. Message-ID: commit d3f869a0fded126050564b4244d0fbb22bfe22b4 Author: Poul-Henning Kamp Date: Mon Feb 13 11:42:31 2012 +0000 Remove sendfile(2) support, it doesn't seem to actually make any difference in practice and complicates the code and increases the size of storage data structures. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e376b66..3fafda1 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -371,10 +371,6 @@ struct storage { unsigned magic; #define STORAGE_MAGIC 0x1a4e51c0 -#ifdef SENDFILE_WORKS - int fd; - off_t where; -#endif VTAILQ_ENTRY(storage) list; struct stevedore *stevedore; @@ -916,9 +912,6 @@ unsigned WRW_Flush(struct worker *w); unsigned WRW_FlushRelease(struct worker *w); unsigned WRW_Write(struct worker *w, const void *ptr, int len); unsigned WRW_WriteH(struct worker *w, const txt *hh, const char *suf); -#ifdef SENDFILE_WORKS -void WRW_Sendfile(struct worker *w, int fd, off_t off, unsigned len); -#endif /* SENDFILE_WORKS */ /* cache_session.c [SES] */ struct sess *SES_Alloc(void); diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 6c48468..2b22829 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -220,20 +220,6 @@ res_WriteDirObj(const struct sess *sp, ssize_t low, ssize_t high) ptr += len; sp->wrk->acct_tmp.bodybytes += len; -#ifdef SENDFILE_WORKS - /* - * XXX: the overhead of setting up sendfile is not - * XXX: epsilon and maybe not even delta, so avoid - * XXX: engaging sendfile for small objects. - * XXX: Should use getpagesize() ? - */ - if (st->fd >= 0 && - st->len >= cache_param->sendfile_threshold) { - VSC_C_main->n_objsendfile++; - WRW_Sendfile(sp->wrk, st->fd, st->where + off, len); - continue; - } -#endif /* SENDFILE_WORKS */ VSC_C_main->n_objwrite++; (void)WRW_Write(sp->wrk, st->ptr + off, len); } diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index e33be6c..4f9bbc5 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -35,17 +35,6 @@ #include "config.h" #include -#ifdef SENDFILE_WORKS -# if defined(__FreeBSD__) || defined(__DragonFly__) -# include -# elif defined(__linux__) -# include -# elif defined(__sun) -# include -# else -# error Unknown sendfile() implementation -# endif -#endif /* SENDFILE_WORKS */ #include #include @@ -290,69 +279,4 @@ WRW_EndChunk(struct worker *wrk) } -#ifdef SENDFILE_WORKS -void -WRW_Sendfile(struct worker *wrk, int fd, off_t off, unsigned len) -{ - struct wrw *wrw; - - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; - AN(wrw->wfd); - assert(fd >= 0); - assert(len > 0); - -#if defined(__FreeBSD__) || defined(__DragonFly__) - do { - struct sf_hdtr sfh; - memset(&sfh, 0, sizeof sfh); - if (wrw->niov > 0) { - sfh.headers = wrw->iov; - sfh.hdr_cnt = wrw->niov; - } - if (sendfile(fd, *wrw->wfd, off, len, &sfh, NULL, 0) != 0) - wrw->werr++; - wrw->liov = 0; - wrw->niov = 0; - } while (0); -#elif defined(__linux__) - do { - if (WRW_Flush(wrk) == 0 && - sendfile(*wrw->wfd, fd, &off, len) != len) - wrw->werr++; - } while (0); -#elif defined(__sun) && defined(HAVE_SENDFILEV) - do { - sendfilevec_t svvec[cache_param->http_headers * 2 + 1]; - size_t xferred = 0, expected = 0; - int i; - for (i = 0; i < wrw->niov; i++) { - svvec[i].sfv_fd = SFV_FD_SELF; - svvec[i].sfv_flag = 0; - svvec[i].sfv_off = (off_t) wrw->iov[i].iov_base; - svvec[i].sfv_len = wrw->iov[i].iov_len; - expected += svvec[i].sfv_len; - } - svvec[i].sfv_fd = fd; - svvec[i].sfv_flag = 0; - svvec[i].sfv_off = off; - svvec[i].sfv_len = len; - expected += svvec[i].sfv_len; - if (sendfilev(*wrw->wfd, svvec, i, &xferred) == -1 || - xferred != expected) - wrw->werr++; - wrw->liov = 0; - wrw->niov = 0; - } while (0); -#elif defined(__sun) && defined(HAVE_SENDFILE) - do { - if (WRW_Flush(wrk) == 0 && - sendfile(*wrw->wfd, fd, &off, len) != len) - wrw->werr++; - } while (0); -#else -#error Unknown sendfile() implementation -#endif -} -#endif /* SENDFILE_WORKS */ diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 1e51656..7694435 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -102,10 +102,6 @@ struct params { ssize_t fetch_maxchunksize; unsigned nuke_limit; -#ifdef SENDFILE_WORKS - /* Sendfile object minimum size */ - ssize_t sendfile_threshold; -#endif /* VCL traces */ unsigned vcl_trace; diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 1abb273..97492ed 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -863,13 +863,6 @@ static const struct parspec input_parspec[] = { "fragmentation.\n", EXPERIMENTAL, "256m", "bytes" }, -#ifdef SENDFILE_WORKS - { "sendfile_threshold", - tweak_bytes, &mgt_param.sendfile_threshold, 0, 0, - "The minimum size of objects transmitted with sendfile.", - EXPERIMENTAL, - "1E", "bytes" }, -#endif /* SENDFILE_WORKS */ { "vcl_trace", tweak_bool, &mgt_param.vcl_trace, 0, 0, "Trace VCL execution in the shmlog.\n" "Enabling this will allow you to see the path each " diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 9eb44d9..680b870 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -482,10 +482,6 @@ smf_alloc(struct stevedore *st, size_t size) smf->s.ptr = smf->ptr; smf->s.len = 0; smf->s.stevedore = st; -#ifdef SENDFILE_WORKS - smf->s.fd = smf->sc->fd; - smf->s.where = smf->offset; -#endif return (&smf->s); } diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c index 156c832..2f34c98 100644 --- a/bin/varnishd/storage/storage_malloc.c +++ b/bin/varnishd/storage/storage_malloc.c @@ -117,9 +117,6 @@ sma_alloc(struct stevedore *st, size_t size) sma->s.priv = sma; sma->s.len = 0; sma->s.space = size; -#ifdef SENDFILE_WORKS - sma->s.fd = -1; -#endif sma->s.stevedore = st; sma->s.magic = STORAGE_MAGIC; return (&sma->s); diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index f90594e..ff01838 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -450,9 +450,6 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size, ss->space = max_size; ss->priv = sc; ss->stevedore = st; -#ifdef SENDFILE_WORKS - ss->fd = sc->fd; -#endif if (ssg != NULL) *ssg = sg; return (ss); diff --git a/bin/varnishd/storage/storage_synth.c b/bin/varnishd/storage/storage_synth.c index e9e9b2f..ba3fa24 100644 --- a/bin/varnishd/storage/storage_synth.c +++ b/bin/varnishd/storage/storage_synth.c @@ -87,9 +87,6 @@ SMS_Makesynth(struct object *obj) sto->priv = vsb; sto->len = 0; sto->space = 0; -#ifdef SENDFILE_WORKS - sto->fd = -1; -#endif sto->stevedore = &sms_stevedore; sto->magic = STORAGE_MAGIC; diff --git a/configure.ac b/configure.ac index 72d2b7c..952b71b 100644 --- a/configure.ac +++ b/configure.ac @@ -198,40 +198,6 @@ AC_CHECK_FUNCS([pthread_mutex_isowned_np]) AC_CHECK_FUNCS([pthread_timedjoin_np]) LIBS="${save_LIBS}" -# sendfile is tricky: there are multiple versions, and most of them -# don't work. -case $target in -*-*-freebsd*) - AC_CACHE_CHECK([whether sendfile works], - [ac_cv_so_sendfile_works], - [AC_RUN_IFELSE( - [AC_LANG_PROGRAM([[ - #include - #include - #include - ]],[[ - return (SF_SYNC == 0); - ]])], - [ac_cv_so_sendfile_works=yes], - [ac_cv_so_sendfile_works=no]) - ]) - ;; -#*-*-solaris*) -# save_LIBS="${LIBS}" -# LIBS="${NET_LIBS}" -# AC_CHECK_LIB(sendfile, sendfile) -# AC_CHECK_FUNCS([sendfile]) -# AC_CHECK_FUNCS([sendfilev]) -# NET_LIBS="${LIBS}" -# LIBS="${save_LIBS}" -*) - AC_MSG_WARN([won't look for sendfile() on $target]) - ;; -esac -if test "$ac_cv_so_sendfile_works" = yes; then - AC_DEFINE([SENDFILE_WORKS], [1], [Define if SENDFILE works]) -fi - # Support for visibility attribute save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS} -Werror" From phk at varnish-cache.org Mon Feb 13 12:17:13 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 13:17:13 +0100 Subject: [master] 7ec9794 Move res_mode from worker to req Message-ID: commit 7ec9794e3679f4313e9d5c630665b2e34d28030d Author: Poul-Henning Kamp Date: Mon Feb 13 12:17:00 2012 +0000 Move res_mode from worker to req diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 3fafda1..162cbe9 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -343,15 +343,6 @@ struct worker { double first_byte_timeout; double between_bytes_timeout; - /* Delivery mode */ - unsigned res_mode; -#define RES_LEN (1<<1) -#define RES_EOF (1<<2) -#define RES_CHUNKED (1<<3) -#define RES_ESI (1<<4) -#define RES_ESI_CHILD (1<<5) -#define RES_GUNZIP (1<<6) - /* Temporary accounting */ struct acct acct_tmp; }; @@ -626,6 +617,14 @@ struct req { ssize_t l_crc; uint32_t crc; + /* Delivery mode */ + unsigned res_mode; +#define RES_LEN (1<<1) +#define RES_EOF (1<<2) +#define RES_CHUNKED (1<<3) +#define RES_ESI (1<<4) +#define RES_ESI_CHILD (1<<5) +#define RES_GUNZIP (1<<6) }; diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 6692491..826e1d7 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -216,26 +216,26 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) AssertObjCorePassOrBusy(req->obj->objcore); } - wrk->res_mode = 0; + req->res_mode = 0; if (wrk->busyobj == NULL) - wrk->res_mode |= RES_LEN; + req->res_mode |= RES_LEN; if (wrk->busyobj != NULL && (wrk->busyobj->h_content_length != NULL || !wrk->busyobj->do_stream) && !wrk->busyobj->do_gzip && !wrk->busyobj->do_gunzip) - wrk->res_mode |= RES_LEN; + req->res_mode |= RES_LEN; if (!req->disable_esi && req->obj->esidata != NULL) { /* In ESI mode, we don't know the aggregate length */ - wrk->res_mode &= ~RES_LEN; - wrk->res_mode |= RES_ESI; + req->res_mode &= ~RES_LEN; + req->res_mode |= RES_ESI; } if (req->esi_level > 0) { - wrk->res_mode &= ~RES_LEN; - wrk->res_mode |= RES_ESI_CHILD; + req->res_mode &= ~RES_LEN; + req->res_mode |= RES_ESI_CHILD; } if (cache_param->http_gzip_support && req->obj->gziped && @@ -244,24 +244,24 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) * We don't know what it uncompresses to * XXX: we could cache that */ - wrk->res_mode &= ~RES_LEN; - wrk->res_mode |= RES_GUNZIP; + req->res_mode &= ~RES_LEN; + req->res_mode |= RES_GUNZIP; } - if (!(wrk->res_mode & (RES_LEN|RES_CHUNKED|RES_EOF))) { + if (!(req->res_mode & (RES_LEN|RES_CHUNKED|RES_EOF))) { if (req->obj->len == 0 && (wrk->busyobj == NULL || !wrk->busyobj->do_stream)) /* * If the object is empty, neither ESI nor GUNZIP * can make it any different size */ - wrk->res_mode |= RES_LEN; + req->res_mode |= RES_LEN; else if (!req->wantbody) { /* Nothing */ } else if (req->http->protover >= 11) { - wrk->res_mode |= RES_CHUNKED; + req->res_mode |= RES_CHUNKED; } else { - wrk->res_mode |= RES_EOF; + req->res_mode |= RES_EOF; req->doclose = "EOF mode"; } } diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 9747919..bfd6a8c 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -60,7 +60,7 @@ ved_include(struct sess *sp, const char *src, const char *host) obj = sp->req->obj; sp->req->obj = NULL; - res_mode = sp->wrk->res_mode; + res_mode = sp->req->res_mode; /* Reset request to status before we started messing with it */ HTTP_Copy(sp->req->http, sp->req->http0); @@ -107,14 +107,14 @@ ved_include(struct sess *sp, const char *src, const char *host) assert(sp->step == STP_DONE); sp->req->esi_level--; sp->req->obj = obj; - sp->wrk->res_mode = res_mode; + sp->req->res_mode = res_mode; /* Reset the workspace */ WS_Reset(sp->req->ws, sp_ws_wm); WS_Reset(w->aws, wrk_ws_wm); /* XXX ? */ WRW_Reserve(sp->wrk, &sp->fd); - if (sp->wrk->res_mode & RES_CHUNKED) + if (sp->req->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); } @@ -247,7 +247,7 @@ ESI_Deliver(struct sess *sp) * Only the top level document gets to decide this. */ sp->req->gzip_resp = 0; - if (isgzip && !(sp->wrk->res_mode & RES_GUNZIP)) { + if (isgzip && !(sp->req->res_mode & RES_GUNZIP)) { assert(sizeof gzip_hdr == 10); /* Send out the gzip header */ (void)WRW_Write(sp->wrk, gzip_hdr, 10); diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 2b22829..d560211 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -94,7 +94,7 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh) "Content-Range: bytes %jd-%jd/%jd", (intmax_t)low, (intmax_t)high, (intmax_t)req->obj->len); http_Unset(req->resp, H_Content_Length); - assert(sp->wrk->res_mode & RES_LEN); + assert(req->res_mode & RES_LEN); http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, "Content-Length: %jd", (intmax_t)(1 + high - low)); http_SetResp(req->resp, "HTTP/1.1", 206, "Partial Content"); @@ -119,7 +119,7 @@ RES_BuildHttp(const struct sess *sp) req->resp->logtag = HTTP_Tx; http_FilterResp(sp, req->obj->http, req->resp, 0); - if (!(sp->wrk->res_mode & RES_LEN)) { + if (!(req->res_mode & RES_LEN)) { http_Unset(req->resp, H_Content_Length); } else if (cache_param->http_range_support) { /* We only accept ranges if we know the length */ @@ -127,7 +127,7 @@ RES_BuildHttp(const struct sess *sp) "Accept-Ranges: bytes"); } - if (sp->wrk->res_mode & RES_CHUNKED) + if (req->res_mode & RES_CHUNKED) http_SetHeader(sp->wrk, sp->vsl_id, req->resp, "Transfer-Encoding: chunked"); @@ -260,8 +260,8 @@ RES_WriteObj(struct sess *sp) high = req->obj->len - 1; if ( req->wantbody && - (sp->wrk->res_mode & RES_LEN) && - !(sp->wrk->res_mode & (RES_ESI|RES_ESI_CHILD|RES_GUNZIP)) && + (req->res_mode & RES_LEN) && + !(req->res_mode & (RES_ESI|RES_ESI_CHILD|RES_GUNZIP)) && cache_param->http_range_support && req->obj->response == 200 && http_GetHdr(req->http, H_Range, &r)) @@ -270,41 +270,41 @@ RES_WriteObj(struct sess *sp) /* * Always remove C-E if client don't grok it */ - if (sp->wrk->res_mode & RES_GUNZIP) + if (req->res_mode & RES_GUNZIP) http_Unset(req->resp, H_Content_Encoding); /* * Send HTTP protocol header, unless interior ESI object */ - if (!(sp->wrk->res_mode & RES_ESI_CHILD)) + if (!(req->res_mode & RES_ESI_CHILD)) sp->wrk->acct_tmp.hdrbytes += http_Write(sp->wrk, sp->vsl_id, req->resp, 1); if (!req->wantbody) - sp->wrk->res_mode &= ~RES_CHUNKED; + req->res_mode &= ~RES_CHUNKED; - if (sp->wrk->res_mode & RES_CHUNKED) + if (req->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); if (!req->wantbody) { /* This was a HEAD or conditional request */ } else if (req->obj->len == 0) { /* Nothing to do here */ - } else if (sp->wrk->res_mode & RES_ESI) { + } else if (req->res_mode & RES_ESI) { ESI_Deliver(sp); - } else if (sp->wrk->res_mode & RES_ESI_CHILD && req->gzip_resp) { + } else if (req->res_mode & RES_ESI_CHILD && req->gzip_resp) { ESI_DeliverChild(sp); - } else if (sp->wrk->res_mode & RES_ESI_CHILD && + } else if (req->res_mode & RES_ESI_CHILD && !req->gzip_resp && req->obj->gziped) { res_WriteGunzipObj(sp); - } else if (sp->wrk->res_mode & RES_GUNZIP) { + } else if (req->res_mode & RES_GUNZIP) { res_WriteGunzipObj(sp); } else { res_WriteDirObj(sp, low, high); } - if (sp->wrk->res_mode & RES_CHUNKED && - !(sp->wrk->res_mode & RES_ESI_CHILD)) + if (req->res_mode & RES_CHUNKED && + !(req->res_mode & RES_ESI_CHILD)) WRW_EndChunk(sp->wrk); if (WRW_FlushRelease(sp->wrk) && sp->fd >= 0) @@ -321,18 +321,18 @@ RES_StreamStart(struct sess *sp) sctx = sp->wrk->sctx; CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); - AZ(sp->wrk->res_mode & RES_ESI_CHILD); + AZ(sp->req->res_mode & RES_ESI_CHILD); AN(sp->req->wantbody); WRW_Reserve(sp->wrk, &sp->fd); - if (sp->wrk->res_mode & RES_GUNZIP) { + if (sp->req->res_mode & RES_GUNZIP) { sctx->vgz = VGZ_NewUngzip(sp->wrk, "U S -"); AZ(VGZ_WrwInit(sctx->vgz)); http_Unset(sp->req->resp, H_Content_Encoding); } - if (!(sp->wrk->res_mode & RES_CHUNKED) && + if (!(sp->req->res_mode & RES_CHUNKED) && sp->wrk->busyobj->h_content_length != NULL) http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp, "Content-Length: %s", sp->wrk->busyobj->h_content_length); @@ -340,7 +340,7 @@ RES_StreamStart(struct sess *sp) sp->wrk->acct_tmp.hdrbytes += http_Write(sp->wrk, sp->vsl_id, sp->req->resp, 1); - if (sp->wrk->res_mode & RES_CHUNKED) + if (sp->req->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); } @@ -367,7 +367,7 @@ RES_StreamPoll(struct worker *wrk) } l2 = st->len + l - sctx->stream_next; ptr = st->ptr + (sctx->stream_next - l); - if (wrk->res_mode & RES_GUNZIP) { + if (wrk->sp->req->res_mode & RES_GUNZIP) { (void)VGZ_WrwGunzip(wrk, sctx->vgz, ptr, l2); } else { (void)WRW_Write(wrk, ptr, l2); @@ -375,7 +375,7 @@ RES_StreamPoll(struct worker *wrk) l += st->len; sctx->stream_next += l2; } - if (!(wrk->res_mode & RES_GUNZIP)) + if (!(wrk->sp->req->res_mode & RES_GUNZIP)) (void)WRW_Flush(wrk); if (wrk->busyobj->fetch_obj->objcore == NULL || @@ -404,13 +404,13 @@ RES_StreamEnd(struct sess *sp) sctx = sp->wrk->sctx; CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); - if (sp->wrk->res_mode & RES_GUNZIP) { + if (sp->req->res_mode & RES_GUNZIP) { AN(sctx->vgz); VGZ_WrwFlush(sp->wrk, sctx->vgz); (void)VGZ_Destroy(&sctx->vgz, sp->vsl_id); } - if (sp->wrk->res_mode & RES_CHUNKED && - !(sp->wrk->res_mode & RES_ESI_CHILD)) + if (sp->req->res_mode & RES_CHUNKED && + !(sp->req->res_mode & RES_ESI_CHILD)) WRW_EndChunk(sp->wrk); if (WRW_FlushRelease(sp->wrk)) SES_Close(sp, "remote closed"); diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 1942c63..15f91df 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -165,3 +165,4 @@ -e712 // 96 Loss of precision (___) (___ to ___) -e747 // 297 Significant prototype coercion (___) ___ to ___ -e840 // Use of nul character in a string literal (see: vcc_if.c) +-e663 // Suspicious array to pointer conversion From phk at varnish-cache.org Mon Feb 13 12:53:05 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 13:53:05 +0100 Subject: [master] 73b465a Integrate stream_ctx in struct req Message-ID: commit 73b465a073968e22ed13c448178594515ac3a6d9 Author: Poul-Henning Kamp Date: Mon Feb 13 12:52:49 2012 +0000 Integrate stream_ctx in struct req diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 162cbe9..e76b0de 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -257,21 +257,6 @@ struct wrw { /*--------------------------------------------------------------------*/ -struct stream_ctx { - unsigned magic; -#define STREAM_CTX_MAGIC 0x8213728b - - struct vgz *vgz; - - /* Next byte we will take from storage */ - ssize_t stream_next; - - /* First byte of storage if we free it as we go (pass) */ - ssize_t stream_front; -}; - -/*--------------------------------------------------------------------*/ - struct wrk_accept { unsigned magic; #define WRK_ACCEPT_MAGIC 0x8c4b4d59 @@ -335,9 +320,6 @@ struct worker { struct busyobj *busyobj; - /* Stream state */ - struct stream_ctx *sctx; - /* Timeouts */ double connect_timeout; double first_byte_timeout; @@ -626,6 +608,15 @@ struct req { #define RES_ESI_CHILD (1<<5) #define RES_GUNZIP (1<<6) + /* Stream gunzip instance */ + struct vgz *stream_vgz; + + /* Next byte we will take from storage */ + ssize_t stream_next; + + /* First byte of storage if we free it as we go (pass) */ + ssize_t stream_front; + }; /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 826e1d7..fca55b0 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -940,17 +940,12 @@ static int cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) { int i; - struct stream_ctx sctx; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - memset(&sctx, 0, sizeof sctx); - sctx.magic = STREAM_CTX_MAGIC; - AZ(wrk->sctx); - wrk->sctx = &sctx; RES_StreamStart(sp); @@ -978,7 +973,6 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) RES_StreamEnd(sp); - wrk->sctx = NULL; assert(WRW_IsReleased(wrk)); assert(wrk->wrw.ciov == wrk->wrw.siov); (void)HSH_Deref(wrk, NULL, &req->obj); diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index d560211..5e4cab6 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -316,23 +316,26 @@ RES_WriteObj(struct sess *sp) void RES_StreamStart(struct sess *sp) { - struct stream_ctx *sctx; + struct req *req; - sctx = sp->wrk->sctx; - CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); + req = sp->req; + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - AZ(sp->req->res_mode & RES_ESI_CHILD); - AN(sp->req->wantbody); + AZ(req->res_mode & RES_ESI_CHILD); + AN(req->wantbody); + AZ(req->stream_vgz); + AZ(req->stream_next); + AZ(req->stream_front); WRW_Reserve(sp->wrk, &sp->fd); - if (sp->req->res_mode & RES_GUNZIP) { - sctx->vgz = VGZ_NewUngzip(sp->wrk, "U S -"); - AZ(VGZ_WrwInit(sctx->vgz)); - http_Unset(sp->req->resp, H_Content_Encoding); + if (req->res_mode & RES_GUNZIP) { + req->stream_vgz = VGZ_NewUngzip(sp->wrk, "U S -"); + AZ(VGZ_WrwInit(req->stream_vgz)); + http_Unset(req->resp, H_Content_Encoding); } - if (!(sp->req->res_mode & RES_CHUNKED) && + if (!(req->res_mode & RES_CHUNKED) && sp->wrk->busyobj->h_content_length != NULL) http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp, "Content-Length: %s", sp->wrk->busyobj->h_content_length); @@ -340,57 +343,59 @@ RES_StreamStart(struct sess *sp) sp->wrk->acct_tmp.hdrbytes += http_Write(sp->wrk, sp->vsl_id, sp->req->resp, 1); - if (sp->req->res_mode & RES_CHUNKED) + if (req->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); } void RES_StreamPoll(struct worker *wrk) { - struct stream_ctx *sctx; struct storage *st; + struct busyobj *bo; + struct req *req; ssize_t l, l2; void *ptr; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj->fetch_obj, OBJECT_MAGIC); - sctx = wrk->sctx; - CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); - if (wrk->busyobj->fetch_obj->len == sctx->stream_next) + bo = wrk->busyobj; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo->fetch_obj, OBJECT_MAGIC); + req = wrk->sp->req; + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + if (bo->fetch_obj->len == req->stream_next) return; - assert(wrk->busyobj->fetch_obj->len > sctx->stream_next); - l = sctx->stream_front; - VTAILQ_FOREACH(st, &wrk->busyobj->fetch_obj->store, list) { - if (st->len + l <= sctx->stream_next) { + assert(bo->fetch_obj->len > req->stream_next); + l = req->stream_front; + VTAILQ_FOREACH(st, &bo->fetch_obj->store, list) { + if (st->len + l <= req->stream_next) { l += st->len; continue; } - l2 = st->len + l - sctx->stream_next; - ptr = st->ptr + (sctx->stream_next - l); - if (wrk->sp->req->res_mode & RES_GUNZIP) { - (void)VGZ_WrwGunzip(wrk, sctx->vgz, ptr, l2); - } else { + l2 = st->len + l - req->stream_next; + ptr = st->ptr + (req->stream_next - l); + if (wrk->sp->req->res_mode & RES_GUNZIP) + (void)VGZ_WrwGunzip(wrk, req->stream_vgz, ptr, l2); + else (void)WRW_Write(wrk, ptr, l2); - } l += st->len; - sctx->stream_next += l2; + req->stream_next += l2; } if (!(wrk->sp->req->res_mode & RES_GUNZIP)) (void)WRW_Flush(wrk); - if (wrk->busyobj->fetch_obj->objcore == NULL || - (wrk->busyobj->fetch_obj->objcore->flags & OC_F_PASS)) { + if (bo->fetch_obj->objcore == NULL || + (bo->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(&wrk->busyobj->fetch_obj->store); + st = VTAILQ_FIRST(&bo->fetch_obj->store); if (st == NULL || - sctx->stream_front + st->len > sctx->stream_next) + req->stream_front + st->len > req->stream_next) break; - VTAILQ_REMOVE(&wrk->busyobj->fetch_obj->store, st, list); - sctx->stream_front += st->len; + VTAILQ_REMOVE(&bo->fetch_obj->store, st, list); + req->stream_front += st->len; STV_free(st); } } @@ -399,19 +404,21 @@ RES_StreamPoll(struct worker *wrk) void RES_StreamEnd(struct sess *sp) { - struct stream_ctx *sctx; + struct req *req; - sctx = sp->wrk->sctx; - CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); + req = sp->req; + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (sp->req->res_mode & RES_GUNZIP) { - AN(sctx->vgz); - VGZ_WrwFlush(sp->wrk, sctx->vgz); - (void)VGZ_Destroy(&sctx->vgz, sp->vsl_id); + 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); } - if (sp->req->res_mode & RES_CHUNKED && - !(sp->req->res_mode & RES_ESI_CHILD)) + if (req->res_mode & RES_CHUNKED && !(req->res_mode & RES_ESI_CHILD)) WRW_EndChunk(sp->wrk); if (WRW_FlushRelease(sp->wrk)) SES_Close(sp, "remote closed"); + req->stream_vgz = NULL; + req->stream_next = 0; + req->stream_front = 0; } From martin at varnish-cache.org Mon Feb 13 13:13:44 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Mon, 13 Feb 2012 14:13:44 +0100 Subject: [master] ab47f76 Move VCL-controlled backend timeouts from struct worker to busyobj Message-ID: commit ab47f76a79c82f615fb3f964db61f1ecbfdf87e5 Author: Martin Blix Grydeland Date: Mon Feb 13 13:49:11 2012 +0100 Move VCL-controlled backend timeouts from struct worker to busyobj diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e76b0de..1371d48 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -320,11 +320,6 @@ struct worker { struct busyobj *busyobj; - /* Timeouts */ - double connect_timeout; - double first_byte_timeout; - double between_bytes_timeout; - /* Temporary accounting */ struct acct acct_tmp; }; @@ -494,6 +489,11 @@ struct busyobj { unsigned do_gunzip; unsigned do_stream; unsigned do_pass; + + /* Timeouts */ + double connect_timeout; + double first_byte_timeout; + double between_bytes_timeout; }; /* Object structure --------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index b683300..039300b 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -89,13 +89,14 @@ VBE_ReleaseConn(struct vbc *vc) MPL_Free(vbcpool, vc); } -#define FIND_TMO(tmx, dst, sp, be) \ - do { \ - dst = sp->wrk->tmx; \ - if (dst == 0.0) \ - dst = be->tmx; \ - if (dst == 0.0) \ - dst = cache_param->tmx; \ +#define FIND_TMO(tmx, dst, sp, be) \ + do { \ + CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); \ + dst = sp->wrk->busyobj->tmx; \ + if (dst == 0.0) \ + dst = be->tmx; \ + if (dst == 0.0) \ + dst = cache_param->tmx; \ } while (0) /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index fca55b0..137f198 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -1418,10 +1418,6 @@ cnt_recv(struct sess *sp, struct worker *wrk, struct req *req) req->director = req->vcl->director[0]; AN(req->director); - wrk->connect_timeout = 0; - wrk->first_byte_timeout = 0; - wrk->between_bytes_timeout = 0; - req->disable_esi = 0; req->hash_always_miss = 0; req->hash_ignore_busy = 0; diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index ec067a2..cc7fb5b 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -236,7 +236,8 @@ VRT_l_bereq_##which(struct sess *sp, double num) \ { \ \ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ - sp->wrk->which = (num > 0.0 ? num : 0.0); \ + CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); \ + sp->wrk->busyobj->which = (num > 0.0 ? num : 0.0); \ } \ \ double __match_proto__() \ @@ -244,7 +245,8 @@ VRT_r_bereq_##which(struct sess *sp) \ { \ \ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ - return(sp->wrk->which); \ + CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); \ + return(sp->wrk->busyobj->which); \ } BEREQ_TIMEOUT(connect_timeout) From phk at varnish-cache.org Mon Feb 13 20:31:29 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 21:31:29 +0100 Subject: [master] ffea64d Shave 256 bytes of the worker thread footprint, by using the thread workspace for WRW also. Message-ID: commit ffea64d751612a6584fd21f0d39a9574c55d18dd Author: Poul-Henning Kamp Date: Mon Feb 13 20:30:48 2012 +0000 Shave 256 bytes of the worker thread footprint, by using the thread workspace for WRW also. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 1371d48..4b1bfc3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -114,6 +114,7 @@ struct vrt_backend; struct vsb; struct waitinglist; struct worker; +struct wrw; #define DIGEST_LEN 32 @@ -244,19 +245,6 @@ struct exp { /*--------------------------------------------------------------------*/ -struct wrw { - int *wfd; - unsigned werr; /* valid after WRW_Flush() */ - struct iovec *iov; - unsigned siov; - unsigned niov; - ssize_t liov; - ssize_t cliov; - unsigned ciov; /* Chunked header marker */ -}; - -/*--------------------------------------------------------------------*/ - struct wrk_accept { unsigned magic; #define WRK_ACCEPT_MAGIC 0x8c4b4d59 @@ -301,7 +289,7 @@ struct worker { double lastused; - struct wrw wrw; + struct wrw *wrw; pthread_cond_t cond; @@ -312,10 +300,6 @@ struct worker { uint32_t *wlb, *wlp, *wle; unsigned wlr; - /* - * In practice this workspace is only used for wrk_accept now - * but it might come handy later, so keep it around. For now. - */ struct ws aws[1]; struct busyobj *busyobj; @@ -893,7 +877,7 @@ void Pool_Init(void); void Pool_Work_Thread(void *priv, struct worker *w); int Pool_Task(struct pool *pp, struct pool_task *task, enum pool_how how); -#define WRW_IsReleased(w) ((w)->wrw.wfd == NULL) +#define WRW_IsReleased(w) ((w)->wrw == NULL) int WRW_Error(const struct worker *w); void WRW_Chunked(struct worker *w); void WRW_EndChunk(struct worker *w); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 137f198..345d0cf 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -338,7 +338,6 @@ cnt_deliver(struct sess *sp, struct worker *wrk, struct req *req) RES_WriteObj(sp); assert(WRW_IsReleased(wrk)); - assert(wrk->wrw.ciov == wrk->wrw.siov); (void)HSH_Deref(wrk, NULL, &req->obj); http_Setup(req->resp, NULL); sp->step = STP_DONE; @@ -974,7 +973,6 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) RES_StreamEnd(sp); assert(WRW_IsReleased(wrk)); - assert(wrk->wrw.ciov == wrk->wrw.siov); (void)HSH_Deref(wrk, NULL, &req->obj); VBO_DerefBusyObj(wrk, &wrk->busyobj); http_Setup(req->resp, NULL); @@ -1411,7 +1409,6 @@ cnt_recv(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->obj); AZ(wrk->busyobj); - assert(wrk->wrw.ciov == wrk->wrw.siov); /* By default we use the first backend */ AZ(req->director); diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c index dd76c91..a2927fa 100644 --- a/bin/varnishd/cache/cache_cli.c +++ b/bin/varnishd/cache/cache_cli.c @@ -138,7 +138,6 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv) SZOF(struct vbc); SZOF(struct VSC_C_main); SZOF(struct lock); - SZOF(struct wrw); SZOF(struct dstat); #if 0 #define OFOF(foo, bar) { foo __foo; VCLI_Out(cli, \ diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 07b5cfb..ea0668b 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -155,7 +155,7 @@ ses_pool_task(struct worker *wrk, void *arg) wrk->sp = NULL; WS_Assert(wrk->aws); AZ(wrk->busyobj); - AZ(wrk->wrw.wfd); + AZ(wrk->wrw); assert(wrk->wlp == wrk->wlb); if (cache_param->diag_bitmap & 0x00040000) { if (wrk->vcl != NULL) diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 98de83f..2f0b575 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -131,14 +131,11 @@ WRK_BgThread(pthread_t *thr, const char *name, bgthread_t *func, void *priv) /*--------------------------------------------------------------------*/ static void * -wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace, - unsigned siov) +wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace) { struct worker *w, ww; uint32_t wlog[shm_workspace / 4]; - /* XXX: can we trust these to be properly aligned ? */ unsigned char ws[thread_workspace]; - struct iovec iov[siov]; THR_SetName("cache-worker"); w = &ww; @@ -147,9 +144,6 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace, w->lastused = NAN; w->wlb = w->wlp = wlog; w->wle = wlog + (sizeof wlog) / 4; - w->wrw.iov = iov; - w->wrw.siov = siov; - w->wrw.ciov = siov; AZ(pthread_cond_init(&w->cond, NULL)); WS_Init(w->aws, "wrk", ws, thread_workspace); @@ -173,18 +167,10 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace, void * WRK_thread(void *priv) { - uint16_t nhttp; - unsigned siov; - - assert(cache_param->http_max_hdr <= 65535); - /* We need to snapshot these two for consistency */ - nhttp = (uint16_t)cache_param->http_max_hdr; - siov = nhttp * 2; - if (siov > IOV_MAX) - siov = IOV_MAX; + return (wrk_thread_real(priv, cache_param->shm_workspace, - cache_param->workspace_thread, siov)); + cache_param->workspace_thread)); } void diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index 4f9bbc5..2c0d7c3 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -42,6 +42,21 @@ #include "cache.h" #include "vtim.h" +/*--------------------------------------------------------------------*/ + +struct wrw { + unsigned magic; +#define WRW_MAGIC 0x2f2142e5 + int *wfd; + unsigned werr; /* valid after WRW_Flush() */ + struct iovec *iov; + unsigned siov; + unsigned niov; + ssize_t liov; + ssize_t cliov; + unsigned ciov; /* Chunked header marker */ +}; + /*-------------------------------------------------------------------- */ @@ -49,22 +64,32 @@ int WRW_Error(const struct worker *wrk) { - return (wrk->wrw.werr); + return (wrk->wrw->werr); } void WRW_Reserve(struct worker *wrk, int *fd) { struct wrw *wrw; + unsigned u; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; - AZ(wrw->wfd); + AZ(wrk->wrw); + wrw = (void*)WS_Alloc(wrk->aws, sizeof *wrw); + AN(wrw); + memset(wrw, 0, sizeof *wrw); + wrw->magic = WRW_MAGIC; + u = WS_Reserve(wrk->aws, 0); + u /= sizeof(struct iovec); + AN(u); + wrw->iov = (void*)wrk->aws->f; + wrw->siov = u; + wrw->ciov = u; wrw->werr = 0; wrw->liov = 0; wrw->niov = 0; - wrw->ciov = wrw->siov; wrw->wfd = fd; + wrk->wrw = wrw; } static void @@ -73,13 +98,11 @@ WRW_Release(struct worker *wrk) struct wrw *wrw; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; - AN(wrw->wfd); - wrw->werr = 0; - wrw->liov = 0; - wrw->niov = 0; - wrw->ciov = wrw->siov; - wrw->wfd = NULL; + wrw = wrk->wrw; + wrk->wrw = NULL; + CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC); + WS_Release(wrk->aws, 0); + WS_Reset(wrk->aws, NULL); } static void @@ -114,7 +137,8 @@ WRW_Flush(struct worker *wrk) char cbuf[32]; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; + wrw = wrk->wrw; + CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC); AN(wrw->wfd); /* For chunked, there must be one slot reserved for the chunked tail */ @@ -186,7 +210,7 @@ WRW_FlushRelease(struct worker *wrk) unsigned u; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - AN(wrk->wrw.wfd); + AN(wrk->wrw->wfd); u = WRW_Flush(wrk); WRW_Release(wrk); return (u); @@ -198,7 +222,7 @@ WRW_WriteH(struct worker *wrk, const txt *hh, const char *suf) unsigned u; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - AN(wrk->wrw.wfd); + AN(wrk->wrw->wfd); AN(wrk); AN(hh); AN(hh->b); @@ -215,7 +239,8 @@ WRW_Write(struct worker *wrk, const void *ptr, int len) struct wrw *wrw; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; + wrw = wrk->wrw; + CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC); AN(wrw->wfd); if (len == 0 || *wrw->wfd < 0) return (0); @@ -240,7 +265,8 @@ WRW_Chunked(struct worker *wrk) struct wrw *wrw; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; + wrw = wrk->wrw; + CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC); assert(wrw->ciov == wrw->siov); /* @@ -268,7 +294,8 @@ WRW_EndChunk(struct worker *wrk) struct wrw *wrw; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; + wrw = wrk->wrw; + CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC); assert(wrw->ciov < wrw->siov); (void)WRW_Flush(wrk); diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 97492ed..e2e1a3a 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -712,12 +712,16 @@ static const struct parspec input_parspec[] = { DELAYED_EFFECT, "64k", "bytes" }, { "workspace_thread", - tweak_bytes_u, &mgt_param.workspace_thread, 256, 256, - "Bytes of auxillary workspace per thread." - /* XXX: See comment in cache.h */ - "This is not the workspace you are looking for.", + tweak_bytes_u, &mgt_param.workspace_thread, 256, 8192, + "Bytes of auxillary workspace per thread.\n" + "This workspace is used for certain temporary data structures" + " during the operation of a worker thread.\n" + "One use is for the io-vectors for writing requests and" + " responses to sockets, having too little space will" + " result in more writev(2) system calls, having too much" + " just wastes the space.\n", DELAYED_EFFECT, - "256", "bytes" }, + "2048", "bytes" }, { "http_req_hdr_len", tweak_bytes_u, &mgt_param.http_req_hdr_len, 40, UINT_MAX, From phk at varnish-cache.org Mon Feb 13 21:18:13 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 22:18:13 +0100 Subject: [master] 1fd2741 Start abstracting the VSL handling a bit. Message-ID: commit 1fd274110b3247131461ab4632b8e00fa1db7ca4 Author: Poul-Henning Kamp Date: Mon Feb 13 21:17:59 2012 +0000 Start abstracting the VSL handling a bit. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 4b1bfc3..9a31cb4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -245,6 +245,13 @@ struct exp { /*--------------------------------------------------------------------*/ +struct vsl_log { + uint32_t *wlb, *wlp, *wle; + unsigned wlr; +}; + +/*--------------------------------------------------------------------*/ + struct wrk_accept { unsigned magic; #define WRK_ACCEPT_MAGIC 0x8c4b4d59 @@ -297,8 +304,7 @@ struct worker { struct VCL_conf *vcl; - uint32_t *wlb, *wlp, *wle; - unsigned wlr; + struct vsl_log vsl[1]; struct ws aws[1]; @@ -909,13 +915,13 @@ void VSM_Free(void *ptr); #ifdef VSL_ENDMARKER void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) __printflike(3, 4); -void WSLR(struct worker *w, enum VSL_tag_e tag, int id, txt t); -void WSL(struct worker *w, enum VSL_tag_e tag, int id, const char *fmt, ...) +void WSLR(struct vsl_log *, enum VSL_tag_e tag, int id, txt t); +void WSL(struct vsl_log *, enum VSL_tag_e tag, int id, const char *fmt, ...) __printflike(4, 5); -void WSLB(struct worker *w, enum VSL_tag_e tag, const char *fmt, ...) +void WSLB(struct worker *, enum VSL_tag_e tag, const char *fmt, ...) __printflike(3, 4); -void WSL_Flush(struct worker *w, int overflow); +void WSL_Flush(struct vsl_log *, int overflow); #define DSL(flag, tag, id, ...) \ do { \ @@ -924,10 +930,10 @@ void WSL_Flush(struct worker *w, int overflow); } while (0) #define WSP(sess, tag, ...) \ - WSL((sess)->wrk, tag, (sess)->vsl_id, __VA_ARGS__) + WSL((sess)->wrk->vsl, tag, (sess)->vsl_id, __VA_ARGS__) #define WSPR(sess, tag, txt) \ - WSLR((sess)->wrk, tag, (sess)->vsl_id, txt) + WSLR((sess)->wrk->vsl, tag, (sess)->vsl_id, txt) #define INCOMPL() do { \ VSL(SLT_Debug, 0, "INCOMPLETE AT: %s(%d)", __func__, __LINE__); \ diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 039300b..267e7ba 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -185,7 +185,7 @@ bes_conn_try(const struct sess *sp, struct vbc *vc, const struct vdi_simple *vs) } else { vc->vsl_id = s | VSL_BACKENDMARKER; VTCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1); - WSL(sp->wrk, SLT_BackendOpen, vc->vsl_id, "%s %s %s ", + WSL(sp->wrk->vsl, SLT_BackendOpen, vc->vsl_id, "%s %s %s ", vs->backend->display_name, abuf1, pbuf1); } @@ -356,12 +356,12 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs) return (vc); } VSC_C_main->backend_toolate++; - WSL(sp->wrk, SLT_BackendClose, vc->vsl_id, "%s", + WSL(sp->wrk->vsl, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name); /* Checkpoint log to flush all info related to this connection before the OS reuses the FD */ - WSL_Flush(sp->wrk, 0); + WSL_Flush(sp->wrk->vsl, 0); VTCP_close(&vc->fd); VBE_DropRefConn(bp); diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 451e504..6dc3618 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -954,7 +954,7 @@ ban_lurker(struct sess *sp, void *priv) } i = ban_lurker_work(sp, pass); - WSL_Flush(sp->wrk, 0); + WSL_Flush(sp->wrk->vsl, 0); WRK_SumStat(sp->wrk); if (i) { pass += (1 << LURK_SHIFT); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 345d0cf..0cb3a38 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -407,7 +407,7 @@ cnt_done(struct sess *sp, struct worker *wrk, struct req *req) req->xid, sp->t_req, sp->t_idle, dh, dp, da); } req->xid = 0; - WSL_Flush(wrk, 0); + WSL_Flush(wrk->vsl, 0); sp->t_req = NAN; req->t_resp = NAN; @@ -1592,7 +1592,7 @@ cnt_diag(struct sess *sp, const char *state) if (sp->wrk != NULL) { WSP(sp, SLT_Debug, "vsl_id %u STP_%s sp %p obj %p vcl %p", sp->vsl_id, state, sp, obj, vcl); - WSL_Flush(sp->wrk, 0); + WSL_Flush(sp->wrk->vsl, 0); } else { VSL(SLT_Debug, sp->vsl_id, "vsl_id %u STP_%s sp %p obj %p vcl %p", @@ -1673,7 +1673,7 @@ CNT_Session(struct sess *sp) WS_Assert(wrk->aws); CHECK_OBJ_ORNULL(wrk->nobjhead, OBJHEAD_MAGIC); } - WSL_Flush(wrk, 0); + WSL_Flush(wrk->vsl, 0); #define ACCT(foo) AZ(wrk->acct_tmp.foo); #include "tbl/acct_fields.h" #undef ACCT diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index 4ec81fb..53a3e50 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -55,11 +55,11 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp) bp = vc->backend; - WSL(wrk, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name); + WSL(wrk->vsl, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name); /* Checkpoint log to flush all info related to this connection before the OS reuses the FD */ - WSL_Flush(wrk, 0); + WSL_Flush(wrk->vsl, 0); VTCP_close(&vc->fd); VBE_DropRefConn(bp); @@ -85,12 +85,12 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp) bp = vc->backend; - WSL(wrk, SLT_BackendReuse, vc->vsl_id, "%s", bp->display_name); + WSL(wrk->vsl, SLT_BackendReuse, vc->vsl_id, "%s", bp->display_name); /* * Flush the shmlog, so that another session reusing this backend * will log chronologically later than our use of it. */ - WSL_Flush(wrk, 0); + WSL_Flush(wrk->vsl, 0); Lck_Lock(&bp->mtx); VSC_C_main->backend_recycle++; VTAILQ_INSERT_HEAD(&bp->connlist, vc, list); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index bfd6a8c..8ef35a3 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -98,7 +98,7 @@ ved_include(struct sess *sp, const char *src, const char *host) if (sp->step == STP_DONE) break; AZ(sp->wrk); - WSL_Flush(w, 0); + WSL_Flush(w->vsl, 0); DSL(0x20, SLT_Debug, sp->vsl_id, "loop waiting for ESI"); (void)usleep(10000); } diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index e93a1aa..1060bac 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -342,7 +342,7 @@ exp_timer(struct sess *sp, void *priv) oc = NULL; while (1) { if (oc == NULL) { - WSL_Flush(sp->wrk, 0); + WSL_Flush(sp->wrk->vsl, 0); WRK_SumStat(sp->wrk); VTIM_sleep(cache_param->expiry_sleep); t = VTIM_real(); @@ -400,7 +400,7 @@ exp_timer(struct sess *sp, void *priv) CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC); o = oc_getobj(sp->wrk, oc); - WSL(sp->wrk, SLT_ExpKill, 0, "%u %.0f", + WSL(sp->wrk->vsl, SLT_ExpKill, 0, "%u %.0f", oc_getxid(sp->wrk, oc), EXP_Ttl(NULL, o) - t); (void)HSH_Deref(sp->wrk, oc, NULL); } @@ -445,7 +445,7 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru) return (-1); /* XXX: bad idea for -spersistent */ - WSL(wrk, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc)); + WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc)); (void)HSH_Deref(wrk, oc, NULL); return (1); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index c4c0718..018c4f9 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -439,7 +439,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) } /* Checkpoint the vsl.here */ - WSL_Flush(wrk, 0); + WSL_Flush(wrk->vsl, 0); /* XXX is this the right place? */ VSC_C_main->backend_req++; diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 9d81f62..2ee1abf 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -407,7 +407,7 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id) (intmax_t)vg->vz.last_bit, (intmax_t)vg->vz.stop_bit); else - WSL(vg->wrk, SLT_Gzip, vsl_id, "%s %jd %jd %jd %jd %jd", + 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, diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index c8cb6cc..b330c67 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -612,7 +612,7 @@ HSH_Unbusy(struct worker *wrk) if (o->ws_o->overflow) wrk->stats.n_objoverflow++; if (cache_param->diag_bitmap & 0x40) - WSL(wrk, SLT_Debug, 0, + WSL(wrk->vsl, SLT_Debug, 0, "Object %u workspace free %u", o->xid, WS_Free(o->ws_o)); /* XXX: pretouch neighbors on oh->objcs to prevent page-on under mtx */ diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index cdf95f1..314c05f 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -77,7 +77,7 @@ WSLH(struct worker *w, unsigned vsl_id, const struct http *hp, unsigned hdr) { AN(vsl_id & (VSL_CLIENTMARKER|VSL_BACKENDMARKER)); - WSLR(w, http2shmlog(hp, hdr), vsl_id, hp->hd[hdr]); + WSLR(w->vsl, http2shmlog(hp, hdr), vsl_id, hp->hd[hdr]); } /*--------------------------------------------------------------------*/ @@ -519,7 +519,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, if (q - p > htc->maxhdr) { VSC_C_main->losthdr++; - WSL(w, SLT_LostHeader, vsl_id, "%.*s", + WSL(w->vsl, SLT_LostHeader, vsl_id, "%.*s", (int)(q - p > 20 ? 20 : q - p), p); return (413); } @@ -545,7 +545,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, hp->nhd++; } else { VSC_C_main->losthdr++; - WSL(w, SLT_LostHeader, vsl_id, "%.*s", + WSL(w->vsl, SLT_LostHeader, vsl_id, "%.*s", (int)(q - p > 20 ? 20 : q - p), p); return (413); } @@ -716,7 +716,7 @@ http_DissectResponse(struct worker *w, const struct http_conn *htc, } if (retval != 0) { - WSLR(w, SLT_HttpGarbage, htc->vsl_id, htc->rxbuf); + WSLR(w->vsl, SLT_HttpGarbage, htc->vsl_id, htc->rxbuf); assert(retval >= 100 && retval <= 999); hp->status = retval; } else { @@ -835,7 +835,7 @@ http_filterfields(struct worker *w, unsigned vsl_id, struct http *to, to->nhd++; } else { VSC_C_main->losthdr++; - WSLR(w, SLT_LostHeader, vsl_id, fm->hd[u]); + WSLR(w->vsl, SLT_LostHeader, vsl_id, fm->hd[u]); } } } @@ -905,7 +905,7 @@ http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp) } else { /* XXX This leaves a slot empty */ VSC_C_main->losthdr++; - WSLR(w, SLT_LostHeader, vsl_id, hp->hd[u]); + WSLR(w->vsl, SLT_LostHeader, vsl_id, hp->hd[u]); hp->hd[u].b = NULL; hp->hd[u].e = NULL; } @@ -936,7 +936,7 @@ http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); if (to->nhd >= to->shd) { VSC_C_main->losthdr++; - WSL(w, SLT_LostHeader, vsl_id, "%s", hdr); + WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", hdr); return; } http_SetH(to, to->nhd++, hdr); @@ -955,7 +955,7 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to, l = strlen(string); p = WS_Alloc(to->ws, l + 1); if (p == NULL) { - WSL(w, SLT_LostHeader, vsl_id, "%s", string); + WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", string); to->hd[field].b = NULL; to->hd[field].e = NULL; to->hdf[field] = 0; @@ -1011,7 +1011,7 @@ http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to, va_end(ap); if (n + 1 >= l || to->nhd >= to->shd) { VSC_C_main->losthdr++; - WSL(w, SLT_LostHeader, vsl_id, "%s", to->ws->f); + WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", to->ws->f); WS_Release(to->ws, 0); } else { to->hd[to->nhd].b = to->ws->f; diff --git a/bin/varnishd/cache/cache_httpconn.c b/bin/varnishd/cache/cache_httpconn.c index 1abd2a4..1a1eaf0 100644 --- a/bin/varnishd/cache/cache_httpconn.c +++ b/bin/varnishd/cache/cache_httpconn.c @@ -225,7 +225,7 @@ HTC_Read(struct worker *w, struct http_conn *htc, void *d, size_t len) return (l); i = read(htc->fd, p, len); if (i < 0) { - WSL(w, SLT_FetchError, htc->vsl_id, "%s", strerror(errno)); + WSL(w->vsl, SLT_FetchError, htc->vsl_id, "%s", strerror(errno)); return (i); } return (i + l); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index ea0668b..196cead 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -156,7 +156,7 @@ ses_pool_task(struct worker *wrk, void *arg) WS_Assert(wrk->aws); AZ(wrk->busyobj); AZ(wrk->wrw); - assert(wrk->wlp == wrk->wlb); + assert(wrk->vsl->wlp == wrk->vsl->wlb); if (cache_param->diag_bitmap & 0x00040000) { if (wrk->vcl != NULL) VCL_Rel(&wrk->vcl); diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index a839f5a..461aa97 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -180,30 +180,30 @@ VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) /*--------------------------------------------------------------------*/ void -WSL_Flush(struct worker *wrk, int overflow) +WSL_Flush(struct vsl_log *vsl, int overflow) { uint32_t *p; unsigned l; - l = pdiff(wrk->wlb, wrk->wlp); + l = pdiff(vsl->wlb, vsl->wlp); if (l == 0) return; assert(l >= 8); - p = vsl_get(l - 8, wrk->wlr, overflow); + p = vsl_get(l - 8, vsl->wlr, overflow); - memcpy(p + 1, wrk->wlb + 1, l - 4); + memcpy(p + 1, vsl->wlb + 1, l - 4); VWMB(); - p[0] = wrk->wlb[0]; - wrk->wlp = wrk->wlb; - wrk->wlr = 0; + p[0] = vsl->wlb[0]; + vsl->wlp = vsl->wlb; + vsl->wlr = 0; } /*--------------------------------------------------------------------*/ void -WSLR(struct worker *wrk, enum VSL_tag_e tag, int id, txt t) +WSLR(struct vsl_log *vsl, enum VSL_tag_e tag, int id, txt t) { unsigned l, mlen; @@ -217,29 +217,29 @@ WSLR(struct worker *wrk, enum VSL_tag_e tag, int id, txt t) t.e = t.b + l; } - assert(wrk->wlp < wrk->wle); + assert(vsl->wlp < vsl->wle); /* Wrap if necessary */ - if (VSL_END(wrk->wlp, l) >= wrk->wle) - WSL_Flush(wrk, 1); - assert (VSL_END(wrk->wlp, l) < wrk->wle); - memcpy(VSL_DATA(wrk->wlp), t.b, l); - vsl_hdr(tag, wrk->wlp, l, id); - wrk->wlp = VSL_END(wrk->wlp, l); - assert(wrk->wlp < wrk->wle); - wrk->wlr++; + if (VSL_END(vsl->wlp, l) >= vsl->wle) + WSL_Flush(vsl, 1); + assert (VSL_END(vsl->wlp, l) < vsl->wle); + memcpy(VSL_DATA(vsl->wlp), t.b, l); + vsl_hdr(tag, vsl->wlp, l, id); + vsl->wlp = VSL_END(vsl->wlp, l); + assert(vsl->wlp < vsl->wle); + vsl->wlr++; if (cache_param->diag_bitmap & 0x10000) - WSL_Flush(wrk, 0); + WSL_Flush(vsl, 0); } /*--------------------------------------------------------------------*/ static void -wsl(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) +wsl(struct vsl_log *, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) __printflike(4, 0); static void -wsl(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) +wsl(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) { char *p; unsigned n, mlen; @@ -251,38 +251,37 @@ wsl(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) if (strchr(fmt, '%') == NULL) { t.b = TRUST_ME(fmt); t.e = strchr(t.b, '\0'); - WSLR(wrk, tag, id, t); + WSLR(vsl, tag, id, t); } else { - assert(wrk->wlp < wrk->wle); + assert(vsl->wlp < vsl->wle); /* Wrap if we cannot fit a full size record */ - if (VSL_END(wrk->wlp, mlen) >= wrk->wle) - WSL_Flush(wrk, 1); + if (VSL_END(vsl->wlp, mlen) >= vsl->wle) + WSL_Flush(vsl, 1); - p = VSL_DATA(wrk->wlp); + p = VSL_DATA(vsl->wlp); n = vsnprintf(p, mlen, fmt, ap); if (n > mlen) n = mlen; /* we truncate long fields */ - vsl_hdr(tag, wrk->wlp, n, id); - wrk->wlp = VSL_END(wrk->wlp, n); - assert(wrk->wlp < wrk->wle); - wrk->wlr++; + vsl_hdr(tag, vsl->wlp, n, id); + vsl->wlp = VSL_END(vsl->wlp, n); + assert(vsl->wlp < vsl->wle); + vsl->wlr++; } if (cache_param->diag_bitmap & 0x10000) - WSL_Flush(wrk, 0); + WSL_Flush(vsl, 0); } /*--------------------------------------------------------------------*/ void -WSL(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, ...) +WSL(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, ...) { va_list ap; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); AN(fmt); va_start(ap, fmt); - wsl(wrk, tag, id, fmt, ap); + wsl(vsl, tag, id, fmt, ap); va_end(ap); } @@ -299,7 +298,7 @@ WSLB(struct worker *wrk, enum VSL_tag_e tag, const char *fmt, ...) CHECK_OBJ_NOTNULL(wrk->busyobj->vbc, VBC_MAGIC); AN(fmt); va_start(ap, fmt); - wsl(wrk, tag, wrk->busyobj->vbc->vsl_id, fmt, ap); + wsl(wrk->vsl, tag, wrk->busyobj->vbc->vsl_id, fmt, ap); va_end(ap); } diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 643f0a3..d69c7fb 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -56,7 +56,7 @@ VRT_error(const struct sess *sp, unsigned code, const char *reason) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - WSL(sp->wrk, SLT_Debug, 0, "VCL_error(%u, %s)", code, reason ? + WSL(sp->wrk->vsl, SLT_Debug, 0, "VCL_error(%u, %s)", code, reason ? reason : "(null)"); if (code < 100 || code > 999) code = 503; diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index cc7fb5b..417fcee 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -55,7 +55,7 @@ vrt_do_string(struct worker *w, int fd, const struct http *hp, int fld, AN(hp); b = VRT_String(hp->ws, NULL, p, ap); if (b == NULL || *b == '\0') { - WSL(w, SLT_LostHeader, fd, "%s", err); + WSL(w->vsl, SLT_LostHeader, fd, "%s", err); } else { http_SetH(hp, fld, b); } diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 2f0b575..591e633 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -104,8 +104,8 @@ wrk_bgthread(void *arg) memset(&wrk, 0, sizeof wrk); sp->wrk = &wrk; wrk.magic = WORKER_MAGIC; - wrk.wlp = wrk.wlb = logbuf; - wrk.wle = logbuf + (sizeof logbuf) / 4; + wrk.vsl->wlp = wrk.vsl->wlb = logbuf; + wrk.vsl->wle = logbuf + (sizeof logbuf) / 4; (void)bt->func(sp, bt->priv); @@ -142,8 +142,8 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace) memset(w, 0, sizeof *w); w->magic = WORKER_MAGIC; w->lastused = NAN; - w->wlb = w->wlp = wlog; - w->wle = wlog + (sizeof wlog) / 4; + w->vsl->wlb = w->vsl->wlp = wlog; + w->vsl->wle = wlog + (sizeof wlog) / 4; AZ(pthread_cond_init(&w->cond, NULL)); WS_Init(w->aws, "wrk", ws, thread_workspace); diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index 2c0d7c3..5c4b280 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -174,7 +174,7 @@ WRW_Flush(struct worker *wrk) if (VTIM_real() - wrk->sp->req->t_resp > cache_param->send_timeout) { - WSL(wrk, SLT_Debug, *wrw->wfd, + WSL(wrk->vsl, SLT_Debug, *wrw->wfd, "Hit total send timeout, " "wrote = %zd/%zd; not retrying", i, wrw->liov); @@ -182,7 +182,7 @@ WRW_Flush(struct worker *wrk) break; } - WSL(wrk, SLT_Debug, *wrw->wfd, + WSL(wrk->vsl, SLT_Debug, *wrw->wfd, "Hit send timeout, wrote = %zd/%zd; retrying", i, wrw->liov); @@ -191,7 +191,7 @@ WRW_Flush(struct worker *wrk) } if (i <= 0) { wrw->werr++; - WSL(wrk, SLT_Debug, *wrw->wfd, + WSL(wrk->vsl, SLT_Debug, *wrw->wfd, "Write error, retval = %zd, len = %zd, errno = %s", i, wrw->liov, strerror(errno)); } diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index ccd45b1..22971a3 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -141,7 +141,7 @@ stv_pick_stevedore(struct worker *wrk, const char **hint) return (stv_transient); /* Hint was not valid, nuke it */ - WSL(wrk, SLT_Debug, 0, /* XXX VSL_id ?? */ + WSL(wrk->vsl, SLT_Debug, 0, /* XXX VSL_id ?? */ "Storage hint not usable"); *hint = NULL; } From phk at varnish-cache.org Mon Feb 13 21:29:13 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 22:29:13 +0100 Subject: [master] 892c92a Make refcount signed. Message-ID: commit 892c92ab7fb0fe7afe69ef96ed0eda063ec2ce90 Author: Poul-Henning Kamp Date: Mon Feb 13 21:29:03 2012 +0000 Make refcount signed. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 9a31cb4..0ff57c9 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -364,7 +364,7 @@ struct objcore_methods { struct objcore { unsigned magic; #define OBJCORE_MAGIC 0x4d301302 - unsigned refcnt; + int refcnt; struct objcore_methods *methods; void *priv; unsigned priv2; From phk at varnish-cache.org Mon Feb 13 21:40:40 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 22:40:40 +0100 Subject: [master] a5d9851 Introduce a function to initialize a VSL buffer Message-ID: commit a5d9851ae5120aaa434838dcd576d2af54b74a89 Author: Poul-Henning Kamp Date: Mon Feb 13 21:40:29 2012 +0000 Introduce a function to initialize a VSL buffer diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 0ff57c9..dd3b004 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -911,6 +911,7 @@ extern struct VSC_C_main *VSC_C_main; void VSM_Init(void); void *VSM_Alloc(unsigned size, const char *class, const char *type, const char *ident); +void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len); void VSM_Free(void *ptr); #ifdef VSL_ENDMARKER void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 461aa97..ab715b7 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -304,6 +304,18 @@ WSLB(struct worker *wrk, enum VSL_tag_e tag, const char *fmt, ...) /*--------------------------------------------------------------------*/ +void +VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len) +{ + vsl->wlp = ptr; + vsl->wlb = ptr; + vsl->wle = ptr; + vsl->wle += len / sizeof(*vsl->wle); + vsl->wlr = 0; +} + +/*--------------------------------------------------------------------*/ + static void * vsm_cleaner(void *priv) { diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 591e633..d421740 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -104,8 +104,7 @@ wrk_bgthread(void *arg) memset(&wrk, 0, sizeof wrk); sp->wrk = &wrk; wrk.magic = WORKER_MAGIC; - wrk.vsl->wlp = wrk.vsl->wlb = logbuf; - wrk.vsl->wle = logbuf + (sizeof logbuf) / 4; + VSL_Setup(wrk.vsl, logbuf, sizeof logbuf); (void)bt->func(sp, bt->priv); From phk at varnish-cache.org Mon Feb 13 21:50:40 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2012 22:50:40 +0100 Subject: [master] c9c0572 Use VSL_Setup() once more Message-ID: commit c9c0572849473c712e46424e717f3267f0e24a1c Author: Poul-Henning Kamp Date: Mon Feb 13 21:50:32 2012 +0000 Use VSL_Setup() once more diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index d421740..6862a1f 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -141,8 +141,7 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace) memset(w, 0, sizeof *w); w->magic = WORKER_MAGIC; w->lastused = NAN; - w->vsl->wlb = w->vsl->wlp = wlog; - w->vsl->wle = wlog + (sizeof wlog) / 4; + VSL_Setup(w->vsl, wlog, sizeof wlog); AZ(pthread_cond_init(&w->cond, NULL)); WS_Init(w->aws, "wrk", ws, thread_workspace); From phk at varnish-cache.org Tue Feb 14 07:39:47 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 08:39:47 +0100 Subject: [master] ad277d2 Add a facility to give each session a unique number with a minimum of locking: Each pool fetches blocks of numbers to assign, then hands them out one by one using the existing lock. Message-ID: commit ad277d29774e800c9a2e7059b759e50225d0e448 Author: Poul-Henning Kamp Date: Tue Feb 14 07:36:49 2012 +0000 Add a facility to give each session a unique number with a minimum of locking: Each pool fetches blocks of numbers to assign, then hands them out one by one using the existing lock. Session numbers are 32bit and start at zero on worker process startup. Together with another 32bit number, local to the session, they will be used to link VSL records into transactions. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index dd3b004..ad23c24 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -252,6 +252,13 @@ struct vsl_log { /*--------------------------------------------------------------------*/ +struct vxid { + uint32_t next; + uint32_t count; +}; + +/*--------------------------------------------------------------------*/ + struct wrk_accept { unsigned magic; #define WRK_ACCEPT_MAGIC 0x8c4b4d59 @@ -261,6 +268,7 @@ struct wrk_accept { socklen_t acceptaddrlen; int acceptsock; struct listen_sock *acceptlsock; + uint32_t vxid; }; /* Worker pool stuff -------------------------------------------------*/ @@ -626,6 +634,8 @@ struct sess { enum step step; int fd; unsigned vsl_id; + uint32_t vxid; + uint32_t vseq; /* Cross references ------------------------------------------*/ @@ -834,6 +844,7 @@ int HTC_Complete(struct http_conn *htc); #undef HTTPH /* cache_main.c */ +uint32_t VXID_Get(struct vxid *v); extern volatile struct params * cache_param; void THR_SetName(const char *name); const char* THR_GetName(void); diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 9384d1c..4d7b771 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -249,6 +249,8 @@ VCA_SetupSess(struct worker *wrk) CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC); sp = wrk->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + sp->vxid = wa->vxid; + sp->vseq = 0; sp->fd = wa->acceptsock; sp->vsl_id = wa->acceptsock | VSL_CLIENTMARKER ; wa->acceptsock = -1; diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 48e934d..f038c9e 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -85,6 +85,33 @@ THR_GetName(void) } /*-------------------------------------------------------------------- + */ + +static uint32_t vxid_base; +static struct lock vxid_lock; + +static void +vxid_More(struct vxid *v) +{ + + Lck_Lock(&vxid_lock); + v->next = vxid_base; + v->count = 32768; + vxid_base = v->count; + Lck_Unlock(&vxid_lock); +} + +uint32_t +VXID_Get(struct vxid *v) +{ + if (v->count == 0) + vxid_More(v); + AN(v->count); + v->count--; + return (v->next++); +} + +/*-------------------------------------------------------------------- * XXX: Think more about which order we start things */ @@ -107,6 +134,8 @@ child_main(void) LCK_Init(); /* Second, locking */ + Lck_New(&vxid_lock, lck_vxid); + WAIT_Init(); PAN_Init(); CLI_Init(); diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index be4af0a..c6253b2 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -100,6 +100,8 @@ struct pool { struct lock herder_mtx; pthread_t herder_thr; + struct vxid vxid; + struct lock mtx; struct taskhead idle_queue; struct taskhead front_queue; @@ -182,6 +184,7 @@ pool_accept(struct worker *wrk, void *arg) } Lck_Lock(&pp->mtx); + wa->vxid = VXID_Get(&pp->vxid); wrk2 = pool_getidleworker(pp, 0); if (wrk2 == NULL) { /* No idle threads, do it ourselves */ From phk at varnish-cache.org Tue Feb 14 07:40:58 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 08:40:58 +0100 Subject: [master] c305b19 Forgot to add the lock type. Message-ID: commit c305b19cea8b7084db8129efe7ac7a06021a5e58 Author: Poul-Henning Kamp Date: Tue Feb 14 07:40:50 2012 +0000 Forgot to add the lock type. diff --git a/include/tbl/locks.h b/include/tbl/locks.h index 697752d..68077ce 100644 --- a/include/tbl/locks.h +++ b/include/tbl/locks.h @@ -51,4 +51,5 @@ LOCK(vcapace) LOCK(nbusyobj) LOCK(busyobj) LOCK(mempool) +LOCK(vxid) /*lint -restore */ From phk at varnish-cache.org Tue Feb 14 08:03:37 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 09:03:37 +0100 Subject: [master] b762016 Give struct req its own buffer for batching VSL records Message-ID: commit b7620169552e638771676df2f57749657cf12f0b Author: Poul-Henning Kamp Date: Tue Feb 14 08:02:41 2012 +0000 Give struct req its own buffer for batching VSL records Size controlled by param vsl_buffer which will replace shm_workspace. The space comes out of request workspace. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ad23c24..d9d9f48 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -248,6 +248,7 @@ struct exp { struct vsl_log { uint32_t *wlb, *wlp, *wle; unsigned wlr; + unsigned wid; }; /*--------------------------------------------------------------------*/ @@ -615,6 +616,9 @@ struct req { /* First byte of storage if we free it as we go (pass) */ ssize_t stream_front; + /* Transaction VSL buffer */ + struct vsl_log vsl[1]; + }; /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 196cead..1bd74fe 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -318,7 +318,7 @@ SES_GetReq(struct sess *sp) struct sesspool *pp; uint16_t nhttp; unsigned sz, hl; - char *p; + char *p, *e; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); pp = sp->sesspool; @@ -330,27 +330,38 @@ SES_GetReq(struct sess *sp) AN(sp->req); sp->req->magic = REQ_MAGIC; + e = (char*)sp->req + sz; p = (char*)(sp->req + 1); - sz -= sizeof *sp->req; + p = (void*)PRNDUP(p); + assert(p < e); nhttp = (uint16_t)cache_param->http_max_hdr; hl = HTTP_estimate(nhttp); - xxxassert(sz > 3 * hl + 128); - sp->req->http = HTTP_create(p, nhttp); - p += hl; // XXX: align ? - sz -= hl; + p += hl; + p = (void*)PRNDUP(p); + assert(p < e); sp->req->http0 = HTTP_create(p, nhttp); - p += hl; // XXX: align ? - sz -= hl; + p += hl; + p = (void*)PRNDUP(p); + assert(p < e); sp->req->resp = HTTP_create(p, nhttp); - p += hl; // XXX: align ? - sz -= hl; + p += hl; + p = (void*)PRNDUP(p); + assert(p < e); + + sz = cache_param->workspace_thread; + VSL_Setup(sp->req->vsl, p, sz); + sp->req->vsl->wid = sp->vsl_id; + p += sz; + p = (void*)PRNDUP(p); + + assert(p < e); - WS_Init(sp->req->ws, "req", p, sz); + WS_Init(sp->req->ws, "req", p, e - p); } void @@ -364,6 +375,7 @@ SES_ReleaseReq(struct sess *sp) AN(pp->pool); CHECK_OBJ_NOTNULL(sp->req, REQ_MAGIC); MPL_AssertSane(sp->req); + WSL_Flush(sp->req->vsl, 0); MPL_Free(pp->mpl_req, sp->req); sp->req = NULL; } diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 7694435..916fad8 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -78,6 +78,8 @@ struct params { unsigned workspace_backend; unsigned workspace_thread; + unsigned vsl_buffer; + unsigned shm_workspace; unsigned http_req_size; unsigned http_req_hdr_len; diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index e2e1a3a..475806d 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -766,6 +766,18 @@ static const struct parspec input_parspec[] = { "objects allocate exact space for the headers they store.\n", 0, "64", "header lines" }, + { "vsl_buffer", + tweak_bytes_u, &mgt_param.vsl_buffer, 1024, UINT_MAX, + "Bytes of (req-/backend-)workspace dedicated to buffering" + " VSL records.\n" + "At a bare minimum, this must be longer than" + " the longest HTTP header to be logged.\n" + "Setting this too high costs memory, setting it too low" + " will cause more VSL flushes and likely increase" + " lock-contention on the VSL mutex.\n" + "Minimum is 1k bytes.", + 0, + "4k", "bytes" }, { "shm_workspace", tweak_bytes_u, &mgt_param.shm_workspace, 4096, UINT_MAX, "Bytes of shmlog workspace allocated for worker threads. " From phk at varnish-cache.org Tue Feb 14 08:17:55 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 09:17:55 +0100 Subject: [master] d98dee2 Give busyobj its own VSL staging buffer too. Message-ID: commit d98dee20689a3f9671e7177e5412d0837d46aeb1 Author: Poul-Henning Kamp Date: Tue Feb 14 08:17:32 2012 +0000 Give busyobj its own VSL staging buffer too. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index d9d9f48..39b30da 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -451,8 +451,6 @@ oc_getlru(const struct objcore *oc) * * One of these aspects will be how much has been fetched, which * streaming delivery will make use of. - * - * XXX: many fields from worker needs to move here. */ struct busyobj { @@ -493,6 +491,8 @@ struct busyobj { double connect_timeout; double first_byte_timeout; double between_bytes_timeout; + + struct vsl_log vsl[1]; }; /* Object structure --------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 0252d57..8f0f31e 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -98,14 +98,11 @@ VBO_GetBusyObj(struct worker *wrk) { struct vbo *vbo = NULL; uint16_t nhttp; - unsigned httpsz; + unsigned sz; char *p; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - nhttp = (uint16_t)cache_param->http_max_hdr; - httpsz = HTTP_estimate(nhttp); - if (wrk->nvbo != NULL) { vbo = wrk->nvbo; wrk->nvbo = NULL; @@ -123,15 +120,28 @@ VBO_GetBusyObj(struct worker *wrk) vbo->bo.vbo = vbo; p = (void*)(vbo + 1); + p = (void*)PRNDUP(p); + assert(p < vbo->end); + + nhttp = (uint16_t)cache_param->http_max_hdr; + sz = HTTP_estimate(nhttp); + vbo->bo.bereq = HTTP_create(p, nhttp); - p += httpsz; + p += sz; + p = (void*)PRNDUP(p); + assert(p < vbo->end); + vbo->bo.beresp = HTTP_create(p, nhttp); - p += httpsz; - if (p >= vbo->end) { - fprintf(stderr, "workspace_backend is at least %jd to small\n", - (p - vbo->end)); - assert (p < vbo->end); - } + p += sz; + p = (void*)PRNDUP(p); + assert(p < vbo->end); + + sz = cache_param->vsl_buffer; + VSL_Setup(vbo->bo.vsl, p, sz); + p += sz; + p = (void*)PRNDUP(p); + assert(p < vbo->end); + WS_Init(vbo->bo.ws, "bo", p, vbo->end - p); return (&vbo->bo); @@ -170,13 +180,15 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) r = --vbo->refcount; Lck_Unlock(&vbo->mtx); - if (r == 0) { - /* XXX: Sanity checks & cleanup */ - memset(&vbo->bo, 0, sizeof vbo->bo); + if (r) + return; - if (cache_param->bo_cache && wrk->nvbo == NULL) - wrk->nvbo = vbo; - else - VBO_Free(&vbo); - } + WSL_Flush(vbo->bo.vsl, 0); + /* XXX: Sanity checks & cleanup */ + memset(&vbo->bo, 0, sizeof vbo->bo); + + if (cache_param->bo_cache && wrk->nvbo == NULL) + wrk->nvbo = vbo; + else + VBO_Free(&vbo); } diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 0cb3a38..45e069e 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -480,6 +480,7 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) AZ(wrk->busyobj); wrk->busyobj = VBO_GetBusyObj(wrk); + wrk->busyobj->vsl->wid = sp->vsl_id; req->obj = STV_NewObject(wrk, TRANSIENT_STORAGE, cache_param->http_resp_size, (uint16_t)cache_param->http_max_hdr); @@ -1222,7 +1223,6 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(req->obj); - wrk->busyobj = VBO_GetBusyObj(wrk); http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); http_FilterReq(sp, HTTPH_R_FETCH); http_ForceGet(wrk->busyobj->bereq); @@ -1297,6 +1297,7 @@ cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req) AZ(wrk->busyobj); wrk->busyobj = VBO_GetBusyObj(wrk); + wrk->busyobj->vsl->wid = sp->vsl_id; http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); http_FilterReq(sp, HTTPH_R_PASS); @@ -1351,6 +1352,7 @@ cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req) wrk->acct_tmp.pipe++; wrk->busyobj = VBO_GetBusyObj(wrk); + wrk->busyobj->vsl->wid = sp->vsl_id; http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); http_FilterReq(sp, 0); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 018c4f9..73e4f08 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -416,6 +416,8 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) if (vc->recycled) retry = 1; + sp->wrk->busyobj->vsl->wid = vc->vsl_id; + /* * Now that we know our backend, we can set a default Host: * header if one is necessary. This cannot be done in the VCL diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index b330c67..49f6d30 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -453,6 +453,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh) AZ(wrk->busyobj); wrk->busyobj = VBO_GetBusyObj(wrk); + wrk->busyobj->vsl->wid = sp->vsl_id; VRY_Validate(sp->req->vary_b); if (sp->req->vary_l != NULL) diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc index cecb009..983b704 100644 --- a/bin/varnishtest/tests/r01038.vtc +++ b/bin/varnishtest/tests/r01038.vtc @@ -45,7 +45,7 @@ server s1 { txresp -body "foo8" } -start -varnish v1 -arg "-p workspace_backend=3072" -vcl+backend { +varnish v1 -arg "-p workspace_backend=7k" -vcl+backend { sub vcl_fetch { set beresp.do_esi = true; } From phk at varnish-cache.org Tue Feb 14 08:53:08 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 09:53:08 +0100 Subject: [master] f093a08 Tag vbc's with the vsl buffer they should log into. Update the buffers wid with the vbc's vsl_id. Flush the buffer when we recycle/close the vbc. Message-ID: commit f093a082a7beb579a9e09c2c7e5cae577c235652 Author: Poul-Henning Kamp Date: Tue Feb 14 08:52:06 2012 +0000 Tag vbc's with the vsl buffer they should log into. Update the buffers wid with the vbc's vsl_id. Flush the buffer when we recycle/close the vbc. diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index ad71169..a836fac 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -152,6 +152,7 @@ struct vbc { VTAILQ_ENTRY(vbc) list; struct backend *backend; struct vdi_simple *vdis; + struct vsl_log *vsl; unsigned vsl_id; int fd; diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index 53a3e50..bbb13bb 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -55,11 +55,13 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp) bp = vc->backend; - WSL(wrk->vsl, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name); + WSL(vc->vsl, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name); /* Checkpoint log to flush all info related to this connection before the OS reuses the FD */ WSL_Flush(wrk->vsl, 0); + WSL_Flush(vc->vsl, 0); + vc->vsl = NULL; VTCP_close(&vc->fd); VBE_DropRefConn(bp); @@ -85,12 +87,16 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp) bp = vc->backend; - WSL(wrk->vsl, SLT_BackendReuse, vc->vsl_id, "%s", bp->display_name); + WSL(vc->vsl, SLT_BackendReuse, vc->vsl_id, "%s", bp->display_name); + /* * Flush the shmlog, so that another session reusing this backend * will log chronologically later than our use of it. */ WSL_Flush(wrk->vsl, 0); + WSL_Flush(vc->vsl, 0); + vc->vsl = NULL; + Lck_Lock(&bp->mtx); VSC_C_main->backend_recycle++; VTAILQ_INSERT_HEAD(&bp->connlist, vc, list); @@ -102,12 +108,18 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp) struct vbc * VDI_GetFd(const struct director *d, struct sess *sp) { + struct vbc *vc; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); if (d == NULL) d = sp->req->director; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - return (d->getfd(d, sp)); + vc = d->getfd(d, sp); + if (vc != NULL) { + vc->vsl = sp->wrk->busyobj->vsl; + vc->vsl->wid = vc->vsl_id; + } + return (vc); } /* Check health ------------------------------------------------------ diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 73e4f08..018c4f9 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -416,8 +416,6 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) if (vc->recycled) retry = 1; - sp->wrk->busyobj->vsl->wid = vc->vsl_id; - /* * Now that we know our backend, we can set a default Host: * header if one is necessary. This cannot be done in the VCL From phk at varnish-cache.org Tue Feb 14 09:19:28 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 10:19:28 +0100 Subject: [master] fe68764 Attach the vslbuffer to the vbc while in use and lend it the vbc's vsl_id. When the vbc is returned, restore the original vsl_id. Message-ID: commit fe687646b00aed6d0f2b589353551e98e4a0d64d Author: Poul-Henning Kamp Date: Tue Feb 14 09:18:21 2012 +0000 Attach the vslbuffer to the vbc while in use and lend it the vbc's vsl_id. When the vbc is returned, restore the original vsl_id. Change WSLB() to VSLB() and have it take a busyobj as arg. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 39b30da..eac81df 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -756,8 +756,8 @@ int EXP_NukeOne(struct worker *w, struct lru *lru); /* cache_fetch.c */ struct storage *FetchStorage(struct worker *w, ssize_t sz); -int FetchError(struct worker *w, const char *error); -int FetchError2(struct worker *w, const char *error, const char *more); +int FetchError(const struct worker *w, const char *error); +int FetchError2(const struct worker *w, const char *error, const char *more); int FetchHdr(struct sess *sp, int need_host_hdr, int sendbody); int FetchBody(struct worker *w, struct object *obj); int FetchReqBody(const struct sess *sp, int sendbody); @@ -934,7 +934,7 @@ void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) void WSLR(struct vsl_log *, enum VSL_tag_e tag, int id, txt t); void WSL(struct vsl_log *, enum VSL_tag_e tag, int id, const char *fmt, ...) __printflike(4, 5); -void WSLB(struct worker *, enum VSL_tag_e tag, const char *fmt, ...) +void VSLB(struct busyobj *, enum VSL_tag_e tag, const char *fmt, ...) __printflike(3, 4); void WSL_Flush(struct vsl_log *, int overflow); diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index a836fac..b1688f9 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -153,6 +153,7 @@ struct vbc { struct backend *backend; struct vdi_simple *vdis; struct vsl_log *vsl; + unsigned orig_vsl_id; unsigned vsl_id; int fd; diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index bbb13bb..b1359e3 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -61,7 +61,9 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp) before the OS reuses the FD */ WSL_Flush(wrk->vsl, 0); WSL_Flush(vc->vsl, 0); + vc->vsl->wid = vc->orig_vsl_id; vc->vsl = NULL; + vc->orig_vsl_id = 0; VTCP_close(&vc->fd); VBE_DropRefConn(bp); @@ -95,7 +97,9 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp) */ WSL_Flush(wrk->vsl, 0); WSL_Flush(vc->vsl, 0); + vc->vsl->wid = vc->orig_vsl_id; vc->vsl = NULL; + vc->orig_vsl_id = 0; Lck_Lock(&bp->mtx); VSC_C_main->backend_recycle++; @@ -117,6 +121,7 @@ VDI_GetFd(const struct director *d, struct sess *sp) vc = d->getfd(d, sp); if (vc != NULL) { vc->vsl = sp->wrk->busyobj->vsl; + vc->orig_vsl_id = vc->vsl->wid; vc->vsl->wid = vc->vsl_id; } return (vc); diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 1d705b1..3154784 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -61,6 +61,7 @@ struct vep_state { struct vsb *vsb; struct worker *wrk; + struct busyobj *bo; int dogzip; vep_callback_t *cb; @@ -186,7 +187,7 @@ vep_error(const struct vep_state *vep, const char *p) VSC_C_main->esi_errors++; l = (intmax_t)(vep->ver_p - vep->hack_p); - WSLB(vep->wrk, SLT_ESI_xmlerror, "ERR at %jd %s", l, p); + VSLB(vep->bo, SLT_ESI_xmlerror, "ERR at %jd %s", l, p); } @@ -202,7 +203,7 @@ vep_warn(const struct vep_state *vep, const char *p) VSC_C_main->esi_warnings++; l = (intmax_t)(vep->ver_p - vep->hack_p); printf("WARNING at %jd %s\n", l, p); - WSLB(vep->wrk, SLT_ESI_xmlerror, "WARN at %jd %s", l, p); + VSLB(vep->bo, SLT_ESI_xmlerror, "WARN at %jd %s", l, p); } @@ -602,7 +603,7 @@ VEP_Parse(const struct worker *wrk, const char *p, size_t l) p++; vep->state = VEP_STARTTAG; } else if (p < e) { - WSLB(vep->wrk, SLT_ESI_xmlerror, + VSLB(vep->bo, SLT_ESI_xmlerror, "No ESI processing, first char not '<'"); vep->state = VEP_NOTXML; } @@ -1010,6 +1011,7 @@ VEP_Init(struct worker *wrk, vep_callback_t *cb) memset(vep, 0, sizeof *vep); vep->magic = VEP_MAGIC; vep->wrk = wrk; + vep->bo = wrk->busyobj; vep->vsb = VSB_new_auto(); AN(vep->vsb); wrk->busyobj->vep = vep; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 018c4f9..1e2ef44 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -52,22 +52,23 @@ static unsigned fetchfrag; */ int -FetchError2(struct worker *wrk, const char *error, const char *more) +FetchError2(const struct worker *wrk, const char *error, const char *more) { CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); if (!wrk->busyobj->fetch_failed) { if (more == NULL) - WSLB(wrk, SLT_FetchError, "%s", error); + VSLB(wrk->busyobj, SLT_FetchError, "%s", error); else - WSLB(wrk, SLT_FetchError, "%s: %s", error, more); + VSLB(wrk->busyobj, SLT_FetchError, "%s: %s", error, + more); } wrk->busyobj->fetch_failed = 1; return (-1); } int -FetchError(struct worker *wrk, const char *error) +FetchError(const struct worker *wrk, const char *error) { return(FetchError2(wrk, error, NULL)); } @@ -574,7 +575,7 @@ FetchBody(struct worker *wrk, struct object *obj) bo->fetch_obj = NULL; - WSLB(wrk, SLT_Fetch_Body, "%u(%s) cls %d mklen %d", + VSLB(bo, SLT_Fetch_Body, "%u(%s) cls %d mklen %d", bo->body_status, body_status(bo->body_status), cls, mklen); @@ -594,7 +595,7 @@ FetchBody(struct worker *wrk, struct object *obj) if (cls == 0 && bo->should_close) cls = 1; - WSLB(wrk, SLT_Length, "%zd", obj->len); + VSLB(bo, SLT_Length, "%zd", obj->len); { /* Sanity check fetch methods accounting */ diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 2ee1abf..cf270c5 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -399,7 +399,7 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id) *vgp = NULL; if (vsl_id < 0) - WSLB(vg->wrk, SLT_Gzip, "%s %jd %jd %jd %jd %jd", + 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, diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index ab715b7..299389f 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -289,16 +289,14 @@ WSL(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, ...) /*--------------------------------------------------------------------*/ void -WSLB(struct worker *wrk, enum VSL_tag_e tag, const char *fmt, ...) +VSLB(struct busyobj *bo, enum VSL_tag_e tag, const char *fmt, ...) { va_list ap; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj->vbc, VBC_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AN(fmt); va_start(ap, fmt); - wsl(wrk->vsl, tag, wrk->busyobj->vbc->vsl_id, fmt, ap); + wsl(bo->vsl, tag, bo->vsl->wid, fmt, ap); va_end(ap); } From phk at varnish-cache.org Tue Feb 14 09:26:27 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 10:26:27 +0100 Subject: [master] 75739f8 Split http_Setup() into http_Setup() and http_Teardown() Message-ID: commit 75739f85b056a3c4d9a0e23382754490cba07910 Author: Poul-Henning Kamp Date: Tue Feb 14 09:26:11 2012 +0000 Split http_Setup() into http_Setup() and http_Teardown() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index eac81df..94c0284 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -818,6 +818,7 @@ void http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, void http_SetH(const struct http *to, unsigned n, const char *fm); void http_ForceGet(const struct http *to); void http_Setup(struct http *ht, struct ws *ws); +void http_Teardown(struct http *ht); int http_GetHdr(const struct http *hp, const char *hdr, char **ptr); int http_GetHdrData(const struct http *hp, const char *hdr, const char *field, char **ptr); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 45e069e..5e85542 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -294,7 +294,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) AZ(req->obj); req->restarts++; req->director = NULL; - http_Setup(req->resp, NULL); + http_Teardown(req->resp); sp->step = STP_RECV; return (0); default: @@ -339,7 +339,7 @@ cnt_deliver(struct sess *sp, struct worker *wrk, struct req *req) assert(WRW_IsReleased(wrk)); (void)HSH_Deref(wrk, NULL, &req->obj); - http_Setup(req->resp, NULL); + http_Teardown(req->resp); sp->step = STP_DONE; return (0); } @@ -487,8 +487,8 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) if (req->obj == NULL) { req->doclose = "Out of objects"; req->director = NULL; - http_Setup(wrk->busyobj->beresp, NULL); - http_Setup(wrk->busyobj->bereq, NULL); + http_Teardown(wrk->busyobj->beresp); + http_Teardown(wrk->busyobj->bereq); sp->step = STP_DONE; return(0); } @@ -533,7 +533,7 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) assert(req->handling == VCL_RET_DELIVER); req->err_code = 0; req->err_reason = NULL; - http_Setup(wrk->busyobj->bereq, NULL); + http_Teardown(wrk->busyobj->bereq); VBO_DerefBusyObj(wrk, &wrk->busyobj); sp->step = STP_PREPRESP; return (0); @@ -897,8 +897,8 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req) /* Use unmodified headers*/ i = FetchBody(wrk, req->obj); - http_Setup(bo->bereq, NULL); - http_Setup(bo->beresp, NULL); + http_Teardown(bo->bereq); + http_Teardown(bo->beresp); bo->vfp = NULL; assert(WRW_IsReleased(wrk)); AZ(bo->vbc); @@ -953,8 +953,8 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) i = FetchBody(wrk, req->obj); - http_Setup(wrk->busyobj->bereq, NULL); - http_Setup(wrk->busyobj->beresp, NULL); + http_Teardown(wrk->busyobj->bereq); + http_Teardown(wrk->busyobj->beresp); wrk->busyobj->vfp = NULL; AZ(wrk->busyobj->vbc); AN(req->director); @@ -976,7 +976,7 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) assert(WRW_IsReleased(wrk)); (void)HSH_Deref(wrk, NULL, &req->obj); VBO_DerefBusyObj(wrk, &wrk->busyobj); - http_Setup(req->resp, NULL); + http_Teardown(req->resp); sp->step = STP_DONE; return (0); } @@ -1247,7 +1247,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) AZ(HSH_Deref(wrk, req->objcore, NULL)); req->objcore = NULL; - http_Setup(wrk->busyobj->bereq, NULL); + http_Teardown(wrk->busyobj->bereq); VBO_DerefBusyObj(wrk, &wrk->busyobj); switch(req->handling) { @@ -1304,7 +1304,7 @@ cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req) VCL_pass_method(sp); if (req->handling == VCL_RET_ERROR) { - http_Setup(wrk->busyobj->bereq, NULL); + http_Teardown(wrk->busyobj->bereq); VBO_DerefBusyObj(wrk, &wrk->busyobj); sp->step = STP_ERROR; return (0); @@ -1364,7 +1364,7 @@ cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req) PipeSession(sp); assert(WRW_IsReleased(wrk)); - http_Setup(wrk->busyobj->bereq, NULL); + http_Teardown(wrk->busyobj->bereq); VBO_DerefBusyObj(wrk, &wrk->busyobj); sp->step = STP_DONE; return (0); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 314c05f..d947de1 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -132,6 +132,15 @@ HTTP_create(void *p, uint16_t nhttp) void http_Setup(struct http *hp, struct ws *ws) { + http_Teardown(hp); + hp->ws = ws; +} + +/*--------------------------------------------------------------------*/ + +void +http_Teardown(struct http *hp) +{ uint16_t shd; txt *hd; unsigned char *hdf; @@ -144,7 +153,6 @@ http_Setup(struct http *hp, struct ws *ws) memset(hd, 0, sizeof *hd * shd); memset(hdf, 0, sizeof *hdf * shd); hp->magic = HTTP_MAGIC; - hp->ws = ws; hp->nhd = HTTP_HDR_FIRST; hp->shd = shd; hp->hd = hd; From phk at varnish-cache.org Tue Feb 14 09:35:22 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 10:35:22 +0100 Subject: [master] 628fdea Tag struct http with which vsl buffer to use. Message-ID: commit 628fdeacf3efc8450d8722a6205339d8acd9aa8c Author: Poul-Henning Kamp Date: Tue Feb 14 09:35:10 2012 +0000 Tag struct http with which vsl buffer to use. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 94c0284..98771a3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -167,6 +167,7 @@ struct http { #define HTTP_MAGIC 0x6428b5c9 enum httpwhence logtag; + struct vsl_log *vsl; struct ws *ws; txt *hd; @@ -817,7 +818,7 @@ void http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, const char *hdr); void http_SetH(const struct http *to, unsigned n, const char *fm); void http_ForceGet(const struct http *to); -void http_Setup(struct http *ht, struct ws *ws); +void http_Setup(struct http *ht, struct ws *ws, struct vsl_log *); void http_Teardown(struct http *ht); int http_GetHdr(const struct http *hp, const char *hdr, char **ptr); int http_GetHdrData(const struct http *hp, const char *hdr, diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 5e85542..f7cbc38 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -274,7 +274,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) req->obj->last_lru = req->t_resp; req->obj->last_use = req->t_resp; /* XXX: locking ? */ } - http_Setup(req->resp, req->ws); + http_Setup(req->resp, req->ws, req->vsl); RES_BuildHttp(sp); VCL_deliver_method(sp); switch (req->handling) { @@ -569,7 +569,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) AZ(wrk->busyobj->should_close); AZ(req->storage_hint); - http_Setup(wrk->busyobj->beresp, wrk->busyobj->ws); + http_Setup(wrk->busyobj->beresp, wrk->busyobj->ws, wrk->busyobj->vsl); need_host_hdr = !http_GetHdr(wrk->busyobj->bereq, H_Host, NULL); @@ -1223,7 +1223,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(req->obj); - http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl); http_FilterReq(sp, HTTPH_R_FETCH); http_ForceGet(wrk->busyobj->bereq); if (cache_param->http_gzip_support) { @@ -1298,7 +1298,7 @@ cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req) wrk->busyobj = VBO_GetBusyObj(wrk); wrk->busyobj->vsl->wid = sp->vsl_id; - http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl); http_FilterReq(sp, HTTPH_R_PASS); VCL_pass_method(sp); @@ -1353,7 +1353,7 @@ cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req) wrk->acct_tmp.pipe++; wrk->busyobj = VBO_GetBusyObj(wrk); wrk->busyobj->vsl->wid = sp->vsl_id; - http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl); http_FilterReq(sp, 0); VCL_pipe_method(sp); @@ -1529,7 +1529,7 @@ cnt_start(struct sess *sp, struct worker *wrk, struct req *req) EXP_Clr(&req->exp); - http_Setup(req->http, req->ws); + http_Setup(req->http, req->ws, req->vsl); req->err_code = http_DissectRequest(sp); /* If we could not even parse the request, just close */ diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index d947de1..c8db4c7 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -130,10 +130,11 @@ HTTP_create(void *p, uint16_t nhttp) /*--------------------------------------------------------------------*/ void -http_Setup(struct http *hp, struct ws *ws) +http_Setup(struct http *hp, struct ws *ws, struct vsl_log *vsl) { http_Teardown(hp); hp->ws = ws; + hp->vsl = vsl; } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 22971a3..5c44c98 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -250,7 +250,7 @@ STV_MkObject(struct worker *wrk, void *ptr, unsigned ltot, WS_Assert(o->ws_o); assert(o->ws_o->e <= (char*)ptr + ltot); - http_Setup(o->http, o->ws_o); + http_Setup(o->http, o->ws_o, wrk->busyobj->vsl); o->http->magic = HTTP_MAGIC; o->exp = wrk->busyobj->exp; VTAILQ_INIT(&o->store); From phk at varnish-cache.org Tue Feb 14 09:55:16 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 10:55:16 +0100 Subject: [master] 88fd1b2 Adjust testcases for changes struct http size Message-ID: commit 88fd1b2d4ca1ba8d70235339b5a9ca2d873ceb0b Author: Poul-Henning Kamp Date: Tue Feb 14 09:55:00 2012 +0000 Adjust testcases for changes struct http size diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc index 943592f..f72d2e1 100644 --- a/bin/varnishtest/tests/c00044.vtc +++ b/bin/varnishtest/tests/c00044.vtc @@ -2,17 +2,17 @@ varnishtest "Object/LRU/Stevedores" server s1 { rxreq - txresp -bodylen 1048100 + txresp -bodylen 1048092 rxreq - txresp -bodylen 1048101 + txresp -bodylen 1048093 rxreq - txresp -bodylen 1048102 + txresp -bodylen 1048094 rxreq - txresp -bodylen 1048103 + txresp -bodylen 1048095 rxreq - txresp -bodylen 1048104 + txresp -bodylen 1048096 } -start varnish v1 -storage "-smalloc,1m -smalloc,1m, -smalloc,1m" -vcl+backend { @@ -26,7 +26,7 @@ client c1 { txreq -url /foo rxresp expect resp.status == 200 - expect resp.bodylen == 1048100 + expect resp.bodylen == 1048092 } -run varnish v1 -expect SMA.Transient.g_bytes == 0 @@ -41,7 +41,7 @@ client c1 { txreq -url /bar rxresp expect resp.status == 200 - expect resp.bodylen == 1048101 + expect resp.bodylen == 1048093 } -run varnish v1 -expect SMA.Transient.g_bytes == 0 @@ -56,7 +56,7 @@ client c1 { txreq -url /burp rxresp expect resp.status == 200 - expect resp.bodylen == 1048102 + expect resp.bodylen == 1048094 } -run varnish v1 -expect SMA.Transient.g_bytes == 0 @@ -71,7 +71,7 @@ client c1 { txreq -url /foo1 rxresp expect resp.status == 200 - expect resp.bodylen == 1048103 + expect resp.bodylen == 1048095 } -run varnish v1 -expect n_lru_nuked == 1 @@ -80,7 +80,7 @@ client c1 { txreq -url /foo rxresp expect resp.status == 200 - expect resp.bodylen == 1048104 + expect resp.bodylen == 1048096 } -run varnish v1 -expect n_lru_nuked == 2 diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc index 419381c..683c443 100644 --- a/bin/varnishtest/tests/c00045.vtc +++ b/bin/varnishtest/tests/c00045.vtc @@ -2,11 +2,11 @@ varnishtest "Object/LRU/Stevedores with hinting" server s1 { rxreq - txresp -bodylen 1048100 + txresp -bodylen 1048092 rxreq - txresp -bodylen 1048101 + txresp -bodylen 1048093 rxreq - txresp -bodylen 1048102 + txresp -bodylen 1048094 } -start varnish v1 -storage "-smalloc,1m -smalloc,1m, -smalloc,1m" -vcl+backend { @@ -20,7 +20,7 @@ client c1 { txreq -url /foo rxresp expect resp.status == 200 - expect resp.bodylen == 1048100 + expect resp.bodylen == 1048092 } -run varnish v1 -expect SMA.Transient.g_bytes == 0 @@ -35,7 +35,7 @@ client c1 { txreq -url /bar rxresp expect resp.status == 200 - expect resp.bodylen == 1048101 + expect resp.bodylen == 1048093 } -run varnish v1 -expect n_lru_nuked == 1 @@ -51,7 +51,7 @@ client c1 { txreq -url /foo rxresp expect resp.status == 200 - expect resp.bodylen == 1048102 + expect resp.bodylen == 1048094 } -run varnish v1 -expect n_lru_nuked == 2 From phk at varnish-cache.org Tue Feb 14 10:04:21 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 11:04:21 +0100 Subject: [master] f7dbf53 Clean up a lot of now needless argument passing for struct http's VSL logging. More to come. Message-ID: commit f7dbf53eb01d26170f6c4bafd3f0a50d00444dc5 Author: Poul-Henning Kamp Date: Tue Feb 14 10:03:55 2012 +0000 Clean up a lot of now needless argument passing for struct http's VSL logging. More to come. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 98771a3..0bac299 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -799,13 +799,11 @@ const char *http_StatusMessage(unsigned); unsigned http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd); void HTTP_Init(void); void http_ClrHeader(struct http *to); -unsigned http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, - int resp); +unsigned http_Write(struct worker *w, const struct http *hp, int resp); void http_SetResp(struct http *to, const char *proto, uint16_t status, const char *response); void http_FilterReq(const struct sess *sp, unsigned how); -void http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to, - unsigned how); +void http_FilterResp(const struct http *fm, struct http *to, unsigned how); void http_PutProtocol(struct worker *w, unsigned vsl_id, const struct http *to, const char *protocol); void http_PutStatus(struct http *to, uint16_t status); @@ -830,8 +828,7 @@ uint16_t http_GetStatus(const struct http *hp); const char *http_GetReq(const struct http *hp); int http_HdrIs(const struct http *hp, const char *hdr, const char *val); uint16_t http_DissectRequest(const struct sess *sp); -uint16_t http_DissectResponse(struct worker *w, const struct http_conn *htc, - struct http *sp); +uint16_t http_DissectResponse(struct http *sp, const struct http_conn *htc); const char *http_DoConnection(const struct http *hp); void http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp); void http_Unset(struct http *hp, const char *hdr); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index f7cbc38..54a883b 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -838,7 +838,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) hp2 = req->obj->http; hp2->logtag = HTTP_Obj; - http_FilterResp(sp, hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS); + http_FilterResp(hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS); http_CopyHome(wrk, sp->vsl_id, hp2); if (http_GetHdr(hp, H_Last_Modified, &b)) diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 1e2ef44..327ae0a 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -427,7 +427,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) (void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */ WRW_Reserve(wrk, &vc->fd); - (void)http_Write(wrk, vc->vsl_id, hp, 0); /* XXX: stats ? */ + (void)http_Write(wrk, hp, 0); /* XXX: stats ? */ /* Deal with any message-body the request might have */ i = FetchReqBody(sp, sendbody); @@ -480,7 +480,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) hp = wrk->busyobj->beresp; - if (http_DissectResponse(wrk, htc, hp)) { + if (http_DissectResponse(hp, htc)) { WSP(sp, SLT_FetchError, "http format error"); VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc); /* XXX: other cleanup ? */ diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index c8db4c7..2a97829 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -73,11 +73,12 @@ http2shmlog(const struct http *hp, int t) } static void -WSLH(struct worker *w, unsigned vsl_id, const struct http *hp, unsigned hdr) +http_VSLH(const struct http *hp, unsigned hdr) { - AN(vsl_id & (VSL_CLIENTMARKER|VSL_BACKENDMARKER)); - WSLR(w->vsl, http2shmlog(hp, hdr), vsl_id, hp->hd[hdr]); + AN(hp->vsl); + AN(hp->vsl->wid & (VSL_CLIENTMARKER|VSL_BACKENDMARKER)); + WSLR(hp->vsl, http2shmlog(hp, hdr), -1, hp->hd[hdr]); } /*--------------------------------------------------------------------*/ @@ -491,8 +492,7 @@ http_GetReq(const struct http *hp) */ static uint16_t -http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, - const struct http_conn *htc) +http_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) { char *q, *r; txt t = htc->rxbuf; @@ -528,7 +528,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, if (q - p > htc->maxhdr) { VSC_C_main->losthdr++; - WSL(w->vsl, SLT_LostHeader, vsl_id, "%.*s", + WSL(hp->vsl, SLT_LostHeader, -1, "%.*s", (int)(q - p > 20 ? 20 : q - p), p); return (413); } @@ -550,11 +550,11 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, hp->hdf[hp->nhd] = 0; hp->hd[hp->nhd].b = p; hp->hd[hp->nhd].e = q; - WSLH(w, vsl_id, hp, hp->nhd); + http_VSLH(hp, hp->nhd); hp->nhd++; } else { VSC_C_main->losthdr++; - WSL(w->vsl, SLT_LostHeader, vsl_id, "%.*s", + WSL(hp->vsl, SLT_LostHeader, -1, "%.*s", (int)(q - p > 20 ? 20 : q - p), p); return (413); } @@ -567,7 +567,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, */ static uint16_t -http_splitline(struct worker *w, unsigned vsl_id, struct http *hp, +http_splitline(struct http *hp, const struct http_conn *htc, int h1, int h2, int h3) { char *p, *q; @@ -629,17 +629,17 @@ http_splitline(struct worker *w, unsigned vsl_id, struct http *hp, p += vct_skipcrlf(p); *hp->hd[h1].e = '\0'; - WSLH(w, vsl_id, hp, h1); + http_VSLH(hp, h1); *hp->hd[h2].e = '\0'; - WSLH(w, vsl_id, hp, h2); + http_VSLH(hp, h2); if (hp->hd[h3].e != NULL) { *hp->hd[h3].e = '\0'; - WSLH(w, vsl_id, hp, h3); + http_VSLH(hp, h3); } - return (http_dissect_hdrs(w, hp, vsl_id, p, htc)); + return (http_dissect_hdrs(hp, p, htc)); } /*--------------------------------------------------------------------*/ @@ -674,7 +674,7 @@ http_DissectRequest(const struct sess *sp) hp->logtag = HTTP_Rx; - retval = http_splitline(sp->wrk, sp->vsl_id, hp, htc, + retval = http_splitline(hp, htc, HTTP_HDR_REQ, HTTP_HDR_URL, HTTP_HDR_PROTO); if (retval != 0) { WSPR(sp, SLT_HttpGarbage, htc->rxbuf); @@ -687,8 +687,7 @@ http_DissectRequest(const struct sess *sp) /*--------------------------------------------------------------------*/ uint16_t -http_DissectResponse(struct worker *w, const struct http_conn *htc, - struct http *hp) +http_DissectResponse(struct http *hp, const struct http_conn *htc) { int j; uint16_t retval = 0; @@ -699,7 +698,7 @@ http_DissectResponse(struct worker *w, const struct http_conn *htc, CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); hp->logtag = HTTP_Rx; - if (http_splitline(w, htc->vsl_id, hp, htc, + if (http_splitline(hp, htc, HTTP_HDR_PROTO, HTTP_HDR_STATUS, HTTP_HDR_RESPONSE)) retval = 503; @@ -725,7 +724,7 @@ http_DissectResponse(struct worker *w, const struct http_conn *htc, } if (retval != 0) { - WSLR(w->vsl, SLT_HttpGarbage, htc->vsl_id, htc->rxbuf); + WSLR(hp->vsl, SLT_HttpGarbage, -1, htc->rxbuf); assert(retval >= 100 && retval <= 999); hp->status = retval; } else { @@ -818,8 +817,7 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd) /*--------------------------------------------------------------------*/ static void -http_filterfields(struct worker *w, unsigned vsl_id, struct http *to, - const struct http *fm, unsigned how) +http_filterfields(struct http *to, const struct http *fm, unsigned how) { unsigned u; @@ -844,7 +842,7 @@ http_filterfields(struct worker *w, unsigned vsl_id, struct http *to, to->nhd++; } else { VSC_C_main->losthdr++; - WSLR(w->vsl, SLT_LostHeader, vsl_id, fm->hd[u]); + WSLR(to->vsl, SLT_LostHeader, -1, fm->hd[u]); } } } @@ -866,7 +864,7 @@ http_FilterReq(const struct sess *sp, unsigned how) http_SetH(hp, HTTP_HDR_PROTO, "HTTP/1.1"); else http_linkh(hp, sp->req->http, HTTP_HDR_PROTO); - http_filterfields(sp->wrk, sp->vsl_id, hp, sp->req->http, how); + http_filterfields(hp, sp->req->http, how); http_PrintfHeader(sp->wrk, sp->vsl_id, hp, "X-Varnish: %u", sp->req->xid); } @@ -874,8 +872,7 @@ http_FilterReq(const struct sess *sp, unsigned how) /*--------------------------------------------------------------------*/ void -http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to, - unsigned how) +http_FilterResp(const struct http *fm, struct http *to, unsigned how) { CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); @@ -883,7 +880,7 @@ http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to, http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1"); to->status = fm->status; http_linkh(to, fm, HTTP_HDR_RESPONSE); - http_filterfields(sp->wrk, sp->vsl_id, to, fm, how); + http_filterfields(to, fm, how); } /*-------------------------------------------------------------------- @@ -901,13 +898,13 @@ http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp) if (hp->hd[u].b == NULL) continue; if (hp->hd[u].b >= hp->ws->s && hp->hd[u].e <= hp->ws->e) { - WSLH(w, vsl_id, hp, u); + http_VSLH(hp, u); continue; } l = Tlen(hp->hd[u]); p = WS_Alloc(hp->ws, l + 1); if (p != NULL) { - WSLH(w, vsl_id, hp, u); + http_VSLH(hp, u); memcpy(p, hp->hd[u].b, l + 1L); hp->hd[u].b = p; hp->hd[u].e = p + l; @@ -1070,13 +1067,13 @@ HTTP_Copy(struct http *to, const struct http * const fm) /*--------------------------------------------------------------------*/ unsigned -http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, int resp) +http_Write(struct worker *w, const struct http *hp, int resp) { unsigned u, l; if (resp) { l = WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], " "); - WSLH(w, vsl_id, hp, HTTP_HDR_PROTO); + http_VSLH(hp, HTTP_HDR_PROTO); hp->hd[HTTP_HDR_STATUS].b = WS_Alloc(hp->ws, 4); AN(hp->hd[HTTP_HDR_STATUS].b); @@ -1085,18 +1082,18 @@ http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, int resp) hp->hd[HTTP_HDR_STATUS].e = hp->hd[HTTP_HDR_STATUS].b + 3; l += WRW_WriteH(w, &hp->hd[HTTP_HDR_STATUS], " "); - WSLH(w, vsl_id, hp, HTTP_HDR_STATUS); + http_VSLH(hp, HTTP_HDR_STATUS); l += WRW_WriteH(w, &hp->hd[HTTP_HDR_RESPONSE], "\r\n"); - WSLH(w, vsl_id, hp, HTTP_HDR_RESPONSE); + http_VSLH(hp, HTTP_HDR_RESPONSE); } else { AN(hp->hd[HTTP_HDR_URL].b); l = WRW_WriteH(w, &hp->hd[HTTP_HDR_REQ], " "); - WSLH(w, vsl_id, hp, HTTP_HDR_REQ); + http_VSLH(hp, HTTP_HDR_REQ); l += WRW_WriteH(w, &hp->hd[HTTP_HDR_URL], " "); - WSLH(w, vsl_id, hp, HTTP_HDR_URL); + http_VSLH(hp, HTTP_HDR_URL); l += WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], "\r\n"); - WSLH(w, vsl_id, hp, HTTP_HDR_PROTO); + http_VSLH(hp, HTTP_HDR_PROTO); } for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) { if (hp->hd[u].b == NULL) @@ -1104,7 +1101,7 @@ http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, int resp) AN(hp->hd[u].b); AN(hp->hd[u].e); l += WRW_WriteH(w, &hp->hd[u], "\r\n"); - WSLH(w, vsl_id, hp, u); + http_VSLH(hp, u); } l += WRW_Write(w, "\r\n", -1); return (l); diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c index 21fefef..6f1fbcb 100644 --- a/bin/varnishd/cache/cache_pipe.c +++ b/bin/varnishd/cache/cache_pipe.c @@ -80,7 +80,7 @@ PipeSession(struct sess *sp) WRW_Reserve(w, &vc->fd); sp->wrk->acct_tmp.hdrbytes += - http_Write(w, sp->vsl_id, sp->wrk->busyobj->bereq, 0); + http_Write(w, sp->wrk->busyobj->bereq, 0); if (sp->req->htc->pipeline.b != NULL) sp->wrk->acct_tmp.bodybytes += diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 5e4cab6..df9c137 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -117,7 +117,7 @@ RES_BuildHttp(const struct sess *sp) http_ClrHeader(req->resp); req->resp->logtag = HTTP_Tx; - http_FilterResp(sp, req->obj->http, req->resp, 0); + http_FilterResp(req->obj->http, req->resp, 0); if (!(req->res_mode & RES_LEN)) { http_Unset(req->resp, H_Content_Length); @@ -278,7 +278,7 @@ RES_WriteObj(struct sess *sp) */ if (!(req->res_mode & RES_ESI_CHILD)) sp->wrk->acct_tmp.hdrbytes += - http_Write(sp->wrk, sp->vsl_id, req->resp, 1); + http_Write(sp->wrk, req->resp, 1); if (!req->wantbody) req->res_mode &= ~RES_CHUNKED; @@ -341,7 +341,7 @@ RES_StreamStart(struct sess *sp) "Content-Length: %s", sp->wrk->busyobj->h_content_length); sp->wrk->acct_tmp.hdrbytes += - http_Write(sp->wrk, sp->vsl_id, sp->req->resp, 1); + http_Write(sp->wrk, sp->req->resp, 1); if (req->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 299389f..d4dae9d 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -208,6 +208,8 @@ WSLR(struct vsl_log *vsl, enum VSL_tag_e tag, int id, txt t) unsigned l, mlen; Tcheck(t); + if (id == -1) + id = vsl->wid; mlen = cache_param->shm_reclen; /* Truncate */ @@ -279,6 +281,8 @@ WSL(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, ...) { va_list ap; + if (id == -1) + id = vsl->wid; AN(fmt); va_start(ap, fmt); wsl(vsl, tag, id, fmt, ap); From phk at varnish-cache.org Tue Feb 14 10:32:23 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 11:32:23 +0100 Subject: [master] e9e3e2e Eliminate a lot of arguments to http_ functions which used to convey the VSL coords which are now a property of struct http. Message-ID: commit e9e3e2e80f0e1d6aad3899a55647ed2b5e311673 Author: Poul-Henning Kamp Date: Tue Feb 14 10:31:51 2012 +0000 Eliminate a lot of arguments to http_ functions which used to convey the VSL coords which are now a property of struct http. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 0bac299..2349470 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -691,7 +691,7 @@ struct vbc *VDI_GetFd(const struct director *, struct sess *sp); int VDI_Healthy(const struct director *, const struct sess *sp); void VDI_CloseFd(struct worker *wrk, struct vbc **vbp); void VDI_RecycleFd(struct worker *wrk, struct vbc **vbp); -void VDI_AddHostHeader(struct worker *wrk, const struct vbc *vbc); +void VDI_AddHostHeader(struct http *to, const struct vbc *vbc); void VBE_Poll(void); void VDI_Init(void); @@ -804,16 +804,12 @@ void http_SetResp(struct http *to, const char *proto, uint16_t status, const char *response); void http_FilterReq(const struct sess *sp, unsigned how); void http_FilterResp(const struct http *fm, struct http *to, unsigned how); -void http_PutProtocol(struct worker *w, unsigned vsl_id, const struct http *to, - const char *protocol); +void http_PutProtocol(const struct http *to, const char *protocol); void http_PutStatus(struct http *to, uint16_t status); -void http_PutResponse(struct worker *w, unsigned vsl_id, const struct http *to, - const char *response); -void http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to, - const char *fmt, ...) - __printflike(4, 5); -void http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, - const char *hdr); +void http_PutResponse(const struct http *to, const char *response); +void http_PrintfHeader(struct http *to, const char *fmt, ...) + __printflike(2, 3); +void http_SetHeader(struct http *to, const char *hdr); void http_SetH(const struct http *to, unsigned n, const char *fm); void http_ForceGet(const struct http *to); void http_Setup(struct http *ht, struct ws *ws, struct vsl_log *); @@ -830,7 +826,7 @@ int http_HdrIs(const struct http *hp, const char *hdr, const char *val); uint16_t http_DissectRequest(const struct sess *sp); uint16_t http_DissectResponse(struct http *sp, const struct http_conn *htc); const char *http_DoConnection(const struct http *hp); -void http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp); +void http_CopyHome(const struct http *hp); void http_Unset(struct http *hp, const char *hdr); void http_CollectHdr(struct http *hp, const char *hdr); diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 267e7ba..6e86538 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -65,14 +65,12 @@ struct vdi_simple { * Create default Host: header for backend request */ void -VDI_AddHostHeader(struct worker *wrk, const struct vbc *vbc) +VDI_AddHostHeader(struct http *hp, const struct vbc *vbc) { - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj->bereq, HTTP_MAGIC); CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); CHECK_OBJ_NOTNULL(vbc->vdis, VDI_SIMPLE_MAGIC); - http_PrintfHeader(wrk, vbc->vsl_id, wrk->busyobj->bereq, + http_PrintfHeader(hp, "Host: %s", vbc->vdis->vrt->hosthdr); } diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 54a883b..8aa80d1 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -501,17 +501,16 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) if (req->err_code < 100 || req->err_code > 999) req->err_code = 501; - http_PutProtocol(wrk, sp->vsl_id, h, "HTTP/1.1"); + http_PutProtocol(h, "HTTP/1.1"); http_PutStatus(h, req->err_code); VTIM_format(W_TIM_real(wrk), date); - http_PrintfHeader(wrk, sp->vsl_id, h, "Date: %s", date); - http_SetHeader(wrk, sp->vsl_id, h, "Server: Varnish"); + http_PrintfHeader(h, "Date: %s", date); + http_SetHeader(h, "Server: Varnish"); if (req->err_reason != NULL) - http_PutResponse(wrk, sp->vsl_id, h, req->err_reason); + http_PutResponse(h, req->err_reason); else - http_PutResponse(wrk, sp->vsl_id, h, - http_StatusMessage(req->err_code)); + http_PutResponse(h, http_StatusMessage(req->err_code)); VCL_error_method(sp); if (req->handling == VCL_RET_RESTART && @@ -745,8 +744,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) /* If we do gzip, add the C-E header */ if (bo->do_gzip) - http_SetHeader(wrk, sp->vsl_id, bo->beresp, - "Content-Encoding: gzip"); + http_SetHeader(bo->beresp, "Content-Encoding: gzip"); /* But we can't do both at the same time */ assert(bo->do_gzip == 0 || bo->do_gunzip == 0); @@ -839,7 +837,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) hp2->logtag = HTTP_Obj; http_FilterResp(hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS); - http_CopyHome(wrk, sp->vsl_id, hp2); + http_CopyHome(hp2); if (http_GetHdr(hp, H_Last_Modified, &b)) req->obj->last_modified = VTIM_parse(b); @@ -1233,8 +1231,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) * the minority of clients which don't. */ http_Unset(wrk->busyobj->bereq, H_Accept_Encoding); - http_SetHeader(wrk, sp->vsl_id, wrk->busyobj->bereq, - "Accept-Encoding: gzip"); + http_SetHeader(wrk->busyobj->bereq, "Accept-Encoding: gzip"); } VCL_miss_method(sp); @@ -1400,7 +1397,7 @@ DOT hash -> lookup [label="hash",style=bold,color=green] */ static int -cnt_recv(struct sess *sp, struct worker *wrk, struct req *req) +cnt_recv(struct sess *sp, const struct worker *wrk, struct req *req) { unsigned recv_handling; struct SHA256Context sha256ctx; @@ -1444,8 +1441,7 @@ cnt_recv(struct sess *sp, struct worker *wrk, struct req *req) (recv_handling != VCL_RET_PASS)) { if (RFC2616_Req_Gzip(sp)) { http_Unset(req->http, H_Accept_Encoding); - http_SetHeader(wrk, sp->vsl_id, req->http, - "Accept-Encoding: gzip"); + http_SetHeader(req->http, "Accept-Encoding: gzip"); } else { http_Unset(req->http, H_Accept_Encoding); } diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 8ef35a3..360a70f 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -73,7 +73,7 @@ ved_include(struct sess *sp, const char *src, const char *host) if (host != NULL && *host != '\0') { http_Unset(sp->req->http, H_Host); http_Unset(sp->req->http, H_If_Modified_Since); - http_SetHeader(w, sp->vsl_id, sp->req->http, host); + http_SetHeader(sp->req->http, host); } /* * XXX: We should decide if we should cache the director diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 327ae0a..f5995ca 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -393,8 +393,8 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) struct http_conn *htc; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); wrk = sp->wrk; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); htc = &wrk->busyobj->htc; @@ -408,12 +408,12 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) hp = wrk->busyobj->bereq; - sp->wrk->busyobj->vbc = VDI_GetFd(NULL, sp); - if (sp->wrk->busyobj->vbc == NULL) { + wrk->busyobj->vbc = VDI_GetFd(NULL, sp); + if (wrk->busyobj->vbc == NULL) { WSP(sp, SLT_FetchError, "no backend connection"); return (-1); } - vc = sp->wrk->busyobj->vbc; + vc = wrk->busyobj->vbc; if (vc->recycled) retry = 1; @@ -423,7 +423,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) * because the backend may be chosen by a director. */ if (need_host_hdr) - VDI_AddHostHeader(sp->wrk, vc); + VDI_AddHostHeader(wrk->busyobj->bereq, vc); (void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */ WRW_Reserve(wrk, &vc->fd); @@ -434,7 +434,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) if (WRW_FlushRelease(wrk) || i > 0) { WSP(sp, SLT_FetchError, "backend write error: %d (%s)", errno, strerror(errno)); - VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc); + VDI_CloseFd(wrk, &wrk->busyobj->vbc); /* XXX: other cleanup ? */ return (retry); } @@ -458,7 +458,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) if (i < 0) { WSP(sp, SLT_FetchError, "http first read error: %d %d (%s)", i, errno, strerror(errno)); - VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc); + VDI_CloseFd(wrk, &wrk->busyobj->vbc); /* XXX: other cleanup ? */ /* Retryable if we never received anything */ return (i == -1 ? retry : -1); @@ -472,7 +472,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) WSP(sp, SLT_FetchError, "http first read error: %d %d (%s)", i, errno, strerror(errno)); - VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc); + VDI_CloseFd(wrk, &wrk->busyobj->vbc); /* XXX: other cleanup ? */ return (-1); } @@ -482,7 +482,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) if (http_DissectResponse(hp, htc)) { WSP(sp, SLT_FetchError, "http format error"); - VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc); + VDI_CloseFd(wrk, &wrk->busyobj->vbc); /* XXX: other cleanup ? */ return (-1); } @@ -614,8 +614,7 @@ FetchBody(struct worker *wrk, struct object *obj) if (mklen > 0) { http_Unset(obj->http, H_Content_Length); - http_PrintfHeader(wrk, bo->vbc->vsl_id, obj->http, - "Content-Length: %zd", obj->len); + http_PrintfHeader(obj->http, "Content-Length: %zd", obj->len); } if (cls) diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 2a97829..de71ada 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -865,8 +865,7 @@ http_FilterReq(const struct sess *sp, unsigned how) else http_linkh(hp, sp->req->http, HTTP_HDR_PROTO); http_filterfields(hp, sp->req->http, how); - http_PrintfHeader(sp->wrk, sp->vsl_id, hp, - "X-Varnish: %u", sp->req->xid); + http_PrintfHeader(hp, "X-Varnish: %u", sp->req->xid); } /*--------------------------------------------------------------------*/ @@ -889,7 +888,7 @@ http_FilterResp(const struct http *fm, struct http *to, unsigned how) */ void -http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp) +http_CopyHome(const struct http *hp) { unsigned u, l; char *p; @@ -911,7 +910,7 @@ http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp) } else { /* XXX This leaves a slot empty */ VSC_C_main->losthdr++; - WSLR(w->vsl, SLT_LostHeader, vsl_id, hp->hd[u]); + WSLR(hp->vsl, SLT_LostHeader, -1, hp->hd[u]); hp->hd[u].b = NULL; hp->hd[u].e = NULL; } @@ -935,14 +934,13 @@ http_ClrHeader(struct http *to) /*--------------------------------------------------------------------*/ void -http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, - const char *hdr) +http_SetHeader(struct http *to, const char *hdr) { CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); if (to->nhd >= to->shd) { VSC_C_main->losthdr++; - WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", hdr); + WSL(to->vsl, SLT_LostHeader, -1, "%s", hdr); return; } http_SetH(to, to->nhd++, hdr); @@ -951,8 +949,7 @@ http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, /*--------------------------------------------------------------------*/ static void -http_PutField(struct worker *w, unsigned vsl_id, const struct http *to, - int field, const char *string) +http_PutField(const struct http *to, int field, const char *string) { char *p; unsigned l; @@ -961,7 +958,7 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to, l = strlen(string); p = WS_Alloc(to->ws, l + 1); if (p == NULL) { - WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", string); + WSL(to->vsl, SLT_LostHeader, -1, "%s", string); to->hd[field].b = NULL; to->hd[field].e = NULL; to->hdf[field] = 0; @@ -974,11 +971,10 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to, } void -http_PutProtocol(struct worker *w, unsigned vsl_id, const struct http *to, - const char *protocol) +http_PutProtocol(const struct http *to, const char *protocol) { - http_PutField(w, vsl_id, to, HTTP_HDR_PROTO, protocol); + http_PutField(to, HTTP_HDR_PROTO, protocol); if (to->hd[HTTP_HDR_PROTO].b == NULL) http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1"); Tcheck(to->hd[HTTP_HDR_PROTO]); @@ -993,19 +989,17 @@ http_PutStatus(struct http *to, uint16_t status) } void -http_PutResponse(struct worker *w, unsigned vsl_id, const struct http *to, - const char *response) +http_PutResponse(const struct http *to, const char *response) { - http_PutField(w, vsl_id, to, HTTP_HDR_RESPONSE, response); + http_PutField(to, HTTP_HDR_RESPONSE, response); if (to->hd[HTTP_HDR_RESPONSE].b == NULL) http_SetH(to, HTTP_HDR_RESPONSE, "Lost Response"); Tcheck(to->hd[HTTP_HDR_RESPONSE]); } void -http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to, - const char *fmt, ...) +http_PrintfHeader(struct http *to, const char *fmt, ...) { va_list ap; unsigned l, n; @@ -1017,7 +1011,7 @@ http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to, va_end(ap); if (n + 1 >= l || to->nhd >= to->shd) { VSC_C_main->losthdr++; - WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", to->ws->f); + WSL(to->vsl, SLT_LostHeader, -1, "%s", to->ws->f); WS_Release(to->ws, 0); } else { to->hd[to->nhd].b = to->ws->f; diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index df9c137..148a73c 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -90,13 +90,12 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh) if (low > high) return; - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, - "Content-Range: bytes %jd-%jd/%jd", + http_PrintfHeader(req->resp, "Content-Range: bytes %jd-%jd/%jd", (intmax_t)low, (intmax_t)high, (intmax_t)req->obj->len); http_Unset(req->resp, H_Content_Length); assert(req->res_mode & RES_LEN); - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, - "Content-Length: %jd", (intmax_t)(1 + high - low)); + http_PrintfHeader(req->resp, "Content-Length: %jd", + (intmax_t)(1 + high - low)); http_SetResp(req->resp, "HTTP/1.1", 206, "Partial Content"); *plow = low; @@ -123,29 +122,25 @@ RES_BuildHttp(const struct sess *sp) http_Unset(req->resp, H_Content_Length); } else if (cache_param->http_range_support) { /* We only accept ranges if we know the length */ - http_SetHeader(sp->wrk, sp->vsl_id, req->resp, - "Accept-Ranges: bytes"); + http_SetHeader(req->resp, "Accept-Ranges: bytes"); } if (req->res_mode & RES_CHUNKED) - http_SetHeader(sp->wrk, sp->vsl_id, req->resp, - "Transfer-Encoding: chunked"); + http_SetHeader(req->resp, "Transfer-Encoding: chunked"); VTIM_format(VTIM_real(), time_str); - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, - "Date: %s", time_str); + http_PrintfHeader(req->resp, "Date: %s", time_str); if (req->xid != req->obj->xid) - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, + http_PrintfHeader(req->resp, "X-Varnish: %u %u", req->xid, req->obj->xid); else - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, - "X-Varnish: %u", req->xid); - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, "Age: %.0f", + http_PrintfHeader(req->resp, "X-Varnish: %u", req->xid); + http_PrintfHeader(req->resp, "Age: %.0f", req->obj->exp.age + req->t_resp - req->obj->exp.entered); - http_SetHeader(sp->wrk, sp->vsl_id, req->resp, "Via: 1.1 varnish"); - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, "Connection: %s", + http_SetHeader(req->resp, "Via: 1.1 varnish"); + http_PrintfHeader(req->resp, "Connection: %s", req->doclose ? "close" : "keep-alive"); } @@ -337,7 +332,7 @@ RES_StreamStart(struct sess *sp) if (!(req->res_mode & RES_CHUNKED) && sp->wrk->busyobj->h_content_length != NULL) - http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp, + http_PrintfHeader(sp->req->resp, "Content-Length: %s", sp->wrk->busyobj->h_content_length); sp->wrk->acct_tmp.hdrbytes += diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index d69c7fb..6271e49 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -231,7 +231,7 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr, WSP(sp, SLT_LostHeader, "%s", hdr + 1); } else { http_Unset(hp, hdr); - http_SetHeader(sp->wrk, sp->vsl_id, hp, b); + http_SetHeader(hp, b); } } va_end(ap); @@ -417,7 +417,7 @@ VRT_synth_page(const struct sess *sp, unsigned flags, const char *str, ...) va_end(ap); SMS_Finish(sp->req->obj); http_Unset(sp->req->obj->http, H_Content_Length); - http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->obj->http, + http_PrintfHeader(sp->req->obj->http, "Content-Length: %zd", sp->req->obj->len); } diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 15f91df..97ff04a 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -1,7 +1,7 @@ -d__flexelint_v9__=1 -printf(3, VSL) --printf(4, http_PrintfHeader) +-printf(2, http_PrintfHeader) -printf(4, WSL) -printf(3, WSLB) -printf(2, VSB_printf) From phk at varnish-cache.org Tue Feb 14 10:51:39 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 11:51:39 +0100 Subject: [master] f33a076 Give struct htc the same "tell it what vsl_buffer to use" treatment. Message-ID: commit f33a076b477487e66bea47e77c78408f1bf80a29 Author: Poul-Henning Kamp Date: Tue Feb 14 10:50:49 2012 +0000 Give struct htc the same "tell it what vsl_buffer to use" treatment. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 2349470..8ff3688 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -189,7 +189,7 @@ struct http_conn { #define HTTP_CONN_MAGIC 0x3e19edd1 int fd; - unsigned vsl_id; + struct vsl_log *vsl; unsigned maxbytes; unsigned maxhdr; struct ws *ws; @@ -831,11 +831,11 @@ void http_Unset(struct http *hp, const char *hdr); void http_CollectHdr(struct http *hp, const char *hdr); /* cache_httpconn.c */ -void HTC_Init(struct http_conn *htc, struct ws *ws, int fd, unsigned vsl_id, +void HTC_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *, unsigned maxbytes, unsigned maxhdr); int HTC_Reinit(struct http_conn *htc); int HTC_Rx(struct http_conn *htc); -ssize_t HTC_Read(struct worker *w, struct http_conn *htc, void *d, size_t len); +ssize_t HTC_Read(struct http_conn *htc, void *d, size_t len); int HTC_Complete(struct http_conn *htc); #define HTTPH(a, b, c) extern char b[]; diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 8aa80d1..57e5616 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -116,7 +116,7 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req) SES_GetReq(sp); req = sp->req; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - HTC_Init(req->htc, req->ws, sp->fd, sp->vsl_id, + HTC_Init(req->htc, req->ws, sp->fd, sp->req->vsl, cache_param->http_req_size, cache_param->http_req_hdr_len); } diff --git a/bin/varnishd/cache/cache_esi.h b/bin/varnishd/cache/cache_esi.h index 4867614..bcc815b 100644 --- a/bin/varnishd/cache/cache_esi.h +++ b/bin/varnishd/cache/cache_esi.h @@ -42,7 +42,7 @@ typedef ssize_t vep_callback_t(struct worker *w, ssize_t l, enum vgz_flag flg); void VEP_Init(struct worker *w, vep_callback_t *cb); -void VEP_Parse(const struct worker *w, const char *p, size_t l); +void VEP_Parse(const struct busyobj *, const char *p, size_t l); struct vsb *VEP_Finish(const struct worker *w); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 64adf51..620082d 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -64,7 +64,7 @@ struct vef_priv { */ static ssize_t -vef_read(struct worker *wrk, struct http_conn *htc, void *buf, ssize_t buflen, +vef_read(struct http_conn *htc, void *buf, ssize_t buflen, ssize_t bytes) { ssize_t d; @@ -76,7 +76,7 @@ vef_read(struct worker *wrk, struct http_conn *htc, void *buf, ssize_t buflen, if (d < bytes) bytes = d; } - return (HTC_Read(wrk, htc, buf, bytes)); + return (HTC_Read(htc, buf, bytes)); } /*--------------------------------------------------------------------- @@ -97,11 +97,11 @@ vfp_esi_bytes_uu(struct worker *wrk, const struct vef_priv *vef, st = FetchStorage(wrk, 0); if (st == NULL) return (-1); - wl = vef_read(wrk, htc, + wl = vef_read(htc, st->ptr + st->len, st->space - st->len, bytes); if (wl <= 0) return (wl); - VEP_Parse(wrk, (const char *)st->ptr + st->len, wl); + VEP_Parse(wrk->busyobj, (const char *)st->ptr + st->len, wl); st->len += wl; wrk->busyobj->fetch_obj->len += wl; bytes -= wl; @@ -129,7 +129,7 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, while (bytes > 0) { if (VGZ_IbufEmpty(vg) && bytes > 0) { - wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes); + wl = vef_read(htc, vef->ibuf, vef->ibuf_sz, bytes); if (wl <= 0) return (wl); VGZ_Ibuf(vg, vef->ibuf, wl); @@ -139,7 +139,7 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, return(-1); i = VGZ_Gunzip(vg, &dp, &dl); xxxassert(i == VGZ_OK || i == VGZ_END); - VEP_Parse(wrk, dp, dl); + VEP_Parse(wrk->busyobj, dp, dl); wrk->busyobj->fetch_obj->len += dl; } return (1); @@ -167,7 +167,7 @@ vfp_vep_inject(const struct worker *wrk, struct vef_priv *vef, ssize_t wl) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - VEP_Parse(wrk, vef->ibuf_i, wl); + VEP_Parse(wrk->busyobj, vef->ibuf_i, wl); vef->ibuf_i += wl; assert(vef->ibuf_o >= vef->ibuf && vef->ibuf_o <= vef->ibuf_i); if (vef->error) { @@ -235,7 +235,7 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) */ static int -vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef, +vfp_esi_bytes_ug(const struct worker *wrk, struct vef_priv *vef, struct http_conn *htc, ssize_t bytes) { ssize_t wl; @@ -246,7 +246,7 @@ vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef, while (bytes > 0) { wl = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf); - wl = vef_read(wrk, htc, vef->ibuf_i, wl, bytes); + wl = vef_read(htc, vef->ibuf_i, wl, bytes); if (wl <= 0) return (wl); bytes -= wl; @@ -261,7 +261,7 @@ vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef, */ static int -vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef, +vfp_esi_bytes_gg(const struct worker *wrk, struct vef_priv *vef, struct http_conn *htc, size_t bytes) { ssize_t wl; @@ -274,7 +274,7 @@ vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef, CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); while (bytes > 0) { - wl = vef_read(wrk, htc, vef->ibuf2, vef->ibuf2_sz, bytes); + wl = vef_read(htc, vef->ibuf2, vef->ibuf2_sz, bytes); if (wl <= 0) return (wl); bytes -= wl; diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 3154784..433208d 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -549,16 +549,15 @@ vep_do_include(struct vep_state *vep, enum dowhat what) */ void -VEP_Parse(const struct worker *wrk, const char *p, size_t l) +VEP_Parse(const struct busyobj *bo, const char *p, size_t l) { struct vep_state *vep; const char *e; struct vep_match *vm; int i; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vep = wrk->busyobj->vep; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vep = bo->vep; CHECK_OBJ_NOTNULL(vep, VEP_MAGIC); assert(l > 0); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index f5995ca..8b94fd7 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -121,7 +121,7 @@ vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) l = st->space - st->len; if (l > bytes) l = bytes; - wl = HTC_Read(wrk, htc, st->ptr + st->len, l); + wl = HTC_Read(htc, st->ptr + st->len, l); if (wl <= 0) return (wl); st->len += wl; @@ -261,7 +261,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) do { /* Skip leading whitespace */ do { - if (HTC_Read(wrk, htc, buf, 1) <= 0) + if (HTC_Read(htc, buf, 1) <= 0) return (-1); } while (vct_islws(buf[0])); @@ -271,7 +271,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) /* Collect hex digits, skipping leading zeros */ for (u = 1; u < sizeof buf; u++) { do { - if (HTC_Read(wrk, htc, buf + u, 1) <= 0) + if (HTC_Read(htc, buf + u, 1) <= 0) return (-1); } while (u == 1 && buf[0] == '0' && buf[u] == '0'); if (!vct_ishex(buf[u])) @@ -283,7 +283,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) /* Skip trailing white space */ while(vct_islws(buf[u]) && buf[u] != '\n') - if (HTC_Read(wrk, htc, buf + u, 1) <= 0) + if (HTC_Read(htc, buf + u, 1) <= 0) return (-1); if (buf[u] != '\n') @@ -297,10 +297,10 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) if (cl > 0 && wrk->busyobj->vfp->bytes(wrk, htc, cl) <= 0) return (-1); - i = HTC_Read(wrk, htc, buf, 1); + i = HTC_Read(htc, buf, 1); if (i <= 0) return (-1); - if (buf[0] == '\r' && HTC_Read(wrk, htc, buf, 1) <= 0) + if (buf[0] == '\r' && HTC_Read( htc, buf, 1) <= 0) return (-1); if (buf[0] != '\n') return (FetchError(wrk,"chunked tail no NL")); @@ -352,7 +352,7 @@ FetchReqBody(const struct sess *sp, int sendbody) rdcnt = sizeof buf; else rdcnt = content_length; - rdcnt = HTC_Read(sp->wrk, sp->req->htc, buf, rdcnt); + rdcnt = HTC_Read(sp->req->htc, buf, rdcnt); if (rdcnt <= 0) return (1); content_length -= rdcnt; @@ -447,7 +447,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) /* Receive response */ - HTC_Init(htc, wrk->busyobj->ws, vc->fd, vc->vsl_id, + HTC_Init(htc, wrk->busyobj->ws, vc->fd, vc->vsl, cache_param->http_resp_size, cache_param->http_resp_hdr_len); diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index cf270c5..5901930 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -471,7 +471,7 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) l = vg->m_sz; if (l > bytes) l = bytes; - wl = HTC_Read(wrk, htc, vg->m_buf, l); + wl = HTC_Read(htc, vg->m_buf, l); if (wl <= 0) return (wl); VGZ_Ibuf(vg, vg->m_buf, wl); @@ -554,7 +554,7 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) l = vg->m_sz; if (l > bytes) l = bytes; - wl = HTC_Read(wrk, htc, vg->m_buf, l); + wl = HTC_Read(htc, vg->m_buf, l); if (wl <= 0) return (wl); VGZ_Ibuf(vg, vg->m_buf, wl); @@ -650,7 +650,7 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) l = st->space - st->len; if (l > bytes) l = bytes; - wl = HTC_Read(wrk, htc, st->ptr + st->len, l); + wl = HTC_Read(htc, st->ptr + st->len, l); if (wl <= 0) return (wl); bytes -= wl; diff --git a/bin/varnishd/cache/cache_httpconn.c b/bin/varnishd/cache/cache_httpconn.c index 1a1eaf0..d0b7199 100644 --- a/bin/varnishd/cache/cache_httpconn.c +++ b/bin/varnishd/cache/cache_httpconn.c @@ -88,14 +88,14 @@ htc_header_complete(txt *t) /*--------------------------------------------------------------------*/ void -HTC_Init(struct http_conn *htc, struct ws *ws, int fd, unsigned vsl_id, +HTC_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *vsl, unsigned maxbytes, unsigned maxhdr) { htc->magic = HTTP_CONN_MAGIC; htc->ws = ws; htc->fd = fd; - htc->vsl_id = vsl_id; + htc->vsl = vsl; htc->maxbytes = maxbytes; htc->maxhdr = maxhdr; @@ -200,13 +200,12 @@ HTC_Rx(struct http_conn *htc) */ ssize_t -HTC_Read(struct worker *w, struct http_conn *htc, void *d, size_t len) +HTC_Read(struct http_conn *htc, void *d, size_t len) { size_t l; unsigned char *p; ssize_t i; - CHECK_OBJ_NOTNULL(w, WORKER_MAGIC); CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); l = 0; p = d; @@ -225,7 +224,7 @@ HTC_Read(struct worker *w, struct http_conn *htc, void *d, size_t len) return (l); i = read(htc->fd, p, len); if (i < 0) { - WSL(w->vsl, SLT_FetchError, htc->vsl_id, "%s", strerror(errno)); + WSL(htc->vsl, SLT_FetchError, -1, "%s", strerror(errno)); return (i); } return (i + l); From phk at varnish-cache.org Tue Feb 14 11:01:07 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 12:01:07 +0100 Subject: [master] 2d49712 Change FetchError() to take busyobj as arg. Message-ID: commit 2d49712fb096255ae1178275c3a0a8c955142853 Author: Poul-Henning Kamp Date: Tue Feb 14 11:00:54 2012 +0000 Change FetchError() to take busyobj as arg. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 8ff3688..50d9541 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -757,8 +757,8 @@ int EXP_NukeOne(struct worker *w, struct lru *lru); /* cache_fetch.c */ struct storage *FetchStorage(struct worker *w, ssize_t sz); -int FetchError(const struct worker *w, const char *error); -int FetchError2(const struct worker *w, const char *error, const char *more); +int FetchError(struct busyobj *, const char *error); +int FetchError2(struct busyobj *, const char *error, const char *more); int FetchHdr(struct sess *sp, int need_host_hdr, int sendbody); int FetchBody(struct worker *w, struct object *obj); int FetchReqBody(const struct sess *sp, int sendbody); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 620082d..45bfa86 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -387,7 +387,7 @@ vfp_esi_end(struct worker *wrk) retval = bo->fetch_failed; if (bo->vgz_rx != NULL && VGZ_Destroy(&bo->vgz_rx, -1) != VGZ_END) - retval = FetchError(wrk, "Gunzip+ESI Failed at the very end"); + retval = FetchError(bo, "Gunzip+ESI Failed at the very end"); vsb = VEP_Finish(wrk); @@ -402,7 +402,7 @@ vfp_esi_end(struct worker *wrk) VSB_data(vsb), l); bo->fetch_obj->esidata->len = l; } else { - retval = FetchError(wrk, + retval = FetchError(bo, "Could not allocate storage for esidata"); } } @@ -415,7 +415,7 @@ vfp_esi_end(struct worker *wrk) if (vef->vgz != NULL) { VGZ_UpdateObj(vef->vgz, bo->fetch_obj); if (VGZ_Destroy(&vef->vgz, -1) != VGZ_END) - retval = FetchError(wrk, + retval = FetchError(bo, "ESI+Gzip Failed at the very end"); } if (vef->ibuf != NULL) diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 8b94fd7..2924130 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -52,25 +52,24 @@ static unsigned fetchfrag; */ int -FetchError2(const struct worker *wrk, const char *error, const char *more) +FetchError2(struct busyobj *bo, const char *error, const char *more) { - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - if (!wrk->busyobj->fetch_failed) { + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + if (!bo->fetch_failed) { if (more == NULL) - VSLB(wrk->busyobj, SLT_FetchError, "%s", error); + VSLB(bo, SLT_FetchError, "%s", error); else - VSLB(wrk->busyobj, SLT_FetchError, "%s: %s", error, - more); + VSLB(bo, SLT_FetchError, "%s: %s", error, more); } - wrk->busyobj->fetch_failed = 1; + bo->fetch_failed = 1; return (-1); } int -FetchError(const struct worker *wrk, const char *error) +FetchError(struct busyobj *bo, const char *error) { - return(FetchError2(wrk, error, NULL)); + return(FetchError2(bo, error, NULL)); } /*-------------------------------------------------------------------- @@ -192,7 +191,7 @@ FetchStorage(struct worker *wrk, ssize_t sz) l = cache_param->fetch_chunksize; st = STV_alloc(wrk, l); if (st == NULL) { - (void)FetchError(wrk, "Could not get storage"); + (void)FetchError(wrk->busyobj, "Could not get storage"); return (NULL); } AZ(st->len); @@ -233,13 +232,13 @@ fetch_straight(struct worker *wrk, struct http_conn *htc, ssize_t cl) assert(wrk->busyobj->body_status == BS_LENGTH); if (cl < 0) { - return (FetchError(wrk, "straight length field bogus")); + return (FetchError(wrk->busyobj, "straight length field bogus")); } else if (cl == 0) return (0); i = wrk->busyobj->vfp->bytes(wrk, htc, cl); if (i <= 0) - return (FetchError(wrk, "straight insufficient bytes")); + return (FetchError(wrk->busyobj, "straight insufficient bytes")); return (0); } @@ -266,7 +265,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) } while (vct_islws(buf[0])); if (!vct_ishex(buf[0])) - return (FetchError(wrk,"chunked header non-hex")); + return (FetchError(wrk->busyobj, "chunked header non-hex")); /* Collect hex digits, skipping leading zeros */ for (u = 1; u < sizeof buf; u++) { @@ -279,7 +278,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) } if (u >= sizeof buf) - return (FetchError(wrk,"chunked header too long")); + return (FetchError(wrk->busyobj,"chunked header too long")); /* Skip trailing white space */ while(vct_islws(buf[u]) && buf[u] != '\n') @@ -287,12 +286,12 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) return (-1); if (buf[u] != '\n') - return (FetchError(wrk,"chunked header no NL")); + return (FetchError(wrk->busyobj,"chunked header no NL")); buf[u] = '\0'; cl = fetch_number(buf, 16); if (cl < 0) - return (FetchError(wrk,"chunked header number syntax")); + return (FetchError(wrk->busyobj,"chunked header number syntax")); if (cl > 0 && wrk->busyobj->vfp->bytes(wrk, htc, cl) <= 0) return (-1); @@ -303,7 +302,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) if (buf[0] == '\r' && HTC_Read( htc, buf, 1) <= 0) return (-1); if (buf[0] != '\n') - return (FetchError(wrk,"chunked tail no NL")); + return (FetchError(wrk->busyobj,"chunked tail no NL")); } while (cl > 0); return (0); } diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 5901930..c4eab44 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -482,7 +482,7 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) return(-1); i = VGZ_Gunzip(vg, &dp, &dl); if (i != VGZ_OK && i != VGZ_END) - return(FetchError(wrk, "Gunzip data error")); + return(FetchError(wrk->busyobj, "Gunzip data error")); wrk->busyobj->fetch_obj->len += dl; if (wrk->busyobj->do_stream) RES_StreamPoll(wrk); @@ -506,7 +506,8 @@ vfp_gunzip_end(struct worker *wrk) return(0); } if (VGZ_Destroy(&vg, -1) != VGZ_END) - return(FetchError(wrk, "Gunzip error at the very end")); + return(FetchError(wrk->busyobj, + "Gunzip error at the very end")); return (0); } @@ -599,7 +600,7 @@ vfp_gzip_end(struct worker *wrk) RES_StreamPoll(wrk); VGZ_UpdateObj(vg, wrk->busyobj->fetch_obj); if (VGZ_Destroy(&vg, -1) != VGZ_END) - return(FetchError(wrk, "Gzip error at the very end")); + return(FetchError(wrk->busyobj, "Gzip error at the very end")); return (0); } @@ -664,9 +665,10 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) VGZ_Obuf(vg, vg->m_buf, vg->m_sz); i = VGZ_Gunzip(vg, &dp, &dl); if (i == VGZ_END && !VGZ_IbufEmpty(vg)) - return(FetchError(wrk, "Junk after gzip data")); + return(FetchError(wrk->busyobj, + "Junk after gzip data")); if (i != VGZ_OK && i != VGZ_END) - return(FetchError2(wrk, + return(FetchError2(wrk->busyobj, "Invalid Gzip data", vg->vz.msg)); } } @@ -690,7 +692,8 @@ vfp_testgzip_end(struct worker *wrk) } VGZ_UpdateObj(vg, wrk->busyobj->fetch_obj); if (VGZ_Destroy(&vg, -1) != VGZ_END) - return(FetchError(wrk, "TestGunzip error at the very end")); + return(FetchError(wrk->busyobj, + "TestGunzip error at the very end")); return (0); } From phk at varnish-cache.org Tue Feb 14 11:19:39 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 12:19:39 +0100 Subject: [master] fe8ec80 Argument strength-reduction: from worker to dstats Message-ID: commit fe8ec801f6ed776522df03c7ff271406b76bc298 Author: Poul-Henning Kamp Date: Tue Feb 14 11:19:22 2012 +0000 Argument strength-reduction: from worker to dstats diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 6dc3618..b02e5f9 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -908,7 +908,7 @@ ban_lurker_work(const struct sess *sp, unsigned pass) if (cache_param->diag_bitmap & 0x80000) VSL(SLT_Debug, 0, "lurker done: %p %u %u", oc, oc->flags & OC_F_LURK, pass); - (void)HSH_Deref(sp->wrk, NULL, &o); + (void)HSH_Deref(&sp->wrk->stats, NULL, &o); VTIM_sleep(cache_param->ban_lurker_sleep); } Lck_AssertHeld(&ban_mtx); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 57e5616..61d1a94 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -289,7 +289,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) HSH_Drop(wrk); VBO_DerefBusyObj(wrk, &wrk->busyobj); } else { - (void)HSH_Deref(wrk, NULL, &req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &req->obj); } AZ(req->obj); req->restarts++; @@ -338,7 +338,7 @@ cnt_deliver(struct sess *sp, struct worker *wrk, struct req *req) RES_WriteObj(sp); assert(WRW_IsReleased(wrk)); - (void)HSH_Deref(wrk, NULL, &req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &req->obj); http_Teardown(req->resp); sp->step = STP_DONE; return (0); @@ -641,7 +641,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) if (req->objcore != NULL) { CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); - AZ(HSH_Deref(wrk, req->objcore, NULL)); + AZ(HSH_Deref(&wrk->stats, req->objcore, NULL)); req->objcore = NULL; } VBO_DerefBusyObj(wrk, &wrk->busyobj); @@ -972,7 +972,7 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) RES_StreamEnd(sp); assert(WRW_IsReleased(wrk)); - (void)HSH_Deref(wrk, NULL, &req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &req->obj); VBO_DerefBusyObj(wrk, &wrk->busyobj); http_Teardown(req->resp); sp->step = STP_DONE; @@ -1065,7 +1065,7 @@ cnt_hit(struct sess *sp, struct worker *wrk, struct req *req) } /* Drop our object, we won't need it */ - (void)HSH_Deref(wrk, NULL, &req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &req->obj); req->objcore = NULL; switch(req->handling) { @@ -1183,7 +1183,7 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req) if (oc->flags & OC_F_PASS) { wrk->stats.cache_hitpass++; WSP(sp, SLT_HitPass, "%u", req->obj->xid); - (void)HSH_Deref(wrk, NULL, &req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &req->obj); AZ(req->objcore); sp->step = STP_PASS; return (0); @@ -1242,7 +1242,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) return (0); } - AZ(HSH_Deref(wrk, req->objcore, NULL)); + AZ(HSH_Deref(&wrk->stats, req->objcore, NULL)); req->objcore = NULL; http_Teardown(wrk->busyobj->bereq); VBO_DerefBusyObj(wrk, &wrk->busyobj); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 1060bac..840e0b7 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -402,7 +402,7 @@ exp_timer(struct sess *sp, void *priv) o = oc_getobj(sp->wrk, oc); WSL(sp->wrk->vsl, SLT_ExpKill, 0, "%u %.0f", oc_getxid(sp->wrk, oc), EXP_Ttl(NULL, o) - t); - (void)HSH_Deref(sp->wrk, oc, NULL); + (void)HSH_Deref(&sp->wrk->stats, oc, NULL); } NEEDLESS_RETURN(NULL); } @@ -446,7 +446,7 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru) /* XXX: bad idea for -spersistent */ WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc)); - (void)HSH_Deref(wrk, oc, NULL); + (void)HSH_Deref(&wrk->stats, oc, NULL); return (1); } diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 49f6d30..eebb999 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -139,13 +139,13 @@ HSH_Cleanup(struct worker *wrk) } void -HSH_DeleteObjHead(struct worker *wrk, struct objhead *oh) +HSH_DeleteObjHead(struct dstat *ds, struct objhead *oh) { AZ(oh->refcnt); assert(VTAILQ_EMPTY(&oh->objcs)); Lck_Delete(&oh->mtx); - wrk->stats.n_objecthead--; + ds->n_objecthead--; FREE_OBJ(oh); } @@ -564,7 +564,7 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace) o->exp.ttl = ttl; o->exp.grace = grace; EXP_Rearm(o); - (void)HSH_Deref(sp->wrk, NULL, &o); + (void)HSH_Deref(&sp->wrk->stats, NULL, &o); } WS_Release(sp->req->ws, 0); } @@ -588,7 +588,7 @@ HSH_Drop(struct worker *wrk) o->exp.ttl = -1.; if (o->objcore != NULL) /* Pass has no objcore */ HSH_Unbusy(wrk); - (void)HSH_Deref(wrk, NULL, &wrk->sp->req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &wrk->sp->req->obj); } void @@ -660,7 +660,7 @@ HSH_Ref(struct objcore *oc) */ int -HSH_Deref(struct worker *wrk, struct objcore *oc, struct object **oo) +HSH_Deref(struct dstat *ds, struct objcore *oc, struct object **oo) { struct object *o = NULL; struct objhead *oh; @@ -683,7 +683,7 @@ HSH_Deref(struct worker *wrk, struct objcore *oc, struct object **oo) */ STV_Freestore(o); STV_free(o->objstore); - wrk->stats.n_object--; + ds->n_object--; return (0); } @@ -713,16 +713,16 @@ HSH_Deref(struct worker *wrk, struct objcore *oc, struct object **oo) if (oc->methods != NULL) { oc_freeobj(oc); - wrk->stats.n_object--; + ds->n_object--; } FREE_OBJ(oc); - wrk->stats.n_objectcore--; + ds->n_objectcore--; /* Drop our ref on the objhead */ assert(oh->refcnt > 0); if (hash->deref(oh)) return (0); - HSH_DeleteObjHead(wrk, oh); + HSH_DeleteObjHead(ds, oh); return (0); } diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index 5fafac5..069a1c2 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -359,7 +359,7 @@ hcb_cleaner(struct sess *sp, void *priv) } VTAILQ_FOREACH_SAFE(oh, &dead_h, hoh_list, oh2) { VTAILQ_REMOVE(&dead_h, oh, hoh_list); - HSH_DeleteObjHead(wrk, oh); + HSH_DeleteObjHead(&wrk->stats, oh); } Lck_Lock(&hcb_mtx); VSTAILQ_CONCAT(&dead_y, &cool_y); diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index b45e604..1bc08b1 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -95,8 +95,8 @@ struct objhead { #define hoh_head _u.n.u_n_hoh_head }; -void HSH_DeleteObjHead(struct worker *w, struct objhead *oh); -int HSH_Deref(struct worker *w, struct objcore *oc, struct object **o); +void HSH_DeleteObjHead(struct dstat *, struct objhead *oh); +int HSH_Deref(struct dstat *, struct objcore *oc, struct object **o); #endif /* VARNISH_CACHE_CHILD */ extern const struct hash_slinger hsl_slinger; From phk at varnish-cache.org Tue Feb 14 11:48:36 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 12:48:36 +0100 Subject: [master] ac85937 More argument strength reduction to reduce the spread of struct wrk Message-ID: commit ac859374aac0c9b93c2b2975e280ea83d8f5105a Author: Poul-Henning Kamp Date: Tue Feb 14 11:48:16 2012 +0000 More argument strength reduction to reduce the spread of struct wrk diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 50d9541..42788c3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -357,8 +357,8 @@ struct storage { * housekeeping fields parts of an object. */ -typedef struct object *getobj_f(struct worker *wrk, struct objcore *oc); -typedef unsigned getxid_f(struct worker *wrk, struct objcore *oc); +typedef struct object *getobj_f(struct dstat *ds, struct objcore *oc); +typedef unsigned getxid_f(struct dstat *ds, struct objcore *oc); typedef void updatemeta_f(struct objcore *oc); typedef void freeobj_f(struct objcore *oc); typedef struct lru *getlru_f(const struct objcore *oc); @@ -395,24 +395,24 @@ struct objcore { }; static inline unsigned -oc_getxid(struct worker *wrk, struct objcore *oc) +oc_getxid(struct dstat *ds, struct objcore *oc) { CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(oc->methods); AN(oc->methods->getxid); - return (oc->methods->getxid(wrk, oc)); + return (oc->methods->getxid(ds, oc)); } static inline struct object * -oc_getobj(struct worker *wrk, struct objcore *oc) +oc_getobj(struct dstat *ds, struct objcore *oc) { CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AZ(oc->flags & OC_F_BUSY); AN(oc->methods); AN(oc->methods->getobj); - return (oc->methods->getobj(wrk, oc)); + return (oc->methods->getobj(ds, oc)); } static inline void @@ -1014,7 +1014,6 @@ void WS_Assert(const struct ws *ws); void WS_Reset(struct ws *ws, char *p); char *WS_Alloc(struct ws *ws, unsigned bytes); char *WS_Snapshot(struct ws *ws); -unsigned WS_Free(const struct ws *ws); /* rfc2616.c */ void RFC2616_Ttl(const struct sess *sp); @@ -1092,11 +1091,11 @@ Tadd(txt *t, const char *p, int l) } static inline void -AssertObjBusy(const struct object *o) +AssertOCBusy(const struct objcore *oc) { - AN(o->objcore); - AN (o->objcore->flags & OC_F_BUSY); - AN(o->objcore->busyobj); + AN(oc); + AN (oc->flags & OC_F_BUSY); + AN(oc->busyobj); } static inline void diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index b02e5f9..24a150e 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -891,7 +891,7 @@ ban_lurker_work(const struct sess *sp, unsigned pass) /* * Get the object and check it against all relevant bans */ - o = oc_getobj(sp->wrk, oc); + o = oc_getobj(&sp->wrk->stats, oc); i = ban_check_object(o, sp, 0); if (cache_param->diag_bitmap & 0x80000) VSL(SLT_Debug, 0, "lurker got: %p %d", diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 61d1a94..0be9304 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -915,7 +915,8 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req) EXP_Insert(req->obj); AN(req->obj->objcore); AN(req->obj->objcore->ban); - HSH_Unbusy(wrk); + AZ(req->obj->ws_o->overflow); + HSH_Unbusy(req->obj->objcore); } VBO_DerefBusyObj(wrk, &wrk->busyobj); wrk->acct_tmp.fetch++; @@ -961,7 +962,8 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) EXP_Insert(req->obj); AN(req->obj->objcore); AN(req->obj->objcore->ban); - HSH_Unbusy(wrk); + AZ(req->obj->ws_o->overflow); + HSH_Unbusy(req->obj->objcore); } else { req->doclose = "Stream error"; } @@ -1171,7 +1173,7 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req) return (0); } - o = oc_getobj(wrk, oc); + o = oc_getobj(&wrk->stats, oc); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); req->obj = o; diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 840e0b7..0d8ffe1 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -224,7 +224,7 @@ EXP_Insert(struct object *o) CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); oc = o->objcore; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - AssertObjBusy(o); + AssertOCBusy(oc); HSH_Ref(oc); assert(o->exp.entered != 0 && !isnan(o->exp.entered)); @@ -399,9 +399,9 @@ exp_timer(struct sess *sp, void *priv) VSC_C_main->n_expired++; CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC); - o = oc_getobj(sp->wrk, oc); + o = oc_getobj(&sp->wrk->stats, oc); WSL(sp->wrk->vsl, SLT_ExpKill, 0, "%u %.0f", - oc_getxid(sp->wrk, oc), EXP_Ttl(NULL, o) - t); + oc_getxid(&sp->wrk->stats, oc), EXP_Ttl(NULL, o) - t); (void)HSH_Deref(&sp->wrk->stats, oc, NULL); } NEEDLESS_RETURN(NULL); @@ -445,7 +445,7 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru) return (-1); /* XXX: bad idea for -spersistent */ - WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc)); + WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(&wrk->stats, oc)); (void)HSH_Deref(&wrk->stats, oc, NULL); return (1); } diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index eebb999..7188ff4 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -353,7 +353,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh) continue; } - o = oc_getobj(sp->wrk, oc); + o = oc_getobj(&sp->wrk->stats, oc); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); if (o->exp.ttl <= 0.) @@ -397,14 +397,14 @@ HSH_Lookup(struct sess *sp, struct objhead **poh) && (busy_oc != NULL /* Somebody else is already busy */ || !VDI_Healthy(sp->req->director, sp))) { /* Or it is impossible to fetch */ - o = oc_getobj(sp->wrk, grace_oc); + o = oc_getobj(&sp->wrk->stats, grace_oc); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); oc = grace_oc; } sp->req->objcore = NULL; if (oc != NULL && !sp->req->hash_always_miss) { - o = oc_getobj(sp->wrk, oc); + o = oc_getobj(&sp->wrk->stats, oc); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); assert(oc->objhead == oh); @@ -540,7 +540,7 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace) continue; } - (void)oc_getobj(sp->wrk, oc); /* XXX: still needed ? */ + (void)oc_getobj(&sp->wrk->stats, oc); /* XXX: still needed ? */ xxxassert(spc >= sizeof *ocp); oc->refcnt++; @@ -557,7 +557,7 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace) for (n = 0; n < nobj; n++) { oc = ocp[n]; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - o = oc_getobj(sp->wrk, oc); + o = oc_getobj(&sp->wrk->stats, oc); if (o == NULL) continue; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); @@ -587,34 +587,23 @@ HSH_Drop(struct worker *wrk) AssertObjCorePassOrBusy(o->objcore); o->exp.ttl = -1.; if (o->objcore != NULL) /* Pass has no objcore */ - HSH_Unbusy(wrk); + HSH_Unbusy(o->objcore); (void)HSH_Deref(&wrk->stats, NULL, &wrk->sp->req->obj); } void -HSH_Unbusy(struct worker *wrk) +HSH_Unbusy(struct objcore *oc) { - struct object *o; struct objhead *oh; - struct objcore *oc; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - o = wrk->sp->req->obj; - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - oc = o->objcore; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); oh = oc->objhead; CHECK_OBJ(oh, OBJHEAD_MAGIC); - AssertObjBusy(o); + AssertOCBusy(oc); AN(oc->ban); assert(oc->refcnt > 0); assert(oh->refcnt > 0); - if (o->ws_o->overflow) - wrk->stats.n_objoverflow++; - if (cache_param->diag_bitmap & 0x40) - WSL(wrk->vsl, SLT_Debug, 0, - "Object %u workspace free %u", o->xid, WS_Free(o->ws_o)); /* XXX: pretouch neighbors on oh->objcs to prevent page-on under mtx */ Lck_Lock(&oh->mtx); @@ -628,7 +617,6 @@ HSH_Unbusy(struct worker *wrk) hsh_rush(oh); AN(oc->ban); Lck_Unlock(&oh->mtx); - assert(oc_getobj(wrk, oc) == o); } void diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index be38496..d84e937 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -116,14 +116,6 @@ WS_Alloc(struct ws *ws, unsigned bytes) return (r); } -unsigned -WS_Free(const struct ws *ws) -{ - - WS_Assert(ws); - return(ws->e - ws->f); -} - char * WS_Snapshot(struct ws *ws) { diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 1bc08b1..ac8ce7e 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -54,7 +54,7 @@ struct hash_slinger { void HSH_Prealloc(const struct sess *sp); void HSH_Cleanup(struct worker *w); struct objcore *HSH_Lookup(struct sess *sp, struct objhead **poh); -void HSH_Unbusy(struct worker *wrk); +void HSH_Unbusy(struct objcore *); void HSH_Ref(struct objcore *o); void HSH_Drop(struct worker *wrk); void HSH_Init(const struct hash_slinger *slinger); diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 5c44c98..ae71f6e 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -49,20 +49,20 @@ static const struct stevedore * volatile stv_next; */ static unsigned __match_proto__(getxid_f) -default_oc_getxid(struct worker *wrk, struct objcore *oc) +default_oc_getxid(struct dstat *ds, struct objcore *oc) { struct object *o; - o = oc_getobj(wrk, oc); + o = oc_getobj(ds, oc); return (o->xid); } static struct object * __match_proto__(getobj_f) -default_oc_getobj(struct worker *wrk, struct objcore *oc) +default_oc_getobj(struct dstat *ds, struct objcore *oc) { struct object *o; - (void)wrk; + (void)ds; if (oc->priv == NULL) return (NULL); CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC); diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 7cafe4f..a6a02e6 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -370,13 +370,13 @@ smp_loaded_st(const struct smp_sc *sc, const struct smp_seg *sg, */ static unsigned __match_proto__(getxid_f) -smp_oc_getxid(struct worker *wrk, struct objcore *oc) +smp_oc_getxid(struct dstat *ds, struct objcore *oc) { struct object *o; struct smp_seg *sg; struct smp_object *so; - (void)wrk; + (void)ds; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC); @@ -399,7 +399,7 @@ smp_oc_getxid(struct worker *wrk, struct objcore *oc) */ static struct object * -smp_oc_getobj(struct worker *wrk, struct objcore *oc) +smp_oc_getobj(struct dstat *ds, struct objcore *oc) { struct object *o; struct smp_seg *sg; @@ -412,7 +412,7 @@ smp_oc_getobj(struct worker *wrk, struct objcore *oc) assert(oc->methods->getobj == smp_oc_getobj); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - if (wrk == NULL) + if (ds == NULL) AZ(oc->flags & OC_F_NEEDFIXUP); CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC); @@ -435,7 +435,7 @@ smp_oc_getobj(struct worker *wrk, struct objcore *oc) if (!(oc->flags & OC_F_NEEDFIXUP)) return (o); - AN(wrk); + AN(ds); Lck_Lock(&sg->sc->mtx); /* Check again, we might have raced. */ if (oc->flags & OC_F_NEEDFIXUP) { @@ -459,8 +459,8 @@ smp_oc_getobj(struct worker *wrk, struct objcore *oc) } sg->nfixed++; - wrk->stats.n_object++; - wrk->stats.n_vampireobject--; + ds->n_object++; + ds->n_vampireobject--; oc->flags &= ~OC_F_NEEDFIXUP; } Lck_Unlock(&sg->sc->mtx); From phk at varnish-cache.org Tue Feb 14 13:50:32 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 14:50:32 +0100 Subject: [master] fe9d181 Align the iovec pointer Message-ID: commit fe9d181a5276843a77ed41b91919a0f5ef0ead77 Author: Poul-Henning Kamp Date: Tue Feb 14 13:50:17 2012 +0000 Align the iovec pointer diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index 5c4b280..00b3a9e 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -80,9 +80,10 @@ WRW_Reserve(struct worker *wrk, int *fd) memset(wrw, 0, sizeof *wrw); wrw->magic = WRW_MAGIC; u = WS_Reserve(wrk->aws, 0); + u = PRNDDN(u); u /= sizeof(struct iovec); AN(u); - wrw->iov = (void*)wrk->aws->f; + wrw->iov = (void*)PRNDUP(wrk->aws->f); wrw->siov = u; wrw->ciov = u; wrw->werr = 0; From phk at varnish-cache.org Tue Feb 14 13:58:24 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 14:58:24 +0100 Subject: [master] d2b5440 Clamp # of iovec to IOV_MAX Message-ID: commit d2b54402c34166044f745f8d92348970e26472b4 Author: Poul-Henning Kamp Date: Tue Feb 14 13:58:04 2012 +0000 Clamp # of iovec to IOV_MAX diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index 00b3a9e..3685bec 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -37,6 +37,7 @@ #include #include +#include #include #include "cache.h" @@ -82,6 +83,8 @@ WRW_Reserve(struct worker *wrk, int *fd) u = WS_Reserve(wrk->aws, 0); u = PRNDDN(u); u /= sizeof(struct iovec); + if (u > IOV_MAX) + u = IOV_MAX; AN(u); wrw->iov = (void*)PRNDUP(wrk->aws->f); wrw->siov = u; From phk at varnish-cache.org Tue Feb 14 14:23:38 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 15:23:38 +0100 Subject: [master] 40273a3 Clean up this file, and GC a unused counter. Message-ID: commit 40273a3357890cc639d76c0acd4b24fff6bf10b8 Author: Poul-Henning Kamp Date: Tue Feb 14 14:23:28 2012 +0000 Clean up this file, and GC a unused counter. diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 1188903..36bb629 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -82,67 +82,119 @@ VSC_F(sess_fail, uint64_t, 1, 'c', /*---------------------------------------------------------------------*/ VSC_F(client_req, uint64_t, 1, 'a', - "Client requests received", - "") + "Client requests received", + "" +) VSC_F(cache_hit, uint64_t, 1, 'a', - "Cache hits", - "Count of cache hits. " - " A cache hit indicates that an object has been delivered to a" - " client without fetching it from a backend server." + "Cache hits", + "Count of cache hits. " + " A cache hit indicates that an object has been delivered to a" + " client without fetching it from a backend server." ) -VSC_F(cache_hitpass, uint64_t, 1, 'a', - "Cache hits for pass", - "Count of hits for pass" - " A cache hit for pass indicates that Varnish is going to" - " pass the request to the backend and this decision has been " - " cached in it self. This counts how many times the cached " - " decision is being used." +VSC_F(cache_hitpass, uint64_t, 1, 'a', + "Cache hits for pass", + "Count of hits for pass" + " A cache hit for pass indicates that Varnish is going to" + " pass the request to the backend and this decision has been " + " cached in it self. This counts how many times the cached " + " decision is being used." ) VSC_F(cache_miss, uint64_t, 1, 'a', - "Cache misses", - "Count of misses" - " A cache miss indicates the object was fetched from the" - " backend before delivering it to the backend.") + "Cache misses", + "Count of misses" + " A cache miss indicates the object was fetched from the" + " backend before delivering it to the backend." +) -VSC_F(backend_conn, uint64_t, 0, 'a', - "Backend conn. success", - "") +VSC_F(backend_conn, uint64_t, 0, 'a', + "Backend conn. success", + "" +) VSC_F(backend_unhealthy, uint64_t, 0, 'a', - "Backend conn. not attempted", - "" -) -VSC_F(backend_busy, uint64_t, 0, 'a', "Backend conn. too many", "") -VSC_F(backend_fail, uint64_t, 0, 'a', "Backend conn. failures", "") -VSC_F(backend_reuse, uint64_t, 0, 'a', - "Backend conn. reuses", - "Count of backend connection reuses" - " This counter is increased whenever we reuse a recycled connection.") -VSC_F(backend_toolate, uint64_t, 0, 'a', "Backend conn. was closed", "") -VSC_F(backend_recycle, uint64_t, 0, 'a', - "Backend conn. recycles", - "Count of backend connection recycles" - " This counter is increased whenever we have a keep-alive" - " connection that is put back into the pool of connections." - " It has not yet been used, but it might be, unless the backend" - " closes it.") -VSC_F(backend_retry, uint64_t, 0, 'a', "Backend conn. retry", "") - -VSC_F(fetch_head, uint64_t, 1, 'a', "Fetch head", "") -VSC_F(fetch_length, uint64_t, 1, 'a', "Fetch with Length", "") -VSC_F(fetch_chunked, uint64_t, 1, 'a', "Fetch chunked", "") -VSC_F(fetch_eof, uint64_t, 1, 'a', "Fetch EOF", "") -VSC_F(fetch_bad, uint64_t, 1, 'a', "Fetch had bad headers", "") -VSC_F(fetch_close, uint64_t, 1, 'a', "Fetch wanted close", "") + "Backend conn. not attempted", + "" +) +VSC_F(backend_busy, uint64_t, 0, 'a', + "Backend conn. too many", + "" +) +VSC_F(backend_fail, uint64_t, 0, 'a', + "Backend conn. failures", + "" +) +VSC_F(backend_reuse, uint64_t, 0, 'a', + "Backend conn. reuses", + "Count of backend connection reuses" + " This counter is increased whenever we reuse a recycled connection." +) +VSC_F(backend_toolate, uint64_t, 0, 'a', + "Backend conn. was closed", + "" +) +VSC_F(backend_recycle, uint64_t, 0, 'a', + "Backend conn. recycles", + "Count of backend connection recycles" + " This counter is increased whenever we have a keep-alive" + " connection that is put back into the pool of connections." + " It has not yet been used, but it might be, unless the backend" + " closes it." +) +VSC_F(backend_retry, uint64_t, 0, 'a', + "Backend conn. retry", + "" +) + +VSC_F(fetch_head, uint64_t, 1, 'a', + "Fetch head", + "" +) +VSC_F(fetch_length, uint64_t, 1, 'a', + "Fetch with Length", + "" +) +VSC_F(fetch_chunked, uint64_t, 1, 'a', + "Fetch chunked", + "" +) +VSC_F(fetch_eof, uint64_t, 1, 'a', + "Fetch EOF", + "" +) +VSC_F(fetch_bad, uint64_t, 1, 'a', + "Fetch had bad headers", + "" +) +VSC_F(fetch_close, uint64_t, 1, 'a', + "Fetch wanted close", + "" +) VSC_F(fetch_oldhttp, uint64_t, 1, 'a', - "Fetch pre HTTP/1.1 closed", "") -VSC_F(fetch_zero, uint64_t, 1, 'a', "Fetch zero len", "") -VSC_F(fetch_failed, uint64_t, 1, 'a', "Fetch failed", "") -VSC_F(fetch_1xx, uint64_t, 1, 'a', "Fetch no body (1xx)", "") -VSC_F(fetch_204, uint64_t, 1, 'a', "Fetch no body (204)", "") -VSC_F(fetch_304, uint64_t, 1, 'a', "Fetch no body (304)", "") + "Fetch pre HTTP/1.1 closed", + "" +) +VSC_F(fetch_zero, uint64_t, 1, 'a', + "Fetch zero len", + "" +) +VSC_F(fetch_failed, uint64_t, 1, 'a', + "Fetch failed", + "" +) +VSC_F(fetch_1xx, uint64_t, 1, 'a', + "Fetch no body (1xx)", + "" +) +VSC_F(fetch_204, uint64_t, 1, 'a', + "Fetch no body (204)", + "" +) +VSC_F(fetch_304, uint64_t, 1, 'a', + "Fetch no body (304)", + "" +) /*--------------------------------------------------------------------- * Pools, threads, and sessions @@ -208,63 +260,171 @@ VSC_F(sess_dropped, uint64_t, 0, 'c', /*---------------------------------------------------------------------*/ -VSC_F(n_object, uint64_t, 1, 'i', "N struct object", "") -VSC_F(n_vampireobject, uint64_t, 1, 'i', "N unresurrected objects", "") -VSC_F(n_objectcore, uint64_t, 1, 'i', "N struct objectcore", "") -VSC_F(n_objecthead, uint64_t, 1, 'i', "N struct objecthead", "") -VSC_F(n_waitinglist, uint64_t, 1, 'i', "N struct waitinglist", "") - -VSC_F(n_backend, uint64_t, 0, 'i', "N backends", "") - -VSC_F(n_expired, uint64_t, 0, 'i', "N expired objects", "") -VSC_F(n_lru_nuked, uint64_t, 0, 'i', "N LRU nuked objects", "") -VSC_F(n_lru_moved, uint64_t, 0, 'i', "N LRU moved objects", "") - -VSC_F(losthdr, uint64_t, 0, 'a', "HTTP header overflows", "") - -VSC_F(n_objsendfile, uint64_t, 0, 'a', "Objects sent with sendfile", - "The number of objects sent with the sendfile system call. If enabled " - "sendfile will be used on object larger than a certain size.") -VSC_F(n_objwrite, uint64_t, 0, 'a', "Objects sent with write", - "The number of objects sent with regular write calls." - "Writes are used when the objects are too small for sendfile " - "or if the sendfile call has been disabled") -VSC_F(n_objoverflow, uint64_t, 1, 'a', - "Objects overflowing workspace", "") - -VSC_F(s_sess, uint64_t, 1, 'a', "Total Sessions", "") -VSC_F(s_req, uint64_t, 1, 'a', "Total Requests", "") -VSC_F(s_pipe, uint64_t, 1, 'a', "Total pipe", "") -VSC_F(s_pass, uint64_t, 1, 'a', "Total pass", "") -VSC_F(s_fetch, uint64_t, 1, 'a', "Total fetch", "") -VSC_F(s_hdrbytes, uint64_t, 1, 'a', "Total header bytes", "") -VSC_F(s_bodybytes, uint64_t, 1, 'a', "Total body bytes", "") - -VSC_F(sess_closed, uint64_t, 1, 'a', "Session Closed", "") -VSC_F(sess_pipeline, uint64_t, 1, 'a', "Session Pipeline", "") -VSC_F(sess_readahead, uint64_t, 1, 'a', "Session Read Ahead", "") -VSC_F(sess_linger, uint64_t, 1, 'a', "Session Linger", "") -VSC_F(sess_herd, uint64_t, 1, 'a', "Session herd", "") - -VSC_F(shm_records, uint64_t, 0, 'a', "SHM records", "") -VSC_F(shm_writes, uint64_t, 0, 'a', "SHM writes", "") +VSC_F(n_object, uint64_t, 1, 'i', + "N struct object", + "" +) +VSC_F(n_vampireobject, uint64_t, 1, 'i', + "N unresurrected objects", + "" +) +VSC_F(n_objectcore, uint64_t, 1, 'i', + "N struct objectcore", + "" +) +VSC_F(n_objecthead, uint64_t, 1, 'i', + "N struct objecthead", + "" +) +VSC_F(n_waitinglist, uint64_t, 1, 'i', + "N struct waitinglist", + "" +) + +VSC_F(n_backend, uint64_t, 0, 'i', + "N backends", + "" +) + +VSC_F(n_expired, uint64_t, 0, 'i', + "N expired objects", + "" +) +VSC_F(n_lru_nuked, uint64_t, 0, 'i', + "N LRU nuked objects", + "" +) +VSC_F(n_lru_moved, uint64_t, 0, 'i', + "N LRU moved objects", + "" +) + +VSC_F(losthdr, uint64_t, 0, 'a', + "HTTP header overflows", + "" +) + +VSC_F(n_objsendfile, uint64_t, 0, 'a', + "Objects sent with sendfile", + "The number of objects sent with the sendfile system call. If enabled " + "sendfile will be used on object larger than a certain size." +) +VSC_F(n_objwrite, uint64_t, 0, 'a', + "Objects sent with write", + "The number of objects sent with regular write calls." + "Writes are used when the objects are too small for sendfile " + "or if the sendfile call has been disabled" +) +VSC_F(n_objoverflow, uint64_t, 1, 'a', + "Objects overflowing workspace", + "" +) + +VSC_F(s_sess, uint64_t, 1, 'a', + "Total Sessions", + "" +) +VSC_F(s_req, uint64_t, 1, 'a', + "Total Requests", + "" +) +VSC_F(s_pipe, uint64_t, 1, 'a', + "Total pipe", + "" +) +VSC_F(s_pass, uint64_t, 1, 'a', + "Total pass", + "" +) +VSC_F(s_fetch, uint64_t, 1, 'a', + "Total fetch", + "" +) +VSC_F(s_hdrbytes, uint64_t, 1, 'a', + "Total header bytes", + "" +) +VSC_F(s_bodybytes, uint64_t, 1, 'a', + "Total body bytes", + "" +) + +VSC_F(sess_closed, uint64_t, 1, 'a', + "Session Closed", + "" +) +VSC_F(sess_pipeline, uint64_t, 1, 'a', + "Session Pipeline", + "" +) +VSC_F(sess_readahead, uint64_t, 1, 'a', + "Session Read Ahead", + "" +) +VSC_F(sess_herd, uint64_t, 1, 'a', + "Session herd", + "" +) + +VSC_F(shm_records, uint64_t, 0, 'a', + "SHM records", + "" +) +VSC_F(shm_writes, uint64_t, 0, 'a', + "SHM writes", + "" +) VSC_F(shm_flushes, uint64_t, 0, 'a', - "SHM flushes due to overflow", "") -VSC_F(shm_cont, uint64_t, 0, 'a', "SHM MTX contention", "") + "SHM flushes due to overflow", + "" +) +VSC_F(shm_cont, uint64_t, 0, 'a', + "SHM MTX contention", + "" +) VSC_F(shm_cycles, uint64_t, 0, 'a', - "SHM cycles through buffer", "") + "SHM cycles through buffer", + "" +) -VSC_F(sms_nreq, uint64_t, 0, 'a', "SMS allocator requests", "") -VSC_F(sms_nobj, uint64_t, 0, 'i', "SMS outstanding allocations", "") -VSC_F(sms_nbytes, uint64_t, 0, 'i', "SMS outstanding bytes", "") -VSC_F(sms_balloc, uint64_t, 0, 'i', "SMS bytes allocated", "") -VSC_F(sms_bfree, uint64_t, 0, 'i', "SMS bytes freed", "") +VSC_F(sms_nreq, uint64_t, 0, 'a', + "SMS allocator requests", + "" +) +VSC_F(sms_nobj, uint64_t, 0, 'i', + "SMS outstanding allocations", + "" +) +VSC_F(sms_nbytes, uint64_t, 0, 'i', + "SMS outstanding bytes", + "" +) +VSC_F(sms_balloc, uint64_t, 0, 'i', + "SMS bytes allocated", + "" +) +VSC_F(sms_bfree, uint64_t, 0, 'i', + "SMS bytes freed", + "" +) -VSC_F(backend_req, uint64_t, 0, 'a', "Backend requests made", "") +VSC_F(backend_req, uint64_t, 0, 'a', + "Backend requests made", + "" +) -VSC_F(n_vcl, uint64_t, 0, 'a', "N vcl total", "") -VSC_F(n_vcl_avail, uint64_t, 0, 'a', "N vcl available", "") -VSC_F(n_vcl_discard, uint64_t, 0, 'a', "N vcl discarded", "") +VSC_F(n_vcl, uint64_t, 0, 'a', + "N vcl total", + "" +) +VSC_F(n_vcl_avail, uint64_t, 0, 'a', + "N vcl available", + "" +) +VSC_F(n_vcl_discard, uint64_t, 0, 'a', + "N vcl discarded", + "" +) /**********************************************************************/ @@ -311,28 +471,65 @@ VSC_F(bans_dups, uint64_t, 0, 'c', /**********************************************************************/ VSC_F(hcb_nolock, uint64_t, 0, 'a', - "HCB Lookups without lock", "") -VSC_F(hcb_lock, uint64_t, 0, 'a', "HCB Lookups with lock", "") -VSC_F(hcb_insert, uint64_t, 0, 'a', "HCB Inserts", "") + "HCB Lookups without lock", + "" +) +VSC_F(hcb_lock, uint64_t, 0, 'a', + "HCB Lookups with lock", + "" +) +VSC_F(hcb_insert, uint64_t, 0, 'a', + "HCB Inserts", + "" +) VSC_F(esi_errors, uint64_t, 0, 'a', - "ESI parse errors (unlock)", "") + "ESI parse errors (unlock)", + "" +) VSC_F(esi_warnings, uint64_t, 0, 'a', - "ESI parse warnings (unlock)", "") -VSC_F(client_drop_late, uint64_t, 0, 'a', "Connection dropped late", "") -VSC_F(uptime, uint64_t, 0, 'a', "Client uptime", "") + "ESI parse warnings (unlock)", + "" +) +VSC_F(client_drop_late, uint64_t, 0, 'a', + "Connection dropped late", + "" +) +VSC_F(uptime, uint64_t, 0, 'a', + "Client uptime", + "" +) -VSC_F(dir_dns_lookups, uint64_t, 0, 'a', "DNS director lookups", "") -VSC_F(dir_dns_failed, uint64_t, 0, 'a', "DNS director failed lookups", "") +VSC_F(dir_dns_lookups, uint64_t, 0, 'a', + "DNS director lookups", + "" +) +VSC_F(dir_dns_failed, uint64_t, 0, 'a', + "DNS director failed lookups", + "" +) VSC_F(dir_dns_hit, uint64_t, 0, 'a', - "DNS director cached lookups hit", "") + "DNS director cached lookups hit", + "" +) VSC_F(dir_dns_cache_full, uint64_t, 0, 'a', - "DNS director full dnscache", "") + "DNS director full dnscache", + "" +) -VSC_F(vmods, uint64_t, 0, 'i', "Loaded VMODs", "") +VSC_F(vmods, uint64_t, 0, 'i', + "Loaded VMODs", + "" +) -VSC_F(n_gzip, uint64_t, 0, 'a', "Gzip operations", "") -VSC_F(n_gunzip, uint64_t, 0, 'a', "Gunzip operations", "") +VSC_F(n_gzip, uint64_t, 0, 'a', + "Gzip operations", + "" +) +VSC_F(n_gunzip, uint64_t, 0, 'a', + "Gunzip operations", + "" +) /**********************************************************************/ From phk at varnish-cache.org Tue Feb 14 14:27:13 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 14 Feb 2012 15:27:13 +0100 Subject: [master] bf5b757 Force this one into the same consistent layout. Message-ID: commit bf5b757b2448ff6f84e2eae5168bd674e9e71677 Author: Poul-Henning Kamp Date: Tue Feb 14 14:27:00 2012 +0000 Force this one into the same consistent layout. diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index 2d83f69..ea70ffb 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -61,10 +61,22 @@ #ifdef VSC_DO_LCK -VSC_F(creat, uint64_t, 0, 'a', "Created locks", "") -VSC_F(destroy, uint64_t, 0, 'a', "Destroyed locks", "") -VSC_F(locks, uint64_t, 0, 'a', "Lock Operations", "") -VSC_F(colls, uint64_t, 0, 'a', "Collisions", "") +VSC_F(creat, uint64_t, 0, 'a', + "Created locks", + "" +) +VSC_F(destroy, uint64_t, 0, 'a', + "Destroyed locks", + "" +) +VSC_F(locks, uint64_t, 0, 'a', + "Lock Operations", + "" +) +VSC_F(colls, uint64_t, 0, 'a', + "Collisions", + "" +) #endif @@ -73,13 +85,34 @@ VSC_F(colls, uint64_t, 0, 'a', "Collisions", "") */ #if defined(VSC_DO_SMA) || defined (VSC_DO_SMF) -VSC_F(c_req, uint64_t, 0, 'a', "Allocator requests", "") -VSC_F(c_fail, uint64_t, 0, 'a', "Allocator failures", "") -VSC_F(c_bytes, uint64_t, 0, 'a', "Bytes allocated", "") -VSC_F(c_freed, uint64_t, 0, 'a', "Bytes freed", "") -VSC_F(g_alloc, uint64_t, 0, 'i', "Allocations outstanding", "") -VSC_F(g_bytes, uint64_t, 0, 'i', "Bytes outstanding", "") -VSC_F(g_space, uint64_t, 0, 'i', "Bytes available", "") +VSC_F(c_req, uint64_t, 0, 'a', + "Allocator requests", + "" +) +VSC_F(c_fail, uint64_t, 0, 'a', + "Allocator failures", + "" +) +VSC_F(c_bytes, uint64_t, 0, 'a', + "Bytes allocated", + "" +) +VSC_F(c_freed, uint64_t, 0, 'a', + "Bytes freed", + "" +) +VSC_F(g_alloc, uint64_t, 0, 'i', + "Allocations outstanding", + "" +) +VSC_F(g_bytes, uint64_t, 0, 'i', + "Bytes outstanding", + "" +) +VSC_F(g_space, uint64_t, 0, 'i', + "Bytes available", + "" +) #endif @@ -92,33 +125,81 @@ VSC_F(g_space, uint64_t, 0, 'i', "Bytes available", "") /**********************************************************************/ #ifdef VSC_DO_SMF -VSC_F(g_smf, uint64_t, 0, 'i', "N struct smf", "") -VSC_F(g_smf_frag, uint64_t, 0, 'i', "N small free smf", "") -VSC_F(g_smf_large, uint64_t, 0, 'i', "N large free smf", "") +VSC_F(g_smf, uint64_t, 0, 'i', + "N struct smf", + "" +) +VSC_F(g_smf_frag, uint64_t, 0, 'i', + "N small free smf", + "" +) +VSC_F(g_smf_large, uint64_t, 0, 'i', + "N large free smf", + "" +) #endif /**********************************************************************/ #ifdef VSC_DO_VBE -VSC_F(vcls, uint64_t, 0, 'i', "VCL references", "") -VSC_F(happy, uint64_t, 0, 'b', "Happy health probes", "") +VSC_F(vcls, uint64_t, 0, 'i', + "VCL references", + "" +) +VSC_F(happy, uint64_t, 0, 'b', + "Happy health probes", + "" +) #endif /**********************************************************************/ #ifdef VSC_DO_MEMPOOL -VSC_F(live, uint64_t, 0, 'g', "In use", "") -VSC_F(pool, uint64_t, 0, 'g', "In Pool", "") -VSC_F(sz_wanted, uint64_t, 0, 'g', "Size requested", "") -VSC_F(sz_needed, uint64_t, 0, 'g', "Size allocated", "") -VSC_F(allocs, uint64_t, 0, 'c', "Allocations", "") -VSC_F(frees, uint64_t, 0, 'c', "Frees", "") -VSC_F(recycle, uint64_t, 0, 'c', "Recycled from pool", "") -VSC_F(timeout, uint64_t, 0, 'c', "Timed out from pool", "") -VSC_F(toosmall, uint64_t, 0, 'c', "Too small to recycle", "") -VSC_F(surplus, uint64_t, 0, 'c', "Too many for pool", "") -VSC_F(randry, uint64_t, 0, 'c', "Pool ran dry", "") +VSC_F(live, uint64_t, 0, 'g', + "In use", + "" +) +VSC_F(pool, uint64_t, 0, 'g', + "In Pool", + "" +) +VSC_F(sz_wanted, uint64_t, 0, 'g', + "Size requested", + "" +) +VSC_F(sz_needed, uint64_t, 0, 'g', + "Size allocated", + "" +) +VSC_F(allocs, uint64_t, 0, 'c', + "Allocations", + "" +) +VSC_F(frees, uint64_t, 0, 'c', + "Frees", + "" +) +VSC_F(recycle, uint64_t, 0, 'c', + "Recycled from pool", + "" +) +VSC_F(timeout, uint64_t, 0, 'c', + "Timed out from pool", + "" +) +VSC_F(toosmall, uint64_t, 0, 'c', + "Too small to recycle", + "" +) +VSC_F(surplus, uint64_t, 0, 'c', + "Too many for pool", + "" +) +VSC_F(randry, uint64_t, 0, 'c', + "Pool ran dry", + "" +) #endif From martin at varnish-cache.org Tue Feb 14 15:03:46 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 14 Feb 2012 16:03:46 +0100 Subject: [master] a434ce4 Honor remove-flag also when processing comments in ESI parsing. Message-ID: commit a434ce46a6362f1dc930d783982a8eda67cb99d6 Author: Martin Blix Grydeland Date: Tue Feb 14 15:02:32 2012 +0100 Honor remove-flag also when processing comments in ESI parsing. Fixes: #1092 diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 433208d..8e9429c 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -706,7 +706,6 @@ VEP_Parse(const struct busyobj *bo, const char *p, size_t l) vep->until_p = vep->until = "-->"; vep->until_s = VEP_NEXTTAG; vep->state = VEP_UNTIL; - vep_mark_verbatim(vep, p); break; } p++; diff --git a/bin/varnishtest/tests/r01092.vtc b/bin/varnishtest/tests/r01092.vtc new file mode 100644 index 0000000..26b0b9c --- /dev/null +++ b/bin/varnishtest/tests/r01092.vtc @@ -0,0 +1,34 @@ +varnishtest "Test case for #1092 - esi:remove and comments" + +server s1 { + rxreq + txresp -body { + + Keep-1 + + + + Remove-1 + + + Remove-4444 + + Keep-4444 + + } +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + set beresp.do_esi = true; + } +} -start -cliok "param.set esi_syntax 4" + +client c1 { + txreq + rxresp + expect resp.bodylen == 80 +} + +client c1 -run +varnish v1 -expect esi_errors == 1 From geoff at varnish-cache.org Tue Feb 14 16:49:18 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:18 +0100 Subject: [experimental-ims] a2a2717 Move more gzip buffers off th wrk->stack and into malloc. Message-ID: commit a2a2717f6c8e5a185151343c70532a9615039583 Author: Poul-Henning Kamp Date: Tue Feb 7 10:27:32 2012 +0000 Move more gzip buffers off th wrk->stack and into malloc. diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index d2f4c01..6b2d271 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -37,6 +37,24 @@ #include "cache_esi.h" /*--------------------------------------------------------------------- + */ + +struct vef_priv { + unsigned magic; +#define VEF_MAGIC 0xf104b51f + struct vgz *vgz; + + char *bufp; + ssize_t tot; + int error; + char pending[20]; + ssize_t npend; + + char *ibuf; + ssize_t ibuf_sz; +}; + +/*--------------------------------------------------------------------- * Read some bytes. * * If the esi_syntax&8 bit is set, we read only a couple of bytes at @@ -64,12 +82,14 @@ vef_read(struct worker *wrk, struct http_conn *htc, void *buf, ssize_t buflen, */ static int -vfp_esi_bytes_uu(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +vfp_esi_bytes_uu(struct worker *wrk, const struct vef_priv *vef, + struct http_conn *htc, ssize_t bytes) { ssize_t wl; struct storage *st; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); while (bytes > 0) { st = FetchStorage(wrk, 0); @@ -92,24 +112,25 @@ vfp_esi_bytes_uu(struct worker *wrk, struct http_conn *htc, ssize_t bytes) */ static int -vfp_esi_bytes_gu(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, + struct http_conn *htc, ssize_t bytes) { struct vgz *vg; ssize_t wl; - uint8_t ibuf[cache_param->gzip_stack_buffer]; int i; size_t dl; const void *dp; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); vg = wrk->busyobj->vgz_rx; while (bytes > 0) { if (VGZ_IbufEmpty(vg) && bytes > 0) { - wl = vef_read(wrk, htc, ibuf, sizeof ibuf, bytes); + wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes); if (wl <= 0) return (wl); - VGZ_Ibuf(vg, ibuf, wl); + VGZ_Ibuf(vg, vef->ibuf, wl); bytes -= wl; } if (VGZ_ObufStorage(wrk, vg)) @@ -123,21 +144,6 @@ vfp_esi_bytes_gu(struct worker *wrk, struct http_conn *htc, ssize_t bytes) } /*--------------------------------------------------------------------- - */ - -struct vef_priv { - unsigned magic; -#define VEF_MAGIC 0xf104b51f - struct vgz *vgz; - - char *bufp; - ssize_t tot; - int error; - char pending[20]; - ssize_t npend; -}; - -/*--------------------------------------------------------------------- * We receive a [un]gzip'ed object, and want to store it gzip'ed. */ @@ -205,31 +211,29 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) } static int -vfp_esi_bytes_ug(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef, + struct http_conn *htc, ssize_t bytes) { ssize_t wl; - char ibuf[cache_param->gzip_stack_buffer]; - struct vef_priv *vef; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vef = wrk->busyobj->vef_priv; CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); + CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); while (bytes > 0) { - wl = vef_read(wrk, htc, ibuf, sizeof ibuf, bytes); + wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes); if (wl <= 0) return (wl); bytes -= wl; - vef->bufp = ibuf; - VEP_Parse(wrk, ibuf, wl); - assert(vef->bufp >= ibuf && vef->bufp <= ibuf + wl); + vef->bufp = vef->ibuf; + VEP_Parse(wrk, vef->ibuf, wl); + assert(vef->bufp >= vef->ibuf && vef->bufp <= vef->ibuf + wl); if (vef->error) { errno = vef->error; return (-1); } - if (vef->bufp < ibuf + wl) { - wl = (ibuf + wl) - vef->bufp; + if (vef->bufp < vef->ibuf + wl) { + wl = (vef->ibuf + wl) - vef->bufp; assert(wl + vef->npend < sizeof vef->pending); memmove(vef->pending + vef->npend, vef->bufp, wl); vef->npend += wl; @@ -243,31 +247,28 @@ vfp_esi_bytes_ug(struct worker *wrk, struct http_conn *htc, ssize_t bytes) */ static int -vfp_esi_bytes_gg(struct worker *wrk, struct http_conn *htc, size_t bytes) +vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef, + struct http_conn *htc, size_t bytes) { ssize_t wl; - char ibuf[cache_param->gzip_stack_buffer]; char ibuf2[cache_param->gzip_stack_buffer]; - struct vef_priv *vef; size_t dl; const void *dp; int i; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vef = wrk->busyobj->vef_priv; CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - assert(sizeof ibuf >= 1024); + CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); ibuf2[0] = 0; /* For Flexelint */ while (bytes > 0) { - wl = vef_read(wrk, htc, ibuf, sizeof ibuf, bytes); + wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes); if (wl <= 0) return (wl); bytes -= wl; - vef->bufp = ibuf; - VGZ_Ibuf(wrk->busyobj->vgz_rx, ibuf, wl); + vef->bufp = vef->ibuf; + VGZ_Ibuf(wrk->busyobj->vgz_rx, vef->ibuf, wl); do { VGZ_Obuf(wrk->busyobj->vgz_rx, ibuf2, sizeof ibuf2); i = VGZ_Gunzip(wrk->busyobj->vgz_rx, &dp, &dl); @@ -306,30 +307,32 @@ vfp_esi_begin(struct worker *wrk, size_t estimate) bo = wrk->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + ALLOC_OBJ(vef, VEF_MAGIC); + XXXAN(vef); + AZ(bo->vef_priv); + bo->vef_priv = vef; + AZ(bo->vgz_rx); if (bo->is_gzip && bo->do_gunzip) { bo->vgz_rx = VGZ_NewUngzip(wrk, "U F E"); VEP_Init(wrk, NULL); + vef->ibuf_sz = cache_param->gzip_stack_buffer; } else if (bo->is_gunzip && bo->do_gzip) { - ALLOC_OBJ(vef, VEF_MAGIC); - AN(vef); vef->vgz = VGZ_NewGzip(wrk, "G F E"); - AZ(bo->vef_priv); - bo->vef_priv = vef; VEP_Init(wrk, vfp_vep_callback); + vef->ibuf_sz = cache_param->gzip_stack_buffer; } else if (bo->is_gzip) { bo->vgz_rx = VGZ_NewUngzip(wrk, "U F E"); - ALLOC_OBJ(vef, VEF_MAGIC); - AN(vef); vef->vgz = VGZ_NewGzip(wrk, "G F E"); - AZ(bo->vef_priv); - bo->vef_priv = vef; VEP_Init(wrk, vfp_vep_callback); + vef->ibuf_sz = cache_param->gzip_stack_buffer; } else { - AZ(bo->vef_priv); VEP_Init(wrk, NULL); } - + if (vef->ibuf_sz > 0) { + vef->ibuf = calloc(1L, vef->ibuf_sz); + XXXAN(vef->ibuf); + } AN(bo->vep); } @@ -337,23 +340,26 @@ static int __match_proto__() vfp_esi_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) { struct busyobj *bo; + struct vef_priv *vef; int i; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); bo = wrk->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vef = bo->vef_priv; + CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); AZ(bo->fetch_failed); AN(bo->vep); assert(&bo->htc == htc); if (bo->is_gzip && bo->do_gunzip) - i = vfp_esi_bytes_gu(wrk, htc, bytes); + i = vfp_esi_bytes_gu(wrk, vef, htc, bytes); else if (bo->is_gunzip && bo->do_gzip) - i = vfp_esi_bytes_ug(wrk, htc, bytes); + i = vfp_esi_bytes_ug(wrk, vef, htc, bytes); else if (bo->is_gzip) - i = vfp_esi_bytes_gg(wrk, htc, bytes); + i = vfp_esi_bytes_gg(wrk, vef, htc, bytes); else - i = vfp_esi_bytes_uu(wrk, htc, bytes); + i = vfp_esi_bytes_uu(wrk, vef, htc, bytes); AN(bo->vep); return (i); } @@ -398,15 +404,17 @@ vfp_esi_end(struct worker *wrk) } vef = bo->vef_priv; - if (vef != NULL) { - CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - bo->vef_priv = NULL; + bo->vef_priv = NULL; + 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) retval = FetchError(wrk, "ESI+Gzip Failed at the very end"); - FREE_OBJ(vef); } + if (vef->ibuf != NULL) + free(vef->ibuf); + FREE_OBJ(vef); return (retval); } From geoff at varnish-cache.org Tue Feb 14 16:49:18 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:18 +0100 Subject: [experimental-ims] da2cdc5 Move the second G-ESI-G buffer away from the stack too. Message-ID: commit da2cdc5d6d89c8533e2acf4ab5f2eeed6b14a40b Author: Poul-Henning Kamp Date: Tue Feb 7 10:47:20 2012 +0000 Move the second G-ESI-G buffer away from the stack too. diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 6b2d271..e5facd7 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -52,6 +52,9 @@ struct vef_priv { char *ibuf; ssize_t ibuf_sz; + + char *ibuf2; + ssize_t ibuf2_sz; }; /*--------------------------------------------------------------------- @@ -251,7 +254,6 @@ vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef, struct http_conn *htc, size_t bytes) { ssize_t wl; - char ibuf2[cache_param->gzip_stack_buffer]; size_t dl; const void *dp; int i; @@ -259,30 +261,30 @@ vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef, CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - ibuf2[0] = 0; /* For Flexelint */ while (bytes > 0) { - wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes); + wl = vef_read(wrk, htc, vef->ibuf2, vef->ibuf2_sz, bytes); if (wl <= 0) return (wl); bytes -= wl; - vef->bufp = vef->ibuf; - VGZ_Ibuf(wrk->busyobj->vgz_rx, vef->ibuf, wl); + vef->bufp = vef->ibuf2; + VGZ_Ibuf(wrk->busyobj->vgz_rx, vef->ibuf2, wl); do { - VGZ_Obuf(wrk->busyobj->vgz_rx, ibuf2, sizeof ibuf2); + VGZ_Obuf(wrk->busyobj->vgz_rx, vef->ibuf, + vef->ibuf_sz); i = VGZ_Gunzip(wrk->busyobj->vgz_rx, &dp, &dl); /* XXX: check i */ assert(i >= VGZ_OK); - vef->bufp = ibuf2; + vef->bufp = vef->ibuf; if (dl > 0) - VEP_Parse(wrk, ibuf2, dl); + VEP_Parse(wrk, vef->ibuf, dl); if (vef->error) { errno = vef->error; return (-1); } - if (vef->bufp < ibuf2 + dl) { - dl = (ibuf2 + dl) - vef->bufp; + if (vef->bufp < vef->ibuf + dl) { + dl = (vef->ibuf + dl) - vef->bufp; assert(dl + vef->npend < sizeof vef->pending); memmove(vef->pending + vef->npend, vef->bufp, dl); @@ -326,6 +328,7 @@ vfp_esi_begin(struct worker *wrk, size_t estimate) vef->vgz = VGZ_NewGzip(wrk, "G F E"); VEP_Init(wrk, vfp_vep_callback); vef->ibuf_sz = cache_param->gzip_stack_buffer; + vef->ibuf2_sz = cache_param->gzip_stack_buffer; } else { VEP_Init(wrk, NULL); } @@ -333,6 +336,10 @@ vfp_esi_begin(struct worker *wrk, size_t estimate) vef->ibuf = calloc(1L, vef->ibuf_sz); XXXAN(vef->ibuf); } + if (vef->ibuf2_sz > 0) { + vef->ibuf2 = calloc(1L, vef->ibuf2_sz); + XXXAN(vef->ibuf2); + } AN(bo->vep); } @@ -414,6 +421,8 @@ vfp_esi_end(struct worker *wrk) } if (vef->ibuf != NULL) free(vef->ibuf); + if (vef->ibuf2 != NULL) + free(vef->ibuf2); FREE_OBJ(vef); return (retval); } From geoff at varnish-cache.org Tue Feb 14 16:49:18 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:18 +0100 Subject: [experimental-ims] 0eae9d0 Now that we have a input buffer which persists over calls to vfp->bytes, loose the dedicated "pending" buffer and just use the front of the input buffer. This simplifies the code quite a bit. Message-ID: commit 0eae9d0076b419b4d9979cba519f7502e43a6384 Author: Poul-Henning Kamp Date: Tue Feb 7 13:17:07 2012 +0000 Now that we have a input buffer which persists over calls to vfp->bytes, loose the dedicated "pending" buffer and just use the front of the input buffer. This simplifies the code quite a bit. diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index e5facd7..4b9d04d 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -44,13 +44,12 @@ struct vef_priv { #define VEF_MAGIC 0xf104b51f struct vgz *vgz; - char *bufp; ssize_t tot; int error; - char pending[20]; - ssize_t npend; char *ibuf; + char *ibuf_i; + char *ibuf_o; ssize_t ibuf_sz; char *ibuf2; @@ -148,13 +147,46 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, /*--------------------------------------------------------------------- * We receive a [un]gzip'ed object, and want to store it gzip'ed. + * + * This is rather complicated, because the ESI parser does not + * spit out all bytes we feed it right away: Sometimes it needs + * more input to make up its mind. + * + * The inject function feeds uncompressed bytes into the VEP, and + * takes care to keep any bytes VEP didn't decide on intact until + * later. + * + * The callback is called by VEP to dispose of bytes and report + * where to find them again later. */ +static int +vfp_vep_inject(const struct worker *wrk, struct vef_priv *vef, ssize_t wl) +{ + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); + + VEP_Parse(wrk, vef->ibuf_i, wl); + vef->ibuf_i += wl; + assert(vef->ibuf_o >= vef->ibuf && vef->ibuf_o <= vef->ibuf_i); + if (vef->error) { + errno = vef->error; + return (-1); + } + wl = vef->ibuf_i - vef->ibuf_o; + if (wl > 0) + memmove(vef->ibuf, vef->ibuf_o, wl); + vef->ibuf_o = vef->ibuf; + vef->ibuf_i = vef->ibuf + wl; + return (0); +} + static ssize_t vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) { struct vef_priv *vef; - size_t dl, px; + size_t dl; const void *dp; int i; @@ -177,35 +209,20 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) if (l == 0 && flg == VGZ_NORMAL) return (vef->tot); + VGZ_Ibuf(vef->vgz, vef->ibuf_o, l); do { - px = vef->npend; - if (l < px) - px = l; - if (px != 0) { - VGZ_Ibuf(vef->vgz, vef->pending, px); - l -= px; - } else { - VGZ_Ibuf(vef->vgz, vef->bufp, l); - vef->bufp += l; - l = 0; - } - do { - if (VGZ_ObufStorage(wrk, vef->vgz)) { - vef->error = ENOMEM; - vef->tot += l; - return (vef->tot); - } - i = VGZ_Gzip(vef->vgz, &dp, &dl, flg); - vef->tot += dl; - wrk->busyobj->fetch_obj->len += dl; - } while (!VGZ_IbufEmpty(vef->vgz) || - (flg != VGZ_NORMAL && VGZ_ObufFull(vef->vgz))); - if (px != 0) { - memmove(vef->pending, vef->pending + px, - vef->npend - px); - vef->npend -= px; + if (VGZ_ObufStorage(wrk, vef->vgz)) { + vef->error = ENOMEM; + vef->tot += l; + return (vef->tot); } - } while (l > 0); + i = VGZ_Gzip(vef->vgz, &dp, &dl, flg); + vef->tot += dl; + wrk->busyobj->fetch_obj->len += dl; + } while (!VGZ_IbufEmpty(vef->vgz) || + (flg != VGZ_NORMAL && VGZ_ObufFull(vef->vgz))); + assert(VGZ_IbufEmpty(vef->vgz)); + vef->ibuf_o += l; if (flg == VGZ_FINISH) assert(i == 1); /* XXX */ else @@ -213,6 +230,10 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) return (vef->tot); } +/*--------------------------------------------------------------------- + * We receive a gunzip'ed object, and want to store it gzip'ed. + */ + static int vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef, struct http_conn *htc, ssize_t bytes) @@ -224,23 +245,13 @@ vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef, CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); while (bytes > 0) { - wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes); + wl = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf); + wl = vef_read(wrk, htc, vef->ibuf_i, wl, bytes); if (wl <= 0) return (wl); bytes -= wl; - vef->bufp = vef->ibuf; - VEP_Parse(wrk, vef->ibuf, wl); - assert(vef->bufp >= vef->ibuf && vef->bufp <= vef->ibuf + wl); - if (vef->error) { - errno = vef->error; + if (vfp_vep_inject(wrk, vef, wl)) return (-1); - } - if (vef->bufp < vef->ibuf + wl) { - wl = (vef->ibuf + wl) - vef->bufp; - assert(wl + vef->npend < sizeof vef->pending); - memmove(vef->pending + vef->npend, vef->bufp, wl); - vef->npend += wl; - } } return (1); } @@ -268,34 +279,20 @@ vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef, return (wl); bytes -= wl; - vef->bufp = vef->ibuf2; VGZ_Ibuf(wrk->busyobj->vgz_rx, vef->ibuf2, wl); do { - VGZ_Obuf(wrk->busyobj->vgz_rx, vef->ibuf, - vef->ibuf_sz); + wl = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf); + VGZ_Obuf(wrk->busyobj->vgz_rx, vef->ibuf_i, wl); i = VGZ_Gunzip(wrk->busyobj->vgz_rx, &dp, &dl); /* XXX: check i */ assert(i >= VGZ_OK); - vef->bufp = vef->ibuf; - if (dl > 0) - VEP_Parse(wrk, vef->ibuf, dl); - if (vef->error) { - errno = vef->error; + if (dl > 0 && vfp_vep_inject(wrk, vef, dl)) return (-1); - } - if (vef->bufp < vef->ibuf + dl) { - dl = (vef->ibuf + dl) - vef->bufp; - assert(dl + vef->npend < sizeof vef->pending); - memmove(vef->pending + vef->npend, - vef->bufp, dl); - vef->npend += dl; - } } while (!VGZ_IbufEmpty(wrk->busyobj->vgz_rx)); } return (1); } - /*---------------------------------------------------------------------*/ static void __match_proto__() @@ -335,6 +332,8 @@ vfp_esi_begin(struct worker *wrk, size_t estimate) if (vef->ibuf_sz > 0) { vef->ibuf = calloc(1L, vef->ibuf_sz); XXXAN(vef->ibuf); + vef->ibuf_i = vef->ibuf; + vef->ibuf_o = vef->ibuf; } if (vef->ibuf2_sz > 0) { vef->ibuf2 = calloc(1L, vef->ibuf2_sz); From geoff at varnish-cache.org Tue Feb 14 16:49:18 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:18 +0100 Subject: [experimental-ims] 42f03cc Move the last g(un)zip buffers from the wrk->stack to malloc(3). Message-ID: commit 42f03cc1c580d1acb811eb63284584d98393a171 Author: Poul-Henning Kamp Date: Tue Feb 7 13:57:39 2012 +0000 Move the last g(un)zip buffers from the wrk->stack to malloc(3). Rename the gzip_stack_buffer param to gzip_buffer. Remove the gzip_tmp_space param. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b89ef23..f7bef9d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -788,7 +788,6 @@ int VGZ_WrwInit(struct vgz *vg); int VGZ_WrwGunzip(struct worker *w, struct vgz *, const void *ibuf, ssize_t ibufl); void VGZ_WrwFlush(struct worker *wrk, struct vgz *vg); -void VGZ_WrwFinish(struct worker *wrk, struct vgz *vg); /* Return values */ #define VGZ_ERROR -1 diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 0175c3d..a9bc694 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -389,7 +389,7 @@ ESI_Deliver(struct sess *sp) } } if (vgz != NULL) { - VGZ_WrwFinish(sp->wrk, vgz); + VGZ_WrwFlush(sp->wrk, vgz); (void)VGZ_Destroy(&vgz, sp->vsl_id); } if (sp->req->gzip_resp && sp->req->esi_level == 0) { diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 4b9d04d..64adf51 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -315,17 +315,17 @@ vfp_esi_begin(struct worker *wrk, size_t estimate) if (bo->is_gzip && bo->do_gunzip) { bo->vgz_rx = VGZ_NewUngzip(wrk, "U F E"); VEP_Init(wrk, NULL); - vef->ibuf_sz = cache_param->gzip_stack_buffer; + vef->ibuf_sz = cache_param->gzip_buffer; } else if (bo->is_gunzip && bo->do_gzip) { vef->vgz = VGZ_NewGzip(wrk, "G F E"); VEP_Init(wrk, vfp_vep_callback); - vef->ibuf_sz = cache_param->gzip_stack_buffer; + 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"); VEP_Init(wrk, vfp_vep_callback); - vef->ibuf_sz = cache_param->gzip_stack_buffer; - vef->ibuf2_sz = cache_param->gzip_stack_buffer; + vef->ibuf_sz = cache_param->gzip_buffer; + vef->ibuf2_sz = cache_param->gzip_buffer; } else { VEP_Init(wrk, NULL); } diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 63a18cd..402633f 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -86,34 +86,13 @@ struct vgz { struct storage *st_obuf; /* Wrw stuff */ - char *wrw_buf; - ssize_t wrw_sz; - ssize_t wrw_len; + char *m_buf; + ssize_t m_sz; + ssize_t m_len; z_stream vz; }; -/*--------------------------------------------------------------------*/ - -static voidpf -vgz_alloc(voidpf opaque, uInt items, uInt size) -{ - struct vgz *vg; - - CAST_OBJ_NOTNULL(vg, opaque, VGZ_MAGIC); - - return (WS_Alloc(vg->tmp, items * size)); -} - -static void -vgz_free(voidpf opaque, voidpf address) -{ - struct vgz *vg; - - CAST_OBJ_NOTNULL(vg, opaque, VGZ_MAGIC); - (void)address; -} - /*-------------------------------------------------------------------- * Set up a gunzip instance */ @@ -127,30 +106,10 @@ vgz_alloc_vgz(struct worker *wrk, const char *id) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); ws = wrk->ws; WS_Assert(ws); - // XXX: we restore workspace in esi:include - // vg = (void*)WS_Alloc(ws, sizeof *vg); ALLOC_OBJ(vg, VGZ_MAGIC); AN(vg); - memset(vg, 0, sizeof *vg); - vg->magic = VGZ_MAGIC; vg->wrk = wrk; vg->id = id; - - switch (cache_param->gzip_tmp_space) { - case 0: - case 1: - /* malloc, the default */ - break; - case 2: - vg->tmp = wrk->ws; - vg->tmp_snapshot = WS_Snapshot(vg->tmp); - vg->vz.zalloc = vgz_alloc; - vg->vz.zfree = vgz_free; - vg->vz.opaque = vg; - break; - default: - assert(0 == __LINE__); - } return (vg); } @@ -210,6 +169,27 @@ VGZ_NewGzip(struct worker *wrk, const char *id) return (vg); } +/*-------------------------------------------------------------------- + */ + +static int +vgz_getmbuf(struct vgz *vg) +{ + + CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); + AZ(vg->m_sz); + AZ(vg->m_len); + AZ(vg->m_buf); + + vg->m_sz = cache_param->gzip_buffer; + vg->m_buf = malloc(vg->m_sz); + if (vg->m_buf == NULL) { + vg->m_sz = 0; + return (-1); + } + return (0); +} + /*--------------------------------------------------------------------*/ void @@ -356,17 +336,11 @@ VGZ_WrwInit(struct vgz *vg) { CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - AZ(vg->wrw_sz); - AZ(vg->wrw_len); - AZ(vg->wrw_buf); - - vg->wrw_sz = cache_param->gzip_stack_buffer; - vg->wrw_buf = malloc(vg->wrw_sz); - if (vg->wrw_buf == NULL) { - vg->wrw_sz = 0; + + if (vgz_getmbuf(vg)) return (-1); - } - VGZ_Obuf(vg, vg->wrw_buf, vg->wrw_sz); + + VGZ_Obuf(vg, vg->m_buf, vg->m_sz); return (0); } @@ -385,27 +359,27 @@ VGZ_WrwGunzip(struct worker *wrk, struct vgz *vg, const void *ibuf, CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - AN(vg->wrw_buf); + AN(vg->m_buf); VGZ_Ibuf(vg, ibuf, ibufl); if (ibufl == 0) return (VGZ_OK); do { - if (vg->wrw_len == vg->wrw_sz) + if (vg->m_len == vg->m_sz) i = VGZ_STUCK; else { i = VGZ_Gunzip(vg, &dp, &dl); - vg->wrw_len += dl; + vg->m_len += dl; } if (i < VGZ_OK) { /* XXX: VSL ? */ return (-1); } - if (vg->wrw_len == vg->wrw_sz || i == VGZ_STUCK) { - wrk->acct_tmp.bodybytes += vg->wrw_len; - (void)WRW_Write(wrk, vg->wrw_buf, vg->wrw_len); + if (vg->m_len == vg->m_sz || i == VGZ_STUCK) { + wrk->acct_tmp.bodybytes += vg->m_len; + (void)WRW_Write(wrk, vg->m_buf, vg->m_len); (void)WRW_Flush(wrk); - vg->wrw_len = 0; - VGZ_Obuf(vg, vg->wrw_buf, vg->wrw_sz); + vg->m_len = 0; + VGZ_Obuf(vg, vg->m_buf, vg->m_sz); } } while (!VGZ_IbufEmpty(vg)); if (i == VGZ_STUCK) @@ -421,25 +395,11 @@ VGZ_WrwFlush(struct worker *wrk, struct vgz *vg) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - if (vg->wrw_len == 0) + if (vg->m_len == 0) return; - (void)WRW_Write(wrk, vg->wrw_buf, vg->wrw_len); + (void)WRW_Write(wrk, vg->m_buf, vg->m_len); (void)WRW_Flush(wrk); - vg->wrw_len = 0; -} - -/*--------------------------------------------------------------------*/ - -void -VGZ_WrwFinish(struct worker *wrk, struct vgz *vg) -{ - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - - VGZ_WrwFlush(wrk, vg); - free(vg->wrw_buf); - vg->wrw_buf = 0; - vg->wrw_sz = 0; + vg->m_len = 0; } /*--------------------------------------------------------------------*/ @@ -468,7 +428,6 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id) vg = *vgp; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); *vgp = NULL; - AZ(vg->wrw_buf); if (vsl_id < 0) WSLB(vg->wrk, SLT_Gzip, "%s %jd %jd %jd %jd %jd", @@ -494,6 +453,8 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id) i = inflateEnd(&vg->vz); if (vg->last_i == Z_STREAM_END && i == Z_OK) i = Z_STREAM_END; + if (vg->m_buf) + free(vg->m_buf); FREE_OBJ(vg); if (i == Z_OK) return (VGZ_OK); @@ -518,6 +479,7 @@ vfp_gunzip_begin(struct worker *wrk, size_t estimate) CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(wrk->busyobj->vgz_rx); wrk->busyobj->vgz_rx = VGZ_NewUngzip(wrk, "U F -"); + XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx)); } static int __match_proto__() @@ -526,7 +488,6 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) struct vgz *vg; ssize_t l, wl; int i = -100; - uint8_t ibuf[cache_param->gzip_stack_buffer]; size_t dl; const void *dp; @@ -538,13 +499,13 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) AZ(vg->vz.avail_in); while (bytes > 0 || vg->vz.avail_in > 0) { if (vg->vz.avail_in == 0 && bytes > 0) { - l = sizeof ibuf; + l = vg->m_sz; if (l > bytes) l = bytes; - wl = HTC_Read(wrk, htc, ibuf, l); + wl = HTC_Read(wrk, htc, vg->m_buf, l); if (wl <= 0) return (wl); - VGZ_Ibuf(vg, ibuf, wl); + VGZ_Ibuf(vg, vg->m_buf, wl); bytes -= wl; } @@ -586,7 +547,6 @@ struct vfp vfp_gunzip = { .end = vfp_gunzip_end, }; - /*-------------------------------------------------------------------- * VFP_GZIP * @@ -602,6 +562,7 @@ vfp_gzip_begin(struct worker *wrk, size_t estimate) CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(wrk->busyobj->vgz_rx); wrk->busyobj->vgz_rx = VGZ_NewGzip(wrk, "G F -"); + XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx)); } static int __match_proto__() @@ -610,7 +571,6 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) struct vgz *vg; ssize_t l, wl; int i = -100; - uint8_t ibuf[cache_param->gzip_stack_buffer]; size_t dl; const void *dp; @@ -622,13 +582,13 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) AZ(vg->vz.avail_in); while (bytes > 0 || !VGZ_IbufEmpty(vg)) { if (VGZ_IbufEmpty(vg) && bytes > 0) { - l = sizeof ibuf; + l = vg->m_sz; if (l > bytes) l = bytes; - wl = HTC_Read(wrk, htc, ibuf, l); + wl = HTC_Read(wrk, htc, vg->m_buf, l); if (wl <= 0) return (wl); - VGZ_Ibuf(vg, ibuf, wl); + VGZ_Ibuf(vg, vg->m_buf, wl); bytes -= wl; } if (VGZ_ObufStorage(wrk, vg)) @@ -695,6 +655,7 @@ vfp_testgzip_begin(struct worker *wrk, size_t estimate) (void)estimate; wrk->busyobj->vgz_rx = VGZ_NewUngzip(wrk, "u F -"); CHECK_OBJ_NOTNULL(wrk->busyobj->vgz_rx, VGZ_MAGIC); + XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx)); } static int __match_proto__() @@ -703,7 +664,6 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) struct vgz *vg; ssize_t l, wl; int i = -100; - uint8_t obuf[cache_param->gzip_stack_buffer]; size_t dl; const void *dp; struct storage *st; @@ -732,7 +692,7 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) RES_StreamPoll(wrk); while (!VGZ_IbufEmpty(vg)) { - VGZ_Obuf(vg, obuf, sizeof obuf); + VGZ_Obuf(vg, vg->m_buf, vg->m_sz); i = VGZ_Gunzip(vg, &dp, &dl); if (i == VGZ_END && !VGZ_IbufEmpty(vg)) return(FetchError(wrk, "Junk after gzip data")); diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 6206c18..6c48468 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -179,7 +179,7 @@ res_WriteGunzipObj(const struct sess *sp) /* XXX: error check */ (void)i; } - VGZ_WrwFinish(sp->wrk, vg); + VGZ_WrwFlush(sp->wrk, vg); (void)VGZ_Destroy(&vg, sp->vsl_id); assert(u == sp->req->obj->len); } @@ -420,7 +420,7 @@ RES_StreamEnd(struct sess *sp) if (sp->wrk->res_mode & RES_GUNZIP) { AN(sctx->vgz); - VGZ_WrwFinish(sp->wrk, sctx->vgz); + VGZ_WrwFlush(sp->wrk, sctx->vgz); (void)VGZ_Destroy(&sctx->vgz, sp->vsl_id); } if (sp->wrk->res_mode & RES_CHUNKED && diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 6c1899a..015e5d2 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -181,8 +181,7 @@ struct params { unsigned http_range_support; unsigned http_gzip_support; - unsigned gzip_stack_buffer; - unsigned gzip_tmp_space; + unsigned gzip_buffer; unsigned gzip_level; unsigned gzip_window; unsigned gzip_memlevel; diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index c984aae..60d49f8 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -1084,17 +1084,6 @@ static const struct parspec input_parspec[] = { "Varnish reference.", EXPERIMENTAL, "on", "bool" }, - { "gzip_tmp_space", tweak_uint, &mgt_param.gzip_tmp_space, 0, 2, - "Where temporary space for gzip/gunzip is allocated:\n" - " 0 - malloc\n" - " 2 - thread workspace\n" - "\n" - "If you have much gzip/gunzip activity, it may be an" - " advantage to use workspace for these allocations to reduce" - " malloc activity. Be aware that gzip needs 256+KB and gunzip" - " needs 32+KB of workspace (64+KB if ESI processing).", - EXPERIMENTAL, - "0", "" }, { "gzip_level", tweak_uint, &mgt_param.gzip_level, 0, 9, "Gzip compression level: 0=debug, 1=fast, 9=best", 0, @@ -1109,11 +1098,11 @@ static const struct parspec input_parspec[] = { "Memory impact is 1=1k, 2=2k, ... 9=256k.", 0, "8", ""}, - { "gzip_stack_buffer", - tweak_bytes_u, &mgt_param.gzip_stack_buffer, + { "gzip_buffer", + tweak_bytes_u, &mgt_param.gzip_buffer, 2048, UINT_MAX, - "Size of stack buffer used for gzip processing.\n" - "The stack buffers are used for in-transit data," + "Size of malloc buffer used for gzip processing.\n" + "These buffers are used for in-transit data," " for instance gunzip'ed data being sent to a client." "Making this space to small results in more overhead," " writes to sockets etc, making it too big is probably" diff --git a/bin/varnishtest/tests/e00020.vtc b/bin/varnishtest/tests/e00020.vtc index 5b40c16..f9b73a4 100644 --- a/bin/varnishtest/tests/e00020.vtc +++ b/bin/varnishtest/tests/e00020.vtc @@ -22,7 +22,6 @@ varnish v1 -vcl+backend { varnish v1 -cliok "param.set esi_syntax 4" varnish v1 -cliok "param.set http_gzip_support true" -varnish v1 -cliok "param.set gzip_tmp_space 2" client c1 { txreq diff --git a/bin/varnishtest/tests/e00022.vtc b/bin/varnishtest/tests/e00022.vtc index 897f3ee..1f13cd3 100644 --- a/bin/varnishtest/tests/e00022.vtc +++ b/bin/varnishtest/tests/e00022.vtc @@ -25,7 +25,6 @@ varnish v1 -arg "-p thread_pool_stack=262144" -vcl+backend { varnish v1 -cliok "param.set esi_syntax 0xc" varnish v1 -cliok "param.set http_gzip_support true" -varnish v1 -cliok "param.set gzip_tmp_space 1" varnish v1 -cliok "param.set gzip_window 8" varnish v1 -cliok "param.set gzip_memlevel 1" From geoff at varnish-cache.org Tue Feb 14 16:49:18 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:18 +0100 Subject: [experimental-ims] 2a5cf8f Remove comment OBE. Message-ID: commit 2a5cf8f7574c92fa7eef4852742f9b25497fed2e Author: Poul-Henning Kamp Date: Tue Feb 7 14:10:06 2012 +0000 Remove comment OBE. diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 402633f..6064f67 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -34,34 +34,6 @@ * The API defined by this file, will also insulate the rest of the code, * should we find a better gzip library at a later date. * - * The absolutely worst case gzip processing path, once we have pipe-lining, - * will be the following, so we need to be a bit careful with the scratch - * space we use: - * - * Backend Tmp Input Output - * | ---------------------- - * v - * gunzip wrk stack ? - * | - * v - * esi - * | - * v - * gzip wrk ? storage - * | - * v - * cache - * | - * v - * gunzip wrk storage stack - * | - * v - * client - * - * XXXX: The two '?' are obviously the same memory, but I have yet to decide - * where it goes. As usual we try to avoid the session->ws if we can but - * I may have to use that. - * */ #include "config.h" From geoff at varnish-cache.org Tue Feb 14 16:49:18 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:18 +0100 Subject: [experimental-ims] 2362e93 Add a call-back function to memory pools, which can be used to update the desired size of objects from the guard thread. Message-ID: commit 2362e936e03bf3ee2093efe3aa663c9c998b272b Author: Poul-Henning Kamp Date: Wed Feb 8 22:03:39 2012 +0000 Add a call-back function to memory pools, which can be used to update the desired size of objects from the guard thread. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f7bef9d..6338750 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -884,9 +884,10 @@ int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, struct timespec *ts); #undef LOCK /* cache_mempool.c */ +typedef void mpl_poll_f(volatile unsigned *); void MPL_AssertSane(void *item); struct mempool * MPL_New(const char *name, volatile struct poolparam *pp, - volatile unsigned *cur_size); + volatile unsigned *cur_size, mpl_poll_f *poll_f); void MPL_Destroy(struct mempool **mpp); void *MPL_Get(struct mempool *mpl, unsigned *size); void MPL_Free(struct mempool *mpl, void *item); diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index b683300..2610b06 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -519,6 +519,6 @@ void VDI_Init(void) { - vbcpool = MPL_New("vbc", &cache_param->vbc_pool, &vbcps); + vbcpool = MPL_New("vbc", &cache_param->vbc_pool, &vbcps, NULL); AN(vbcpool); } diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 468d5a8..ec0d36b 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -57,6 +57,7 @@ struct mempool { struct lock mtx; volatile struct poolparam *param; volatile unsigned *cur_size; + mpl_poll_f *poll_func; uint64_t live; struct VSC_C_mempool *vsc; unsigned n_pool; @@ -104,6 +105,8 @@ mpl_guard(void *priv) mpl_slp = 0.15; // random while (1) { VTIM_sleep(mpl_slp); + if (mpl->poll_func != NULL) + mpl->poll_func(mpl->cur_size); mpl_slp = 0.814; // random mpl->t_now = VTIM_real(); @@ -224,7 +227,7 @@ mpl_guard(void *priv) struct mempool * MPL_New(const char *name, volatile struct poolparam *pp, - volatile unsigned *cur_size) + volatile unsigned *cur_size, mpl_poll_f *poll_f) { struct mempool *mpl; @@ -233,6 +236,7 @@ MPL_New(const char *name, bprintf(mpl->name, "%s", name); mpl->param = pp; mpl->cur_size = cur_size; + mpl->poll_func = poll_f; VTAILQ_INIT(&mpl->list); VTAILQ_INIT(&mpl->surplus); Lck_New(&mpl->mtx, lck_mempool); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 3e144c1..2e080f1 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -383,9 +383,9 @@ SES_NewPool(struct pool *wp, unsigned pool_no) pp->pool = wp; bprintf(nb, "req%u", pool_no); pp->mpl_req = MPL_New(nb, &cache_param->req_pool, - &cache_param->workspace_client); + &cache_param->workspace_client, NULL); bprintf(nb, "sess%u", pool_no); - pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &ses_size); + pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &ses_size, NULL); return (pp); } From geoff at varnish-cache.org Tue Feb 14 16:49:23 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:23 +0100 Subject: [experimental-ims] 4d4e9f7 Use the req workspace, not the worker workspace, as we cannot trust that to be the same throughout the request. Message-ID: commit 4d4e9f7f2a079290bad85275ac9146b49df1a32e Author: Poul-Henning Kamp Date: Wed Feb 8 23:09:12 2012 +0000 Use the req workspace, not the worker workspace, as we cannot trust that to be the same throughout the request. diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index b2ab419..e363b2d 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -58,8 +58,8 @@ vmod_updown(struct sess *sp, int up, const char *s, va_list ap) const char *p; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - u = WS_Reserve(sp->wrk->ws, 0); - e = b = sp->wrk->ws->f; + u = WS_Reserve(sp->req->ws, 0); + e = b = sp->req->ws->f; e += u; p = s; while (p != vrt_magic_string_end && b < e) { @@ -76,12 +76,12 @@ vmod_updown(struct sess *sp, int up, const char *s, va_list ap) *b = '\0'; b++; if (b > e) { - WS_Release(sp->wrk->ws, 0); + WS_Release(sp->req->ws, 0); return (NULL); } else { e = b; - b = sp->wrk->ws->f; - WS_Release(sp->wrk->ws, e - b); + b = sp->req->ws->f; + WS_Release(sp->req->ws, e - b); return (b); } } From geoff at varnish-cache.org Tue Feb 14 16:49:28 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:28 +0100 Subject: [experimental-ims] 21eb82b Rename variable to not confuse people on monday mornings. Message-ID: commit 21eb82b4a96e270e12d0aa8b9b95d2c1a31a7fc9 Author: Poul-Henning Kamp Date: Mon Feb 13 09:18:50 2012 +0000 Rename variable to not confuse people on monday mornings. diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index c1d20e8..98de83f 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -131,13 +131,13 @@ WRK_BgThread(pthread_t *thr, const char *name, bgthread_t *func, void *priv) /*--------------------------------------------------------------------*/ static void * -wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace, +wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace, unsigned siov) { struct worker *w, ww; uint32_t wlog[shm_workspace / 4]; /* XXX: can we trust these to be properly aligned ? */ - unsigned char ws[sess_workspace]; + unsigned char ws[thread_workspace]; struct iovec iov[siov]; THR_SetName("cache-worker"); @@ -152,7 +152,7 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace, w->wrw.ciov = siov; AZ(pthread_cond_init(&w->cond, NULL)); - WS_Init(w->aws, "wrk", ws, sess_workspace); + WS_Init(w->aws, "wrk", ws, thread_workspace); VSL(SLT_WorkThread, 0, "%p start", w); From geoff at varnish-cache.org Tue Feb 14 16:49:29 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:29 +0100 Subject: [experimental-ims] 646d185 Fixup printf format on 32bit platforms Message-ID: commit 646d185e6bee723a848d315b9729b2997443135e Author: Rogier 'DocWilco' Mulhuijzen Date: Wed Jan 18 10:51:15 2012 +0100 Fixup printf format on 32bit platforms diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index c344f9c..e33be6c 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -163,14 +163,14 @@ WRW_Flush(struct worker *wrk) cache_param->send_timeout) { WSL(wrk, SLT_Debug, *wrw->wfd, "Hit total send timeout, " - "wrote = %ld/%ld; not retrying", + "wrote = %zd/%zd; not retrying", i, wrw->liov); i = -1; break; } WSL(wrk, SLT_Debug, *wrw->wfd, - "Hit send timeout, wrote = %ld/%ld; retrying", + "Hit send timeout, wrote = %zd/%zd; retrying", i, wrw->liov); wrw_prune(wrw, i); From geoff at varnish-cache.org Tue Feb 14 16:49:29 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:29 +0100 Subject: [experimental-ims] d119819 32 bit default parameter adjustments Message-ID: commit d1198194c78d204f5eaa4bce3db0d46c1fce2e9d Author: Tollef Fog Heen Date: Mon Feb 13 10:47:04 2012 +0100 32 bit default parameter adjustments thread_pool_workspace is gone, adjust workspace_backend instead diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 6405cdd..e7f1a1c 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -409,7 +409,7 @@ main(int argc, char * const *argv) MCF_ParamSet(cli, "workspace_client", "16384"); cli_check(cli); - MCF_ParamSet(cli, "thread_pool_workspace", "16384"); + MCF_ParamSet(cli, "workspace_backend", "16384"); cli_check(cli); MCF_ParamSet(cli, "http_resp_size", "8192"); From geoff at varnish-cache.org Tue Feb 14 16:49:29 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:29 +0100 Subject: [experimental-ims] 866b419 Fix a printf format issue with time_t Message-ID: commit 866b4195e0c0877d16d952949eca1d0ca02aba45 Author: Charlie Root Date: Mon Feb 13 09:59:23 2012 +0000 Fix a printf format issue with time_t diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c index 547061c..0de26b1 100644 --- a/lib/libvarnish/cli_serve.c +++ b/lib/libvarnish/cli_serve.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -107,7 +108,7 @@ VCLS_func_ping(struct cli *cli, const char * const *av, void *priv) (void)priv; (void)av; t = time(NULL); - VCLI_Out(cli, "PONG %ld 1.0", t); + VCLI_Out(cli, "PONG %jd 1.0", (intmax_t)t); } /*--------------------------------------------------------------------*/ From geoff at varnish-cache.org Tue Feb 14 16:49:34 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:34 +0100 Subject: [experimental-ims] 2e8ff87 Print out the right number in our diagnostics Message-ID: commit 2e8ff8776a536a302047881438f4aaca487fd51f Author: Poul-Henning Kamp Date: Mon Feb 13 10:24:29 2012 +0000 Print out the right number in our diagnostics diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 6c24e91..1abb273 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -323,7 +323,7 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, return; } if ((uintmax_t)((ssize_t)r) != r) { - fmt_bytes(cli, (uintmax_t)max); + fmt_bytes(cli, r); VCLI_Out(cli, " is too large for this architecture.\n"); VCLI_SetResult(cli, CLIS_PARAM); return; From geoff at varnish-cache.org Tue Feb 14 16:49:34 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:34 +0100 Subject: [experimental-ims] d3f869a Remove sendfile(2) support, it doesn't seem to actually make any difference in practice and complicates the code and increases the size of storage data structures. Message-ID: commit d3f869a0fded126050564b4244d0fbb22bfe22b4 Author: Poul-Henning Kamp Date: Mon Feb 13 11:42:31 2012 +0000 Remove sendfile(2) support, it doesn't seem to actually make any difference in practice and complicates the code and increases the size of storage data structures. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e376b66..3fafda1 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -371,10 +371,6 @@ struct storage { unsigned magic; #define STORAGE_MAGIC 0x1a4e51c0 -#ifdef SENDFILE_WORKS - int fd; - off_t where; -#endif VTAILQ_ENTRY(storage) list; struct stevedore *stevedore; @@ -916,9 +912,6 @@ unsigned WRW_Flush(struct worker *w); unsigned WRW_FlushRelease(struct worker *w); unsigned WRW_Write(struct worker *w, const void *ptr, int len); unsigned WRW_WriteH(struct worker *w, const txt *hh, const char *suf); -#ifdef SENDFILE_WORKS -void WRW_Sendfile(struct worker *w, int fd, off_t off, unsigned len); -#endif /* SENDFILE_WORKS */ /* cache_session.c [SES] */ struct sess *SES_Alloc(void); diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 6c48468..2b22829 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -220,20 +220,6 @@ res_WriteDirObj(const struct sess *sp, ssize_t low, ssize_t high) ptr += len; sp->wrk->acct_tmp.bodybytes += len; -#ifdef SENDFILE_WORKS - /* - * XXX: the overhead of setting up sendfile is not - * XXX: epsilon and maybe not even delta, so avoid - * XXX: engaging sendfile for small objects. - * XXX: Should use getpagesize() ? - */ - if (st->fd >= 0 && - st->len >= cache_param->sendfile_threshold) { - VSC_C_main->n_objsendfile++; - WRW_Sendfile(sp->wrk, st->fd, st->where + off, len); - continue; - } -#endif /* SENDFILE_WORKS */ VSC_C_main->n_objwrite++; (void)WRW_Write(sp->wrk, st->ptr + off, len); } diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index e33be6c..4f9bbc5 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -35,17 +35,6 @@ #include "config.h" #include -#ifdef SENDFILE_WORKS -# if defined(__FreeBSD__) || defined(__DragonFly__) -# include -# elif defined(__linux__) -# include -# elif defined(__sun) -# include -# else -# error Unknown sendfile() implementation -# endif -#endif /* SENDFILE_WORKS */ #include #include @@ -290,69 +279,4 @@ WRW_EndChunk(struct worker *wrk) } -#ifdef SENDFILE_WORKS -void -WRW_Sendfile(struct worker *wrk, int fd, off_t off, unsigned len) -{ - struct wrw *wrw; - - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; - AN(wrw->wfd); - assert(fd >= 0); - assert(len > 0); - -#if defined(__FreeBSD__) || defined(__DragonFly__) - do { - struct sf_hdtr sfh; - memset(&sfh, 0, sizeof sfh); - if (wrw->niov > 0) { - sfh.headers = wrw->iov; - sfh.hdr_cnt = wrw->niov; - } - if (sendfile(fd, *wrw->wfd, off, len, &sfh, NULL, 0) != 0) - wrw->werr++; - wrw->liov = 0; - wrw->niov = 0; - } while (0); -#elif defined(__linux__) - do { - if (WRW_Flush(wrk) == 0 && - sendfile(*wrw->wfd, fd, &off, len) != len) - wrw->werr++; - } while (0); -#elif defined(__sun) && defined(HAVE_SENDFILEV) - do { - sendfilevec_t svvec[cache_param->http_headers * 2 + 1]; - size_t xferred = 0, expected = 0; - int i; - for (i = 0; i < wrw->niov; i++) { - svvec[i].sfv_fd = SFV_FD_SELF; - svvec[i].sfv_flag = 0; - svvec[i].sfv_off = (off_t) wrw->iov[i].iov_base; - svvec[i].sfv_len = wrw->iov[i].iov_len; - expected += svvec[i].sfv_len; - } - svvec[i].sfv_fd = fd; - svvec[i].sfv_flag = 0; - svvec[i].sfv_off = off; - svvec[i].sfv_len = len; - expected += svvec[i].sfv_len; - if (sendfilev(*wrw->wfd, svvec, i, &xferred) == -1 || - xferred != expected) - wrw->werr++; - wrw->liov = 0; - wrw->niov = 0; - } while (0); -#elif defined(__sun) && defined(HAVE_SENDFILE) - do { - if (WRW_Flush(wrk) == 0 && - sendfile(*wrw->wfd, fd, &off, len) != len) - wrw->werr++; - } while (0); -#else -#error Unknown sendfile() implementation -#endif -} -#endif /* SENDFILE_WORKS */ diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 1e51656..7694435 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -102,10 +102,6 @@ struct params { ssize_t fetch_maxchunksize; unsigned nuke_limit; -#ifdef SENDFILE_WORKS - /* Sendfile object minimum size */ - ssize_t sendfile_threshold; -#endif /* VCL traces */ unsigned vcl_trace; diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 1abb273..97492ed 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -863,13 +863,6 @@ static const struct parspec input_parspec[] = { "fragmentation.\n", EXPERIMENTAL, "256m", "bytes" }, -#ifdef SENDFILE_WORKS - { "sendfile_threshold", - tweak_bytes, &mgt_param.sendfile_threshold, 0, 0, - "The minimum size of objects transmitted with sendfile.", - EXPERIMENTAL, - "1E", "bytes" }, -#endif /* SENDFILE_WORKS */ { "vcl_trace", tweak_bool, &mgt_param.vcl_trace, 0, 0, "Trace VCL execution in the shmlog.\n" "Enabling this will allow you to see the path each " diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 9eb44d9..680b870 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -482,10 +482,6 @@ smf_alloc(struct stevedore *st, size_t size) smf->s.ptr = smf->ptr; smf->s.len = 0; smf->s.stevedore = st; -#ifdef SENDFILE_WORKS - smf->s.fd = smf->sc->fd; - smf->s.where = smf->offset; -#endif return (&smf->s); } diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c index 156c832..2f34c98 100644 --- a/bin/varnishd/storage/storage_malloc.c +++ b/bin/varnishd/storage/storage_malloc.c @@ -117,9 +117,6 @@ sma_alloc(struct stevedore *st, size_t size) sma->s.priv = sma; sma->s.len = 0; sma->s.space = size; -#ifdef SENDFILE_WORKS - sma->s.fd = -1; -#endif sma->s.stevedore = st; sma->s.magic = STORAGE_MAGIC; return (&sma->s); diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index f90594e..ff01838 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -450,9 +450,6 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size, ss->space = max_size; ss->priv = sc; ss->stevedore = st; -#ifdef SENDFILE_WORKS - ss->fd = sc->fd; -#endif if (ssg != NULL) *ssg = sg; return (ss); diff --git a/bin/varnishd/storage/storage_synth.c b/bin/varnishd/storage/storage_synth.c index e9e9b2f..ba3fa24 100644 --- a/bin/varnishd/storage/storage_synth.c +++ b/bin/varnishd/storage/storage_synth.c @@ -87,9 +87,6 @@ SMS_Makesynth(struct object *obj) sto->priv = vsb; sto->len = 0; sto->space = 0; -#ifdef SENDFILE_WORKS - sto->fd = -1; -#endif sto->stevedore = &sms_stevedore; sto->magic = STORAGE_MAGIC; diff --git a/configure.ac b/configure.ac index 72d2b7c..952b71b 100644 --- a/configure.ac +++ b/configure.ac @@ -198,40 +198,6 @@ AC_CHECK_FUNCS([pthread_mutex_isowned_np]) AC_CHECK_FUNCS([pthread_timedjoin_np]) LIBS="${save_LIBS}" -# sendfile is tricky: there are multiple versions, and most of them -# don't work. -case $target in -*-*-freebsd*) - AC_CACHE_CHECK([whether sendfile works], - [ac_cv_so_sendfile_works], - [AC_RUN_IFELSE( - [AC_LANG_PROGRAM([[ - #include - #include - #include - ]],[[ - return (SF_SYNC == 0); - ]])], - [ac_cv_so_sendfile_works=yes], - [ac_cv_so_sendfile_works=no]) - ]) - ;; -#*-*-solaris*) -# save_LIBS="${LIBS}" -# LIBS="${NET_LIBS}" -# AC_CHECK_LIB(sendfile, sendfile) -# AC_CHECK_FUNCS([sendfile]) -# AC_CHECK_FUNCS([sendfilev]) -# NET_LIBS="${LIBS}" -# LIBS="${save_LIBS}" -*) - AC_MSG_WARN([won't look for sendfile() on $target]) - ;; -esac -if test "$ac_cv_so_sendfile_works" = yes; then - AC_DEFINE([SENDFILE_WORKS], [1], [Define if SENDFILE works]) -fi - # Support for visibility attribute save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS} -Werror" From geoff at varnish-cache.org Tue Feb 14 16:49:34 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:34 +0100 Subject: [experimental-ims] 73b465a Integrate stream_ctx in struct req Message-ID: commit 73b465a073968e22ed13c448178594515ac3a6d9 Author: Poul-Henning Kamp Date: Mon Feb 13 12:52:49 2012 +0000 Integrate stream_ctx in struct req diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 162cbe9..e76b0de 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -257,21 +257,6 @@ struct wrw { /*--------------------------------------------------------------------*/ -struct stream_ctx { - unsigned magic; -#define STREAM_CTX_MAGIC 0x8213728b - - struct vgz *vgz; - - /* Next byte we will take from storage */ - ssize_t stream_next; - - /* First byte of storage if we free it as we go (pass) */ - ssize_t stream_front; -}; - -/*--------------------------------------------------------------------*/ - struct wrk_accept { unsigned magic; #define WRK_ACCEPT_MAGIC 0x8c4b4d59 @@ -335,9 +320,6 @@ struct worker { struct busyobj *busyobj; - /* Stream state */ - struct stream_ctx *sctx; - /* Timeouts */ double connect_timeout; double first_byte_timeout; @@ -626,6 +608,15 @@ struct req { #define RES_ESI_CHILD (1<<5) #define RES_GUNZIP (1<<6) + /* Stream gunzip instance */ + struct vgz *stream_vgz; + + /* Next byte we will take from storage */ + ssize_t stream_next; + + /* First byte of storage if we free it as we go (pass) */ + ssize_t stream_front; + }; /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 826e1d7..fca55b0 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -940,17 +940,12 @@ static int cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) { int i; - struct stream_ctx sctx; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - memset(&sctx, 0, sizeof sctx); - sctx.magic = STREAM_CTX_MAGIC; - AZ(wrk->sctx); - wrk->sctx = &sctx; RES_StreamStart(sp); @@ -978,7 +973,6 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) RES_StreamEnd(sp); - wrk->sctx = NULL; assert(WRW_IsReleased(wrk)); assert(wrk->wrw.ciov == wrk->wrw.siov); (void)HSH_Deref(wrk, NULL, &req->obj); diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index d560211..5e4cab6 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -316,23 +316,26 @@ RES_WriteObj(struct sess *sp) void RES_StreamStart(struct sess *sp) { - struct stream_ctx *sctx; + struct req *req; - sctx = sp->wrk->sctx; - CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); + req = sp->req; + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - AZ(sp->req->res_mode & RES_ESI_CHILD); - AN(sp->req->wantbody); + AZ(req->res_mode & RES_ESI_CHILD); + AN(req->wantbody); + AZ(req->stream_vgz); + AZ(req->stream_next); + AZ(req->stream_front); WRW_Reserve(sp->wrk, &sp->fd); - if (sp->req->res_mode & RES_GUNZIP) { - sctx->vgz = VGZ_NewUngzip(sp->wrk, "U S -"); - AZ(VGZ_WrwInit(sctx->vgz)); - http_Unset(sp->req->resp, H_Content_Encoding); + if (req->res_mode & RES_GUNZIP) { + req->stream_vgz = VGZ_NewUngzip(sp->wrk, "U S -"); + AZ(VGZ_WrwInit(req->stream_vgz)); + http_Unset(req->resp, H_Content_Encoding); } - if (!(sp->req->res_mode & RES_CHUNKED) && + if (!(req->res_mode & RES_CHUNKED) && sp->wrk->busyobj->h_content_length != NULL) http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp, "Content-Length: %s", sp->wrk->busyobj->h_content_length); @@ -340,57 +343,59 @@ RES_StreamStart(struct sess *sp) sp->wrk->acct_tmp.hdrbytes += http_Write(sp->wrk, sp->vsl_id, sp->req->resp, 1); - if (sp->req->res_mode & RES_CHUNKED) + if (req->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); } void RES_StreamPoll(struct worker *wrk) { - struct stream_ctx *sctx; struct storage *st; + struct busyobj *bo; + struct req *req; ssize_t l, l2; void *ptr; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj->fetch_obj, OBJECT_MAGIC); - sctx = wrk->sctx; - CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); - if (wrk->busyobj->fetch_obj->len == sctx->stream_next) + bo = wrk->busyobj; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo->fetch_obj, OBJECT_MAGIC); + req = wrk->sp->req; + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + if (bo->fetch_obj->len == req->stream_next) return; - assert(wrk->busyobj->fetch_obj->len > sctx->stream_next); - l = sctx->stream_front; - VTAILQ_FOREACH(st, &wrk->busyobj->fetch_obj->store, list) { - if (st->len + l <= sctx->stream_next) { + assert(bo->fetch_obj->len > req->stream_next); + l = req->stream_front; + VTAILQ_FOREACH(st, &bo->fetch_obj->store, list) { + if (st->len + l <= req->stream_next) { l += st->len; continue; } - l2 = st->len + l - sctx->stream_next; - ptr = st->ptr + (sctx->stream_next - l); - if (wrk->sp->req->res_mode & RES_GUNZIP) { - (void)VGZ_WrwGunzip(wrk, sctx->vgz, ptr, l2); - } else { + l2 = st->len + l - req->stream_next; + ptr = st->ptr + (req->stream_next - l); + if (wrk->sp->req->res_mode & RES_GUNZIP) + (void)VGZ_WrwGunzip(wrk, req->stream_vgz, ptr, l2); + else (void)WRW_Write(wrk, ptr, l2); - } l += st->len; - sctx->stream_next += l2; + req->stream_next += l2; } if (!(wrk->sp->req->res_mode & RES_GUNZIP)) (void)WRW_Flush(wrk); - if (wrk->busyobj->fetch_obj->objcore == NULL || - (wrk->busyobj->fetch_obj->objcore->flags & OC_F_PASS)) { + if (bo->fetch_obj->objcore == NULL || + (bo->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(&wrk->busyobj->fetch_obj->store); + st = VTAILQ_FIRST(&bo->fetch_obj->store); if (st == NULL || - sctx->stream_front + st->len > sctx->stream_next) + req->stream_front + st->len > req->stream_next) break; - VTAILQ_REMOVE(&wrk->busyobj->fetch_obj->store, st, list); - sctx->stream_front += st->len; + VTAILQ_REMOVE(&bo->fetch_obj->store, st, list); + req->stream_front += st->len; STV_free(st); } } @@ -399,19 +404,21 @@ RES_StreamPoll(struct worker *wrk) void RES_StreamEnd(struct sess *sp) { - struct stream_ctx *sctx; + struct req *req; - sctx = sp->wrk->sctx; - CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); + req = sp->req; + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (sp->req->res_mode & RES_GUNZIP) { - AN(sctx->vgz); - VGZ_WrwFlush(sp->wrk, sctx->vgz); - (void)VGZ_Destroy(&sctx->vgz, sp->vsl_id); + 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); } - if (sp->req->res_mode & RES_CHUNKED && - !(sp->req->res_mode & RES_ESI_CHILD)) + if (req->res_mode & RES_CHUNKED && !(req->res_mode & RES_ESI_CHILD)) WRW_EndChunk(sp->wrk); if (WRW_FlushRelease(sp->wrk)) SES_Close(sp, "remote closed"); + req->stream_vgz = NULL; + req->stream_next = 0; + req->stream_front = 0; } From geoff at varnish-cache.org Tue Feb 14 16:49:34 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:34 +0100 Subject: [experimental-ims] ffea64d Shave 256 bytes of the worker thread footprint, by using the thread workspace for WRW also. Message-ID: commit ffea64d751612a6584fd21f0d39a9574c55d18dd Author: Poul-Henning Kamp Date: Mon Feb 13 20:30:48 2012 +0000 Shave 256 bytes of the worker thread footprint, by using the thread workspace for WRW also. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 1371d48..4b1bfc3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -114,6 +114,7 @@ struct vrt_backend; struct vsb; struct waitinglist; struct worker; +struct wrw; #define DIGEST_LEN 32 @@ -244,19 +245,6 @@ struct exp { /*--------------------------------------------------------------------*/ -struct wrw { - int *wfd; - unsigned werr; /* valid after WRW_Flush() */ - struct iovec *iov; - unsigned siov; - unsigned niov; - ssize_t liov; - ssize_t cliov; - unsigned ciov; /* Chunked header marker */ -}; - -/*--------------------------------------------------------------------*/ - struct wrk_accept { unsigned magic; #define WRK_ACCEPT_MAGIC 0x8c4b4d59 @@ -301,7 +289,7 @@ struct worker { double lastused; - struct wrw wrw; + struct wrw *wrw; pthread_cond_t cond; @@ -312,10 +300,6 @@ struct worker { uint32_t *wlb, *wlp, *wle; unsigned wlr; - /* - * In practice this workspace is only used for wrk_accept now - * but it might come handy later, so keep it around. For now. - */ struct ws aws[1]; struct busyobj *busyobj; @@ -893,7 +877,7 @@ void Pool_Init(void); void Pool_Work_Thread(void *priv, struct worker *w); int Pool_Task(struct pool *pp, struct pool_task *task, enum pool_how how); -#define WRW_IsReleased(w) ((w)->wrw.wfd == NULL) +#define WRW_IsReleased(w) ((w)->wrw == NULL) int WRW_Error(const struct worker *w); void WRW_Chunked(struct worker *w); void WRW_EndChunk(struct worker *w); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 137f198..345d0cf 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -338,7 +338,6 @@ cnt_deliver(struct sess *sp, struct worker *wrk, struct req *req) RES_WriteObj(sp); assert(WRW_IsReleased(wrk)); - assert(wrk->wrw.ciov == wrk->wrw.siov); (void)HSH_Deref(wrk, NULL, &req->obj); http_Setup(req->resp, NULL); sp->step = STP_DONE; @@ -974,7 +973,6 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) RES_StreamEnd(sp); assert(WRW_IsReleased(wrk)); - assert(wrk->wrw.ciov == wrk->wrw.siov); (void)HSH_Deref(wrk, NULL, &req->obj); VBO_DerefBusyObj(wrk, &wrk->busyobj); http_Setup(req->resp, NULL); @@ -1411,7 +1409,6 @@ cnt_recv(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->obj); AZ(wrk->busyobj); - assert(wrk->wrw.ciov == wrk->wrw.siov); /* By default we use the first backend */ AZ(req->director); diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c index dd76c91..a2927fa 100644 --- a/bin/varnishd/cache/cache_cli.c +++ b/bin/varnishd/cache/cache_cli.c @@ -138,7 +138,6 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv) SZOF(struct vbc); SZOF(struct VSC_C_main); SZOF(struct lock); - SZOF(struct wrw); SZOF(struct dstat); #if 0 #define OFOF(foo, bar) { foo __foo; VCLI_Out(cli, \ diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 07b5cfb..ea0668b 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -155,7 +155,7 @@ ses_pool_task(struct worker *wrk, void *arg) wrk->sp = NULL; WS_Assert(wrk->aws); AZ(wrk->busyobj); - AZ(wrk->wrw.wfd); + AZ(wrk->wrw); assert(wrk->wlp == wrk->wlb); if (cache_param->diag_bitmap & 0x00040000) { if (wrk->vcl != NULL) diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 98de83f..2f0b575 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -131,14 +131,11 @@ WRK_BgThread(pthread_t *thr, const char *name, bgthread_t *func, void *priv) /*--------------------------------------------------------------------*/ static void * -wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace, - unsigned siov) +wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace) { struct worker *w, ww; uint32_t wlog[shm_workspace / 4]; - /* XXX: can we trust these to be properly aligned ? */ unsigned char ws[thread_workspace]; - struct iovec iov[siov]; THR_SetName("cache-worker"); w = &ww; @@ -147,9 +144,6 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace, w->lastused = NAN; w->wlb = w->wlp = wlog; w->wle = wlog + (sizeof wlog) / 4; - w->wrw.iov = iov; - w->wrw.siov = siov; - w->wrw.ciov = siov; AZ(pthread_cond_init(&w->cond, NULL)); WS_Init(w->aws, "wrk", ws, thread_workspace); @@ -173,18 +167,10 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace, void * WRK_thread(void *priv) { - uint16_t nhttp; - unsigned siov; - - assert(cache_param->http_max_hdr <= 65535); - /* We need to snapshot these two for consistency */ - nhttp = (uint16_t)cache_param->http_max_hdr; - siov = nhttp * 2; - if (siov > IOV_MAX) - siov = IOV_MAX; + return (wrk_thread_real(priv, cache_param->shm_workspace, - cache_param->workspace_thread, siov)); + cache_param->workspace_thread)); } void diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index 4f9bbc5..2c0d7c3 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -42,6 +42,21 @@ #include "cache.h" #include "vtim.h" +/*--------------------------------------------------------------------*/ + +struct wrw { + unsigned magic; +#define WRW_MAGIC 0x2f2142e5 + int *wfd; + unsigned werr; /* valid after WRW_Flush() */ + struct iovec *iov; + unsigned siov; + unsigned niov; + ssize_t liov; + ssize_t cliov; + unsigned ciov; /* Chunked header marker */ +}; + /*-------------------------------------------------------------------- */ @@ -49,22 +64,32 @@ int WRW_Error(const struct worker *wrk) { - return (wrk->wrw.werr); + return (wrk->wrw->werr); } void WRW_Reserve(struct worker *wrk, int *fd) { struct wrw *wrw; + unsigned u; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; - AZ(wrw->wfd); + AZ(wrk->wrw); + wrw = (void*)WS_Alloc(wrk->aws, sizeof *wrw); + AN(wrw); + memset(wrw, 0, sizeof *wrw); + wrw->magic = WRW_MAGIC; + u = WS_Reserve(wrk->aws, 0); + u /= sizeof(struct iovec); + AN(u); + wrw->iov = (void*)wrk->aws->f; + wrw->siov = u; + wrw->ciov = u; wrw->werr = 0; wrw->liov = 0; wrw->niov = 0; - wrw->ciov = wrw->siov; wrw->wfd = fd; + wrk->wrw = wrw; } static void @@ -73,13 +98,11 @@ WRW_Release(struct worker *wrk) struct wrw *wrw; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; - AN(wrw->wfd); - wrw->werr = 0; - wrw->liov = 0; - wrw->niov = 0; - wrw->ciov = wrw->siov; - wrw->wfd = NULL; + wrw = wrk->wrw; + wrk->wrw = NULL; + CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC); + WS_Release(wrk->aws, 0); + WS_Reset(wrk->aws, NULL); } static void @@ -114,7 +137,8 @@ WRW_Flush(struct worker *wrk) char cbuf[32]; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; + wrw = wrk->wrw; + CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC); AN(wrw->wfd); /* For chunked, there must be one slot reserved for the chunked tail */ @@ -186,7 +210,7 @@ WRW_FlushRelease(struct worker *wrk) unsigned u; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - AN(wrk->wrw.wfd); + AN(wrk->wrw->wfd); u = WRW_Flush(wrk); WRW_Release(wrk); return (u); @@ -198,7 +222,7 @@ WRW_WriteH(struct worker *wrk, const txt *hh, const char *suf) unsigned u; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - AN(wrk->wrw.wfd); + AN(wrk->wrw->wfd); AN(wrk); AN(hh); AN(hh->b); @@ -215,7 +239,8 @@ WRW_Write(struct worker *wrk, const void *ptr, int len) struct wrw *wrw; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; + wrw = wrk->wrw; + CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC); AN(wrw->wfd); if (len == 0 || *wrw->wfd < 0) return (0); @@ -240,7 +265,8 @@ WRW_Chunked(struct worker *wrk) struct wrw *wrw; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; + wrw = wrk->wrw; + CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC); assert(wrw->ciov == wrw->siov); /* @@ -268,7 +294,8 @@ WRW_EndChunk(struct worker *wrk) struct wrw *wrw; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - wrw = &wrk->wrw; + wrw = wrk->wrw; + CHECK_OBJ_NOTNULL(wrw, WRW_MAGIC); assert(wrw->ciov < wrw->siov); (void)WRW_Flush(wrk); diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 97492ed..e2e1a3a 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -712,12 +712,16 @@ static const struct parspec input_parspec[] = { DELAYED_EFFECT, "64k", "bytes" }, { "workspace_thread", - tweak_bytes_u, &mgt_param.workspace_thread, 256, 256, - "Bytes of auxillary workspace per thread." - /* XXX: See comment in cache.h */ - "This is not the workspace you are looking for.", + tweak_bytes_u, &mgt_param.workspace_thread, 256, 8192, + "Bytes of auxillary workspace per thread.\n" + "This workspace is used for certain temporary data structures" + " during the operation of a worker thread.\n" + "One use is for the io-vectors for writing requests and" + " responses to sockets, having too little space will" + " result in more writev(2) system calls, having too much" + " just wastes the space.\n", DELAYED_EFFECT, - "256", "bytes" }, + "2048", "bytes" }, { "http_req_hdr_len", tweak_bytes_u, &mgt_param.http_req_hdr_len, 40, UINT_MAX, From geoff at varnish-cache.org Tue Feb 14 16:49:34 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:34 +0100 Subject: [experimental-ims] 892c92a Make refcount signed. Message-ID: commit 892c92ab7fb0fe7afe69ef96ed0eda063ec2ce90 Author: Poul-Henning Kamp Date: Mon Feb 13 21:29:03 2012 +0000 Make refcount signed. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 9a31cb4..0ff57c9 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -364,7 +364,7 @@ struct objcore_methods { struct objcore { unsigned magic; #define OBJCORE_MAGIC 0x4d301302 - unsigned refcnt; + int refcnt; struct objcore_methods *methods; void *priv; unsigned priv2; From geoff at varnish-cache.org Tue Feb 14 16:49:34 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:34 +0100 Subject: [experimental-ims] c9c0572 Use VSL_Setup() once more Message-ID: commit c9c0572849473c712e46424e717f3267f0e24a1c Author: Poul-Henning Kamp Date: Mon Feb 13 21:50:32 2012 +0000 Use VSL_Setup() once more diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index d421740..6862a1f 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -141,8 +141,7 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace) memset(w, 0, sizeof *w); w->magic = WORKER_MAGIC; w->lastused = NAN; - w->vsl->wlb = w->vsl->wlp = wlog; - w->vsl->wle = wlog + (sizeof wlog) / 4; + VSL_Setup(w->vsl, wlog, sizeof wlog); AZ(pthread_cond_init(&w->cond, NULL)); WS_Init(w->aws, "wrk", ws, thread_workspace); From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] f7dbf53 Clean up a lot of now needless argument passing for struct http's VSL logging. More to come. Message-ID: commit f7dbf53eb01d26170f6c4bafd3f0a50d00444dc5 Author: Poul-Henning Kamp Date: Tue Feb 14 10:03:55 2012 +0000 Clean up a lot of now needless argument passing for struct http's VSL logging. More to come. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 98771a3..0bac299 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -799,13 +799,11 @@ const char *http_StatusMessage(unsigned); unsigned http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd); void HTTP_Init(void); void http_ClrHeader(struct http *to); -unsigned http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, - int resp); +unsigned http_Write(struct worker *w, const struct http *hp, int resp); void http_SetResp(struct http *to, const char *proto, uint16_t status, const char *response); void http_FilterReq(const struct sess *sp, unsigned how); -void http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to, - unsigned how); +void http_FilterResp(const struct http *fm, struct http *to, unsigned how); void http_PutProtocol(struct worker *w, unsigned vsl_id, const struct http *to, const char *protocol); void http_PutStatus(struct http *to, uint16_t status); @@ -830,8 +828,7 @@ uint16_t http_GetStatus(const struct http *hp); const char *http_GetReq(const struct http *hp); int http_HdrIs(const struct http *hp, const char *hdr, const char *val); uint16_t http_DissectRequest(const struct sess *sp); -uint16_t http_DissectResponse(struct worker *w, const struct http_conn *htc, - struct http *sp); +uint16_t http_DissectResponse(struct http *sp, const struct http_conn *htc); const char *http_DoConnection(const struct http *hp); void http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp); void http_Unset(struct http *hp, const char *hdr); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index f7cbc38..54a883b 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -838,7 +838,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) hp2 = req->obj->http; hp2->logtag = HTTP_Obj; - http_FilterResp(sp, hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS); + http_FilterResp(hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS); http_CopyHome(wrk, sp->vsl_id, hp2); if (http_GetHdr(hp, H_Last_Modified, &b)) diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 1e2ef44..327ae0a 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -427,7 +427,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) (void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */ WRW_Reserve(wrk, &vc->fd); - (void)http_Write(wrk, vc->vsl_id, hp, 0); /* XXX: stats ? */ + (void)http_Write(wrk, hp, 0); /* XXX: stats ? */ /* Deal with any message-body the request might have */ i = FetchReqBody(sp, sendbody); @@ -480,7 +480,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) hp = wrk->busyobj->beresp; - if (http_DissectResponse(wrk, htc, hp)) { + if (http_DissectResponse(hp, htc)) { WSP(sp, SLT_FetchError, "http format error"); VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc); /* XXX: other cleanup ? */ diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index c8db4c7..2a97829 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -73,11 +73,12 @@ http2shmlog(const struct http *hp, int t) } static void -WSLH(struct worker *w, unsigned vsl_id, const struct http *hp, unsigned hdr) +http_VSLH(const struct http *hp, unsigned hdr) { - AN(vsl_id & (VSL_CLIENTMARKER|VSL_BACKENDMARKER)); - WSLR(w->vsl, http2shmlog(hp, hdr), vsl_id, hp->hd[hdr]); + AN(hp->vsl); + AN(hp->vsl->wid & (VSL_CLIENTMARKER|VSL_BACKENDMARKER)); + WSLR(hp->vsl, http2shmlog(hp, hdr), -1, hp->hd[hdr]); } /*--------------------------------------------------------------------*/ @@ -491,8 +492,7 @@ http_GetReq(const struct http *hp) */ static uint16_t -http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, - const struct http_conn *htc) +http_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) { char *q, *r; txt t = htc->rxbuf; @@ -528,7 +528,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, if (q - p > htc->maxhdr) { VSC_C_main->losthdr++; - WSL(w->vsl, SLT_LostHeader, vsl_id, "%.*s", + WSL(hp->vsl, SLT_LostHeader, -1, "%.*s", (int)(q - p > 20 ? 20 : q - p), p); return (413); } @@ -550,11 +550,11 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, hp->hdf[hp->nhd] = 0; hp->hd[hp->nhd].b = p; hp->hd[hp->nhd].e = q; - WSLH(w, vsl_id, hp, hp->nhd); + http_VSLH(hp, hp->nhd); hp->nhd++; } else { VSC_C_main->losthdr++; - WSL(w->vsl, SLT_LostHeader, vsl_id, "%.*s", + WSL(hp->vsl, SLT_LostHeader, -1, "%.*s", (int)(q - p > 20 ? 20 : q - p), p); return (413); } @@ -567,7 +567,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, */ static uint16_t -http_splitline(struct worker *w, unsigned vsl_id, struct http *hp, +http_splitline(struct http *hp, const struct http_conn *htc, int h1, int h2, int h3) { char *p, *q; @@ -629,17 +629,17 @@ http_splitline(struct worker *w, unsigned vsl_id, struct http *hp, p += vct_skipcrlf(p); *hp->hd[h1].e = '\0'; - WSLH(w, vsl_id, hp, h1); + http_VSLH(hp, h1); *hp->hd[h2].e = '\0'; - WSLH(w, vsl_id, hp, h2); + http_VSLH(hp, h2); if (hp->hd[h3].e != NULL) { *hp->hd[h3].e = '\0'; - WSLH(w, vsl_id, hp, h3); + http_VSLH(hp, h3); } - return (http_dissect_hdrs(w, hp, vsl_id, p, htc)); + return (http_dissect_hdrs(hp, p, htc)); } /*--------------------------------------------------------------------*/ @@ -674,7 +674,7 @@ http_DissectRequest(const struct sess *sp) hp->logtag = HTTP_Rx; - retval = http_splitline(sp->wrk, sp->vsl_id, hp, htc, + retval = http_splitline(hp, htc, HTTP_HDR_REQ, HTTP_HDR_URL, HTTP_HDR_PROTO); if (retval != 0) { WSPR(sp, SLT_HttpGarbage, htc->rxbuf); @@ -687,8 +687,7 @@ http_DissectRequest(const struct sess *sp) /*--------------------------------------------------------------------*/ uint16_t -http_DissectResponse(struct worker *w, const struct http_conn *htc, - struct http *hp) +http_DissectResponse(struct http *hp, const struct http_conn *htc) { int j; uint16_t retval = 0; @@ -699,7 +698,7 @@ http_DissectResponse(struct worker *w, const struct http_conn *htc, CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); hp->logtag = HTTP_Rx; - if (http_splitline(w, htc->vsl_id, hp, htc, + if (http_splitline(hp, htc, HTTP_HDR_PROTO, HTTP_HDR_STATUS, HTTP_HDR_RESPONSE)) retval = 503; @@ -725,7 +724,7 @@ http_DissectResponse(struct worker *w, const struct http_conn *htc, } if (retval != 0) { - WSLR(w->vsl, SLT_HttpGarbage, htc->vsl_id, htc->rxbuf); + WSLR(hp->vsl, SLT_HttpGarbage, -1, htc->rxbuf); assert(retval >= 100 && retval <= 999); hp->status = retval; } else { @@ -818,8 +817,7 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd) /*--------------------------------------------------------------------*/ static void -http_filterfields(struct worker *w, unsigned vsl_id, struct http *to, - const struct http *fm, unsigned how) +http_filterfields(struct http *to, const struct http *fm, unsigned how) { unsigned u; @@ -844,7 +842,7 @@ http_filterfields(struct worker *w, unsigned vsl_id, struct http *to, to->nhd++; } else { VSC_C_main->losthdr++; - WSLR(w->vsl, SLT_LostHeader, vsl_id, fm->hd[u]); + WSLR(to->vsl, SLT_LostHeader, -1, fm->hd[u]); } } } @@ -866,7 +864,7 @@ http_FilterReq(const struct sess *sp, unsigned how) http_SetH(hp, HTTP_HDR_PROTO, "HTTP/1.1"); else http_linkh(hp, sp->req->http, HTTP_HDR_PROTO); - http_filterfields(sp->wrk, sp->vsl_id, hp, sp->req->http, how); + http_filterfields(hp, sp->req->http, how); http_PrintfHeader(sp->wrk, sp->vsl_id, hp, "X-Varnish: %u", sp->req->xid); } @@ -874,8 +872,7 @@ http_FilterReq(const struct sess *sp, unsigned how) /*--------------------------------------------------------------------*/ void -http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to, - unsigned how) +http_FilterResp(const struct http *fm, struct http *to, unsigned how) { CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); @@ -883,7 +880,7 @@ http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to, http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1"); to->status = fm->status; http_linkh(to, fm, HTTP_HDR_RESPONSE); - http_filterfields(sp->wrk, sp->vsl_id, to, fm, how); + http_filterfields(to, fm, how); } /*-------------------------------------------------------------------- @@ -901,13 +898,13 @@ http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp) if (hp->hd[u].b == NULL) continue; if (hp->hd[u].b >= hp->ws->s && hp->hd[u].e <= hp->ws->e) { - WSLH(w, vsl_id, hp, u); + http_VSLH(hp, u); continue; } l = Tlen(hp->hd[u]); p = WS_Alloc(hp->ws, l + 1); if (p != NULL) { - WSLH(w, vsl_id, hp, u); + http_VSLH(hp, u); memcpy(p, hp->hd[u].b, l + 1L); hp->hd[u].b = p; hp->hd[u].e = p + l; @@ -1070,13 +1067,13 @@ HTTP_Copy(struct http *to, const struct http * const fm) /*--------------------------------------------------------------------*/ unsigned -http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, int resp) +http_Write(struct worker *w, const struct http *hp, int resp) { unsigned u, l; if (resp) { l = WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], " "); - WSLH(w, vsl_id, hp, HTTP_HDR_PROTO); + http_VSLH(hp, HTTP_HDR_PROTO); hp->hd[HTTP_HDR_STATUS].b = WS_Alloc(hp->ws, 4); AN(hp->hd[HTTP_HDR_STATUS].b); @@ -1085,18 +1082,18 @@ http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, int resp) hp->hd[HTTP_HDR_STATUS].e = hp->hd[HTTP_HDR_STATUS].b + 3; l += WRW_WriteH(w, &hp->hd[HTTP_HDR_STATUS], " "); - WSLH(w, vsl_id, hp, HTTP_HDR_STATUS); + http_VSLH(hp, HTTP_HDR_STATUS); l += WRW_WriteH(w, &hp->hd[HTTP_HDR_RESPONSE], "\r\n"); - WSLH(w, vsl_id, hp, HTTP_HDR_RESPONSE); + http_VSLH(hp, HTTP_HDR_RESPONSE); } else { AN(hp->hd[HTTP_HDR_URL].b); l = WRW_WriteH(w, &hp->hd[HTTP_HDR_REQ], " "); - WSLH(w, vsl_id, hp, HTTP_HDR_REQ); + http_VSLH(hp, HTTP_HDR_REQ); l += WRW_WriteH(w, &hp->hd[HTTP_HDR_URL], " "); - WSLH(w, vsl_id, hp, HTTP_HDR_URL); + http_VSLH(hp, HTTP_HDR_URL); l += WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], "\r\n"); - WSLH(w, vsl_id, hp, HTTP_HDR_PROTO); + http_VSLH(hp, HTTP_HDR_PROTO); } for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) { if (hp->hd[u].b == NULL) @@ -1104,7 +1101,7 @@ http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, int resp) AN(hp->hd[u].b); AN(hp->hd[u].e); l += WRW_WriteH(w, &hp->hd[u], "\r\n"); - WSLH(w, vsl_id, hp, u); + http_VSLH(hp, u); } l += WRW_Write(w, "\r\n", -1); return (l); diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c index 21fefef..6f1fbcb 100644 --- a/bin/varnishd/cache/cache_pipe.c +++ b/bin/varnishd/cache/cache_pipe.c @@ -80,7 +80,7 @@ PipeSession(struct sess *sp) WRW_Reserve(w, &vc->fd); sp->wrk->acct_tmp.hdrbytes += - http_Write(w, sp->vsl_id, sp->wrk->busyobj->bereq, 0); + http_Write(w, sp->wrk->busyobj->bereq, 0); if (sp->req->htc->pipeline.b != NULL) sp->wrk->acct_tmp.bodybytes += diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 5e4cab6..df9c137 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -117,7 +117,7 @@ RES_BuildHttp(const struct sess *sp) http_ClrHeader(req->resp); req->resp->logtag = HTTP_Tx; - http_FilterResp(sp, req->obj->http, req->resp, 0); + http_FilterResp(req->obj->http, req->resp, 0); if (!(req->res_mode & RES_LEN)) { http_Unset(req->resp, H_Content_Length); @@ -278,7 +278,7 @@ RES_WriteObj(struct sess *sp) */ if (!(req->res_mode & RES_ESI_CHILD)) sp->wrk->acct_tmp.hdrbytes += - http_Write(sp->wrk, sp->vsl_id, req->resp, 1); + http_Write(sp->wrk, req->resp, 1); if (!req->wantbody) req->res_mode &= ~RES_CHUNKED; @@ -341,7 +341,7 @@ RES_StreamStart(struct sess *sp) "Content-Length: %s", sp->wrk->busyobj->h_content_length); sp->wrk->acct_tmp.hdrbytes += - http_Write(sp->wrk, sp->vsl_id, sp->req->resp, 1); + http_Write(sp->wrk, sp->req->resp, 1); if (req->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 299389f..d4dae9d 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -208,6 +208,8 @@ WSLR(struct vsl_log *vsl, enum VSL_tag_e tag, int id, txt t) unsigned l, mlen; Tcheck(t); + if (id == -1) + id = vsl->wid; mlen = cache_param->shm_reclen; /* Truncate */ @@ -279,6 +281,8 @@ WSL(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, ...) { va_list ap; + if (id == -1) + id = vsl->wid; AN(fmt); va_start(ap, fmt); wsl(vsl, tag, id, fmt, ap); From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] f33a076 Give struct htc the same "tell it what vsl_buffer to use" treatment. Message-ID: commit f33a076b477487e66bea47e77c78408f1bf80a29 Author: Poul-Henning Kamp Date: Tue Feb 14 10:50:49 2012 +0000 Give struct htc the same "tell it what vsl_buffer to use" treatment. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 2349470..8ff3688 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -189,7 +189,7 @@ struct http_conn { #define HTTP_CONN_MAGIC 0x3e19edd1 int fd; - unsigned vsl_id; + struct vsl_log *vsl; unsigned maxbytes; unsigned maxhdr; struct ws *ws; @@ -831,11 +831,11 @@ void http_Unset(struct http *hp, const char *hdr); void http_CollectHdr(struct http *hp, const char *hdr); /* cache_httpconn.c */ -void HTC_Init(struct http_conn *htc, struct ws *ws, int fd, unsigned vsl_id, +void HTC_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *, unsigned maxbytes, unsigned maxhdr); int HTC_Reinit(struct http_conn *htc); int HTC_Rx(struct http_conn *htc); -ssize_t HTC_Read(struct worker *w, struct http_conn *htc, void *d, size_t len); +ssize_t HTC_Read(struct http_conn *htc, void *d, size_t len); int HTC_Complete(struct http_conn *htc); #define HTTPH(a, b, c) extern char b[]; diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 8aa80d1..57e5616 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -116,7 +116,7 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req) SES_GetReq(sp); req = sp->req; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - HTC_Init(req->htc, req->ws, sp->fd, sp->vsl_id, + HTC_Init(req->htc, req->ws, sp->fd, sp->req->vsl, cache_param->http_req_size, cache_param->http_req_hdr_len); } diff --git a/bin/varnishd/cache/cache_esi.h b/bin/varnishd/cache/cache_esi.h index 4867614..bcc815b 100644 --- a/bin/varnishd/cache/cache_esi.h +++ b/bin/varnishd/cache/cache_esi.h @@ -42,7 +42,7 @@ typedef ssize_t vep_callback_t(struct worker *w, ssize_t l, enum vgz_flag flg); void VEP_Init(struct worker *w, vep_callback_t *cb); -void VEP_Parse(const struct worker *w, const char *p, size_t l); +void VEP_Parse(const struct busyobj *, const char *p, size_t l); struct vsb *VEP_Finish(const struct worker *w); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 64adf51..620082d 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -64,7 +64,7 @@ struct vef_priv { */ static ssize_t -vef_read(struct worker *wrk, struct http_conn *htc, void *buf, ssize_t buflen, +vef_read(struct http_conn *htc, void *buf, ssize_t buflen, ssize_t bytes) { ssize_t d; @@ -76,7 +76,7 @@ vef_read(struct worker *wrk, struct http_conn *htc, void *buf, ssize_t buflen, if (d < bytes) bytes = d; } - return (HTC_Read(wrk, htc, buf, bytes)); + return (HTC_Read(htc, buf, bytes)); } /*--------------------------------------------------------------------- @@ -97,11 +97,11 @@ vfp_esi_bytes_uu(struct worker *wrk, const struct vef_priv *vef, st = FetchStorage(wrk, 0); if (st == NULL) return (-1); - wl = vef_read(wrk, htc, + wl = vef_read(htc, st->ptr + st->len, st->space - st->len, bytes); if (wl <= 0) return (wl); - VEP_Parse(wrk, (const char *)st->ptr + st->len, wl); + VEP_Parse(wrk->busyobj, (const char *)st->ptr + st->len, wl); st->len += wl; wrk->busyobj->fetch_obj->len += wl; bytes -= wl; @@ -129,7 +129,7 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, while (bytes > 0) { if (VGZ_IbufEmpty(vg) && bytes > 0) { - wl = vef_read(wrk, htc, vef->ibuf, vef->ibuf_sz, bytes); + wl = vef_read(htc, vef->ibuf, vef->ibuf_sz, bytes); if (wl <= 0) return (wl); VGZ_Ibuf(vg, vef->ibuf, wl); @@ -139,7 +139,7 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, return(-1); i = VGZ_Gunzip(vg, &dp, &dl); xxxassert(i == VGZ_OK || i == VGZ_END); - VEP_Parse(wrk, dp, dl); + VEP_Parse(wrk->busyobj, dp, dl); wrk->busyobj->fetch_obj->len += dl; } return (1); @@ -167,7 +167,7 @@ vfp_vep_inject(const struct worker *wrk, struct vef_priv *vef, ssize_t wl) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - VEP_Parse(wrk, vef->ibuf_i, wl); + VEP_Parse(wrk->busyobj, vef->ibuf_i, wl); vef->ibuf_i += wl; assert(vef->ibuf_o >= vef->ibuf && vef->ibuf_o <= vef->ibuf_i); if (vef->error) { @@ -235,7 +235,7 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) */ static int -vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef, +vfp_esi_bytes_ug(const struct worker *wrk, struct vef_priv *vef, struct http_conn *htc, ssize_t bytes) { ssize_t wl; @@ -246,7 +246,7 @@ vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef, while (bytes > 0) { wl = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf); - wl = vef_read(wrk, htc, vef->ibuf_i, wl, bytes); + wl = vef_read(htc, vef->ibuf_i, wl, bytes); if (wl <= 0) return (wl); bytes -= wl; @@ -261,7 +261,7 @@ vfp_esi_bytes_ug(struct worker *wrk, struct vef_priv *vef, */ static int -vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef, +vfp_esi_bytes_gg(const struct worker *wrk, struct vef_priv *vef, struct http_conn *htc, size_t bytes) { ssize_t wl; @@ -274,7 +274,7 @@ vfp_esi_bytes_gg(struct worker *wrk, struct vef_priv *vef, CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); while (bytes > 0) { - wl = vef_read(wrk, htc, vef->ibuf2, vef->ibuf2_sz, bytes); + wl = vef_read(htc, vef->ibuf2, vef->ibuf2_sz, bytes); if (wl <= 0) return (wl); bytes -= wl; diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 3154784..433208d 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -549,16 +549,15 @@ vep_do_include(struct vep_state *vep, enum dowhat what) */ void -VEP_Parse(const struct worker *wrk, const char *p, size_t l) +VEP_Parse(const struct busyobj *bo, const char *p, size_t l) { struct vep_state *vep; const char *e; struct vep_match *vm; int i; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vep = wrk->busyobj->vep; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vep = bo->vep; CHECK_OBJ_NOTNULL(vep, VEP_MAGIC); assert(l > 0); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index f5995ca..8b94fd7 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -121,7 +121,7 @@ vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) l = st->space - st->len; if (l > bytes) l = bytes; - wl = HTC_Read(wrk, htc, st->ptr + st->len, l); + wl = HTC_Read(htc, st->ptr + st->len, l); if (wl <= 0) return (wl); st->len += wl; @@ -261,7 +261,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) do { /* Skip leading whitespace */ do { - if (HTC_Read(wrk, htc, buf, 1) <= 0) + if (HTC_Read(htc, buf, 1) <= 0) return (-1); } while (vct_islws(buf[0])); @@ -271,7 +271,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) /* Collect hex digits, skipping leading zeros */ for (u = 1; u < sizeof buf; u++) { do { - if (HTC_Read(wrk, htc, buf + u, 1) <= 0) + if (HTC_Read(htc, buf + u, 1) <= 0) return (-1); } while (u == 1 && buf[0] == '0' && buf[u] == '0'); if (!vct_ishex(buf[u])) @@ -283,7 +283,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) /* Skip trailing white space */ while(vct_islws(buf[u]) && buf[u] != '\n') - if (HTC_Read(wrk, htc, buf + u, 1) <= 0) + if (HTC_Read(htc, buf + u, 1) <= 0) return (-1); if (buf[u] != '\n') @@ -297,10 +297,10 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) if (cl > 0 && wrk->busyobj->vfp->bytes(wrk, htc, cl) <= 0) return (-1); - i = HTC_Read(wrk, htc, buf, 1); + i = HTC_Read(htc, buf, 1); if (i <= 0) return (-1); - if (buf[0] == '\r' && HTC_Read(wrk, htc, buf, 1) <= 0) + if (buf[0] == '\r' && HTC_Read( htc, buf, 1) <= 0) return (-1); if (buf[0] != '\n') return (FetchError(wrk,"chunked tail no NL")); @@ -352,7 +352,7 @@ FetchReqBody(const struct sess *sp, int sendbody) rdcnt = sizeof buf; else rdcnt = content_length; - rdcnt = HTC_Read(sp->wrk, sp->req->htc, buf, rdcnt); + rdcnt = HTC_Read(sp->req->htc, buf, rdcnt); if (rdcnt <= 0) return (1); content_length -= rdcnt; @@ -447,7 +447,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) /* Receive response */ - HTC_Init(htc, wrk->busyobj->ws, vc->fd, vc->vsl_id, + HTC_Init(htc, wrk->busyobj->ws, vc->fd, vc->vsl, cache_param->http_resp_size, cache_param->http_resp_hdr_len); diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index cf270c5..5901930 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -471,7 +471,7 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) l = vg->m_sz; if (l > bytes) l = bytes; - wl = HTC_Read(wrk, htc, vg->m_buf, l); + wl = HTC_Read(htc, vg->m_buf, l); if (wl <= 0) return (wl); VGZ_Ibuf(vg, vg->m_buf, wl); @@ -554,7 +554,7 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) l = vg->m_sz; if (l > bytes) l = bytes; - wl = HTC_Read(wrk, htc, vg->m_buf, l); + wl = HTC_Read(htc, vg->m_buf, l); if (wl <= 0) return (wl); VGZ_Ibuf(vg, vg->m_buf, wl); @@ -650,7 +650,7 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) l = st->space - st->len; if (l > bytes) l = bytes; - wl = HTC_Read(wrk, htc, st->ptr + st->len, l); + wl = HTC_Read(htc, st->ptr + st->len, l); if (wl <= 0) return (wl); bytes -= wl; diff --git a/bin/varnishd/cache/cache_httpconn.c b/bin/varnishd/cache/cache_httpconn.c index 1a1eaf0..d0b7199 100644 --- a/bin/varnishd/cache/cache_httpconn.c +++ b/bin/varnishd/cache/cache_httpconn.c @@ -88,14 +88,14 @@ htc_header_complete(txt *t) /*--------------------------------------------------------------------*/ void -HTC_Init(struct http_conn *htc, struct ws *ws, int fd, unsigned vsl_id, +HTC_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *vsl, unsigned maxbytes, unsigned maxhdr) { htc->magic = HTTP_CONN_MAGIC; htc->ws = ws; htc->fd = fd; - htc->vsl_id = vsl_id; + htc->vsl = vsl; htc->maxbytes = maxbytes; htc->maxhdr = maxhdr; @@ -200,13 +200,12 @@ HTC_Rx(struct http_conn *htc) */ ssize_t -HTC_Read(struct worker *w, struct http_conn *htc, void *d, size_t len) +HTC_Read(struct http_conn *htc, void *d, size_t len) { size_t l; unsigned char *p; ssize_t i; - CHECK_OBJ_NOTNULL(w, WORKER_MAGIC); CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); l = 0; p = d; @@ -225,7 +224,7 @@ HTC_Read(struct worker *w, struct http_conn *htc, void *d, size_t len) return (l); i = read(htc->fd, p, len); if (i < 0) { - WSL(w->vsl, SLT_FetchError, htc->vsl_id, "%s", strerror(errno)); + WSL(htc->vsl, SLT_FetchError, -1, "%s", strerror(errno)); return (i); } return (i + l); From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] fe8ec80 Argument strength-reduction: from worker to dstats Message-ID: commit fe8ec801f6ed776522df03c7ff271406b76bc298 Author: Poul-Henning Kamp Date: Tue Feb 14 11:19:22 2012 +0000 Argument strength-reduction: from worker to dstats diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 6dc3618..b02e5f9 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -908,7 +908,7 @@ ban_lurker_work(const struct sess *sp, unsigned pass) if (cache_param->diag_bitmap & 0x80000) VSL(SLT_Debug, 0, "lurker done: %p %u %u", oc, oc->flags & OC_F_LURK, pass); - (void)HSH_Deref(sp->wrk, NULL, &o); + (void)HSH_Deref(&sp->wrk->stats, NULL, &o); VTIM_sleep(cache_param->ban_lurker_sleep); } Lck_AssertHeld(&ban_mtx); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 57e5616..61d1a94 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -289,7 +289,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) HSH_Drop(wrk); VBO_DerefBusyObj(wrk, &wrk->busyobj); } else { - (void)HSH_Deref(wrk, NULL, &req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &req->obj); } AZ(req->obj); req->restarts++; @@ -338,7 +338,7 @@ cnt_deliver(struct sess *sp, struct worker *wrk, struct req *req) RES_WriteObj(sp); assert(WRW_IsReleased(wrk)); - (void)HSH_Deref(wrk, NULL, &req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &req->obj); http_Teardown(req->resp); sp->step = STP_DONE; return (0); @@ -641,7 +641,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) if (req->objcore != NULL) { CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); - AZ(HSH_Deref(wrk, req->objcore, NULL)); + AZ(HSH_Deref(&wrk->stats, req->objcore, NULL)); req->objcore = NULL; } VBO_DerefBusyObj(wrk, &wrk->busyobj); @@ -972,7 +972,7 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) RES_StreamEnd(sp); assert(WRW_IsReleased(wrk)); - (void)HSH_Deref(wrk, NULL, &req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &req->obj); VBO_DerefBusyObj(wrk, &wrk->busyobj); http_Teardown(req->resp); sp->step = STP_DONE; @@ -1065,7 +1065,7 @@ cnt_hit(struct sess *sp, struct worker *wrk, struct req *req) } /* Drop our object, we won't need it */ - (void)HSH_Deref(wrk, NULL, &req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &req->obj); req->objcore = NULL; switch(req->handling) { @@ -1183,7 +1183,7 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req) if (oc->flags & OC_F_PASS) { wrk->stats.cache_hitpass++; WSP(sp, SLT_HitPass, "%u", req->obj->xid); - (void)HSH_Deref(wrk, NULL, &req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &req->obj); AZ(req->objcore); sp->step = STP_PASS; return (0); @@ -1242,7 +1242,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) return (0); } - AZ(HSH_Deref(wrk, req->objcore, NULL)); + AZ(HSH_Deref(&wrk->stats, req->objcore, NULL)); req->objcore = NULL; http_Teardown(wrk->busyobj->bereq); VBO_DerefBusyObj(wrk, &wrk->busyobj); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 1060bac..840e0b7 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -402,7 +402,7 @@ exp_timer(struct sess *sp, void *priv) o = oc_getobj(sp->wrk, oc); WSL(sp->wrk->vsl, SLT_ExpKill, 0, "%u %.0f", oc_getxid(sp->wrk, oc), EXP_Ttl(NULL, o) - t); - (void)HSH_Deref(sp->wrk, oc, NULL); + (void)HSH_Deref(&sp->wrk->stats, oc, NULL); } NEEDLESS_RETURN(NULL); } @@ -446,7 +446,7 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru) /* XXX: bad idea for -spersistent */ WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc)); - (void)HSH_Deref(wrk, oc, NULL); + (void)HSH_Deref(&wrk->stats, oc, NULL); return (1); } diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 49f6d30..eebb999 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -139,13 +139,13 @@ HSH_Cleanup(struct worker *wrk) } void -HSH_DeleteObjHead(struct worker *wrk, struct objhead *oh) +HSH_DeleteObjHead(struct dstat *ds, struct objhead *oh) { AZ(oh->refcnt); assert(VTAILQ_EMPTY(&oh->objcs)); Lck_Delete(&oh->mtx); - wrk->stats.n_objecthead--; + ds->n_objecthead--; FREE_OBJ(oh); } @@ -564,7 +564,7 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace) o->exp.ttl = ttl; o->exp.grace = grace; EXP_Rearm(o); - (void)HSH_Deref(sp->wrk, NULL, &o); + (void)HSH_Deref(&sp->wrk->stats, NULL, &o); } WS_Release(sp->req->ws, 0); } @@ -588,7 +588,7 @@ HSH_Drop(struct worker *wrk) o->exp.ttl = -1.; if (o->objcore != NULL) /* Pass has no objcore */ HSH_Unbusy(wrk); - (void)HSH_Deref(wrk, NULL, &wrk->sp->req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &wrk->sp->req->obj); } void @@ -660,7 +660,7 @@ HSH_Ref(struct objcore *oc) */ int -HSH_Deref(struct worker *wrk, struct objcore *oc, struct object **oo) +HSH_Deref(struct dstat *ds, struct objcore *oc, struct object **oo) { struct object *o = NULL; struct objhead *oh; @@ -683,7 +683,7 @@ HSH_Deref(struct worker *wrk, struct objcore *oc, struct object **oo) */ STV_Freestore(o); STV_free(o->objstore); - wrk->stats.n_object--; + ds->n_object--; return (0); } @@ -713,16 +713,16 @@ HSH_Deref(struct worker *wrk, struct objcore *oc, struct object **oo) if (oc->methods != NULL) { oc_freeobj(oc); - wrk->stats.n_object--; + ds->n_object--; } FREE_OBJ(oc); - wrk->stats.n_objectcore--; + ds->n_objectcore--; /* Drop our ref on the objhead */ assert(oh->refcnt > 0); if (hash->deref(oh)) return (0); - HSH_DeleteObjHead(wrk, oh); + HSH_DeleteObjHead(ds, oh); return (0); } diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index 5fafac5..069a1c2 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -359,7 +359,7 @@ hcb_cleaner(struct sess *sp, void *priv) } VTAILQ_FOREACH_SAFE(oh, &dead_h, hoh_list, oh2) { VTAILQ_REMOVE(&dead_h, oh, hoh_list); - HSH_DeleteObjHead(wrk, oh); + HSH_DeleteObjHead(&wrk->stats, oh); } Lck_Lock(&hcb_mtx); VSTAILQ_CONCAT(&dead_y, &cool_y); diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index b45e604..1bc08b1 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -95,8 +95,8 @@ struct objhead { #define hoh_head _u.n.u_n_hoh_head }; -void HSH_DeleteObjHead(struct worker *w, struct objhead *oh); -int HSH_Deref(struct worker *w, struct objcore *oc, struct object **o); +void HSH_DeleteObjHead(struct dstat *, struct objhead *oh); +int HSH_Deref(struct dstat *, struct objcore *oc, struct object **o); #endif /* VARNISH_CACHE_CHILD */ extern const struct hash_slinger hsl_slinger; From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] d2b5440 Clamp # of iovec to IOV_MAX Message-ID: commit d2b54402c34166044f745f8d92348970e26472b4 Author: Poul-Henning Kamp Date: Tue Feb 14 13:58:04 2012 +0000 Clamp # of iovec to IOV_MAX diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index 00b3a9e..3685bec 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -37,6 +37,7 @@ #include #include +#include #include #include "cache.h" @@ -82,6 +83,8 @@ WRW_Reserve(struct worker *wrk, int *fd) u = WS_Reserve(wrk->aws, 0); u = PRNDDN(u); u /= sizeof(struct iovec); + if (u > IOV_MAX) + u = IOV_MAX; AN(u); wrw->iov = (void*)PRNDUP(wrk->aws->f); wrw->siov = u; From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] f1dfb81 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache into experimental-ims Message-ID: commit f1dfb81ad5f1ef6e6818fef892223caac6609f99 Merge: 99f0d07 d2b5440 Author: Geoff Simmons Date: Tue Feb 14 17:11:17 2012 +0100 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache into experimental-ims Also calling http_CopyHome(beresp) to ensure that header contents are copied from stale_obj into beresp (pointed out by phk). diff --cc bin/varnishd/cache/cache.h index 4009337,42788c3..52aaaa5 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@@ -811,27 -803,17 +805,23 @@@ unsigned http_Write(struct worker *w, c void http_SetResp(struct http *to, const char *proto, uint16_t status, const char *response); void http_FilterReq(const struct sess *sp, unsigned how); - void http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to, - unsigned how); + void http_FilterResp(const struct http *fm, struct http *to, unsigned how); + void http_PutProtocol(const struct http *to, const char *protocol); + +/* Check if a refresh should be done */ +void http_CheckRefresh(struct sess *sp); +/* Check if we got 304 response */ +void http_Check304(struct sess *sp, struct busyobj *busyobj); + - void http_PutProtocol(struct worker *w, unsigned vsl_id, const struct http *to, - const char *protocol); void http_PutStatus(struct http *to, uint16_t status); - void http_PutResponse(struct worker *w, unsigned vsl_id, const struct http *to, - const char *response); - void http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to, - const char *fmt, ...) - __printflike(4, 5); - void http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, - const char *hdr); + void http_PutResponse(const struct http *to, const char *response); + void http_PrintfHeader(struct http *to, const char *fmt, ...) + __printflike(2, 3); + void http_SetHeader(struct http *to, const char *hdr); void http_SetH(const struct http *to, unsigned n, const char *fm); void http_ForceGet(const struct http *to); - void http_Setup(struct http *ht, struct ws *ws); + void http_Setup(struct http *ht, struct ws *ws, struct vsl_log *); + void http_Teardown(struct http *ht); int http_GetHdr(const struct http *hp, const char *hdr, char **ptr); int http_GetHdrData(const struct http *hp, const char *hdr, const char *field, char **ptr); diff --cc bin/varnishd/cache/cache_center.c index f46a68c,0be9304..c86a301 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@@ -862,11 -836,10 +860,11 @@@ cnt_prepfetch(struct sess *sp, struct w hp2 = req->obj->http; hp2->logtag = HTTP_Obj; - http_FilterResp(sp, hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS); - http_CopyHome(wrk, sp->vsl_id, hp2); + http_FilterResp(hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS); + http_CopyHome(hp2); - if (http_GetHdr(hp, H_Last_Modified, &b)) + if (http_GetHdr(hp, H_Last_Modified, &b) + || http_GetHdr(req->obj->http, H_Last_Modified, &b)) req->obj->last_modified = VTIM_parse(b); else req->obj->last_modified = floor(bo->exp.entered); @@@ -922,27 -895,8 +920,27 @@@ cnt_fetchbody(struct sess *sp, struct w /* Use unmodified headers*/ i = FetchBody(wrk, req->obj); + /* + * If a stale_obj was found, dup its storage into the new obj, + * reset Content-Length from the size of the storage, and discard + * the stale_obj. + */ + if (bo->stale_obj) { + STV_dup(sp, bo->stale_obj, req->obj); + assert(bo->stale_obj->len == req->obj->len); + + http_Unset(req->obj->http, H_Content_Length); - http_PrintfHeader(sp->wrk, sp->fd, req->obj->http, - "Content-Length: %u", req->obj->len); ++ http_PrintfHeader(req->obj->http, "Content-Length: %lu", ++ req->obj->len); + + EXP_Clr(&bo->stale_obj->exp); + EXP_Rearm(bo->stale_obj); - HSH_Deref(sp->wrk, NULL, &bo->stale_obj); ++ HSH_Deref(&sp->wrk->stats, NULL, &bo->stale_obj); + AZ(bo->stale_obj); + } + - http_Setup(bo->bereq, NULL); - http_Setup(bo->beresp, NULL); + http_Teardown(bo->bereq); + http_Teardown(bo->beresp); bo->vfp = NULL; assert(WRW_IsReleased(wrk)); AZ(bo->vbc); @@@ -991,11 -945,6 +989,7 @@@ cnt_streambody(struct sess *sp, struct CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); + AZ(wrk->busyobj->stale_obj); - memset(&sctx, 0, sizeof sctx); - sctx.magic = STREAM_CTX_MAGIC; - AZ(wrk->sctx); - wrk->sctx = &sctx; RES_StreamStart(sp); @@@ -1237,9 -1185,7 +1230,10 @@@ cnt_lookup(struct sess *sp, struct work if (oc->flags & OC_F_PASS) { wrk->stats.cache_hitpass++; WSP(sp, SLT_HitPass, "%u", req->obj->xid); - (void)HSH_Deref(wrk, NULL, &req->obj); + (void)HSH_Deref(&wrk->stats, NULL, &req->obj); + if (wrk->busyobj != NULL && wrk->busyobj->stale_obj != NULL) - (void)HSH_Deref(wrk, NULL, &wrk->busyobj->stale_obj); ++ (void)HSH_Deref(&wrk->stats, NULL, ++ &wrk->busyobj->stale_obj); AZ(req->objcore); sp->step = STP_PASS; return (0); @@@ -1277,11 -1223,7 +1271,9 @@@ cnt_miss(struct sess *sp, struct worke CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(req->obj); - if (!wrk->busyobj->stale_obj) { - WS_Reset(wrk->ws, NULL); ++ if (!wrk->busyobj->stale_obj) + wrk->busyobj = VBO_GetBusyObj(wrk); - } - http_Setup(wrk->busyobj->bereq, wrk->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl); http_FilterReq(sp, HTTPH_R_FETCH); http_ForceGet(wrk->busyobj->bereq); if (cache_param->http_gzip_support) { @@@ -1291,16 -1233,9 +1283,15 @@@ * the minority of clients which don't. */ http_Unset(wrk->busyobj->bereq, H_Accept_Encoding); - http_SetHeader(wrk, sp->vsl_id, wrk->busyobj->bereq, - "Accept-Encoding: gzip"); + http_SetHeader(wrk->busyobj->bereq, "Accept-Encoding: gzip"); } + /* If a candidate for a conditional backend request was found, + * add If-Modified-Since and/or If-None-Match to the bereq. + */ + if (wrk->busyobj->stale_obj) + http_CheckRefresh(sp); + VCL_miss_method(sp); if (req->handling == VCL_RET_FETCH) { diff --cc bin/varnishd/cache/cache_hash.c index 9585e7a,7188ff4..c13eb70 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@@ -357,11 -353,10 +357,11 @@@ HSH_Lookup(struct sess *sp, struct objh continue; } - o = oc_getobj(sp->wrk, oc); + o = oc_getobj(&sp->wrk->stats, oc); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - if (o->exp.ttl <= 0.) + if (o->exp.ttl <= 0. && o->exp.grace <= 0. + && o->exp.keep <= 0.) continue; if (BAN_CheckObject(o, sp)) continue; @@@ -477,18 -453,8 +477,19 @@@ AZ(wrk->busyobj); wrk->busyobj = VBO_GetBusyObj(wrk); + wrk->busyobj->vsl->wid = sp->vsl_id; + /* If we're not serving a valid or graced object and we saved stale_o, + * it is a candidate for the conditional backend request. */ + AZ(busy_oc); + if (stale_o != NULL) { + AZ(stale_o->objcore->flags & OC_F_BUSY); + CHECK_OBJ_NOTNULL(stale_o->objcore, OBJCORE_MAGIC); + Lck_AssertHeld(&oh->mtx); + stale_o->objcore->refcnt++; + wrk->busyobj->stale_obj = stale_o; + } + VRY_Validate(sp->req->vary_b); if (sp->req->vary_l != NULL) wrk->busyobj->vary = sp->req->vary_b; diff --cc bin/varnishd/cache/cache_http.c index ac922b8,de71ada..03f3974 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@@ -779,25 -784,6 +787,24 @@@ http_SetResp(struct http *to, const cha http_SetH(to, HTTP_HDR_RESPONSE, response); } +static void - http_copyheader(struct worker *w, unsigned vsl_id, struct http *to, - const struct http *fm, unsigned n) ++http_copyheader(struct http *to, const struct http *fm, unsigned n) +{ + + CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); + CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); + assert(n < fm->shd); + Tcheck(fm->hd[n]); + if (to->nhd < to->shd) { + to->hd[to->nhd] = fm->hd[n]; + to->hdf[to->nhd] = 0; + to->nhd++; + } else { + VSC_C_main->losthdr++; - WSLR(w, SLT_LostHeader, vsl_id, fm->hd[n]); ++ WSLR(to->vsl, SLT_LostHeader, -1, fm->hd[n]); + } +} + /*-------------------------------------------------------------------- * Estimate how much workspace we need to Filter this header according * to 'how'. @@@ -850,38 -835,16 +856,42 @@@ http_filterfields(struct http *to, cons continue; #include "tbl/http_headers.h" #undef HTTPH - http_copyheader(w, vsl_id, to, fm, u); - Tcheck(fm->hd[u]); - if (to->nhd < to->shd) { - to->hd[to->nhd] = fm->hd[u]; - to->hdf[to->nhd] = 0; - to->nhd++; - } else { - VSC_C_main->losthdr++; - WSLR(to->vsl, SLT_LostHeader, -1, fm->hd[u]); - } ++ http_copyheader(to, fm, u); + } +} + +/*--------------------------------------------------------------------- + * Same as http_FilterFields but keep any existing hdrs in fm. + * Furthermore, before copy, check if fm already has that hdr, and if so + * do not copy. Used for 304 refresh processing. + */ + +/* XXX: uplex/GS: Also, don't filter according to the "how" bitmap in + * http_headers.h. We only use this to copy from one cached object to + * another, so if a header made into the first object, we want it. ++ * NB: This assumes that http_EstimateWS(to) has already been called ++ * (so that http_CopyHome() does not run short of workspace). + */ + +void +http_FilterMissingFields(struct worker *w, int fd, struct http *to, + const struct http *fm) +{ + unsigned u; + unsigned hdrlen; + + CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); + CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); + for (u = HTTP_HDR_FIRST; u < fm->nhd; u++) { + if (fm->hd[u].b == NULL) + continue; + hdrlen = strchr(fm->hd[u].b, ':') - fm->hd[u].b; + if (http_findhdr(to, hdrlen, fm->hd[u].b)) + continue; - http_copyheader(w, fd, to, fm, u); ++ http_copyheader(to, fm, u); } ++ /* Copy header contents, presupposes http_EstimateWS(to) */ ++ http_CopyHome(to); } /*--------------------------------------------------------------------*/ @@@ -901,94 -864,10 +911,94 @@@ http_FilterReq(const struct sess *sp, u http_SetH(hp, HTTP_HDR_PROTO, "HTTP/1.1"); else http_linkh(hp, sp->req->http, HTTP_HDR_PROTO); - http_filterfields(sp->wrk, sp->vsl_id, hp, sp->req->http, how); - http_PrintfHeader(sp->wrk, sp->vsl_id, hp, - "X-Varnish: %u", sp->req->xid); + http_filterfields(hp, sp->req->http, how); + http_PrintfHeader(hp, "X-Varnish: %u", sp->req->xid); } +/*------------------------------------------------------------------- + * This function checks if a stale_obj was found in HSH_Lookup(). + * If so, add the appropriate headers for backend validation. + */ + +void +http_CheckRefresh(struct sess *sp) +{ + struct object *freshen_obj; + struct http *obj_hp, *bereq_hp; + char *p; + + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); + freshen_obj = sp->wrk->busyobj->stale_obj; + CHECK_OBJ_NOTNULL(freshen_obj, OBJECT_MAGIC); + bereq_hp = sp->wrk->busyobj->bereq; + CHECK_OBJ_NOTNULL(bereq_hp, HTTP_MAGIC); + obj_hp = freshen_obj->http; + CHECK_OBJ_NOTNULL(obj_hp, HTTP_MAGIC); + + if(http_GetHdr(obj_hp, H_ETag, &p)) - http_PrintfHeader(sp->wrk, sp->fd, bereq_hp, - "If-None-Match: %s", p); ++ http_PrintfHeader(bereq_hp, "If-None-Match: %s", p); + + if(http_GetHdr(obj_hp, H_Last_Modified, &p)) - http_PrintfHeader(sp->wrk, sp->fd, bereq_hp, - "If-Modified-Since: %s", p); ++ http_PrintfHeader(bereq_hp, "If-Modified-Since: %s", p); +} + +/*------------------------------------------------------------------- + * Called after fetch for a backend conditional request. Check + * response and handle as needed. ++ * NB: Assumes that http_EstimateWS(beresp) has already been called ++ * (in cnt_prepfetch(), while this is called in cnt_fetch()). + */ + +void +http_Check304(struct sess *sp, struct busyobj *busyobj) +{ + struct object *o_stale; + char *p; + + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(busyobj, BUSYOBJ_MAGIC); + o_stale = busyobj->stale_obj; + CHECK_OBJ_NOTNULL(o_stale, OBJECT_MAGIC); + + if (busyobj->beresp->status != 304) { + /* + * IMS/INM headers may have been removed in VCL, so only count a + * non-validating response if they were present in the request. + */ + if (http_GetHdr(busyobj->bereq, H_If_Modified_Since, &p) + || http_GetHdr(busyobj->bereq, H_If_None_Match, &p)) + sp->wrk->stats.fetch_not_validated++; + + /* Discard the stale object */ + /* XXX: just deref, or force expire? */ - HSH_Deref(sp->wrk, NULL, &busyobj->stale_obj); ++ HSH_Deref(&sp->wrk->stats, NULL, &busyobj->stale_obj); + AZ(busyobj->stale_obj); + return; + } + + /* + * Copy headers we need from the stale object into the 304 response ++ * http_EstimateWS(beresp) must have been called before this. + */ + http_FilterMissingFields(sp->wrk, sp->fd, busyobj->beresp, + o_stale->http); + + http_SetResp(busyobj->beresp, "HTTP/1.1", 200, "Ok Not Modified"); + http_SetH(busyobj->beresp, HTTP_HDR_REQ, "GET"); + http_linkh(busyobj->beresp, busyobj->bereq, HTTP_HDR_URL); + + /* + * XXX: Are we copying all the necessary fields from stale_obj? + * Should we copy o_stale->hits into o->hits? + * What about do_esi and do_g(un)zip? + */ + busyobj->is_gzip = o_stale->gziped; + + AZ(o_stale->objcore->flags & OC_F_BUSY); +} + /*--------------------------------------------------------------------*/ void From geoff at varnish-cache.org Tue Feb 14 16:49:36 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:36 +0100 Subject: [experimental-ims] ee03e4a Removed superfluous parameters in cache_http.c, or narrowed their scope, following similar cleanup in master. Message-ID: commit ee03e4a88fa769d99674ad8e04fe354fb257d413 Author: Geoff Simmons Date: Tue Feb 14 17:47:27 2012 +0100 Removed superfluous parameters in cache_http.c, or narrowed their scope, following similar cleanup in master. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 52aaaa5..5b6d427 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -809,9 +809,9 @@ void http_FilterResp(const struct http *fm, struct http *to, unsigned how); void http_PutProtocol(const struct http *to, const char *protocol); /* Check if a refresh should be done */ -void http_CheckRefresh(struct sess *sp); +void http_CheckRefresh(struct busyobj *busyobj); /* Check if we got 304 response */ -void http_Check304(struct sess *sp, struct busyobj *busyobj); +void http_Check304(struct worker *wrk); void http_PutStatus(struct http *to, uint16_t status); void http_PutResponse(const struct http *to, const char *response); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index c86a301..517ff3b 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -611,7 +611,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) * Any other response is handled as usual. */ if (wrk->busyobj->stale_obj) - http_Check304(sp, wrk->busyobj); + http_Check304(wrk); req->err_code = http_GetStatus(wrk->busyobj->beresp); @@ -1290,7 +1290,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) * add If-Modified-Since and/or If-None-Match to the bereq. */ if (wrk->busyobj->stale_obj) - http_CheckRefresh(sp); + http_CheckRefresh(wrk->busyobj); VCL_miss_method(sp); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 03f3974..dfdac4c 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -60,8 +60,7 @@ static const enum VSL_tag_e logmtx[][HTTP_HDR_FIRST + 1] = { }; /*lint -restore */ -void http_FilterMissingFields(struct worker *w, int fd, struct http *to, - const struct http *fm); +void http_FilterMissingFields(struct http *to, const struct http *fm); static enum VSL_tag_e http2shmlog(const struct http *hp, int t) @@ -874,8 +873,7 @@ http_filterfields(struct http *to, const struct http *fm, unsigned how) */ void -http_FilterMissingFields(struct worker *w, int fd, struct http *to, - const struct http *fm) +http_FilterMissingFields(struct http *to, const struct http *fm) { unsigned u; unsigned hdrlen; @@ -921,18 +919,16 @@ http_FilterReq(const struct sess *sp, unsigned how) */ void -http_CheckRefresh(struct sess *sp) +http_CheckRefresh(struct busyobj *busyobj) { struct object *freshen_obj; struct http *obj_hp, *bereq_hp; char *p; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); - freshen_obj = sp->wrk->busyobj->stale_obj; + CHECK_OBJ_NOTNULL(busyobj, BUSYOBJ_MAGIC); + freshen_obj = busyobj->stale_obj; CHECK_OBJ_NOTNULL(freshen_obj, OBJECT_MAGIC); - bereq_hp = sp->wrk->busyobj->bereq; + bereq_hp = busyobj->bereq; CHECK_OBJ_NOTNULL(bereq_hp, HTTP_MAGIC); obj_hp = freshen_obj->http; CHECK_OBJ_NOTNULL(obj_hp, HTTP_MAGIC); @@ -952,15 +948,17 @@ http_CheckRefresh(struct sess *sp) */ void -http_Check304(struct sess *sp, struct busyobj *busyobj) +http_Check304(struct worker *wrk) { + struct busyobj *busyobj; struct object *o_stale; char *p; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(busyobj, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); + busyobj = wrk->busyobj; + CHECK_OBJ_NOTNULL(busyobj->stale_obj, OBJECT_MAGIC); o_stale = busyobj->stale_obj; - CHECK_OBJ_NOTNULL(o_stale, OBJECT_MAGIC); if (busyobj->beresp->status != 304) { /* @@ -969,11 +967,11 @@ http_Check304(struct sess *sp, struct busyobj *busyobj) */ if (http_GetHdr(busyobj->bereq, H_If_Modified_Since, &p) || http_GetHdr(busyobj->bereq, H_If_None_Match, &p)) - sp->wrk->stats.fetch_not_validated++; + wrk->stats.fetch_not_validated++; /* Discard the stale object */ /* XXX: just deref, or force expire? */ - HSH_Deref(&sp->wrk->stats, NULL, &busyobj->stale_obj); + HSH_Deref(&wrk->stats, NULL, &busyobj->stale_obj); AZ(busyobj->stale_obj); return; } @@ -982,8 +980,7 @@ http_Check304(struct sess *sp, struct busyobj *busyobj) * Copy headers we need from the stale object into the 304 response * http_EstimateWS(beresp) must have been called before this. */ - http_FilterMissingFields(sp->wrk, sp->fd, busyobj->beresp, - o_stale->http); + http_FilterMissingFields(busyobj->beresp, o_stale->http); http_SetResp(busyobj->beresp, "HTTP/1.1", 200, "Ok Not Modified"); http_SetH(busyobj->beresp, HTTP_HDR_REQ, "GET"); From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] b762016 Give struct req its own buffer for batching VSL records Message-ID: commit b7620169552e638771676df2f57749657cf12f0b Author: Poul-Henning Kamp Date: Tue Feb 14 08:02:41 2012 +0000 Give struct req its own buffer for batching VSL records Size controlled by param vsl_buffer which will replace shm_workspace. The space comes out of request workspace. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ad23c24..d9d9f48 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -248,6 +248,7 @@ struct exp { struct vsl_log { uint32_t *wlb, *wlp, *wle; unsigned wlr; + unsigned wid; }; /*--------------------------------------------------------------------*/ @@ -615,6 +616,9 @@ struct req { /* First byte of storage if we free it as we go (pass) */ ssize_t stream_front; + /* Transaction VSL buffer */ + struct vsl_log vsl[1]; + }; /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 196cead..1bd74fe 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -318,7 +318,7 @@ SES_GetReq(struct sess *sp) struct sesspool *pp; uint16_t nhttp; unsigned sz, hl; - char *p; + char *p, *e; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); pp = sp->sesspool; @@ -330,27 +330,38 @@ SES_GetReq(struct sess *sp) AN(sp->req); sp->req->magic = REQ_MAGIC; + e = (char*)sp->req + sz; p = (char*)(sp->req + 1); - sz -= sizeof *sp->req; + p = (void*)PRNDUP(p); + assert(p < e); nhttp = (uint16_t)cache_param->http_max_hdr; hl = HTTP_estimate(nhttp); - xxxassert(sz > 3 * hl + 128); - sp->req->http = HTTP_create(p, nhttp); - p += hl; // XXX: align ? - sz -= hl; + p += hl; + p = (void*)PRNDUP(p); + assert(p < e); sp->req->http0 = HTTP_create(p, nhttp); - p += hl; // XXX: align ? - sz -= hl; + p += hl; + p = (void*)PRNDUP(p); + assert(p < e); sp->req->resp = HTTP_create(p, nhttp); - p += hl; // XXX: align ? - sz -= hl; + p += hl; + p = (void*)PRNDUP(p); + assert(p < e); + + sz = cache_param->workspace_thread; + VSL_Setup(sp->req->vsl, p, sz); + sp->req->vsl->wid = sp->vsl_id; + p += sz; + p = (void*)PRNDUP(p); + + assert(p < e); - WS_Init(sp->req->ws, "req", p, sz); + WS_Init(sp->req->ws, "req", p, e - p); } void @@ -364,6 +375,7 @@ SES_ReleaseReq(struct sess *sp) AN(pp->pool); CHECK_OBJ_NOTNULL(sp->req, REQ_MAGIC); MPL_AssertSane(sp->req); + WSL_Flush(sp->req->vsl, 0); MPL_Free(pp->mpl_req, sp->req); sp->req = NULL; } diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 7694435..916fad8 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -78,6 +78,8 @@ struct params { unsigned workspace_backend; unsigned workspace_thread; + unsigned vsl_buffer; + unsigned shm_workspace; unsigned http_req_size; unsigned http_req_hdr_len; diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index e2e1a3a..475806d 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -766,6 +766,18 @@ static const struct parspec input_parspec[] = { "objects allocate exact space for the headers they store.\n", 0, "64", "header lines" }, + { "vsl_buffer", + tweak_bytes_u, &mgt_param.vsl_buffer, 1024, UINT_MAX, + "Bytes of (req-/backend-)workspace dedicated to buffering" + " VSL records.\n" + "At a bare minimum, this must be longer than" + " the longest HTTP header to be logged.\n" + "Setting this too high costs memory, setting it too low" + " will cause more VSL flushes and likely increase" + " lock-contention on the VSL mutex.\n" + "Minimum is 1k bytes.", + 0, + "4k", "bytes" }, { "shm_workspace", tweak_bytes_u, &mgt_param.shm_workspace, 4096, UINT_MAX, "Bytes of shmlog workspace allocated for worker threads. " From geoff at varnish-cache.org Tue Feb 14 16:49:34 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:34 +0100 Subject: [experimental-ims] b600f1a Don't use HUGE_VAL to signify no upper limit, we run into infinity in conversions to uintmax_t. Use zero to disable upper limit check. Check separately for byte sizes larger than the architecture can do. Message-ID: commit b600f1a1ad5c59ac9e762e1e9530d78b2ef0ea1f Author: Poul-Henning Kamp Date: Mon Feb 13 10:21:56 2012 +0000 Don't use HUGE_VAL to signify no upper limit, we run into infinity in conversions to uintmax_t. Use zero to disable upper limit check. Check separately for byte sizes larger than the architecture can do. diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index f32cc0e..6c24e91 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -322,7 +322,13 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, VCLI_SetResult(cli, CLIS_PARAM); return; } - if ((uintmax_t)((ssize_t)r) != r || r > max) { + if ((uintmax_t)((ssize_t)r) != r) { + fmt_bytes(cli, (uintmax_t)max); + VCLI_Out(cli, " is too large for this architecture.\n"); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + if (max != 0. && r > max) { VCLI_Out(cli, "Must be no more than "); fmt_bytes(cli, (uintmax_t)max); VCLI_Out(cli, "\n"); @@ -859,7 +865,7 @@ static const struct parspec input_parspec[] = { "256m", "bytes" }, #ifdef SENDFILE_WORKS { "sendfile_threshold", - tweak_bytes, &mgt_param.sendfile_threshold, 0, HUGE_VAL, + tweak_bytes, &mgt_param.sendfile_threshold, 0, 0, "The minimum size of objects transmitted with sendfile.", EXPERIMENTAL, "1E", "bytes" }, @@ -1183,7 +1189,7 @@ static const struct parspec input_parspec[] = { "10000", ""}, { "vsl_space", tweak_bytes, - &mgt_param.vsl_space, 1024*1024, HUGE_VAL, + &mgt_param.vsl_space, 1024*1024, 0, "The amount of space to allocate for the VSL fifo buffer" " in the VSM memory segment." " If you make this too small, varnish{ncsa|log} etc will" @@ -1193,7 +1199,7 @@ static const struct parspec input_parspec[] = { "80M", "bytes"}, { "vsm_space", tweak_bytes, - &mgt_param.vsm_space, 1024*1024, HUGE_VAL, + &mgt_param.vsm_space, 1024*1024, 0, "The amount of space to allocate for stats counters" " in the VSM memory segment." " If you make this too small, some counters will be" From geoff at varnish-cache.org Tue Feb 14 16:49:28 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:28 +0100 Subject: [experimental-ims] 8c2fe8d Clarify that certain parameters are likely to be rounded to page-size by the operating system. Message-ID: commit 8c2fe8d056f11f53b3cfd37d52bda3b93ec075f4 Author: Poul-Henning Kamp Date: Thu Feb 9 07:48:53 2012 +0000 Clarify that certain parameters are likely to be rounded to page-size by the operating system. diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 8c7a668..87b57ec 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -695,12 +695,14 @@ static const struct parspec input_parspec[] = { "120", "seconds" }, { "workspace_client", tweak_bytes_u, &mgt_param.workspace_client, 3072, UINT_MAX, - "Bytes of HTTP protocol workspace for clients HTTP req/resp.", + "Bytes of HTTP protocol workspace for clients HTTP req/resp." + " If larger than 4k, use a multiple of 4k for VM efficiency.", DELAYED_EFFECT, "64k", "bytes" }, { "workspace_backend", tweak_bytes_u, &mgt_param.workspace_backend, 1024, UINT_MAX, - "Bytes of HTTP protocol workspace for backend HTTP req/resp.", + "Bytes of HTTP protocol workspace for backend HTTP req/resp." + " If larger than 4k, use a multiple of 4k for VM efficiency.", DELAYED_EFFECT, "64k", "bytes" }, { "workspace_thread", diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index b716937..a6f020c 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -66,7 +66,7 @@ tweak_thread_pool_min(struct cli *cli, const struct parspec *par, /*-------------------------------------------------------------------- * This is utterly ridiculous: POSIX does not guarantee that the * minimum thread stack size is a compile time constant. - * XXX: "32" is a magic marker for 32bit systems. + * XXX: "32bit" is a magic marker for 32bit systems. */ static void @@ -220,6 +220,7 @@ const struct parspec WRK_parspec[] = { { "thread_pool_stack", tweak_stack_size, &mgt_param.wthread_stacksize, 0, UINT_MAX, "Worker thread stack size.\n" + "This is likely rounded up to a multiple of 4k by the kernel.\n" "On 32bit systems you may need to tweak this down to fit " "many threads into the limited address space.\n", EXPERIMENTAL, From geoff at varnish-cache.org Tue Feb 14 16:49:29 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:29 +0100 Subject: [experimental-ims] fb3cc4b Make fmt_bytes take an uintmax_t Message-ID: commit fb3cc4b53a61b1ca404eb4885e09f497aee00998 Author: Poul-Henning Kamp Date: Mon Feb 13 10:19:26 2012 +0000 Make fmt_bytes take an uintmax_t diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index ff523b1..f32cc0e 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -283,7 +283,7 @@ tweak_uint(struct cli *cli, const struct parspec *par, const char *arg) /*--------------------------------------------------------------------*/ static void -fmt_bytes(struct cli *cli, ssize_t t) +fmt_bytes(struct cli *cli, uintmax_t t) { const char *p; @@ -298,7 +298,7 @@ fmt_bytes(struct cli *cli, ssize_t t) } t /= 1024; if (t & 0x0ff) { - VCLI_Out(cli, "%zu%c", t, *p); + VCLI_Out(cli, "%ju%c", t, *p); return; } } @@ -324,14 +324,14 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, } if ((uintmax_t)((ssize_t)r) != r || r > max) { VCLI_Out(cli, "Must be no more than "); - fmt_bytes(cli, (ssize_t)max); + fmt_bytes(cli, (uintmax_t)max); VCLI_Out(cli, "\n"); VCLI_SetResult(cli, CLIS_PARAM); return; } if (r < min) { VCLI_Out(cli, "Must be at least "); - fmt_bytes(cli, (ssize_t)min); + fmt_bytes(cli, (uintmax_t)min); VCLI_Out(cli, "\n"); VCLI_SetResult(cli, CLIS_PARAM); return; From geoff at varnish-cache.org Tue Feb 14 16:49:23 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:23 +0100 Subject: [experimental-ims] 1366473 Allocate busyobj with a mempool, instead of a private one-item pool. Message-ID: commit 1366473e5a52b2425e6348c395c74fe5381c4140 Author: Poul-Henning Kamp Date: Wed Feb 8 22:28:58 2012 +0000 Allocate busyobj with a mempool, instead of a private one-item pool. diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index ab4db76..51207df 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -38,6 +38,10 @@ #include "cache.h" +static struct mempool *vbopool; + +static volatile unsigned vbosize; + struct vbo { unsigned magic; #define VBO_MAGIC 0xde3d8223 @@ -48,13 +52,35 @@ struct vbo { }; static struct lock vbo_mtx; -static struct vbo *nvbo; + +/*-------------------------------------------------------------------- + */ + +static void +vbo_size_calc(volatile unsigned *u) +{ + uint16_t nhttp; + ssize_t http_space; + + assert(cache_param->http_max_hdr < 65536); + nhttp = (uint16_t)cache_param->http_max_hdr; + + http_space = HTTP_estimate(nhttp); + + *u = sizeof(struct vbo) + http_space * 2L; +} + +/*-------------------------------------------------------------------- + */ void VBO_Init(void) { + + vbopool = MPL_New("vbo", &cache_param->vbo_pool, &vbosize, + vbo_size_calc); + AN(vbopool); Lck_New(&vbo_mtx, lck_busyobj); - nvbo = NULL; } /*-------------------------------------------------------------------- @@ -67,16 +93,19 @@ vbo_New(void) struct vbo *vbo; uint16_t nhttp; ssize_t http_space; + unsigned sz; - assert(cache_param->http_max_hdr < 65536); + vbo = MPL_Get(vbopool, &sz); nhttp = (uint16_t)cache_param->http_max_hdr; - http_space = HTTP_estimate(nhttp); - - vbo = malloc(sizeof *vbo + 2 * http_space); + if (sizeof *vbo + 2 * http_space > sz) { + /* Could be transient, try again */ + MPL_Free(vbopool, vbo); + vbo_size_calc(&vbosize); + vbo = MPL_Get(vbopool, &sz); + assert (sizeof *vbo + 2 * http_space <= sz); + } AN(vbo); - - memset(vbo, 0, sizeof *vbo); vbo->magic = VBO_MAGIC; vbo->nhttp = nhttp; Lck_New(&vbo->mtx, lck_busyobj); @@ -94,7 +123,7 @@ VBO_Free(struct vbo **vbop) CHECK_OBJ_NOTNULL(vbo, VBO_MAGIC); AZ(vbo->refcount); Lck_Delete(&vbo->mtx); - FREE_OBJ(vbo); + MPL_Free(vbopool, vbo); } struct busyobj * @@ -110,21 +139,6 @@ VBO_GetBusyObj(struct worker *wrk) wrk->nvbo = NULL; } - if (vbo == NULL) { - Lck_Lock(&vbo_mtx); - - vbo = nvbo; - nvbo = NULL; - - if (vbo == NULL) - VSC_C_main->busyobj_alloc++; - - Lck_Unlock(&vbo_mtx); - } - - if (vbo != NULL && vbo->nhttp != cache_param->http_max_hdr) - VBO_Free(&vbo); - if (vbo == NULL) vbo = vbo_New(); @@ -181,19 +195,9 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) /* XXX: Sanity checks & cleanup */ memset(&vbo->bo, 0, sizeof vbo->bo); - if (cache_param->bo_cache && wrk->nvbo == NULL) { + if (cache_param->bo_cache && wrk->nvbo == NULL) wrk->nvbo = vbo; - } else { - Lck_Lock(&vbo_mtx); - if (nvbo == NULL) { - nvbo = vbo; - vbo = NULL; - } else - VSC_C_main->busyobj_free++; - Lck_Unlock(&vbo_mtx); - - if (vbo != NULL) - VBO_Free(&vbo); - } + else + VBO_Free(&vbo); } } diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index ec0d36b..4b8ed07 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -237,6 +237,8 @@ MPL_New(const char *name, mpl->param = pp; mpl->cur_size = cur_size; mpl->poll_func = poll_f; + if (poll_f != NULL) + poll_f(mpl->cur_size); VTAILQ_INIT(&mpl->list); VTAILQ_INIT(&mpl->surplus); Lck_New(&mpl->mtx, lck_mempool); diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 015e5d2..40fcf1d 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -201,4 +201,5 @@ struct params { struct poolparam vbc_pool; struct poolparam req_pool; struct poolparam sess_pool; + struct poolparam vbo_pool; }; diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 60d49f8..56c8336 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -662,6 +662,12 @@ tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg) "\nNB: Do not change this parameter, unless a developer tell " \ "you to do so." +#define MEMPOOL_TEXT \ + "The three numbers are:\n" \ + " min_pool -- minimum size of free pool.\n" \ + " max_pool -- maximum size of free pool.\n" \ + " max_age -- max age of free element.\n" + /* * Remember to update varnishd.1 whenever you add / remove a parameter or * change its default value. @@ -1192,27 +1198,23 @@ static const struct parspec input_parspec[] = { { "pool_vbc", tweak_poolparam, &mgt_param.vbc_pool, 0, 10000, "Parameters for backend connection memory pool.\n" - "The three numbers are:\n" - " min_pool -- minimum size of free pool.\n" - " max_pool -- maximum size of free pool.\n" - " max_age -- max age of free element.\n", + MEMPOOL_TEXT, 0, "10,100,10", ""}, { "pool_req", tweak_poolparam, &mgt_param.req_pool, 0, 10000, "Parameters for per worker pool request memory pool.\n" - "The three numbers are:\n" - " min_pool -- minimum size of free pool.\n" - " max_pool -- maximum size of free pool.\n" - " max_age -- max age of free element.\n", + MEMPOOL_TEXT, 0, "10,100,10", ""}, { "pool_sess", tweak_poolparam, &mgt_param.sess_pool, 0, 10000, "Parameters for per worker pool session memory pool.\n" - "The three numbers are:\n" - " min_pool -- minimum size of free pool.\n" - " max_pool -- maximum size of free pool.\n" - " max_age -- max age of free element.\n", + MEMPOOL_TEXT, + 0, + "10,100,10", ""}, + { "pool_vbo", tweak_poolparam, &mgt_param.vbo_pool, 0, 10000, + "Parameters for backend object fetch memory pool.\n" + MEMPOOL_TEXT, 0, "10,100,10", ""}, diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index df7984a..1188903 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -206,20 +206,6 @@ VSC_F(sess_dropped, uint64_t, 0, 'c', " See also param queue_max." ) -/*--------------------------------------------------------------------- - * BusyObj - */ - -VSC_F(busyobj_alloc, uint64_t, 0, 'c', - "Busyobj allocations", - "Number of busyobj structures allocated." -) - -VSC_F(busyobj_free, uint64_t, 0, 'c', - "Busyobj freed", - "Number of busyobj structures freed." -) - /*---------------------------------------------------------------------*/ VSC_F(n_object, uint64_t, 1, 'i', "N struct object", "") From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] e9e3e2e Eliminate a lot of arguments to http_ functions which used to convey the VSL coords which are now a property of struct http. Message-ID: commit e9e3e2e80f0e1d6aad3899a55647ed2b5e311673 Author: Poul-Henning Kamp Date: Tue Feb 14 10:31:51 2012 +0000 Eliminate a lot of arguments to http_ functions which used to convey the VSL coords which are now a property of struct http. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 0bac299..2349470 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -691,7 +691,7 @@ struct vbc *VDI_GetFd(const struct director *, struct sess *sp); int VDI_Healthy(const struct director *, const struct sess *sp); void VDI_CloseFd(struct worker *wrk, struct vbc **vbp); void VDI_RecycleFd(struct worker *wrk, struct vbc **vbp); -void VDI_AddHostHeader(struct worker *wrk, const struct vbc *vbc); +void VDI_AddHostHeader(struct http *to, const struct vbc *vbc); void VBE_Poll(void); void VDI_Init(void); @@ -804,16 +804,12 @@ void http_SetResp(struct http *to, const char *proto, uint16_t status, const char *response); void http_FilterReq(const struct sess *sp, unsigned how); void http_FilterResp(const struct http *fm, struct http *to, unsigned how); -void http_PutProtocol(struct worker *w, unsigned vsl_id, const struct http *to, - const char *protocol); +void http_PutProtocol(const struct http *to, const char *protocol); void http_PutStatus(struct http *to, uint16_t status); -void http_PutResponse(struct worker *w, unsigned vsl_id, const struct http *to, - const char *response); -void http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to, - const char *fmt, ...) - __printflike(4, 5); -void http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, - const char *hdr); +void http_PutResponse(const struct http *to, const char *response); +void http_PrintfHeader(struct http *to, const char *fmt, ...) + __printflike(2, 3); +void http_SetHeader(struct http *to, const char *hdr); void http_SetH(const struct http *to, unsigned n, const char *fm); void http_ForceGet(const struct http *to); void http_Setup(struct http *ht, struct ws *ws, struct vsl_log *); @@ -830,7 +826,7 @@ int http_HdrIs(const struct http *hp, const char *hdr, const char *val); uint16_t http_DissectRequest(const struct sess *sp); uint16_t http_DissectResponse(struct http *sp, const struct http_conn *htc); const char *http_DoConnection(const struct http *hp); -void http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp); +void http_CopyHome(const struct http *hp); void http_Unset(struct http *hp, const char *hdr); void http_CollectHdr(struct http *hp, const char *hdr); diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 267e7ba..6e86538 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -65,14 +65,12 @@ struct vdi_simple { * Create default Host: header for backend request */ void -VDI_AddHostHeader(struct worker *wrk, const struct vbc *vbc) +VDI_AddHostHeader(struct http *hp, const struct vbc *vbc) { - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj->bereq, HTTP_MAGIC); CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); CHECK_OBJ_NOTNULL(vbc->vdis, VDI_SIMPLE_MAGIC); - http_PrintfHeader(wrk, vbc->vsl_id, wrk->busyobj->bereq, + http_PrintfHeader(hp, "Host: %s", vbc->vdis->vrt->hosthdr); } diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 54a883b..8aa80d1 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -501,17 +501,16 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) if (req->err_code < 100 || req->err_code > 999) req->err_code = 501; - http_PutProtocol(wrk, sp->vsl_id, h, "HTTP/1.1"); + http_PutProtocol(h, "HTTP/1.1"); http_PutStatus(h, req->err_code); VTIM_format(W_TIM_real(wrk), date); - http_PrintfHeader(wrk, sp->vsl_id, h, "Date: %s", date); - http_SetHeader(wrk, sp->vsl_id, h, "Server: Varnish"); + http_PrintfHeader(h, "Date: %s", date); + http_SetHeader(h, "Server: Varnish"); if (req->err_reason != NULL) - http_PutResponse(wrk, sp->vsl_id, h, req->err_reason); + http_PutResponse(h, req->err_reason); else - http_PutResponse(wrk, sp->vsl_id, h, - http_StatusMessage(req->err_code)); + http_PutResponse(h, http_StatusMessage(req->err_code)); VCL_error_method(sp); if (req->handling == VCL_RET_RESTART && @@ -745,8 +744,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) /* If we do gzip, add the C-E header */ if (bo->do_gzip) - http_SetHeader(wrk, sp->vsl_id, bo->beresp, - "Content-Encoding: gzip"); + http_SetHeader(bo->beresp, "Content-Encoding: gzip"); /* But we can't do both at the same time */ assert(bo->do_gzip == 0 || bo->do_gunzip == 0); @@ -839,7 +837,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) hp2->logtag = HTTP_Obj; http_FilterResp(hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS); - http_CopyHome(wrk, sp->vsl_id, hp2); + http_CopyHome(hp2); if (http_GetHdr(hp, H_Last_Modified, &b)) req->obj->last_modified = VTIM_parse(b); @@ -1233,8 +1231,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) * the minority of clients which don't. */ http_Unset(wrk->busyobj->bereq, H_Accept_Encoding); - http_SetHeader(wrk, sp->vsl_id, wrk->busyobj->bereq, - "Accept-Encoding: gzip"); + http_SetHeader(wrk->busyobj->bereq, "Accept-Encoding: gzip"); } VCL_miss_method(sp); @@ -1400,7 +1397,7 @@ DOT hash -> lookup [label="hash",style=bold,color=green] */ static int -cnt_recv(struct sess *sp, struct worker *wrk, struct req *req) +cnt_recv(struct sess *sp, const struct worker *wrk, struct req *req) { unsigned recv_handling; struct SHA256Context sha256ctx; @@ -1444,8 +1441,7 @@ cnt_recv(struct sess *sp, struct worker *wrk, struct req *req) (recv_handling != VCL_RET_PASS)) { if (RFC2616_Req_Gzip(sp)) { http_Unset(req->http, H_Accept_Encoding); - http_SetHeader(wrk, sp->vsl_id, req->http, - "Accept-Encoding: gzip"); + http_SetHeader(req->http, "Accept-Encoding: gzip"); } else { http_Unset(req->http, H_Accept_Encoding); } diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 8ef35a3..360a70f 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -73,7 +73,7 @@ ved_include(struct sess *sp, const char *src, const char *host) if (host != NULL && *host != '\0') { http_Unset(sp->req->http, H_Host); http_Unset(sp->req->http, H_If_Modified_Since); - http_SetHeader(w, sp->vsl_id, sp->req->http, host); + http_SetHeader(sp->req->http, host); } /* * XXX: We should decide if we should cache the director diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 327ae0a..f5995ca 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -393,8 +393,8 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) struct http_conn *htc; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); wrk = sp->wrk; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); htc = &wrk->busyobj->htc; @@ -408,12 +408,12 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) hp = wrk->busyobj->bereq; - sp->wrk->busyobj->vbc = VDI_GetFd(NULL, sp); - if (sp->wrk->busyobj->vbc == NULL) { + wrk->busyobj->vbc = VDI_GetFd(NULL, sp); + if (wrk->busyobj->vbc == NULL) { WSP(sp, SLT_FetchError, "no backend connection"); return (-1); } - vc = sp->wrk->busyobj->vbc; + vc = wrk->busyobj->vbc; if (vc->recycled) retry = 1; @@ -423,7 +423,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) * because the backend may be chosen by a director. */ if (need_host_hdr) - VDI_AddHostHeader(sp->wrk, vc); + VDI_AddHostHeader(wrk->busyobj->bereq, vc); (void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */ WRW_Reserve(wrk, &vc->fd); @@ -434,7 +434,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) if (WRW_FlushRelease(wrk) || i > 0) { WSP(sp, SLT_FetchError, "backend write error: %d (%s)", errno, strerror(errno)); - VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc); + VDI_CloseFd(wrk, &wrk->busyobj->vbc); /* XXX: other cleanup ? */ return (retry); } @@ -458,7 +458,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) if (i < 0) { WSP(sp, SLT_FetchError, "http first read error: %d %d (%s)", i, errno, strerror(errno)); - VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc); + VDI_CloseFd(wrk, &wrk->busyobj->vbc); /* XXX: other cleanup ? */ /* Retryable if we never received anything */ return (i == -1 ? retry : -1); @@ -472,7 +472,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) WSP(sp, SLT_FetchError, "http first read error: %d %d (%s)", i, errno, strerror(errno)); - VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc); + VDI_CloseFd(wrk, &wrk->busyobj->vbc); /* XXX: other cleanup ? */ return (-1); } @@ -482,7 +482,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) if (http_DissectResponse(hp, htc)) { WSP(sp, SLT_FetchError, "http format error"); - VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc); + VDI_CloseFd(wrk, &wrk->busyobj->vbc); /* XXX: other cleanup ? */ return (-1); } @@ -614,8 +614,7 @@ FetchBody(struct worker *wrk, struct object *obj) if (mklen > 0) { http_Unset(obj->http, H_Content_Length); - http_PrintfHeader(wrk, bo->vbc->vsl_id, obj->http, - "Content-Length: %zd", obj->len); + http_PrintfHeader(obj->http, "Content-Length: %zd", obj->len); } if (cls) diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 2a97829..de71ada 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -865,8 +865,7 @@ http_FilterReq(const struct sess *sp, unsigned how) else http_linkh(hp, sp->req->http, HTTP_HDR_PROTO); http_filterfields(hp, sp->req->http, how); - http_PrintfHeader(sp->wrk, sp->vsl_id, hp, - "X-Varnish: %u", sp->req->xid); + http_PrintfHeader(hp, "X-Varnish: %u", sp->req->xid); } /*--------------------------------------------------------------------*/ @@ -889,7 +888,7 @@ http_FilterResp(const struct http *fm, struct http *to, unsigned how) */ void -http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp) +http_CopyHome(const struct http *hp) { unsigned u, l; char *p; @@ -911,7 +910,7 @@ http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp) } else { /* XXX This leaves a slot empty */ VSC_C_main->losthdr++; - WSLR(w->vsl, SLT_LostHeader, vsl_id, hp->hd[u]); + WSLR(hp->vsl, SLT_LostHeader, -1, hp->hd[u]); hp->hd[u].b = NULL; hp->hd[u].e = NULL; } @@ -935,14 +934,13 @@ http_ClrHeader(struct http *to) /*--------------------------------------------------------------------*/ void -http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, - const char *hdr) +http_SetHeader(struct http *to, const char *hdr) { CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); if (to->nhd >= to->shd) { VSC_C_main->losthdr++; - WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", hdr); + WSL(to->vsl, SLT_LostHeader, -1, "%s", hdr); return; } http_SetH(to, to->nhd++, hdr); @@ -951,8 +949,7 @@ http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, /*--------------------------------------------------------------------*/ static void -http_PutField(struct worker *w, unsigned vsl_id, const struct http *to, - int field, const char *string) +http_PutField(const struct http *to, int field, const char *string) { char *p; unsigned l; @@ -961,7 +958,7 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to, l = strlen(string); p = WS_Alloc(to->ws, l + 1); if (p == NULL) { - WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", string); + WSL(to->vsl, SLT_LostHeader, -1, "%s", string); to->hd[field].b = NULL; to->hd[field].e = NULL; to->hdf[field] = 0; @@ -974,11 +971,10 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to, } void -http_PutProtocol(struct worker *w, unsigned vsl_id, const struct http *to, - const char *protocol) +http_PutProtocol(const struct http *to, const char *protocol) { - http_PutField(w, vsl_id, to, HTTP_HDR_PROTO, protocol); + http_PutField(to, HTTP_HDR_PROTO, protocol); if (to->hd[HTTP_HDR_PROTO].b == NULL) http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1"); Tcheck(to->hd[HTTP_HDR_PROTO]); @@ -993,19 +989,17 @@ http_PutStatus(struct http *to, uint16_t status) } void -http_PutResponse(struct worker *w, unsigned vsl_id, const struct http *to, - const char *response) +http_PutResponse(const struct http *to, const char *response) { - http_PutField(w, vsl_id, to, HTTP_HDR_RESPONSE, response); + http_PutField(to, HTTP_HDR_RESPONSE, response); if (to->hd[HTTP_HDR_RESPONSE].b == NULL) http_SetH(to, HTTP_HDR_RESPONSE, "Lost Response"); Tcheck(to->hd[HTTP_HDR_RESPONSE]); } void -http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to, - const char *fmt, ...) +http_PrintfHeader(struct http *to, const char *fmt, ...) { va_list ap; unsigned l, n; @@ -1017,7 +1011,7 @@ http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to, va_end(ap); if (n + 1 >= l || to->nhd >= to->shd) { VSC_C_main->losthdr++; - WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", to->ws->f); + WSL(to->vsl, SLT_LostHeader, -1, "%s", to->ws->f); WS_Release(to->ws, 0); } else { to->hd[to->nhd].b = to->ws->f; diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index df9c137..148a73c 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -90,13 +90,12 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh) if (low > high) return; - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, - "Content-Range: bytes %jd-%jd/%jd", + http_PrintfHeader(req->resp, "Content-Range: bytes %jd-%jd/%jd", (intmax_t)low, (intmax_t)high, (intmax_t)req->obj->len); http_Unset(req->resp, H_Content_Length); assert(req->res_mode & RES_LEN); - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, - "Content-Length: %jd", (intmax_t)(1 + high - low)); + http_PrintfHeader(req->resp, "Content-Length: %jd", + (intmax_t)(1 + high - low)); http_SetResp(req->resp, "HTTP/1.1", 206, "Partial Content"); *plow = low; @@ -123,29 +122,25 @@ RES_BuildHttp(const struct sess *sp) http_Unset(req->resp, H_Content_Length); } else if (cache_param->http_range_support) { /* We only accept ranges if we know the length */ - http_SetHeader(sp->wrk, sp->vsl_id, req->resp, - "Accept-Ranges: bytes"); + http_SetHeader(req->resp, "Accept-Ranges: bytes"); } if (req->res_mode & RES_CHUNKED) - http_SetHeader(sp->wrk, sp->vsl_id, req->resp, - "Transfer-Encoding: chunked"); + http_SetHeader(req->resp, "Transfer-Encoding: chunked"); VTIM_format(VTIM_real(), time_str); - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, - "Date: %s", time_str); + http_PrintfHeader(req->resp, "Date: %s", time_str); if (req->xid != req->obj->xid) - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, + http_PrintfHeader(req->resp, "X-Varnish: %u %u", req->xid, req->obj->xid); else - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, - "X-Varnish: %u", req->xid); - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, "Age: %.0f", + http_PrintfHeader(req->resp, "X-Varnish: %u", req->xid); + http_PrintfHeader(req->resp, "Age: %.0f", req->obj->exp.age + req->t_resp - req->obj->exp.entered); - http_SetHeader(sp->wrk, sp->vsl_id, req->resp, "Via: 1.1 varnish"); - http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, "Connection: %s", + http_SetHeader(req->resp, "Via: 1.1 varnish"); + http_PrintfHeader(req->resp, "Connection: %s", req->doclose ? "close" : "keep-alive"); } @@ -337,7 +332,7 @@ RES_StreamStart(struct sess *sp) if (!(req->res_mode & RES_CHUNKED) && sp->wrk->busyobj->h_content_length != NULL) - http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp, + http_PrintfHeader(sp->req->resp, "Content-Length: %s", sp->wrk->busyobj->h_content_length); sp->wrk->acct_tmp.hdrbytes += diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index d69c7fb..6271e49 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -231,7 +231,7 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr, WSP(sp, SLT_LostHeader, "%s", hdr + 1); } else { http_Unset(hp, hdr); - http_SetHeader(sp->wrk, sp->vsl_id, hp, b); + http_SetHeader(hp, b); } } va_end(ap); @@ -417,7 +417,7 @@ VRT_synth_page(const struct sess *sp, unsigned flags, const char *str, ...) va_end(ap); SMS_Finish(sp->req->obj); http_Unset(sp->req->obj->http, H_Content_Length); - http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->obj->http, + http_PrintfHeader(sp->req->obj->http, "Content-Length: %zd", sp->req->obj->len); } diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 15f91df..97ff04a 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -1,7 +1,7 @@ -d__flexelint_v9__=1 -printf(3, VSL) --printf(4, http_PrintfHeader) +-printf(2, http_PrintfHeader) -printf(4, WSL) -printf(3, WSLB) -printf(2, VSB_printf) From geoff at varnish-cache.org Tue Feb 14 16:49:29 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:29 +0100 Subject: [experimental-ims] 8a75838 Fix up some sess_workspace leftovers Message-ID: commit 8a758381848f885f9f39f963345697359bffc787 Author: Rogier 'DocWilco' Mulhuijzen Date: Wed Jan 18 10:51:14 2012 +0100 Fix up some sess_workspace leftovers Found by: Joakim Berg diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index cc918c1..6405cdd 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -406,7 +406,7 @@ main(int argc, char * const *argv) * Adjust default parameters for 32 bit systems to conserve * VM space. */ - MCF_ParamSet(cli, "sess_workspace", "16384"); + MCF_ParamSet(cli, "workspace_client", "16384"); cli_check(cli); MCF_ParamSet(cli, "thread_pool_workspace", "16384"); diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 87b57ec..ff523b1 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -725,8 +725,8 @@ static const struct parspec input_parspec[] = { "Maximum number of bytes of HTTP client request we will deal " "with. This is a limit on all bytes up to the double blank " "line which ends the HTTP request.\n" - "The memory for the request is allocated from the session " - "workspace (param: sess_workspace) and this parameter limits " + "The memory for the request is allocated from the client " + "workspace (param: workspace_client) and this parameter limits " "how much of that the request is allowed to take up.", 0, "32k", "bytes" }, @@ -744,8 +744,8 @@ static const struct parspec input_parspec[] = { "with. This is a limit on all bytes up to the double blank " "line which ends the HTTP request.\n" "The memory for the request is allocated from the worker " - "workspace (param: sess_workspace) and this parameter limits " - "how much of that the request is allowed to take up.", + "workspace (param: thread_pool_workspace) and this parameter " + "limits how much of that the request is allowed to take up.", 0, "32k", "bytes" }, { "http_max_hdr", tweak_uint, &mgt_param.http_max_hdr, 32, 65535, From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] 2d49712 Change FetchError() to take busyobj as arg. Message-ID: commit 2d49712fb096255ae1178275c3a0a8c955142853 Author: Poul-Henning Kamp Date: Tue Feb 14 11:00:54 2012 +0000 Change FetchError() to take busyobj as arg. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 8ff3688..50d9541 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -757,8 +757,8 @@ int EXP_NukeOne(struct worker *w, struct lru *lru); /* cache_fetch.c */ struct storage *FetchStorage(struct worker *w, ssize_t sz); -int FetchError(const struct worker *w, const char *error); -int FetchError2(const struct worker *w, const char *error, const char *more); +int FetchError(struct busyobj *, const char *error); +int FetchError2(struct busyobj *, const char *error, const char *more); int FetchHdr(struct sess *sp, int need_host_hdr, int sendbody); int FetchBody(struct worker *w, struct object *obj); int FetchReqBody(const struct sess *sp, int sendbody); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 620082d..45bfa86 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -387,7 +387,7 @@ vfp_esi_end(struct worker *wrk) retval = bo->fetch_failed; if (bo->vgz_rx != NULL && VGZ_Destroy(&bo->vgz_rx, -1) != VGZ_END) - retval = FetchError(wrk, "Gunzip+ESI Failed at the very end"); + retval = FetchError(bo, "Gunzip+ESI Failed at the very end"); vsb = VEP_Finish(wrk); @@ -402,7 +402,7 @@ vfp_esi_end(struct worker *wrk) VSB_data(vsb), l); bo->fetch_obj->esidata->len = l; } else { - retval = FetchError(wrk, + retval = FetchError(bo, "Could not allocate storage for esidata"); } } @@ -415,7 +415,7 @@ vfp_esi_end(struct worker *wrk) if (vef->vgz != NULL) { VGZ_UpdateObj(vef->vgz, bo->fetch_obj); if (VGZ_Destroy(&vef->vgz, -1) != VGZ_END) - retval = FetchError(wrk, + retval = FetchError(bo, "ESI+Gzip Failed at the very end"); } if (vef->ibuf != NULL) diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 8b94fd7..2924130 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -52,25 +52,24 @@ static unsigned fetchfrag; */ int -FetchError2(const struct worker *wrk, const char *error, const char *more) +FetchError2(struct busyobj *bo, const char *error, const char *more) { - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - if (!wrk->busyobj->fetch_failed) { + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + if (!bo->fetch_failed) { if (more == NULL) - VSLB(wrk->busyobj, SLT_FetchError, "%s", error); + VSLB(bo, SLT_FetchError, "%s", error); else - VSLB(wrk->busyobj, SLT_FetchError, "%s: %s", error, - more); + VSLB(bo, SLT_FetchError, "%s: %s", error, more); } - wrk->busyobj->fetch_failed = 1; + bo->fetch_failed = 1; return (-1); } int -FetchError(const struct worker *wrk, const char *error) +FetchError(struct busyobj *bo, const char *error) { - return(FetchError2(wrk, error, NULL)); + return(FetchError2(bo, error, NULL)); } /*-------------------------------------------------------------------- @@ -192,7 +191,7 @@ FetchStorage(struct worker *wrk, ssize_t sz) l = cache_param->fetch_chunksize; st = STV_alloc(wrk, l); if (st == NULL) { - (void)FetchError(wrk, "Could not get storage"); + (void)FetchError(wrk->busyobj, "Could not get storage"); return (NULL); } AZ(st->len); @@ -233,13 +232,13 @@ fetch_straight(struct worker *wrk, struct http_conn *htc, ssize_t cl) assert(wrk->busyobj->body_status == BS_LENGTH); if (cl < 0) { - return (FetchError(wrk, "straight length field bogus")); + return (FetchError(wrk->busyobj, "straight length field bogus")); } else if (cl == 0) return (0); i = wrk->busyobj->vfp->bytes(wrk, htc, cl); if (i <= 0) - return (FetchError(wrk, "straight insufficient bytes")); + return (FetchError(wrk->busyobj, "straight insufficient bytes")); return (0); } @@ -266,7 +265,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) } while (vct_islws(buf[0])); if (!vct_ishex(buf[0])) - return (FetchError(wrk,"chunked header non-hex")); + return (FetchError(wrk->busyobj, "chunked header non-hex")); /* Collect hex digits, skipping leading zeros */ for (u = 1; u < sizeof buf; u++) { @@ -279,7 +278,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) } if (u >= sizeof buf) - return (FetchError(wrk,"chunked header too long")); + return (FetchError(wrk->busyobj,"chunked header too long")); /* Skip trailing white space */ while(vct_islws(buf[u]) && buf[u] != '\n') @@ -287,12 +286,12 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) return (-1); if (buf[u] != '\n') - return (FetchError(wrk,"chunked header no NL")); + return (FetchError(wrk->busyobj,"chunked header no NL")); buf[u] = '\0'; cl = fetch_number(buf, 16); if (cl < 0) - return (FetchError(wrk,"chunked header number syntax")); + return (FetchError(wrk->busyobj,"chunked header number syntax")); if (cl > 0 && wrk->busyobj->vfp->bytes(wrk, htc, cl) <= 0) return (-1); @@ -303,7 +302,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) if (buf[0] == '\r' && HTC_Read( htc, buf, 1) <= 0) return (-1); if (buf[0] != '\n') - return (FetchError(wrk,"chunked tail no NL")); + return (FetchError(wrk->busyobj,"chunked tail no NL")); } while (cl > 0); return (0); } diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 5901930..c4eab44 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -482,7 +482,7 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) return(-1); i = VGZ_Gunzip(vg, &dp, &dl); if (i != VGZ_OK && i != VGZ_END) - return(FetchError(wrk, "Gunzip data error")); + return(FetchError(wrk->busyobj, "Gunzip data error")); wrk->busyobj->fetch_obj->len += dl; if (wrk->busyobj->do_stream) RES_StreamPoll(wrk); @@ -506,7 +506,8 @@ vfp_gunzip_end(struct worker *wrk) return(0); } if (VGZ_Destroy(&vg, -1) != VGZ_END) - return(FetchError(wrk, "Gunzip error at the very end")); + return(FetchError(wrk->busyobj, + "Gunzip error at the very end")); return (0); } @@ -599,7 +600,7 @@ vfp_gzip_end(struct worker *wrk) RES_StreamPoll(wrk); VGZ_UpdateObj(vg, wrk->busyobj->fetch_obj); if (VGZ_Destroy(&vg, -1) != VGZ_END) - return(FetchError(wrk, "Gzip error at the very end")); + return(FetchError(wrk->busyobj, "Gzip error at the very end")); return (0); } @@ -664,9 +665,10 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) VGZ_Obuf(vg, vg->m_buf, vg->m_sz); i = VGZ_Gunzip(vg, &dp, &dl); if (i == VGZ_END && !VGZ_IbufEmpty(vg)) - return(FetchError(wrk, "Junk after gzip data")); + return(FetchError(wrk->busyobj, + "Junk after gzip data")); if (i != VGZ_OK && i != VGZ_END) - return(FetchError2(wrk, + return(FetchError2(wrk->busyobj, "Invalid Gzip data", vg->vz.msg)); } } @@ -690,7 +692,8 @@ vfp_testgzip_end(struct worker *wrk) } VGZ_UpdateObj(vg, wrk->busyobj->fetch_obj); if (VGZ_Destroy(&vg, -1) != VGZ_END) - return(FetchError(wrk, "TestGunzip error at the very end")); + return(FetchError(wrk->busyobj, + "TestGunzip error at the very end")); return (0); } From geoff at varnish-cache.org Tue Feb 14 16:49:28 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:28 +0100 Subject: [experimental-ims] 1cdbbff NB: Major Reorg Commit Message-ID: commit 1cdbbff4dc0c1886e1a3535ea7580f43ea52008d Author: Poul-Henning Kamp Date: Wed Feb 8 23:34:52 2012 +0000 NB: Major Reorg Commit Introduce a new "backend workspace" which is used for the backend transactions (bereq.*, beresp.*) Together with the "client workspace" which holds the client transaction (req.*, resp.*) this should make memory management much simpler to understand. The backend workspace lives in "busyobj" rather than the worker thread, which therefore needs a lot less stack, allowing many more threads in the same space. Experiments with thread_pool_stack are encouraged, I wouldn't be surprised if 32k is now enough. The per-thread workspace is still around, known as the "auxiallary workspace", but it is down to 256 bytes and it is only used to hand the acceptor information off to worker threads. Once the dust settles, I may remove it entirely, but I can see a value of having a small amount of fast memory in a thread, so I may also keep it. No promises. Ohh, and I removed a couple of small memory leaks which were only present in -trunk, as a result of a git-mis-merge. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 6338750..8df9591 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -327,7 +327,11 @@ struct worker { uint32_t *wlb, *wlp, *wle; unsigned wlr; - struct ws ws[1]; + /* + * In practice this workspace is only used for wrk_accept now + * but it might come handy later, so keep it around. For now. + */ + struct ws aws[1]; struct busyobj *busyobj; @@ -502,6 +506,7 @@ struct busyobj { unsigned fetch_failed; struct vgz *vgz_rx; + struct ws ws[1]; struct vbc *vbc; struct http *bereq; struct http *beresp; diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 434b50c..9384d1c 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -228,7 +228,7 @@ VCA_FailSess(struct worker *wrk) struct wrk_accept *wa; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CAST_OBJ_NOTNULL(wa, (void*)wrk->ws->f, WRK_ACCEPT_MAGIC); + CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC); AZ(wrk->sp); AZ(close(wa->acceptsock)); wrk->stats.sess_drop++; @@ -246,7 +246,7 @@ VCA_SetupSess(struct worker *wrk) struct wrk_accept *wa; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CAST_OBJ_NOTNULL(wa, (void*)wrk->ws->f, WRK_ACCEPT_MAGIC); + CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC); sp = wrk->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); sp->fd = wa->acceptsock; diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 51207df..65791e8 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -47,7 +47,7 @@ struct vbo { #define VBO_MAGIC 0xde3d8223 struct lock mtx; unsigned refcount; - uint16_t nhttp; + char *end; struct busyobj bo; }; @@ -67,7 +67,9 @@ vbo_size_calc(volatile unsigned *u) http_space = HTTP_estimate(nhttp); - *u = sizeof(struct vbo) + http_space * 2L; + *u = sizeof(struct vbo) + + http_space * 2L + + cache_param->workspace_backend; } /*-------------------------------------------------------------------- @@ -91,23 +93,12 @@ static struct vbo * vbo_New(void) { struct vbo *vbo; - uint16_t nhttp; - ssize_t http_space; unsigned sz; vbo = MPL_Get(vbopool, &sz); - nhttp = (uint16_t)cache_param->http_max_hdr; - http_space = HTTP_estimate(nhttp); - if (sizeof *vbo + 2 * http_space > sz) { - /* Could be transient, try again */ - MPL_Free(vbopool, vbo); - vbo_size_calc(&vbosize); - vbo = MPL_Get(vbopool, &sz); - assert (sizeof *vbo + 2 * http_space <= sz); - } AN(vbo); vbo->magic = VBO_MAGIC; - vbo->nhttp = nhttp; + vbo->end = (char *)vbo + sz; Lck_New(&vbo->mtx, lck_busyobj); return (vbo); } @@ -130,10 +121,15 @@ struct busyobj * VBO_GetBusyObj(struct worker *wrk) { struct vbo *vbo = NULL; + uint16_t nhttp; + unsigned httpsz; char *p; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + nhttp = (uint16_t)cache_param->http_max_hdr; + httpsz = HTTP_estimate(nhttp); + if (wrk->nvbo != NULL) { vbo = wrk->nvbo; wrk->nvbo = NULL; @@ -151,9 +147,11 @@ VBO_GetBusyObj(struct worker *wrk) vbo->bo.vbo = vbo; p = (void*)(vbo + 1); - vbo->bo.bereq = HTTP_create(p, vbo->nhttp); - p += HTTP_estimate(vbo->nhttp); - vbo->bo.beresp = HTTP_create(p, vbo->nhttp); + vbo->bo.bereq = HTTP_create(p, nhttp); + p += httpsz; + vbo->bo.beresp = HTTP_create(p, nhttp); + p += httpsz; + WS_Init(vbo->bo.ws, "bo", p, vbo->end - p); return (&vbo->bo); } @@ -197,7 +195,7 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) if (cache_param->bo_cache && wrk->nvbo == NULL) wrk->nvbo = vbo; - else + else VBO_Free(&vbo); } } diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index a8148b5..6692491 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -435,9 +435,9 @@ cnt_done(struct sess *sp, struct worker *wrk, struct req *req) if (wrk->stats.client_req >= cache_param->wthread_stats_rate) WRK_SumStat(wrk); - /* Reset the workspace to the session-watermark */ + WS_Reset(req->ws, NULL); - WS_Reset(wrk->ws, NULL); + WS_Reset(wrk->aws, NULL); sp->t_req = sp->t_idle; i = HTC_Reinit(req->htc); @@ -569,7 +569,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) AZ(wrk->busyobj->should_close); AZ(req->storage_hint); - http_Setup(wrk->busyobj->beresp, wrk->ws); + http_Setup(wrk->busyobj->beresp, wrk->busyobj->ws); need_host_hdr = !http_GetHdr(wrk->busyobj->bereq, H_Host, NULL); @@ -1230,9 +1230,8 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(req->obj); - WS_Reset(wrk->ws, NULL); wrk->busyobj = VBO_GetBusyObj(wrk); - http_Setup(wrk->busyobj->bereq, wrk->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); http_FilterReq(sp, HTTPH_R_FETCH); http_ForceGet(wrk->busyobj->bereq); if (cache_param->http_gzip_support) { @@ -1306,9 +1305,7 @@ cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req) AZ(wrk->busyobj); wrk->busyobj = VBO_GetBusyObj(wrk); - WS_Reset(wrk->ws, NULL); - wrk->busyobj = VBO_GetBusyObj(wrk); - http_Setup(wrk->busyobj->bereq, wrk->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); http_FilterReq(sp, HTTPH_R_PASS); VCL_pass_method(sp); @@ -1362,9 +1359,7 @@ cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req) wrk->acct_tmp.pipe++; wrk->busyobj = VBO_GetBusyObj(wrk); - WS_Reset(wrk->ws, NULL); - wrk->busyobj = VBO_GetBusyObj(wrk); - http_Setup(wrk->busyobj->bereq, wrk->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); http_FilterReq(sp, 0); VCL_pipe_method(sp); @@ -1674,7 +1669,7 @@ CNT_Session(struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_ORNULL(wrk->nobjhead, OBJHEAD_MAGIC); - WS_Assert(wrk->ws); + WS_Assert(wrk->aws); switch (sp->step) { #define STEP(l,u,arg) \ @@ -1688,7 +1683,7 @@ CNT_Session(struct sess *sp) default: WRONG("State engine misfire"); } - WS_Assert(wrk->ws); + WS_Assert(wrk->aws); CHECK_OBJ_ORNULL(wrk->nobjhead, OBJHEAD_MAGIC); } WSL_Flush(wrk, 0); diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c index de8265d..dd76c91 100644 --- a/bin/varnishd/cache/cache_cli.c +++ b/bin/varnishd/cache/cache_cli.c @@ -129,6 +129,7 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv) SZOF(struct worker); SZOF(struct wrk_accept); SZOF(struct storage); + SZOF(struct busyobj); SZOF(struct object); SZOF(struct objcore); SZOF(struct objhead); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index a9bc694..9747919 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -67,7 +67,7 @@ ved_include(struct sess *sp, const char *src, const char *host) /* Take a workspace snapshot */ sp_ws_wm = WS_Snapshot(sp->req->ws); - wrk_ws_wm = WS_Snapshot(w->ws); + wrk_ws_wm = WS_Snapshot(w->aws); /* XXX ? */ http_SetH(sp->req->http, HTTP_HDR_URL, src); if (host != NULL && *host != '\0') { @@ -111,7 +111,7 @@ ved_include(struct sess *sp, const char *src, const char *host) /* Reset the workspace */ WS_Reset(sp->req->ws, sp_ws_wm); - WS_Reset(w->ws, wrk_ws_wm); + WS_Reset(w->aws, wrk_ws_wm); /* XXX ? */ WRW_Reserve(sp->wrk, &sp->fd); if (sp->wrk->res_mode & RES_CHUNKED) @@ -476,7 +476,7 @@ ESI_DeliverChild(const struct sess *sp) * padding it, as necessary, to a byte boundary. */ - dbits = (void*)WS_Alloc(sp->wrk->ws, 8); + dbits = (void*)WS_Alloc(sp->req->ws, 8); AN(dbits); obj = sp->req->obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 8352717..1d705b1 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -1004,7 +1004,7 @@ VEP_Init(struct worker *wrk, vep_callback_t *cb) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(wrk->busyobj->vep); - vep = (void*)WS_Alloc(wrk->ws, sizeof *vep); + vep = (void*)WS_Alloc(wrk->busyobj->ws, sizeof *vep); AN(vep); memset(vep, 0, sizeof *vep); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index abef6b1..c4c0718 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -446,7 +446,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) /* Receive response */ - HTC_Init(htc, wrk->ws, vc->fd, vc->vsl_id, + HTC_Init(htc, wrk->busyobj->ws, vc->fd, vc->vsl_id, cache_param->http_resp_size, cache_param->http_resp_hdr_len); diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index d967291..c8cb6cc 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -521,8 +521,8 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace) struct object *o; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); - spc = WS_Reserve(sp->wrk->ws, 0); - ocp = (void*)sp->wrk->ws->f; + spc = WS_Reserve(sp->req->ws, 0); + ocp = (void*)sp->req->ws->f; Lck_Lock(&oh->mtx); assert(oh->refcnt > 0); nobj = 0; @@ -565,7 +565,7 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace) EXP_Rearm(o); (void)HSH_Deref(sp->wrk, NULL, &o); } - WS_Release(sp->wrk->ws, 0); + WS_Release(sp->req->ws, 0); } diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index b09bcb8..5a2a805 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -196,7 +196,7 @@ pan_wrk(const struct worker *wrk) { VSB_printf(pan_vsp, " worker = %p {\n", wrk); - pan_ws(wrk->ws, 4); + pan_ws(wrk->aws, 4); if (wrk->busyobj != NULL && wrk->busyobj->bereq->ws != NULL) pan_http("bereq", wrk->busyobj->bereq, 4); if (wrk->busyobj != NULL && wrk->busyobj->beresp->ws != NULL) @@ -209,6 +209,7 @@ pan_busyobj(const struct busyobj *bo) { VSB_printf(pan_vsp, " busyobj = %p {\n", bo); + pan_ws(bo->ws, 4); if (bo->is_gzip) VSB_printf(pan_vsp, " is_gzip\n"); if (bo->is_gunzip) VSB_printf(pan_vsp, " is_gunzip\n"); if (bo->do_gzip) VSB_printf(pan_vsp, " do_gzip\n"); diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index dab5b11..be4af0a 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -162,8 +162,8 @@ pool_accept(struct worker *wrk, void *arg) CAST_OBJ_NOTNULL(ps, arg, POOLSOCK_MAGIC); CHECK_OBJ_NOTNULL(ps->lsock, LISTEN_SOCK_MAGIC); - assert(sizeof *wa == WS_Reserve(wrk->ws, sizeof *wa)); - wa = (void*)wrk->ws->f; + assert(sizeof *wa == WS_Reserve(wrk->aws, sizeof *wa)); + wa = (void*)wrk->aws->f; while (1) { memset(wa, 0, sizeof *wa); wa->magic = WRK_ACCEPT_MAGIC; @@ -171,7 +171,7 @@ pool_accept(struct worker *wrk, void *arg) if (ps->lsock->sock < 0) { /* Socket Shutdown */ FREE_OBJ(ps); - WS_Release(wrk->ws, 0); + WS_Release(wrk->aws, 0); return; } if (VCA_Accept(ps->lsock, wa) < 0) { @@ -192,8 +192,8 @@ pool_accept(struct worker *wrk, void *arg) } VTAILQ_REMOVE(&pp->idle_queue, &wrk2->task, list); Lck_Unlock(&pp->mtx); - assert(sizeof *wa2 == WS_Reserve(wrk2->ws, sizeof *wa2)); - wa2 = (void*)wrk2->ws->f; + assert(sizeof *wa2 == WS_Reserve(wrk2->aws, sizeof *wa2)); + wa2 = (void*)wrk2->aws->f; memcpy(wa2, wa, sizeof *wa); wrk2->task.func = SES_pool_accept_task; wrk2->task.priv = pp->sesspool; @@ -277,7 +277,7 @@ Pool_Work_Thread(void *priv, struct worker *wrk) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - WS_Reset(wrk->ws, NULL); + WS_Reset(wrk->aws, NULL); tp = VTAILQ_FIRST(&pp->front_queue); if (tp != NULL) { diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 2e080f1..58ff960 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -139,7 +139,7 @@ ses_pool_task(struct worker *wrk, void *arg) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CAST_OBJ_NOTNULL(sp, arg, SESS_MAGIC); - AZ(wrk->ws->r); + AZ(wrk->aws->r); wrk->lastused = NAN; THR_SetSession(sp); if (wrk->sp == NULL) @@ -153,7 +153,7 @@ ses_pool_task(struct worker *wrk, void *arg) /* Cannot access sp now */ THR_SetSession(NULL); wrk->sp = NULL; - WS_Assert(wrk->ws); + WS_Assert(wrk->aws); AZ(wrk->busyobj); AZ(wrk->wrw.wfd); assert(wrk->wlp == wrk->wlb); @@ -177,7 +177,7 @@ SES_pool_accept_task(struct worker *wrk, void *arg) /* Turn accepted socket into a session */ AZ(wrk->sp); - AN(wrk->ws->r); + AN(wrk->aws->r); wrk->sp = ses_new(pp); if (wrk->sp == NULL) { VCA_FailSess(wrk); @@ -185,7 +185,7 @@ SES_pool_accept_task(struct worker *wrk, void *arg) } VCA_SetupSess(wrk); wrk->sp->step = STP_FIRST; - WS_Release(wrk->ws, 0); + WS_Release(wrk->aws, 0); ses_pool_task(wrk, wrk->sp); } diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 2623bcc..643f0a3 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -205,7 +205,7 @@ VRT_WrkString(const struct sess *sp, const char *p, ...) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); va_start(ap, p); - b = VRT_String(sp->wrk->ws, NULL, p, ap); + b = VRT_String(sp->wrk->aws, NULL, p, ap); va_end(ap); return (b); } diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index c4c0c56..ec067a2 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -297,7 +297,7 @@ VRT_l_beresp_storage(struct sess *sp, const char *str, ...) char *b; va_start(ap, str); - b = VRT_String(sp->wrk->ws, NULL, str, ap); + b = VRT_String(sp->wrk->busyobj->ws, NULL, str, ap); va_end(ap); sp->req->storage_hint = b; } diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 6087991..32ad21d 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -152,7 +152,7 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace, w->wrw.ciov = siov; AZ(pthread_cond_init(&w->cond, NULL)); - WS_Init(w->ws, "wrk", ws, sess_workspace); + WS_Init(w->aws, "wrk", ws, sess_workspace); VSL(SLT_WorkThread, 0, "%p start", w); @@ -182,7 +182,7 @@ WRK_thread(void *priv) siov = IOV_MAX; return (wrk_thread_real(priv, cache_param->shm_workspace, - cache_param->wthread_workspace, siov)); + cache_param->workspace_thread, siov)); } void diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 40fcf1d..1e51656 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -70,12 +70,14 @@ struct params { unsigned wthread_purge_delay; unsigned wthread_stats_rate; unsigned wthread_stacksize; - unsigned wthread_workspace; unsigned queue_max; /* Memory allocation hints */ unsigned workspace_client; + unsigned workspace_backend; + unsigned workspace_thread; + unsigned shm_workspace; unsigned http_req_size; unsigned http_req_hdr_len; diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 56c8336..8c7a668 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -662,7 +662,7 @@ tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg) "\nNB: Do not change this parameter, unless a developer tell " \ "you to do so." -#define MEMPOOL_TEXT \ +#define MEMPOOL_TEXT \ "The three numbers are:\n" \ " min_pool -- minimum size of free pool.\n" \ " max_pool -- maximum size of free pool.\n" \ @@ -698,6 +698,18 @@ static const struct parspec input_parspec[] = { "Bytes of HTTP protocol workspace for clients HTTP req/resp.", DELAYED_EFFECT, "64k", "bytes" }, + { "workspace_backend", + tweak_bytes_u, &mgt_param.workspace_backend, 1024, UINT_MAX, + "Bytes of HTTP protocol workspace for backend HTTP req/resp.", + DELAYED_EFFECT, + "64k", "bytes" }, + { "workspace_thread", + tweak_bytes_u, &mgt_param.workspace_thread, 256, 256, + "Bytes of auxillary workspace per thread." + /* XXX: See comment in cache.h */ + "This is not the workspace you are looking for.", + DELAYED_EFFECT, + "256", "bytes" }, { "http_req_hdr_len", tweak_bytes_u, &mgt_param.http_req_hdr_len, 40, UINT_MAX, @@ -1194,7 +1206,7 @@ static const struct parspec input_parspec[] = { "Disable this if you have very high hitrates and want" "to save the memory of one busyobj per worker thread.", 0, - "true", ""}, + "false", ""}, { "pool_vbc", tweak_poolparam, &mgt_param.vbc_pool, 0, 10000, "Parameters for backend connection memory pool.\n" diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index d34eef2..b716937 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -224,16 +224,5 @@ const struct parspec WRK_parspec[] = { "many threads into the limited address space.\n", EXPERIMENTAL, "-1", "bytes" }, - { "thread_pool_workspace", tweak_uint, &mgt_param.wthread_workspace, - 1024, UINT_MAX, - "Bytes of HTTP protocol workspace allocated for worker " - "threads. " - "This space must be big enough for the backend request " - "and responses, and response to the client plus any other " - "memory needs in the VCL code." - "Minimum is 1024 bytes.", - DELAYED_EFFECT, - "65536", - "bytes" }, { NULL, NULL, NULL } }; diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc index a4173b4..ff94c72 100644 --- a/bin/varnishtest/tests/r01038.vtc +++ b/bin/varnishtest/tests/r01038.vtc @@ -45,7 +45,7 @@ server s1 { txresp -body "foo8" } -start -varnish v1 -arg "-p thread_pool_workspace=1024" -vcl+backend { +varnish v1 -arg "-p workspace_backend=1024" -vcl+backend { sub vcl_fetch { set beresp.do_esi = true; } From geoff at varnish-cache.org Tue Feb 14 16:49:28 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:28 +0100 Subject: [experimental-ims] c2a2576 Make sure to free workers cached busyobj when threads are reaped. Message-ID: commit c2a2576ca15d3bdbdf0b151383833332f0be1f22 Author: Poul-Henning Kamp Date: Thu Feb 9 07:58:04 2012 +0000 Make sure to free workers cached busyobj when threads are reaped. diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 32ad21d..c1d20e8 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -163,6 +163,8 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace, if (w->vcl != NULL) VCL_Rel(&w->vcl); AZ(pthread_cond_destroy(&w->cond)); + if (w->nvbo != NULL) + VBO_Free(&w->nvbo); HSH_Cleanup(w); WRK_SumStat(w); return (NULL); From geoff at varnish-cache.org Tue Feb 14 16:49:34 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:34 +0100 Subject: [experimental-ims] a5d9851 Introduce a function to initialize a VSL buffer Message-ID: commit a5d9851ae5120aaa434838dcd576d2af54b74a89 Author: Poul-Henning Kamp Date: Mon Feb 13 21:40:29 2012 +0000 Introduce a function to initialize a VSL buffer diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 0ff57c9..dd3b004 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -911,6 +911,7 @@ extern struct VSC_C_main *VSC_C_main; void VSM_Init(void); void *VSM_Alloc(unsigned size, const char *class, const char *type, const char *ident); +void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len); void VSM_Free(void *ptr); #ifdef VSL_ENDMARKER void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 461aa97..ab715b7 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -304,6 +304,18 @@ WSLB(struct worker *wrk, enum VSL_tag_e tag, const char *fmt, ...) /*--------------------------------------------------------------------*/ +void +VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len) +{ + vsl->wlp = ptr; + vsl->wlb = ptr; + vsl->wle = ptr; + vsl->wle += len / sizeof(*vsl->wle); + vsl->wlr = 0; +} + +/*--------------------------------------------------------------------*/ + static void * vsm_cleaner(void *priv) { diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 591e633..d421740 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -104,8 +104,7 @@ wrk_bgthread(void *arg) memset(&wrk, 0, sizeof wrk); sp->wrk = &wrk; wrk.magic = WORKER_MAGIC; - wrk.vsl->wlp = wrk.vsl->wlb = logbuf; - wrk.vsl->wle = logbuf + (sizeof logbuf) / 4; + VSL_Setup(wrk.vsl, logbuf, sizeof logbuf); (void)bt->func(sp, bt->priv); From geoff at varnish-cache.org Tue Feb 14 16:49:23 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:23 +0100 Subject: [experimental-ims] 5454314 Remove now unused ws variable. Message-ID: commit 54543147bf099e71c9a3094c838911d6d3228c8d Author: Poul-Henning Kamp Date: Wed Feb 8 23:26:19 2012 +0000 Remove now unused ws variable. diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 6064f67..9d81f62 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -73,11 +73,8 @@ static struct vgz * vgz_alloc_vgz(struct worker *wrk, const char *id) { struct vgz *vg; - struct ws *ws; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - ws = wrk->ws; - WS_Assert(ws); ALLOC_OBJ(vg, VGZ_MAGIC); AN(vg); vg->wrk = wrk; From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] ad277d2 Add a facility to give each session a unique number with a minimum of locking: Each pool fetches blocks of numbers to assign, then hands them out one by one using the existing lock. Message-ID: commit ad277d29774e800c9a2e7059b759e50225d0e448 Author: Poul-Henning Kamp Date: Tue Feb 14 07:36:49 2012 +0000 Add a facility to give each session a unique number with a minimum of locking: Each pool fetches blocks of numbers to assign, then hands them out one by one using the existing lock. Session numbers are 32bit and start at zero on worker process startup. Together with another 32bit number, local to the session, they will be used to link VSL records into transactions. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index dd3b004..ad23c24 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -252,6 +252,13 @@ struct vsl_log { /*--------------------------------------------------------------------*/ +struct vxid { + uint32_t next; + uint32_t count; +}; + +/*--------------------------------------------------------------------*/ + struct wrk_accept { unsigned magic; #define WRK_ACCEPT_MAGIC 0x8c4b4d59 @@ -261,6 +268,7 @@ struct wrk_accept { socklen_t acceptaddrlen; int acceptsock; struct listen_sock *acceptlsock; + uint32_t vxid; }; /* Worker pool stuff -------------------------------------------------*/ @@ -626,6 +634,8 @@ struct sess { enum step step; int fd; unsigned vsl_id; + uint32_t vxid; + uint32_t vseq; /* Cross references ------------------------------------------*/ @@ -834,6 +844,7 @@ int HTC_Complete(struct http_conn *htc); #undef HTTPH /* cache_main.c */ +uint32_t VXID_Get(struct vxid *v); extern volatile struct params * cache_param; void THR_SetName(const char *name); const char* THR_GetName(void); diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 9384d1c..4d7b771 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -249,6 +249,8 @@ VCA_SetupSess(struct worker *wrk) CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC); sp = wrk->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + sp->vxid = wa->vxid; + sp->vseq = 0; sp->fd = wa->acceptsock; sp->vsl_id = wa->acceptsock | VSL_CLIENTMARKER ; wa->acceptsock = -1; diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 48e934d..f038c9e 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -85,6 +85,33 @@ THR_GetName(void) } /*-------------------------------------------------------------------- + */ + +static uint32_t vxid_base; +static struct lock vxid_lock; + +static void +vxid_More(struct vxid *v) +{ + + Lck_Lock(&vxid_lock); + v->next = vxid_base; + v->count = 32768; + vxid_base = v->count; + Lck_Unlock(&vxid_lock); +} + +uint32_t +VXID_Get(struct vxid *v) +{ + if (v->count == 0) + vxid_More(v); + AN(v->count); + v->count--; + return (v->next++); +} + +/*-------------------------------------------------------------------- * XXX: Think more about which order we start things */ @@ -107,6 +134,8 @@ child_main(void) LCK_Init(); /* Second, locking */ + Lck_New(&vxid_lock, lck_vxid); + WAIT_Init(); PAN_Init(); CLI_Init(); diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index be4af0a..c6253b2 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -100,6 +100,8 @@ struct pool { struct lock herder_mtx; pthread_t herder_thr; + struct vxid vxid; + struct lock mtx; struct taskhead idle_queue; struct taskhead front_queue; @@ -182,6 +184,7 @@ pool_accept(struct worker *wrk, void *arg) } Lck_Lock(&pp->mtx); + wa->vxid = VXID_Get(&pp->vxid); wrk2 = pool_getidleworker(pp, 0); if (wrk2 == NULL) { /* No idle threads, do it ourselves */ From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] 88fd1b2 Adjust testcases for changes struct http size Message-ID: commit 88fd1b2d4ca1ba8d70235339b5a9ca2d873ceb0b Author: Poul-Henning Kamp Date: Tue Feb 14 09:55:00 2012 +0000 Adjust testcases for changes struct http size diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc index 943592f..f72d2e1 100644 --- a/bin/varnishtest/tests/c00044.vtc +++ b/bin/varnishtest/tests/c00044.vtc @@ -2,17 +2,17 @@ varnishtest "Object/LRU/Stevedores" server s1 { rxreq - txresp -bodylen 1048100 + txresp -bodylen 1048092 rxreq - txresp -bodylen 1048101 + txresp -bodylen 1048093 rxreq - txresp -bodylen 1048102 + txresp -bodylen 1048094 rxreq - txresp -bodylen 1048103 + txresp -bodylen 1048095 rxreq - txresp -bodylen 1048104 + txresp -bodylen 1048096 } -start varnish v1 -storage "-smalloc,1m -smalloc,1m, -smalloc,1m" -vcl+backend { @@ -26,7 +26,7 @@ client c1 { txreq -url /foo rxresp expect resp.status == 200 - expect resp.bodylen == 1048100 + expect resp.bodylen == 1048092 } -run varnish v1 -expect SMA.Transient.g_bytes == 0 @@ -41,7 +41,7 @@ client c1 { txreq -url /bar rxresp expect resp.status == 200 - expect resp.bodylen == 1048101 + expect resp.bodylen == 1048093 } -run varnish v1 -expect SMA.Transient.g_bytes == 0 @@ -56,7 +56,7 @@ client c1 { txreq -url /burp rxresp expect resp.status == 200 - expect resp.bodylen == 1048102 + expect resp.bodylen == 1048094 } -run varnish v1 -expect SMA.Transient.g_bytes == 0 @@ -71,7 +71,7 @@ client c1 { txreq -url /foo1 rxresp expect resp.status == 200 - expect resp.bodylen == 1048103 + expect resp.bodylen == 1048095 } -run varnish v1 -expect n_lru_nuked == 1 @@ -80,7 +80,7 @@ client c1 { txreq -url /foo rxresp expect resp.status == 200 - expect resp.bodylen == 1048104 + expect resp.bodylen == 1048096 } -run varnish v1 -expect n_lru_nuked == 2 diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc index 419381c..683c443 100644 --- a/bin/varnishtest/tests/c00045.vtc +++ b/bin/varnishtest/tests/c00045.vtc @@ -2,11 +2,11 @@ varnishtest "Object/LRU/Stevedores with hinting" server s1 { rxreq - txresp -bodylen 1048100 + txresp -bodylen 1048092 rxreq - txresp -bodylen 1048101 + txresp -bodylen 1048093 rxreq - txresp -bodylen 1048102 + txresp -bodylen 1048094 } -start varnish v1 -storage "-smalloc,1m -smalloc,1m, -smalloc,1m" -vcl+backend { @@ -20,7 +20,7 @@ client c1 { txreq -url /foo rxresp expect resp.status == 200 - expect resp.bodylen == 1048100 + expect resp.bodylen == 1048092 } -run varnish v1 -expect SMA.Transient.g_bytes == 0 @@ -35,7 +35,7 @@ client c1 { txreq -url /bar rxresp expect resp.status == 200 - expect resp.bodylen == 1048101 + expect resp.bodylen == 1048093 } -run varnish v1 -expect n_lru_nuked == 1 @@ -51,7 +51,7 @@ client c1 { txreq -url /foo rxresp expect resp.status == 200 - expect resp.bodylen == 1048102 + expect resp.bodylen == 1048094 } -run varnish v1 -expect n_lru_nuked == 2 From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] f093a08 Tag vbc's with the vsl buffer they should log into. Update the buffers wid with the vbc's vsl_id. Flush the buffer when we recycle/close the vbc. Message-ID: commit f093a082a7beb579a9e09c2c7e5cae577c235652 Author: Poul-Henning Kamp Date: Tue Feb 14 08:52:06 2012 +0000 Tag vbc's with the vsl buffer they should log into. Update the buffers wid with the vbc's vsl_id. Flush the buffer when we recycle/close the vbc. diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index ad71169..a836fac 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -152,6 +152,7 @@ struct vbc { VTAILQ_ENTRY(vbc) list; struct backend *backend; struct vdi_simple *vdis; + struct vsl_log *vsl; unsigned vsl_id; int fd; diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index 53a3e50..bbb13bb 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -55,11 +55,13 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp) bp = vc->backend; - WSL(wrk->vsl, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name); + WSL(vc->vsl, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name); /* Checkpoint log to flush all info related to this connection before the OS reuses the FD */ WSL_Flush(wrk->vsl, 0); + WSL_Flush(vc->vsl, 0); + vc->vsl = NULL; VTCP_close(&vc->fd); VBE_DropRefConn(bp); @@ -85,12 +87,16 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp) bp = vc->backend; - WSL(wrk->vsl, SLT_BackendReuse, vc->vsl_id, "%s", bp->display_name); + WSL(vc->vsl, SLT_BackendReuse, vc->vsl_id, "%s", bp->display_name); + /* * Flush the shmlog, so that another session reusing this backend * will log chronologically later than our use of it. */ WSL_Flush(wrk->vsl, 0); + WSL_Flush(vc->vsl, 0); + vc->vsl = NULL; + Lck_Lock(&bp->mtx); VSC_C_main->backend_recycle++; VTAILQ_INSERT_HEAD(&bp->connlist, vc, list); @@ -102,12 +108,18 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp) struct vbc * VDI_GetFd(const struct director *d, struct sess *sp) { + struct vbc *vc; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); if (d == NULL) d = sp->req->director; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - return (d->getfd(d, sp)); + vc = d->getfd(d, sp); + if (vc != NULL) { + vc->vsl = sp->wrk->busyobj->vsl; + vc->vsl->wid = vc->vsl_id; + } + return (vc); } /* Check health ------------------------------------------------------ diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 73e4f08..018c4f9 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -416,8 +416,6 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) if (vc->recycled) retry = 1; - sp->wrk->busyobj->vsl->wid = vc->vsl_id; - /* * Now that we know our backend, we can set a default Host: * header if one is necessary. This cannot be done in the VCL From geoff at varnish-cache.org Tue Feb 14 16:49:34 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:34 +0100 Subject: [experimental-ims] ab47f76 Move VCL-controlled backend timeouts from struct worker to busyobj Message-ID: commit ab47f76a79c82f615fb3f964db61f1ecbfdf87e5 Author: Martin Blix Grydeland Date: Mon Feb 13 13:49:11 2012 +0100 Move VCL-controlled backend timeouts from struct worker to busyobj diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e76b0de..1371d48 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -320,11 +320,6 @@ struct worker { struct busyobj *busyobj; - /* Timeouts */ - double connect_timeout; - double first_byte_timeout; - double between_bytes_timeout; - /* Temporary accounting */ struct acct acct_tmp; }; @@ -494,6 +489,11 @@ struct busyobj { unsigned do_gunzip; unsigned do_stream; unsigned do_pass; + + /* Timeouts */ + double connect_timeout; + double first_byte_timeout; + double between_bytes_timeout; }; /* Object structure --------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index b683300..039300b 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -89,13 +89,14 @@ VBE_ReleaseConn(struct vbc *vc) MPL_Free(vbcpool, vc); } -#define FIND_TMO(tmx, dst, sp, be) \ - do { \ - dst = sp->wrk->tmx; \ - if (dst == 0.0) \ - dst = be->tmx; \ - if (dst == 0.0) \ - dst = cache_param->tmx; \ +#define FIND_TMO(tmx, dst, sp, be) \ + do { \ + CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); \ + dst = sp->wrk->busyobj->tmx; \ + if (dst == 0.0) \ + dst = be->tmx; \ + if (dst == 0.0) \ + dst = cache_param->tmx; \ } while (0) /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index fca55b0..137f198 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -1418,10 +1418,6 @@ cnt_recv(struct sess *sp, struct worker *wrk, struct req *req) req->director = req->vcl->director[0]; AN(req->director); - wrk->connect_timeout = 0; - wrk->first_byte_timeout = 0; - wrk->between_bytes_timeout = 0; - req->disable_esi = 0; req->hash_always_miss = 0; req->hash_ignore_busy = 0; diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index ec067a2..cc7fb5b 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -236,7 +236,8 @@ VRT_l_bereq_##which(struct sess *sp, double num) \ { \ \ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ - sp->wrk->which = (num > 0.0 ? num : 0.0); \ + CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); \ + sp->wrk->busyobj->which = (num > 0.0 ? num : 0.0); \ } \ \ double __match_proto__() \ @@ -244,7 +245,8 @@ VRT_r_bereq_##which(struct sess *sp) \ { \ \ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ - return(sp->wrk->which); \ + CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); \ + return(sp->wrk->busyobj->which); \ } BEREQ_TIMEOUT(connect_timeout) From geoff at varnish-cache.org Tue Feb 14 16:49:28 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:28 +0100 Subject: [experimental-ims] fc387c3 Eliminate the mempool poll function again, we don't need it anyway. Message-ID: commit fc387c38ed38ddf3748f26b558a3c2e3589921b4 Author: Poul-Henning Kamp Date: Thu Feb 9 07:51:52 2012 +0000 Eliminate the mempool poll function again, we don't need it anyway. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 8df9591..e376b66 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -889,15 +889,13 @@ int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, struct timespec *ts); #undef LOCK /* cache_mempool.c */ -typedef void mpl_poll_f(volatile unsigned *); void MPL_AssertSane(void *item); struct mempool * MPL_New(const char *name, volatile struct poolparam *pp, - volatile unsigned *cur_size, mpl_poll_f *poll_f); + volatile unsigned *cur_size); void MPL_Destroy(struct mempool **mpp); void *MPL_Get(struct mempool *mpl, unsigned *size); void MPL_Free(struct mempool *mpl, void *item); - /* cache_panic.c */ void PAN_Init(void); diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 2610b06..b683300 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -519,6 +519,6 @@ void VDI_Init(void) { - vbcpool = MPL_New("vbc", &cache_param->vbc_pool, &vbcps, NULL); + vbcpool = MPL_New("vbc", &cache_param->vbc_pool, &vbcps); AN(vbcpool); } diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index d6074a7..3a60bfd 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -57,7 +57,7 @@ VBO_Init(void) { vbopool = MPL_New("vbo", &cache_param->vbo_pool, - &cache_param->workspace_backend, NULL); + &cache_param->workspace_backend); AN(vbopool); } diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index 4b8ed07..8906406 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -57,7 +57,6 @@ struct mempool { struct lock mtx; volatile struct poolparam *param; volatile unsigned *cur_size; - mpl_poll_f *poll_func; uint64_t live; struct VSC_C_mempool *vsc; unsigned n_pool; @@ -105,8 +104,6 @@ mpl_guard(void *priv) mpl_slp = 0.15; // random while (1) { VTIM_sleep(mpl_slp); - if (mpl->poll_func != NULL) - mpl->poll_func(mpl->cur_size); mpl_slp = 0.814; // random mpl->t_now = VTIM_real(); @@ -226,8 +223,7 @@ mpl_guard(void *priv) struct mempool * MPL_New(const char *name, - volatile struct poolparam *pp, - volatile unsigned *cur_size, mpl_poll_f *poll_f) + volatile struct poolparam *pp, volatile unsigned *cur_size) { struct mempool *mpl; @@ -236,9 +232,6 @@ MPL_New(const char *name, bprintf(mpl->name, "%s", name); mpl->param = pp; mpl->cur_size = cur_size; - mpl->poll_func = poll_f; - if (poll_f != NULL) - poll_f(mpl->cur_size); VTAILQ_INIT(&mpl->list); VTAILQ_INIT(&mpl->surplus); Lck_New(&mpl->mtx, lck_mempool); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 58ff960..07b5cfb 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -383,9 +383,9 @@ SES_NewPool(struct pool *wp, unsigned pool_no) pp->pool = wp; bprintf(nb, "req%u", pool_no); pp->mpl_req = MPL_New(nb, &cache_param->req_pool, - &cache_param->workspace_client, NULL); + &cache_param->workspace_client); bprintf(nb, "sess%u", pool_no); - pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &ses_size, NULL); + pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &ses_size); return (pp); } From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] 628fdea Tag struct http with which vsl buffer to use. Message-ID: commit 628fdeacf3efc8450d8722a6205339d8acd9aa8c Author: Poul-Henning Kamp Date: Tue Feb 14 09:35:10 2012 +0000 Tag struct http with which vsl buffer to use. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 94c0284..98771a3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -167,6 +167,7 @@ struct http { #define HTTP_MAGIC 0x6428b5c9 enum httpwhence logtag; + struct vsl_log *vsl; struct ws *ws; txt *hd; @@ -817,7 +818,7 @@ void http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, const char *hdr); void http_SetH(const struct http *to, unsigned n, const char *fm); void http_ForceGet(const struct http *to); -void http_Setup(struct http *ht, struct ws *ws); +void http_Setup(struct http *ht, struct ws *ws, struct vsl_log *); void http_Teardown(struct http *ht); int http_GetHdr(const struct http *hp, const char *hdr, char **ptr); int http_GetHdrData(const struct http *hp, const char *hdr, diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 5e85542..f7cbc38 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -274,7 +274,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) req->obj->last_lru = req->t_resp; req->obj->last_use = req->t_resp; /* XXX: locking ? */ } - http_Setup(req->resp, req->ws); + http_Setup(req->resp, req->ws, req->vsl); RES_BuildHttp(sp); VCL_deliver_method(sp); switch (req->handling) { @@ -569,7 +569,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) AZ(wrk->busyobj->should_close); AZ(req->storage_hint); - http_Setup(wrk->busyobj->beresp, wrk->busyobj->ws); + http_Setup(wrk->busyobj->beresp, wrk->busyobj->ws, wrk->busyobj->vsl); need_host_hdr = !http_GetHdr(wrk->busyobj->bereq, H_Host, NULL); @@ -1223,7 +1223,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(req->obj); - http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl); http_FilterReq(sp, HTTPH_R_FETCH); http_ForceGet(wrk->busyobj->bereq); if (cache_param->http_gzip_support) { @@ -1298,7 +1298,7 @@ cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req) wrk->busyobj = VBO_GetBusyObj(wrk); wrk->busyobj->vsl->wid = sp->vsl_id; - http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl); http_FilterReq(sp, HTTPH_R_PASS); VCL_pass_method(sp); @@ -1353,7 +1353,7 @@ cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req) wrk->acct_tmp.pipe++; wrk->busyobj = VBO_GetBusyObj(wrk); wrk->busyobj->vsl->wid = sp->vsl_id; - http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); + http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl); http_FilterReq(sp, 0); VCL_pipe_method(sp); @@ -1529,7 +1529,7 @@ cnt_start(struct sess *sp, struct worker *wrk, struct req *req) EXP_Clr(&req->exp); - http_Setup(req->http, req->ws); + http_Setup(req->http, req->ws, req->vsl); req->err_code = http_DissectRequest(sp); /* If we could not even parse the request, just close */ diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index d947de1..c8db4c7 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -130,10 +130,11 @@ HTTP_create(void *p, uint16_t nhttp) /*--------------------------------------------------------------------*/ void -http_Setup(struct http *hp, struct ws *ws) +http_Setup(struct http *hp, struct ws *ws, struct vsl_log *vsl) { http_Teardown(hp); hp->ws = ws; + hp->vsl = vsl; } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 22971a3..5c44c98 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -250,7 +250,7 @@ STV_MkObject(struct worker *wrk, void *ptr, unsigned ltot, WS_Assert(o->ws_o); assert(o->ws_o->e <= (char*)ptr + ltot); - http_Setup(o->http, o->ws_o); + http_Setup(o->http, o->ws_o, wrk->busyobj->vsl); o->http->magic = HTTP_MAGIC; o->exp = wrk->busyobj->exp; VTAILQ_INIT(&o->store); From geoff at varnish-cache.org Tue Feb 14 16:49:29 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:29 +0100 Subject: [experimental-ims] b42a6d1 More 32 bit adjustments, now rename gzip_stack_buffer to gzip_buffer Message-ID: commit b42a6d17865d929f3b657d6e0e0516f59583a012 Author: Tollef Fog Heen Date: Mon Feb 13 10:50:54 2012 +0100 More 32 bit adjustments, now rename gzip_stack_buffer to gzip_buffer diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index e7f1a1c..a74fd17 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -421,7 +421,7 @@ main(int argc, char * const *argv) MCF_ParamSet(cli, "thread_pool_stack", "32bit"); cli_check(cli); - MCF_ParamSet(cli, "gzip_stack_buffer", "4096"); + MCF_ParamSet(cli, "gzip_buffer", "4096"); cli_check(cli); } From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] fe9d181 Align the iovec pointer Message-ID: commit fe9d181a5276843a77ed41b91919a0f5ef0ead77 Author: Poul-Henning Kamp Date: Tue Feb 14 13:50:17 2012 +0000 Align the iovec pointer diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index 5c4b280..00b3a9e 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -80,9 +80,10 @@ WRW_Reserve(struct worker *wrk, int *fd) memset(wrw, 0, sizeof *wrw); wrw->magic = WRW_MAGIC; u = WS_Reserve(wrk->aws, 0); + u = PRNDDN(u); u /= sizeof(struct iovec); AN(u); - wrw->iov = (void*)wrk->aws->f; + wrw->iov = (void*)PRNDUP(wrk->aws->f); wrw->siov = u; wrw->ciov = u; wrw->werr = 0; From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] c305b19 Forgot to add the lock type. Message-ID: commit c305b19cea8b7084db8129efe7ac7a06021a5e58 Author: Poul-Henning Kamp Date: Tue Feb 14 07:40:50 2012 +0000 Forgot to add the lock type. diff --git a/include/tbl/locks.h b/include/tbl/locks.h index 697752d..68077ce 100644 --- a/include/tbl/locks.h +++ b/include/tbl/locks.h @@ -51,4 +51,5 @@ LOCK(vcapace) LOCK(nbusyobj) LOCK(busyobj) LOCK(mempool) +LOCK(vxid) /*lint -restore */ From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] ac85937 More argument strength reduction to reduce the spread of struct wrk Message-ID: commit ac859374aac0c9b93c2b2975e280ea83d8f5105a Author: Poul-Henning Kamp Date: Tue Feb 14 11:48:16 2012 +0000 More argument strength reduction to reduce the spread of struct wrk diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 50d9541..42788c3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -357,8 +357,8 @@ struct storage { * housekeeping fields parts of an object. */ -typedef struct object *getobj_f(struct worker *wrk, struct objcore *oc); -typedef unsigned getxid_f(struct worker *wrk, struct objcore *oc); +typedef struct object *getobj_f(struct dstat *ds, struct objcore *oc); +typedef unsigned getxid_f(struct dstat *ds, struct objcore *oc); typedef void updatemeta_f(struct objcore *oc); typedef void freeobj_f(struct objcore *oc); typedef struct lru *getlru_f(const struct objcore *oc); @@ -395,24 +395,24 @@ struct objcore { }; static inline unsigned -oc_getxid(struct worker *wrk, struct objcore *oc) +oc_getxid(struct dstat *ds, struct objcore *oc) { CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(oc->methods); AN(oc->methods->getxid); - return (oc->methods->getxid(wrk, oc)); + return (oc->methods->getxid(ds, oc)); } static inline struct object * -oc_getobj(struct worker *wrk, struct objcore *oc) +oc_getobj(struct dstat *ds, struct objcore *oc) { CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AZ(oc->flags & OC_F_BUSY); AN(oc->methods); AN(oc->methods->getobj); - return (oc->methods->getobj(wrk, oc)); + return (oc->methods->getobj(ds, oc)); } static inline void @@ -1014,7 +1014,6 @@ void WS_Assert(const struct ws *ws); void WS_Reset(struct ws *ws, char *p); char *WS_Alloc(struct ws *ws, unsigned bytes); char *WS_Snapshot(struct ws *ws); -unsigned WS_Free(const struct ws *ws); /* rfc2616.c */ void RFC2616_Ttl(const struct sess *sp); @@ -1092,11 +1091,11 @@ Tadd(txt *t, const char *p, int l) } static inline void -AssertObjBusy(const struct object *o) +AssertOCBusy(const struct objcore *oc) { - AN(o->objcore); - AN (o->objcore->flags & OC_F_BUSY); - AN(o->objcore->busyobj); + AN(oc); + AN (oc->flags & OC_F_BUSY); + AN(oc->busyobj); } static inline void diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index b02e5f9..24a150e 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -891,7 +891,7 @@ ban_lurker_work(const struct sess *sp, unsigned pass) /* * Get the object and check it against all relevant bans */ - o = oc_getobj(sp->wrk, oc); + o = oc_getobj(&sp->wrk->stats, oc); i = ban_check_object(o, sp, 0); if (cache_param->diag_bitmap & 0x80000) VSL(SLT_Debug, 0, "lurker got: %p %d", diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 61d1a94..0be9304 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -915,7 +915,8 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req) EXP_Insert(req->obj); AN(req->obj->objcore); AN(req->obj->objcore->ban); - HSH_Unbusy(wrk); + AZ(req->obj->ws_o->overflow); + HSH_Unbusy(req->obj->objcore); } VBO_DerefBusyObj(wrk, &wrk->busyobj); wrk->acct_tmp.fetch++; @@ -961,7 +962,8 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) EXP_Insert(req->obj); AN(req->obj->objcore); AN(req->obj->objcore->ban); - HSH_Unbusy(wrk); + AZ(req->obj->ws_o->overflow); + HSH_Unbusy(req->obj->objcore); } else { req->doclose = "Stream error"; } @@ -1171,7 +1173,7 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req) return (0); } - o = oc_getobj(wrk, oc); + o = oc_getobj(&wrk->stats, oc); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); req->obj = o; diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 840e0b7..0d8ffe1 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -224,7 +224,7 @@ EXP_Insert(struct object *o) CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); oc = o->objcore; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - AssertObjBusy(o); + AssertOCBusy(oc); HSH_Ref(oc); assert(o->exp.entered != 0 && !isnan(o->exp.entered)); @@ -399,9 +399,9 @@ exp_timer(struct sess *sp, void *priv) VSC_C_main->n_expired++; CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC); - o = oc_getobj(sp->wrk, oc); + o = oc_getobj(&sp->wrk->stats, oc); WSL(sp->wrk->vsl, SLT_ExpKill, 0, "%u %.0f", - oc_getxid(sp->wrk, oc), EXP_Ttl(NULL, o) - t); + oc_getxid(&sp->wrk->stats, oc), EXP_Ttl(NULL, o) - t); (void)HSH_Deref(&sp->wrk->stats, oc, NULL); } NEEDLESS_RETURN(NULL); @@ -445,7 +445,7 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru) return (-1); /* XXX: bad idea for -spersistent */ - WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc)); + WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(&wrk->stats, oc)); (void)HSH_Deref(&wrk->stats, oc, NULL); return (1); } diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index eebb999..7188ff4 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -353,7 +353,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh) continue; } - o = oc_getobj(sp->wrk, oc); + o = oc_getobj(&sp->wrk->stats, oc); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); if (o->exp.ttl <= 0.) @@ -397,14 +397,14 @@ HSH_Lookup(struct sess *sp, struct objhead **poh) && (busy_oc != NULL /* Somebody else is already busy */ || !VDI_Healthy(sp->req->director, sp))) { /* Or it is impossible to fetch */ - o = oc_getobj(sp->wrk, grace_oc); + o = oc_getobj(&sp->wrk->stats, grace_oc); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); oc = grace_oc; } sp->req->objcore = NULL; if (oc != NULL && !sp->req->hash_always_miss) { - o = oc_getobj(sp->wrk, oc); + o = oc_getobj(&sp->wrk->stats, oc); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); assert(oc->objhead == oh); @@ -540,7 +540,7 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace) continue; } - (void)oc_getobj(sp->wrk, oc); /* XXX: still needed ? */ + (void)oc_getobj(&sp->wrk->stats, oc); /* XXX: still needed ? */ xxxassert(spc >= sizeof *ocp); oc->refcnt++; @@ -557,7 +557,7 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace) for (n = 0; n < nobj; n++) { oc = ocp[n]; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - o = oc_getobj(sp->wrk, oc); + o = oc_getobj(&sp->wrk->stats, oc); if (o == NULL) continue; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); @@ -587,34 +587,23 @@ HSH_Drop(struct worker *wrk) AssertObjCorePassOrBusy(o->objcore); o->exp.ttl = -1.; if (o->objcore != NULL) /* Pass has no objcore */ - HSH_Unbusy(wrk); + HSH_Unbusy(o->objcore); (void)HSH_Deref(&wrk->stats, NULL, &wrk->sp->req->obj); } void -HSH_Unbusy(struct worker *wrk) +HSH_Unbusy(struct objcore *oc) { - struct object *o; struct objhead *oh; - struct objcore *oc; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - o = wrk->sp->req->obj; - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - oc = o->objcore; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); oh = oc->objhead; CHECK_OBJ(oh, OBJHEAD_MAGIC); - AssertObjBusy(o); + AssertOCBusy(oc); AN(oc->ban); assert(oc->refcnt > 0); assert(oh->refcnt > 0); - if (o->ws_o->overflow) - wrk->stats.n_objoverflow++; - if (cache_param->diag_bitmap & 0x40) - WSL(wrk->vsl, SLT_Debug, 0, - "Object %u workspace free %u", o->xid, WS_Free(o->ws_o)); /* XXX: pretouch neighbors on oh->objcs to prevent page-on under mtx */ Lck_Lock(&oh->mtx); @@ -628,7 +617,6 @@ HSH_Unbusy(struct worker *wrk) hsh_rush(oh); AN(oc->ban); Lck_Unlock(&oh->mtx); - assert(oc_getobj(wrk, oc) == o); } void diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index be38496..d84e937 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -116,14 +116,6 @@ WS_Alloc(struct ws *ws, unsigned bytes) return (r); } -unsigned -WS_Free(const struct ws *ws) -{ - - WS_Assert(ws); - return(ws->e - ws->f); -} - char * WS_Snapshot(struct ws *ws) { diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 1bc08b1..ac8ce7e 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -54,7 +54,7 @@ struct hash_slinger { void HSH_Prealloc(const struct sess *sp); void HSH_Cleanup(struct worker *w); struct objcore *HSH_Lookup(struct sess *sp, struct objhead **poh); -void HSH_Unbusy(struct worker *wrk); +void HSH_Unbusy(struct objcore *); void HSH_Ref(struct objcore *o); void HSH_Drop(struct worker *wrk); void HSH_Init(const struct hash_slinger *slinger); diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 5c44c98..ae71f6e 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -49,20 +49,20 @@ static const struct stevedore * volatile stv_next; */ static unsigned __match_proto__(getxid_f) -default_oc_getxid(struct worker *wrk, struct objcore *oc) +default_oc_getxid(struct dstat *ds, struct objcore *oc) { struct object *o; - o = oc_getobj(wrk, oc); + o = oc_getobj(ds, oc); return (o->xid); } static struct object * __match_proto__(getobj_f) -default_oc_getobj(struct worker *wrk, struct objcore *oc) +default_oc_getobj(struct dstat *ds, struct objcore *oc) { struct object *o; - (void)wrk; + (void)ds; if (oc->priv == NULL) return (NULL); CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC); diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 7cafe4f..a6a02e6 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -370,13 +370,13 @@ smp_loaded_st(const struct smp_sc *sc, const struct smp_seg *sg, */ static unsigned __match_proto__(getxid_f) -smp_oc_getxid(struct worker *wrk, struct objcore *oc) +smp_oc_getxid(struct dstat *ds, struct objcore *oc) { struct object *o; struct smp_seg *sg; struct smp_object *so; - (void)wrk; + (void)ds; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC); @@ -399,7 +399,7 @@ smp_oc_getxid(struct worker *wrk, struct objcore *oc) */ static struct object * -smp_oc_getobj(struct worker *wrk, struct objcore *oc) +smp_oc_getobj(struct dstat *ds, struct objcore *oc) { struct object *o; struct smp_seg *sg; @@ -412,7 +412,7 @@ smp_oc_getobj(struct worker *wrk, struct objcore *oc) assert(oc->methods->getobj == smp_oc_getobj); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - if (wrk == NULL) + if (ds == NULL) AZ(oc->flags & OC_F_NEEDFIXUP); CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC); @@ -435,7 +435,7 @@ smp_oc_getobj(struct worker *wrk, struct objcore *oc) if (!(oc->flags & OC_F_NEEDFIXUP)) return (o); - AN(wrk); + AN(ds); Lck_Lock(&sg->sc->mtx); /* Check again, we might have raced. */ if (oc->flags & OC_F_NEEDFIXUP) { @@ -459,8 +459,8 @@ smp_oc_getobj(struct worker *wrk, struct objcore *oc) } sg->nfixed++; - wrk->stats.n_object++; - wrk->stats.n_vampireobject--; + ds->n_object++; + ds->n_vampireobject--; oc->flags &= ~OC_F_NEEDFIXUP; } Lck_Unlock(&sg->sc->mtx); From geoff at varnish-cache.org Tue Feb 14 16:49:28 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:28 +0100 Subject: [experimental-ims] e88413b Allocate HTTP.status from http's designated workspace. Message-ID: commit e88413bccbd000157da949eedc3ee4b0c6889dec Author: Poul-Henning Kamp Date: Wed Feb 8 23:26:57 2012 +0000 Allocate HTTP.status from http's designated workspace. diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 0b0b926..cdf95f1 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -1069,7 +1069,7 @@ http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, int resp) l = WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], " "); WSLH(w, vsl_id, hp, HTTP_HDR_PROTO); - hp->hd[HTTP_HDR_STATUS].b = WS_Alloc(w->ws, 4); + hp->hd[HTTP_HDR_STATUS].b = WS_Alloc(hp->ws, 4); AN(hp->hd[HTTP_HDR_STATUS].b); sprintf(hp->hd[HTTP_HDR_STATUS].b, "%3d", hp->status); From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] fe68764 Attach the vslbuffer to the vbc while in use and lend it the vbc's vsl_id. When the vbc is returned, restore the original vsl_id. Message-ID: commit fe687646b00aed6d0f2b589353551e98e4a0d64d Author: Poul-Henning Kamp Date: Tue Feb 14 09:18:21 2012 +0000 Attach the vslbuffer to the vbc while in use and lend it the vbc's vsl_id. When the vbc is returned, restore the original vsl_id. Change WSLB() to VSLB() and have it take a busyobj as arg. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 39b30da..eac81df 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -756,8 +756,8 @@ int EXP_NukeOne(struct worker *w, struct lru *lru); /* cache_fetch.c */ struct storage *FetchStorage(struct worker *w, ssize_t sz); -int FetchError(struct worker *w, const char *error); -int FetchError2(struct worker *w, const char *error, const char *more); +int FetchError(const struct worker *w, const char *error); +int FetchError2(const struct worker *w, const char *error, const char *more); int FetchHdr(struct sess *sp, int need_host_hdr, int sendbody); int FetchBody(struct worker *w, struct object *obj); int FetchReqBody(const struct sess *sp, int sendbody); @@ -934,7 +934,7 @@ void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) void WSLR(struct vsl_log *, enum VSL_tag_e tag, int id, txt t); void WSL(struct vsl_log *, enum VSL_tag_e tag, int id, const char *fmt, ...) __printflike(4, 5); -void WSLB(struct worker *, enum VSL_tag_e tag, const char *fmt, ...) +void VSLB(struct busyobj *, enum VSL_tag_e tag, const char *fmt, ...) __printflike(3, 4); void WSL_Flush(struct vsl_log *, int overflow); diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index a836fac..b1688f9 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -153,6 +153,7 @@ struct vbc { struct backend *backend; struct vdi_simple *vdis; struct vsl_log *vsl; + unsigned orig_vsl_id; unsigned vsl_id; int fd; diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index bbb13bb..b1359e3 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -61,7 +61,9 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp) before the OS reuses the FD */ WSL_Flush(wrk->vsl, 0); WSL_Flush(vc->vsl, 0); + vc->vsl->wid = vc->orig_vsl_id; vc->vsl = NULL; + vc->orig_vsl_id = 0; VTCP_close(&vc->fd); VBE_DropRefConn(bp); @@ -95,7 +97,9 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp) */ WSL_Flush(wrk->vsl, 0); WSL_Flush(vc->vsl, 0); + vc->vsl->wid = vc->orig_vsl_id; vc->vsl = NULL; + vc->orig_vsl_id = 0; Lck_Lock(&bp->mtx); VSC_C_main->backend_recycle++; @@ -117,6 +121,7 @@ VDI_GetFd(const struct director *d, struct sess *sp) vc = d->getfd(d, sp); if (vc != NULL) { vc->vsl = sp->wrk->busyobj->vsl; + vc->orig_vsl_id = vc->vsl->wid; vc->vsl->wid = vc->vsl_id; } return (vc); diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 1d705b1..3154784 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -61,6 +61,7 @@ struct vep_state { struct vsb *vsb; struct worker *wrk; + struct busyobj *bo; int dogzip; vep_callback_t *cb; @@ -186,7 +187,7 @@ vep_error(const struct vep_state *vep, const char *p) VSC_C_main->esi_errors++; l = (intmax_t)(vep->ver_p - vep->hack_p); - WSLB(vep->wrk, SLT_ESI_xmlerror, "ERR at %jd %s", l, p); + VSLB(vep->bo, SLT_ESI_xmlerror, "ERR at %jd %s", l, p); } @@ -202,7 +203,7 @@ vep_warn(const struct vep_state *vep, const char *p) VSC_C_main->esi_warnings++; l = (intmax_t)(vep->ver_p - vep->hack_p); printf("WARNING at %jd %s\n", l, p); - WSLB(vep->wrk, SLT_ESI_xmlerror, "WARN at %jd %s", l, p); + VSLB(vep->bo, SLT_ESI_xmlerror, "WARN at %jd %s", l, p); } @@ -602,7 +603,7 @@ VEP_Parse(const struct worker *wrk, const char *p, size_t l) p++; vep->state = VEP_STARTTAG; } else if (p < e) { - WSLB(vep->wrk, SLT_ESI_xmlerror, + VSLB(vep->bo, SLT_ESI_xmlerror, "No ESI processing, first char not '<'"); vep->state = VEP_NOTXML; } @@ -1010,6 +1011,7 @@ VEP_Init(struct worker *wrk, vep_callback_t *cb) memset(vep, 0, sizeof *vep); vep->magic = VEP_MAGIC; vep->wrk = wrk; + vep->bo = wrk->busyobj; vep->vsb = VSB_new_auto(); AN(vep->vsb); wrk->busyobj->vep = vep; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 018c4f9..1e2ef44 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -52,22 +52,23 @@ static unsigned fetchfrag; */ int -FetchError2(struct worker *wrk, const char *error, const char *more) +FetchError2(const struct worker *wrk, const char *error, const char *more) { CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); if (!wrk->busyobj->fetch_failed) { if (more == NULL) - WSLB(wrk, SLT_FetchError, "%s", error); + VSLB(wrk->busyobj, SLT_FetchError, "%s", error); else - WSLB(wrk, SLT_FetchError, "%s: %s", error, more); + VSLB(wrk->busyobj, SLT_FetchError, "%s: %s", error, + more); } wrk->busyobj->fetch_failed = 1; return (-1); } int -FetchError(struct worker *wrk, const char *error) +FetchError(const struct worker *wrk, const char *error) { return(FetchError2(wrk, error, NULL)); } @@ -574,7 +575,7 @@ FetchBody(struct worker *wrk, struct object *obj) bo->fetch_obj = NULL; - WSLB(wrk, SLT_Fetch_Body, "%u(%s) cls %d mklen %d", + VSLB(bo, SLT_Fetch_Body, "%u(%s) cls %d mklen %d", bo->body_status, body_status(bo->body_status), cls, mklen); @@ -594,7 +595,7 @@ FetchBody(struct worker *wrk, struct object *obj) if (cls == 0 && bo->should_close) cls = 1; - WSLB(wrk, SLT_Length, "%zd", obj->len); + VSLB(bo, SLT_Length, "%zd", obj->len); { /* Sanity check fetch methods accounting */ diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 2ee1abf..cf270c5 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -399,7 +399,7 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id) *vgp = NULL; if (vsl_id < 0) - WSLB(vg->wrk, SLT_Gzip, "%s %jd %jd %jd %jd %jd", + 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, diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index ab715b7..299389f 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -289,16 +289,14 @@ WSL(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, ...) /*--------------------------------------------------------------------*/ void -WSLB(struct worker *wrk, enum VSL_tag_e tag, const char *fmt, ...) +VSLB(struct busyobj *bo, enum VSL_tag_e tag, const char *fmt, ...) { va_list ap; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj->vbc, VBC_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AN(fmt); va_start(ap, fmt); - wsl(wrk->vsl, tag, wrk->busyobj->vbc->vsl_id, fmt, ap); + wsl(bo->vsl, tag, bo->vsl->wid, fmt, ap); va_end(ap); } From geoff at varnish-cache.org Tue Feb 14 16:49:34 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:34 +0100 Subject: [experimental-ims] 1fd2741 Start abstracting the VSL handling a bit. Message-ID: commit 1fd274110b3247131461ab4632b8e00fa1db7ca4 Author: Poul-Henning Kamp Date: Mon Feb 13 21:17:59 2012 +0000 Start abstracting the VSL handling a bit. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 4b1bfc3..9a31cb4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -245,6 +245,13 @@ struct exp { /*--------------------------------------------------------------------*/ +struct vsl_log { + uint32_t *wlb, *wlp, *wle; + unsigned wlr; +}; + +/*--------------------------------------------------------------------*/ + struct wrk_accept { unsigned magic; #define WRK_ACCEPT_MAGIC 0x8c4b4d59 @@ -297,8 +304,7 @@ struct worker { struct VCL_conf *vcl; - uint32_t *wlb, *wlp, *wle; - unsigned wlr; + struct vsl_log vsl[1]; struct ws aws[1]; @@ -909,13 +915,13 @@ void VSM_Free(void *ptr); #ifdef VSL_ENDMARKER void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) __printflike(3, 4); -void WSLR(struct worker *w, enum VSL_tag_e tag, int id, txt t); -void WSL(struct worker *w, enum VSL_tag_e tag, int id, const char *fmt, ...) +void WSLR(struct vsl_log *, enum VSL_tag_e tag, int id, txt t); +void WSL(struct vsl_log *, enum VSL_tag_e tag, int id, const char *fmt, ...) __printflike(4, 5); -void WSLB(struct worker *w, enum VSL_tag_e tag, const char *fmt, ...) +void WSLB(struct worker *, enum VSL_tag_e tag, const char *fmt, ...) __printflike(3, 4); -void WSL_Flush(struct worker *w, int overflow); +void WSL_Flush(struct vsl_log *, int overflow); #define DSL(flag, tag, id, ...) \ do { \ @@ -924,10 +930,10 @@ void WSL_Flush(struct worker *w, int overflow); } while (0) #define WSP(sess, tag, ...) \ - WSL((sess)->wrk, tag, (sess)->vsl_id, __VA_ARGS__) + WSL((sess)->wrk->vsl, tag, (sess)->vsl_id, __VA_ARGS__) #define WSPR(sess, tag, txt) \ - WSLR((sess)->wrk, tag, (sess)->vsl_id, txt) + WSLR((sess)->wrk->vsl, tag, (sess)->vsl_id, txt) #define INCOMPL() do { \ VSL(SLT_Debug, 0, "INCOMPLETE AT: %s(%d)", __func__, __LINE__); \ diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 039300b..267e7ba 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -185,7 +185,7 @@ bes_conn_try(const struct sess *sp, struct vbc *vc, const struct vdi_simple *vs) } else { vc->vsl_id = s | VSL_BACKENDMARKER; VTCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1); - WSL(sp->wrk, SLT_BackendOpen, vc->vsl_id, "%s %s %s ", + WSL(sp->wrk->vsl, SLT_BackendOpen, vc->vsl_id, "%s %s %s ", vs->backend->display_name, abuf1, pbuf1); } @@ -356,12 +356,12 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs) return (vc); } VSC_C_main->backend_toolate++; - WSL(sp->wrk, SLT_BackendClose, vc->vsl_id, "%s", + WSL(sp->wrk->vsl, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name); /* Checkpoint log to flush all info related to this connection before the OS reuses the FD */ - WSL_Flush(sp->wrk, 0); + WSL_Flush(sp->wrk->vsl, 0); VTCP_close(&vc->fd); VBE_DropRefConn(bp); diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 451e504..6dc3618 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -954,7 +954,7 @@ ban_lurker(struct sess *sp, void *priv) } i = ban_lurker_work(sp, pass); - WSL_Flush(sp->wrk, 0); + WSL_Flush(sp->wrk->vsl, 0); WRK_SumStat(sp->wrk); if (i) { pass += (1 << LURK_SHIFT); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 345d0cf..0cb3a38 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -407,7 +407,7 @@ cnt_done(struct sess *sp, struct worker *wrk, struct req *req) req->xid, sp->t_req, sp->t_idle, dh, dp, da); } req->xid = 0; - WSL_Flush(wrk, 0); + WSL_Flush(wrk->vsl, 0); sp->t_req = NAN; req->t_resp = NAN; @@ -1592,7 +1592,7 @@ cnt_diag(struct sess *sp, const char *state) if (sp->wrk != NULL) { WSP(sp, SLT_Debug, "vsl_id %u STP_%s sp %p obj %p vcl %p", sp->vsl_id, state, sp, obj, vcl); - WSL_Flush(sp->wrk, 0); + WSL_Flush(sp->wrk->vsl, 0); } else { VSL(SLT_Debug, sp->vsl_id, "vsl_id %u STP_%s sp %p obj %p vcl %p", @@ -1673,7 +1673,7 @@ CNT_Session(struct sess *sp) WS_Assert(wrk->aws); CHECK_OBJ_ORNULL(wrk->nobjhead, OBJHEAD_MAGIC); } - WSL_Flush(wrk, 0); + WSL_Flush(wrk->vsl, 0); #define ACCT(foo) AZ(wrk->acct_tmp.foo); #include "tbl/acct_fields.h" #undef ACCT diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index 4ec81fb..53a3e50 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -55,11 +55,11 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp) bp = vc->backend; - WSL(wrk, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name); + WSL(wrk->vsl, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name); /* Checkpoint log to flush all info related to this connection before the OS reuses the FD */ - WSL_Flush(wrk, 0); + WSL_Flush(wrk->vsl, 0); VTCP_close(&vc->fd); VBE_DropRefConn(bp); @@ -85,12 +85,12 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp) bp = vc->backend; - WSL(wrk, SLT_BackendReuse, vc->vsl_id, "%s", bp->display_name); + WSL(wrk->vsl, SLT_BackendReuse, vc->vsl_id, "%s", bp->display_name); /* * Flush the shmlog, so that another session reusing this backend * will log chronologically later than our use of it. */ - WSL_Flush(wrk, 0); + WSL_Flush(wrk->vsl, 0); Lck_Lock(&bp->mtx); VSC_C_main->backend_recycle++; VTAILQ_INSERT_HEAD(&bp->connlist, vc, list); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index bfd6a8c..8ef35a3 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -98,7 +98,7 @@ ved_include(struct sess *sp, const char *src, const char *host) if (sp->step == STP_DONE) break; AZ(sp->wrk); - WSL_Flush(w, 0); + WSL_Flush(w->vsl, 0); DSL(0x20, SLT_Debug, sp->vsl_id, "loop waiting for ESI"); (void)usleep(10000); } diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index e93a1aa..1060bac 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -342,7 +342,7 @@ exp_timer(struct sess *sp, void *priv) oc = NULL; while (1) { if (oc == NULL) { - WSL_Flush(sp->wrk, 0); + WSL_Flush(sp->wrk->vsl, 0); WRK_SumStat(sp->wrk); VTIM_sleep(cache_param->expiry_sleep); t = VTIM_real(); @@ -400,7 +400,7 @@ exp_timer(struct sess *sp, void *priv) CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC); o = oc_getobj(sp->wrk, oc); - WSL(sp->wrk, SLT_ExpKill, 0, "%u %.0f", + WSL(sp->wrk->vsl, SLT_ExpKill, 0, "%u %.0f", oc_getxid(sp->wrk, oc), EXP_Ttl(NULL, o) - t); (void)HSH_Deref(sp->wrk, oc, NULL); } @@ -445,7 +445,7 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru) return (-1); /* XXX: bad idea for -spersistent */ - WSL(wrk, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc)); + WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc)); (void)HSH_Deref(wrk, oc, NULL); return (1); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index c4c0718..018c4f9 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -439,7 +439,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) } /* Checkpoint the vsl.here */ - WSL_Flush(wrk, 0); + WSL_Flush(wrk->vsl, 0); /* XXX is this the right place? */ VSC_C_main->backend_req++; diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 9d81f62..2ee1abf 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -407,7 +407,7 @@ VGZ_Destroy(struct vgz **vgp, int vsl_id) (intmax_t)vg->vz.last_bit, (intmax_t)vg->vz.stop_bit); else - WSL(vg->wrk, SLT_Gzip, vsl_id, "%s %jd %jd %jd %jd %jd", + 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, diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index c8cb6cc..b330c67 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -612,7 +612,7 @@ HSH_Unbusy(struct worker *wrk) if (o->ws_o->overflow) wrk->stats.n_objoverflow++; if (cache_param->diag_bitmap & 0x40) - WSL(wrk, SLT_Debug, 0, + WSL(wrk->vsl, SLT_Debug, 0, "Object %u workspace free %u", o->xid, WS_Free(o->ws_o)); /* XXX: pretouch neighbors on oh->objcs to prevent page-on under mtx */ diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index cdf95f1..314c05f 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -77,7 +77,7 @@ WSLH(struct worker *w, unsigned vsl_id, const struct http *hp, unsigned hdr) { AN(vsl_id & (VSL_CLIENTMARKER|VSL_BACKENDMARKER)); - WSLR(w, http2shmlog(hp, hdr), vsl_id, hp->hd[hdr]); + WSLR(w->vsl, http2shmlog(hp, hdr), vsl_id, hp->hd[hdr]); } /*--------------------------------------------------------------------*/ @@ -519,7 +519,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, if (q - p > htc->maxhdr) { VSC_C_main->losthdr++; - WSL(w, SLT_LostHeader, vsl_id, "%.*s", + WSL(w->vsl, SLT_LostHeader, vsl_id, "%.*s", (int)(q - p > 20 ? 20 : q - p), p); return (413); } @@ -545,7 +545,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p, hp->nhd++; } else { VSC_C_main->losthdr++; - WSL(w, SLT_LostHeader, vsl_id, "%.*s", + WSL(w->vsl, SLT_LostHeader, vsl_id, "%.*s", (int)(q - p > 20 ? 20 : q - p), p); return (413); } @@ -716,7 +716,7 @@ http_DissectResponse(struct worker *w, const struct http_conn *htc, } if (retval != 0) { - WSLR(w, SLT_HttpGarbage, htc->vsl_id, htc->rxbuf); + WSLR(w->vsl, SLT_HttpGarbage, htc->vsl_id, htc->rxbuf); assert(retval >= 100 && retval <= 999); hp->status = retval; } else { @@ -835,7 +835,7 @@ http_filterfields(struct worker *w, unsigned vsl_id, struct http *to, to->nhd++; } else { VSC_C_main->losthdr++; - WSLR(w, SLT_LostHeader, vsl_id, fm->hd[u]); + WSLR(w->vsl, SLT_LostHeader, vsl_id, fm->hd[u]); } } } @@ -905,7 +905,7 @@ http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp) } else { /* XXX This leaves a slot empty */ VSC_C_main->losthdr++; - WSLR(w, SLT_LostHeader, vsl_id, hp->hd[u]); + WSLR(w->vsl, SLT_LostHeader, vsl_id, hp->hd[u]); hp->hd[u].b = NULL; hp->hd[u].e = NULL; } @@ -936,7 +936,7 @@ http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); if (to->nhd >= to->shd) { VSC_C_main->losthdr++; - WSL(w, SLT_LostHeader, vsl_id, "%s", hdr); + WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", hdr); return; } http_SetH(to, to->nhd++, hdr); @@ -955,7 +955,7 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to, l = strlen(string); p = WS_Alloc(to->ws, l + 1); if (p == NULL) { - WSL(w, SLT_LostHeader, vsl_id, "%s", string); + WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", string); to->hd[field].b = NULL; to->hd[field].e = NULL; to->hdf[field] = 0; @@ -1011,7 +1011,7 @@ http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to, va_end(ap); if (n + 1 >= l || to->nhd >= to->shd) { VSC_C_main->losthdr++; - WSL(w, SLT_LostHeader, vsl_id, "%s", to->ws->f); + WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", to->ws->f); WS_Release(to->ws, 0); } else { to->hd[to->nhd].b = to->ws->f; diff --git a/bin/varnishd/cache/cache_httpconn.c b/bin/varnishd/cache/cache_httpconn.c index 1abd2a4..1a1eaf0 100644 --- a/bin/varnishd/cache/cache_httpconn.c +++ b/bin/varnishd/cache/cache_httpconn.c @@ -225,7 +225,7 @@ HTC_Read(struct worker *w, struct http_conn *htc, void *d, size_t len) return (l); i = read(htc->fd, p, len); if (i < 0) { - WSL(w, SLT_FetchError, htc->vsl_id, "%s", strerror(errno)); + WSL(w->vsl, SLT_FetchError, htc->vsl_id, "%s", strerror(errno)); return (i); } return (i + l); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index ea0668b..196cead 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -156,7 +156,7 @@ ses_pool_task(struct worker *wrk, void *arg) WS_Assert(wrk->aws); AZ(wrk->busyobj); AZ(wrk->wrw); - assert(wrk->wlp == wrk->wlb); + assert(wrk->vsl->wlp == wrk->vsl->wlb); if (cache_param->diag_bitmap & 0x00040000) { if (wrk->vcl != NULL) VCL_Rel(&wrk->vcl); diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index a839f5a..461aa97 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -180,30 +180,30 @@ VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) /*--------------------------------------------------------------------*/ void -WSL_Flush(struct worker *wrk, int overflow) +WSL_Flush(struct vsl_log *vsl, int overflow) { uint32_t *p; unsigned l; - l = pdiff(wrk->wlb, wrk->wlp); + l = pdiff(vsl->wlb, vsl->wlp); if (l == 0) return; assert(l >= 8); - p = vsl_get(l - 8, wrk->wlr, overflow); + p = vsl_get(l - 8, vsl->wlr, overflow); - memcpy(p + 1, wrk->wlb + 1, l - 4); + memcpy(p + 1, vsl->wlb + 1, l - 4); VWMB(); - p[0] = wrk->wlb[0]; - wrk->wlp = wrk->wlb; - wrk->wlr = 0; + p[0] = vsl->wlb[0]; + vsl->wlp = vsl->wlb; + vsl->wlr = 0; } /*--------------------------------------------------------------------*/ void -WSLR(struct worker *wrk, enum VSL_tag_e tag, int id, txt t) +WSLR(struct vsl_log *vsl, enum VSL_tag_e tag, int id, txt t) { unsigned l, mlen; @@ -217,29 +217,29 @@ WSLR(struct worker *wrk, enum VSL_tag_e tag, int id, txt t) t.e = t.b + l; } - assert(wrk->wlp < wrk->wle); + assert(vsl->wlp < vsl->wle); /* Wrap if necessary */ - if (VSL_END(wrk->wlp, l) >= wrk->wle) - WSL_Flush(wrk, 1); - assert (VSL_END(wrk->wlp, l) < wrk->wle); - memcpy(VSL_DATA(wrk->wlp), t.b, l); - vsl_hdr(tag, wrk->wlp, l, id); - wrk->wlp = VSL_END(wrk->wlp, l); - assert(wrk->wlp < wrk->wle); - wrk->wlr++; + if (VSL_END(vsl->wlp, l) >= vsl->wle) + WSL_Flush(vsl, 1); + assert (VSL_END(vsl->wlp, l) < vsl->wle); + memcpy(VSL_DATA(vsl->wlp), t.b, l); + vsl_hdr(tag, vsl->wlp, l, id); + vsl->wlp = VSL_END(vsl->wlp, l); + assert(vsl->wlp < vsl->wle); + vsl->wlr++; if (cache_param->diag_bitmap & 0x10000) - WSL_Flush(wrk, 0); + WSL_Flush(vsl, 0); } /*--------------------------------------------------------------------*/ static void -wsl(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) +wsl(struct vsl_log *, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) __printflike(4, 0); static void -wsl(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) +wsl(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) { char *p; unsigned n, mlen; @@ -251,38 +251,37 @@ wsl(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) if (strchr(fmt, '%') == NULL) { t.b = TRUST_ME(fmt); t.e = strchr(t.b, '\0'); - WSLR(wrk, tag, id, t); + WSLR(vsl, tag, id, t); } else { - assert(wrk->wlp < wrk->wle); + assert(vsl->wlp < vsl->wle); /* Wrap if we cannot fit a full size record */ - if (VSL_END(wrk->wlp, mlen) >= wrk->wle) - WSL_Flush(wrk, 1); + if (VSL_END(vsl->wlp, mlen) >= vsl->wle) + WSL_Flush(vsl, 1); - p = VSL_DATA(wrk->wlp); + p = VSL_DATA(vsl->wlp); n = vsnprintf(p, mlen, fmt, ap); if (n > mlen) n = mlen; /* we truncate long fields */ - vsl_hdr(tag, wrk->wlp, n, id); - wrk->wlp = VSL_END(wrk->wlp, n); - assert(wrk->wlp < wrk->wle); - wrk->wlr++; + vsl_hdr(tag, vsl->wlp, n, id); + vsl->wlp = VSL_END(vsl->wlp, n); + assert(vsl->wlp < vsl->wle); + vsl->wlr++; } if (cache_param->diag_bitmap & 0x10000) - WSL_Flush(wrk, 0); + WSL_Flush(vsl, 0); } /*--------------------------------------------------------------------*/ void -WSL(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, ...) +WSL(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, ...) { va_list ap; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); AN(fmt); va_start(ap, fmt); - wsl(wrk, tag, id, fmt, ap); + wsl(vsl, tag, id, fmt, ap); va_end(ap); } @@ -299,7 +298,7 @@ WSLB(struct worker *wrk, enum VSL_tag_e tag, const char *fmt, ...) CHECK_OBJ_NOTNULL(wrk->busyobj->vbc, VBC_MAGIC); AN(fmt); va_start(ap, fmt); - wsl(wrk, tag, wrk->busyobj->vbc->vsl_id, fmt, ap); + wsl(wrk->vsl, tag, wrk->busyobj->vbc->vsl_id, fmt, ap); va_end(ap); } diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 643f0a3..d69c7fb 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -56,7 +56,7 @@ VRT_error(const struct sess *sp, unsigned code, const char *reason) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - WSL(sp->wrk, SLT_Debug, 0, "VCL_error(%u, %s)", code, reason ? + WSL(sp->wrk->vsl, SLT_Debug, 0, "VCL_error(%u, %s)", code, reason ? reason : "(null)"); if (code < 100 || code > 999) code = 503; diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index cc7fb5b..417fcee 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -55,7 +55,7 @@ vrt_do_string(struct worker *w, int fd, const struct http *hp, int fld, AN(hp); b = VRT_String(hp->ws, NULL, p, ap); if (b == NULL || *b == '\0') { - WSL(w, SLT_LostHeader, fd, "%s", err); + WSL(w->vsl, SLT_LostHeader, fd, "%s", err); } else { http_SetH(hp, fld, b); } diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 2f0b575..591e633 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -104,8 +104,8 @@ wrk_bgthread(void *arg) memset(&wrk, 0, sizeof wrk); sp->wrk = &wrk; wrk.magic = WORKER_MAGIC; - wrk.wlp = wrk.wlb = logbuf; - wrk.wle = logbuf + (sizeof logbuf) / 4; + wrk.vsl->wlp = wrk.vsl->wlb = logbuf; + wrk.vsl->wle = logbuf + (sizeof logbuf) / 4; (void)bt->func(sp, bt->priv); @@ -142,8 +142,8 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace) memset(w, 0, sizeof *w); w->magic = WORKER_MAGIC; w->lastused = NAN; - w->wlb = w->wlp = wlog; - w->wle = wlog + (sizeof wlog) / 4; + w->vsl->wlb = w->vsl->wlp = wlog; + w->vsl->wle = wlog + (sizeof wlog) / 4; AZ(pthread_cond_init(&w->cond, NULL)); WS_Init(w->aws, "wrk", ws, thread_workspace); diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index 2c0d7c3..5c4b280 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -174,7 +174,7 @@ WRW_Flush(struct worker *wrk) if (VTIM_real() - wrk->sp->req->t_resp > cache_param->send_timeout) { - WSL(wrk, SLT_Debug, *wrw->wfd, + WSL(wrk->vsl, SLT_Debug, *wrw->wfd, "Hit total send timeout, " "wrote = %zd/%zd; not retrying", i, wrw->liov); @@ -182,7 +182,7 @@ WRW_Flush(struct worker *wrk) break; } - WSL(wrk, SLT_Debug, *wrw->wfd, + WSL(wrk->vsl, SLT_Debug, *wrw->wfd, "Hit send timeout, wrote = %zd/%zd; retrying", i, wrw->liov); @@ -191,7 +191,7 @@ WRW_Flush(struct worker *wrk) } if (i <= 0) { wrw->werr++; - WSL(wrk, SLT_Debug, *wrw->wfd, + WSL(wrk->vsl, SLT_Debug, *wrw->wfd, "Write error, retval = %zd, len = %zd, errno = %s", i, wrw->liov, strerror(errno)); } diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index ccd45b1..22971a3 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -141,7 +141,7 @@ stv_pick_stevedore(struct worker *wrk, const char **hint) return (stv_transient); /* Hint was not valid, nuke it */ - WSL(wrk, SLT_Debug, 0, /* XXX VSL_id ?? */ + WSL(wrk->vsl, SLT_Debug, 0, /* XXX VSL_id ?? */ "Storage hint not usable"); *hint = NULL; } From geoff at varnish-cache.org Tue Feb 14 16:49:28 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:28 +0100 Subject: [experimental-ims] cd2ce96 Allocate the vbo and http's out of the backend workspace to avoid wasting partial pages with likely parameter values. Message-ID: commit cd2ce96c4d4d6300fb44d526cf2fc0cc9a39db43 Author: Poul-Henning Kamp Date: Thu Feb 9 07:48:04 2012 +0000 Allocate the vbo and http's out of the backend workspace to avoid wasting partial pages with likely parameter values. diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 65791e8..d6074a7 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -40,8 +40,6 @@ static struct mempool *vbopool; -static volatile unsigned vbosize; - struct vbo { unsigned magic; #define VBO_MAGIC 0xde3d8223 @@ -51,27 +49,6 @@ struct vbo { struct busyobj bo; }; -static struct lock vbo_mtx; - -/*-------------------------------------------------------------------- - */ - -static void -vbo_size_calc(volatile unsigned *u) -{ - uint16_t nhttp; - ssize_t http_space; - - assert(cache_param->http_max_hdr < 65536); - nhttp = (uint16_t)cache_param->http_max_hdr; - - http_space = HTTP_estimate(nhttp); - - *u = sizeof(struct vbo) + - http_space * 2L + - cache_param->workspace_backend; -} - /*-------------------------------------------------------------------- */ @@ -79,10 +56,9 @@ void VBO_Init(void) { - vbopool = MPL_New("vbo", &cache_param->vbo_pool, &vbosize, - vbo_size_calc); + vbopool = MPL_New("vbo", &cache_param->vbo_pool, + &cache_param->workspace_backend, NULL); AN(vbopool); - Lck_New(&vbo_mtx, lck_busyobj); } /*-------------------------------------------------------------------- From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] 75739f8 Split http_Setup() into http_Setup() and http_Teardown() Message-ID: commit 75739f85b056a3c4d9a0e23382754490cba07910 Author: Poul-Henning Kamp Date: Tue Feb 14 09:26:11 2012 +0000 Split http_Setup() into http_Setup() and http_Teardown() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index eac81df..94c0284 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -818,6 +818,7 @@ void http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, void http_SetH(const struct http *to, unsigned n, const char *fm); void http_ForceGet(const struct http *to); void http_Setup(struct http *ht, struct ws *ws); +void http_Teardown(struct http *ht); int http_GetHdr(const struct http *hp, const char *hdr, char **ptr); int http_GetHdrData(const struct http *hp, const char *hdr, const char *field, char **ptr); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 45e069e..5e85542 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -294,7 +294,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) AZ(req->obj); req->restarts++; req->director = NULL; - http_Setup(req->resp, NULL); + http_Teardown(req->resp); sp->step = STP_RECV; return (0); default: @@ -339,7 +339,7 @@ cnt_deliver(struct sess *sp, struct worker *wrk, struct req *req) assert(WRW_IsReleased(wrk)); (void)HSH_Deref(wrk, NULL, &req->obj); - http_Setup(req->resp, NULL); + http_Teardown(req->resp); sp->step = STP_DONE; return (0); } @@ -487,8 +487,8 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) if (req->obj == NULL) { req->doclose = "Out of objects"; req->director = NULL; - http_Setup(wrk->busyobj->beresp, NULL); - http_Setup(wrk->busyobj->bereq, NULL); + http_Teardown(wrk->busyobj->beresp); + http_Teardown(wrk->busyobj->bereq); sp->step = STP_DONE; return(0); } @@ -533,7 +533,7 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) assert(req->handling == VCL_RET_DELIVER); req->err_code = 0; req->err_reason = NULL; - http_Setup(wrk->busyobj->bereq, NULL); + http_Teardown(wrk->busyobj->bereq); VBO_DerefBusyObj(wrk, &wrk->busyobj); sp->step = STP_PREPRESP; return (0); @@ -897,8 +897,8 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req) /* Use unmodified headers*/ i = FetchBody(wrk, req->obj); - http_Setup(bo->bereq, NULL); - http_Setup(bo->beresp, NULL); + http_Teardown(bo->bereq); + http_Teardown(bo->beresp); bo->vfp = NULL; assert(WRW_IsReleased(wrk)); AZ(bo->vbc); @@ -953,8 +953,8 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) i = FetchBody(wrk, req->obj); - http_Setup(wrk->busyobj->bereq, NULL); - http_Setup(wrk->busyobj->beresp, NULL); + http_Teardown(wrk->busyobj->bereq); + http_Teardown(wrk->busyobj->beresp); wrk->busyobj->vfp = NULL; AZ(wrk->busyobj->vbc); AN(req->director); @@ -976,7 +976,7 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) assert(WRW_IsReleased(wrk)); (void)HSH_Deref(wrk, NULL, &req->obj); VBO_DerefBusyObj(wrk, &wrk->busyobj); - http_Setup(req->resp, NULL); + http_Teardown(req->resp); sp->step = STP_DONE; return (0); } @@ -1247,7 +1247,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) AZ(HSH_Deref(wrk, req->objcore, NULL)); req->objcore = NULL; - http_Setup(wrk->busyobj->bereq, NULL); + http_Teardown(wrk->busyobj->bereq); VBO_DerefBusyObj(wrk, &wrk->busyobj); switch(req->handling) { @@ -1304,7 +1304,7 @@ cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req) VCL_pass_method(sp); if (req->handling == VCL_RET_ERROR) { - http_Setup(wrk->busyobj->bereq, NULL); + http_Teardown(wrk->busyobj->bereq); VBO_DerefBusyObj(wrk, &wrk->busyobj); sp->step = STP_ERROR; return (0); @@ -1364,7 +1364,7 @@ cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req) PipeSession(sp); assert(WRW_IsReleased(wrk)); - http_Setup(wrk->busyobj->bereq, NULL); + http_Teardown(wrk->busyobj->bereq); VBO_DerefBusyObj(wrk, &wrk->busyobj); sp->step = STP_DONE; return (0); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 314c05f..d947de1 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -132,6 +132,15 @@ HTTP_create(void *p, uint16_t nhttp) void http_Setup(struct http *hp, struct ws *ws) { + http_Teardown(hp); + hp->ws = ws; +} + +/*--------------------------------------------------------------------*/ + +void +http_Teardown(struct http *hp) +{ uint16_t shd; txt *hd; unsigned char *hdf; @@ -144,7 +153,6 @@ http_Setup(struct http *hp, struct ws *ws) memset(hd, 0, sizeof *hd * shd); memset(hdf, 0, sizeof *hdf * shd); hp->magic = HTTP_MAGIC; - hp->ws = ws; hp->nhd = HTTP_HDR_FIRST; hp->shd = shd; hp->hd = hd; From geoff at varnish-cache.org Tue Feb 14 16:49:35 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:35 +0100 Subject: [experimental-ims] d98dee2 Give busyobj its own VSL staging buffer too. Message-ID: commit d98dee20689a3f9671e7177e5412d0837d46aeb1 Author: Poul-Henning Kamp Date: Tue Feb 14 08:17:32 2012 +0000 Give busyobj its own VSL staging buffer too. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index d9d9f48..39b30da 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -451,8 +451,6 @@ oc_getlru(const struct objcore *oc) * * One of these aspects will be how much has been fetched, which * streaming delivery will make use of. - * - * XXX: many fields from worker needs to move here. */ struct busyobj { @@ -493,6 +491,8 @@ struct busyobj { double connect_timeout; double first_byte_timeout; double between_bytes_timeout; + + struct vsl_log vsl[1]; }; /* Object structure --------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 0252d57..8f0f31e 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -98,14 +98,11 @@ VBO_GetBusyObj(struct worker *wrk) { struct vbo *vbo = NULL; uint16_t nhttp; - unsigned httpsz; + unsigned sz; char *p; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - nhttp = (uint16_t)cache_param->http_max_hdr; - httpsz = HTTP_estimate(nhttp); - if (wrk->nvbo != NULL) { vbo = wrk->nvbo; wrk->nvbo = NULL; @@ -123,15 +120,28 @@ VBO_GetBusyObj(struct worker *wrk) vbo->bo.vbo = vbo; p = (void*)(vbo + 1); + p = (void*)PRNDUP(p); + assert(p < vbo->end); + + nhttp = (uint16_t)cache_param->http_max_hdr; + sz = HTTP_estimate(nhttp); + vbo->bo.bereq = HTTP_create(p, nhttp); - p += httpsz; + p += sz; + p = (void*)PRNDUP(p); + assert(p < vbo->end); + vbo->bo.beresp = HTTP_create(p, nhttp); - p += httpsz; - if (p >= vbo->end) { - fprintf(stderr, "workspace_backend is at least %jd to small\n", - (p - vbo->end)); - assert (p < vbo->end); - } + p += sz; + p = (void*)PRNDUP(p); + assert(p < vbo->end); + + sz = cache_param->vsl_buffer; + VSL_Setup(vbo->bo.vsl, p, sz); + p += sz; + p = (void*)PRNDUP(p); + assert(p < vbo->end); + WS_Init(vbo->bo.ws, "bo", p, vbo->end - p); return (&vbo->bo); @@ -170,13 +180,15 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) r = --vbo->refcount; Lck_Unlock(&vbo->mtx); - if (r == 0) { - /* XXX: Sanity checks & cleanup */ - memset(&vbo->bo, 0, sizeof vbo->bo); + if (r) + return; - if (cache_param->bo_cache && wrk->nvbo == NULL) - wrk->nvbo = vbo; - else - VBO_Free(&vbo); - } + WSL_Flush(vbo->bo.vsl, 0); + /* XXX: Sanity checks & cleanup */ + memset(&vbo->bo, 0, sizeof vbo->bo); + + if (cache_param->bo_cache && wrk->nvbo == NULL) + wrk->nvbo = vbo; + else + VBO_Free(&vbo); } diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 0cb3a38..45e069e 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -480,6 +480,7 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) AZ(wrk->busyobj); wrk->busyobj = VBO_GetBusyObj(wrk); + wrk->busyobj->vsl->wid = sp->vsl_id; req->obj = STV_NewObject(wrk, TRANSIENT_STORAGE, cache_param->http_resp_size, (uint16_t)cache_param->http_max_hdr); @@ -1222,7 +1223,6 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); AZ(req->obj); - wrk->busyobj = VBO_GetBusyObj(wrk); http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); http_FilterReq(sp, HTTPH_R_FETCH); http_ForceGet(wrk->busyobj->bereq); @@ -1297,6 +1297,7 @@ cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req) AZ(wrk->busyobj); wrk->busyobj = VBO_GetBusyObj(wrk); + wrk->busyobj->vsl->wid = sp->vsl_id; http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); http_FilterReq(sp, HTTPH_R_PASS); @@ -1351,6 +1352,7 @@ cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req) wrk->acct_tmp.pipe++; wrk->busyobj = VBO_GetBusyObj(wrk); + wrk->busyobj->vsl->wid = sp->vsl_id; http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws); http_FilterReq(sp, 0); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 018c4f9..73e4f08 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -416,6 +416,8 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) if (vc->recycled) retry = 1; + sp->wrk->busyobj->vsl->wid = vc->vsl_id; + /* * Now that we know our backend, we can set a default Host: * header if one is necessary. This cannot be done in the VCL diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index b330c67..49f6d30 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -453,6 +453,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh) AZ(wrk->busyobj); wrk->busyobj = VBO_GetBusyObj(wrk); + wrk->busyobj->vsl->wid = sp->vsl_id; VRY_Validate(sp->req->vary_b); if (sp->req->vary_l != NULL) diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc index cecb009..983b704 100644 --- a/bin/varnishtest/tests/r01038.vtc +++ b/bin/varnishtest/tests/r01038.vtc @@ -45,7 +45,7 @@ server s1 { txresp -body "foo8" } -start -varnish v1 -arg "-p workspace_backend=3072" -vcl+backend { +varnish v1 -arg "-p workspace_backend=7k" -vcl+backend { sub vcl_fetch { set beresp.do_esi = true; } From geoff at varnish-cache.org Tue Feb 14 16:49:28 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:28 +0100 Subject: [experimental-ims] 877f011 Wait a bit before trying to start/use varnishd again Message-ID: commit 877f011eda4a1c83f7b5f1fa7e537e16f752e63c Author: Rogier 'DocWilco' Mulhuijzen Date: Wed Jan 18 10:51:16 2012 +0100 Wait a bit before trying to start/use varnishd again diff --git a/bin/varnishtest/tests/p00007.vtc b/bin/varnishtest/tests/p00007.vtc index 78aa8fb..7dc2e68 100644 --- a/bin/varnishtest/tests/p00007.vtc +++ b/bin/varnishtest/tests/p00007.vtc @@ -53,6 +53,8 @@ varnish v1 -cliok "debug.persistent s0 dump" # Panic worker so second segment does not get closed varnish v1 -clierr 400 "debug.panic.worker" +delay 0.5 + # start again varnish v1 -start diff --git a/bin/varnishtest/tests/v00010.vtc b/bin/varnishtest/tests/v00010.vtc index 45dbc79..b44fc13 100644 --- a/bin/varnishtest/tests/v00010.vtc +++ b/bin/varnishtest/tests/v00010.vtc @@ -42,6 +42,8 @@ varnish v1 -cliok "start" varnish v1 -wait-running sema r1 sync 2 +delay 0.5 + client c1 { txreq -url "/" rxresp From geoff at varnish-cache.org Tue Feb 14 16:49:34 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:34 +0100 Subject: [experimental-ims] 7ec9794 Move res_mode from worker to req Message-ID: commit 7ec9794e3679f4313e9d5c630665b2e34d28030d Author: Poul-Henning Kamp Date: Mon Feb 13 12:17:00 2012 +0000 Move res_mode from worker to req diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 3fafda1..162cbe9 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -343,15 +343,6 @@ struct worker { double first_byte_timeout; double between_bytes_timeout; - /* Delivery mode */ - unsigned res_mode; -#define RES_LEN (1<<1) -#define RES_EOF (1<<2) -#define RES_CHUNKED (1<<3) -#define RES_ESI (1<<4) -#define RES_ESI_CHILD (1<<5) -#define RES_GUNZIP (1<<6) - /* Temporary accounting */ struct acct acct_tmp; }; @@ -626,6 +617,14 @@ struct req { ssize_t l_crc; uint32_t crc; + /* Delivery mode */ + unsigned res_mode; +#define RES_LEN (1<<1) +#define RES_EOF (1<<2) +#define RES_CHUNKED (1<<3) +#define RES_ESI (1<<4) +#define RES_ESI_CHILD (1<<5) +#define RES_GUNZIP (1<<6) }; diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 6692491..826e1d7 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -216,26 +216,26 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) AssertObjCorePassOrBusy(req->obj->objcore); } - wrk->res_mode = 0; + req->res_mode = 0; if (wrk->busyobj == NULL) - wrk->res_mode |= RES_LEN; + req->res_mode |= RES_LEN; if (wrk->busyobj != NULL && (wrk->busyobj->h_content_length != NULL || !wrk->busyobj->do_stream) && !wrk->busyobj->do_gzip && !wrk->busyobj->do_gunzip) - wrk->res_mode |= RES_LEN; + req->res_mode |= RES_LEN; if (!req->disable_esi && req->obj->esidata != NULL) { /* In ESI mode, we don't know the aggregate length */ - wrk->res_mode &= ~RES_LEN; - wrk->res_mode |= RES_ESI; + req->res_mode &= ~RES_LEN; + req->res_mode |= RES_ESI; } if (req->esi_level > 0) { - wrk->res_mode &= ~RES_LEN; - wrk->res_mode |= RES_ESI_CHILD; + req->res_mode &= ~RES_LEN; + req->res_mode |= RES_ESI_CHILD; } if (cache_param->http_gzip_support && req->obj->gziped && @@ -244,24 +244,24 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) * We don't know what it uncompresses to * XXX: we could cache that */ - wrk->res_mode &= ~RES_LEN; - wrk->res_mode |= RES_GUNZIP; + req->res_mode &= ~RES_LEN; + req->res_mode |= RES_GUNZIP; } - if (!(wrk->res_mode & (RES_LEN|RES_CHUNKED|RES_EOF))) { + if (!(req->res_mode & (RES_LEN|RES_CHUNKED|RES_EOF))) { if (req->obj->len == 0 && (wrk->busyobj == NULL || !wrk->busyobj->do_stream)) /* * If the object is empty, neither ESI nor GUNZIP * can make it any different size */ - wrk->res_mode |= RES_LEN; + req->res_mode |= RES_LEN; else if (!req->wantbody) { /* Nothing */ } else if (req->http->protover >= 11) { - wrk->res_mode |= RES_CHUNKED; + req->res_mode |= RES_CHUNKED; } else { - wrk->res_mode |= RES_EOF; + req->res_mode |= RES_EOF; req->doclose = "EOF mode"; } } diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 9747919..bfd6a8c 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -60,7 +60,7 @@ ved_include(struct sess *sp, const char *src, const char *host) obj = sp->req->obj; sp->req->obj = NULL; - res_mode = sp->wrk->res_mode; + res_mode = sp->req->res_mode; /* Reset request to status before we started messing with it */ HTTP_Copy(sp->req->http, sp->req->http0); @@ -107,14 +107,14 @@ ved_include(struct sess *sp, const char *src, const char *host) assert(sp->step == STP_DONE); sp->req->esi_level--; sp->req->obj = obj; - sp->wrk->res_mode = res_mode; + sp->req->res_mode = res_mode; /* Reset the workspace */ WS_Reset(sp->req->ws, sp_ws_wm); WS_Reset(w->aws, wrk_ws_wm); /* XXX ? */ WRW_Reserve(sp->wrk, &sp->fd); - if (sp->wrk->res_mode & RES_CHUNKED) + if (sp->req->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); } @@ -247,7 +247,7 @@ ESI_Deliver(struct sess *sp) * Only the top level document gets to decide this. */ sp->req->gzip_resp = 0; - if (isgzip && !(sp->wrk->res_mode & RES_GUNZIP)) { + if (isgzip && !(sp->req->res_mode & RES_GUNZIP)) { assert(sizeof gzip_hdr == 10); /* Send out the gzip header */ (void)WRW_Write(sp->wrk, gzip_hdr, 10); diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 2b22829..d560211 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -94,7 +94,7 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh) "Content-Range: bytes %jd-%jd/%jd", (intmax_t)low, (intmax_t)high, (intmax_t)req->obj->len); http_Unset(req->resp, H_Content_Length); - assert(sp->wrk->res_mode & RES_LEN); + assert(req->res_mode & RES_LEN); http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, "Content-Length: %jd", (intmax_t)(1 + high - low)); http_SetResp(req->resp, "HTTP/1.1", 206, "Partial Content"); @@ -119,7 +119,7 @@ RES_BuildHttp(const struct sess *sp) req->resp->logtag = HTTP_Tx; http_FilterResp(sp, req->obj->http, req->resp, 0); - if (!(sp->wrk->res_mode & RES_LEN)) { + if (!(req->res_mode & RES_LEN)) { http_Unset(req->resp, H_Content_Length); } else if (cache_param->http_range_support) { /* We only accept ranges if we know the length */ @@ -127,7 +127,7 @@ RES_BuildHttp(const struct sess *sp) "Accept-Ranges: bytes"); } - if (sp->wrk->res_mode & RES_CHUNKED) + if (req->res_mode & RES_CHUNKED) http_SetHeader(sp->wrk, sp->vsl_id, req->resp, "Transfer-Encoding: chunked"); @@ -260,8 +260,8 @@ RES_WriteObj(struct sess *sp) high = req->obj->len - 1; if ( req->wantbody && - (sp->wrk->res_mode & RES_LEN) && - !(sp->wrk->res_mode & (RES_ESI|RES_ESI_CHILD|RES_GUNZIP)) && + (req->res_mode & RES_LEN) && + !(req->res_mode & (RES_ESI|RES_ESI_CHILD|RES_GUNZIP)) && cache_param->http_range_support && req->obj->response == 200 && http_GetHdr(req->http, H_Range, &r)) @@ -270,41 +270,41 @@ RES_WriteObj(struct sess *sp) /* * Always remove C-E if client don't grok it */ - if (sp->wrk->res_mode & RES_GUNZIP) + if (req->res_mode & RES_GUNZIP) http_Unset(req->resp, H_Content_Encoding); /* * Send HTTP protocol header, unless interior ESI object */ - if (!(sp->wrk->res_mode & RES_ESI_CHILD)) + if (!(req->res_mode & RES_ESI_CHILD)) sp->wrk->acct_tmp.hdrbytes += http_Write(sp->wrk, sp->vsl_id, req->resp, 1); if (!req->wantbody) - sp->wrk->res_mode &= ~RES_CHUNKED; + req->res_mode &= ~RES_CHUNKED; - if (sp->wrk->res_mode & RES_CHUNKED) + if (req->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); if (!req->wantbody) { /* This was a HEAD or conditional request */ } else if (req->obj->len == 0) { /* Nothing to do here */ - } else if (sp->wrk->res_mode & RES_ESI) { + } else if (req->res_mode & RES_ESI) { ESI_Deliver(sp); - } else if (sp->wrk->res_mode & RES_ESI_CHILD && req->gzip_resp) { + } else if (req->res_mode & RES_ESI_CHILD && req->gzip_resp) { ESI_DeliverChild(sp); - } else if (sp->wrk->res_mode & RES_ESI_CHILD && + } else if (req->res_mode & RES_ESI_CHILD && !req->gzip_resp && req->obj->gziped) { res_WriteGunzipObj(sp); - } else if (sp->wrk->res_mode & RES_GUNZIP) { + } else if (req->res_mode & RES_GUNZIP) { res_WriteGunzipObj(sp); } else { res_WriteDirObj(sp, low, high); } - if (sp->wrk->res_mode & RES_CHUNKED && - !(sp->wrk->res_mode & RES_ESI_CHILD)) + if (req->res_mode & RES_CHUNKED && + !(req->res_mode & RES_ESI_CHILD)) WRW_EndChunk(sp->wrk); if (WRW_FlushRelease(sp->wrk) && sp->fd >= 0) @@ -321,18 +321,18 @@ RES_StreamStart(struct sess *sp) sctx = sp->wrk->sctx; CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); - AZ(sp->wrk->res_mode & RES_ESI_CHILD); + AZ(sp->req->res_mode & RES_ESI_CHILD); AN(sp->req->wantbody); WRW_Reserve(sp->wrk, &sp->fd); - if (sp->wrk->res_mode & RES_GUNZIP) { + if (sp->req->res_mode & RES_GUNZIP) { sctx->vgz = VGZ_NewUngzip(sp->wrk, "U S -"); AZ(VGZ_WrwInit(sctx->vgz)); http_Unset(sp->req->resp, H_Content_Encoding); } - if (!(sp->wrk->res_mode & RES_CHUNKED) && + if (!(sp->req->res_mode & RES_CHUNKED) && sp->wrk->busyobj->h_content_length != NULL) http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp, "Content-Length: %s", sp->wrk->busyobj->h_content_length); @@ -340,7 +340,7 @@ RES_StreamStart(struct sess *sp) sp->wrk->acct_tmp.hdrbytes += http_Write(sp->wrk, sp->vsl_id, sp->req->resp, 1); - if (sp->wrk->res_mode & RES_CHUNKED) + if (sp->req->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); } @@ -367,7 +367,7 @@ RES_StreamPoll(struct worker *wrk) } l2 = st->len + l - sctx->stream_next; ptr = st->ptr + (sctx->stream_next - l); - if (wrk->res_mode & RES_GUNZIP) { + if (wrk->sp->req->res_mode & RES_GUNZIP) { (void)VGZ_WrwGunzip(wrk, sctx->vgz, ptr, l2); } else { (void)WRW_Write(wrk, ptr, l2); @@ -375,7 +375,7 @@ RES_StreamPoll(struct worker *wrk) l += st->len; sctx->stream_next += l2; } - if (!(wrk->res_mode & RES_GUNZIP)) + if (!(wrk->sp->req->res_mode & RES_GUNZIP)) (void)WRW_Flush(wrk); if (wrk->busyobj->fetch_obj->objcore == NULL || @@ -404,13 +404,13 @@ RES_StreamEnd(struct sess *sp) sctx = sp->wrk->sctx; CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); - if (sp->wrk->res_mode & RES_GUNZIP) { + if (sp->req->res_mode & RES_GUNZIP) { AN(sctx->vgz); VGZ_WrwFlush(sp->wrk, sctx->vgz); (void)VGZ_Destroy(&sctx->vgz, sp->vsl_id); } - if (sp->wrk->res_mode & RES_CHUNKED && - !(sp->wrk->res_mode & RES_ESI_CHILD)) + if (sp->req->res_mode & RES_CHUNKED && + !(sp->req->res_mode & RES_ESI_CHILD)) WRW_EndChunk(sp->wrk); if (WRW_FlushRelease(sp->wrk)) SES_Close(sp, "remote closed"); diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 1942c63..15f91df 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -165,3 +165,4 @@ -e712 // 96 Loss of precision (___) (___ to ___) -e747 // 297 Significant prototype coercion (___) ___ to ___ -e840 // Use of nul character in a string literal (see: vcc_if.c) +-e663 // Suspicious array to pointer conversion From geoff at varnish-cache.org Tue Feb 14 16:49:34 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 17:49:34 +0100 Subject: [experimental-ims] 23cffba Check that workspace_backend is big enough, rather than run on the mercy of mallocs rounding algorithm. Message-ID: commit 23cffba4d1fc94bb765c30c6271a52f52691689e Author: Poul-Henning Kamp Date: Mon Feb 13 11:07:55 2012 +0000 Check that workspace_backend is big enough, rather than run on the mercy of mallocs rounding algorithm. Fix overly optimistictest-case. diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 3a60bfd..0252d57 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -127,6 +127,11 @@ VBO_GetBusyObj(struct worker *wrk) p += httpsz; vbo->bo.beresp = HTTP_create(p, nhttp); p += httpsz; + if (p >= vbo->end) { + fprintf(stderr, "workspace_backend is at least %jd to small\n", + (p - vbo->end)); + assert (p < vbo->end); + } WS_Init(vbo->bo.ws, "bo", p, vbo->end - p); return (&vbo->bo); diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc index ff94c72..cecb009 100644 --- a/bin/varnishtest/tests/r01038.vtc +++ b/bin/varnishtest/tests/r01038.vtc @@ -45,7 +45,7 @@ server s1 { txresp -body "foo8" } -start -varnish v1 -arg "-p workspace_backend=1024" -vcl+backend { +varnish v1 -arg "-p workspace_backend=3072" -vcl+backend { sub vcl_fetch { set beresp.do_esi = true; } @@ -54,8 +54,11 @@ varnish v1 -arg "-p workspace_backend=1024" -vcl+backend { client c1 { txreq rxresp + expect resp.bodylen == 42 + txreq rxresp + expect resp.bodylen == 42 } -run varnish v1 -expect losthdr == 0 From geoff at varnish-cache.org Tue Feb 14 17:30:52 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 18:30:52 +0100 Subject: [experimental-ims] 40273a3 Clean up this file, and GC a unused counter. Message-ID: commit 40273a3357890cc639d76c0acd4b24fff6bf10b8 Author: Poul-Henning Kamp Date: Tue Feb 14 14:23:28 2012 +0000 Clean up this file, and GC a unused counter. diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 1188903..36bb629 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -82,67 +82,119 @@ VSC_F(sess_fail, uint64_t, 1, 'c', /*---------------------------------------------------------------------*/ VSC_F(client_req, uint64_t, 1, 'a', - "Client requests received", - "") + "Client requests received", + "" +) VSC_F(cache_hit, uint64_t, 1, 'a', - "Cache hits", - "Count of cache hits. " - " A cache hit indicates that an object has been delivered to a" - " client without fetching it from a backend server." + "Cache hits", + "Count of cache hits. " + " A cache hit indicates that an object has been delivered to a" + " client without fetching it from a backend server." ) -VSC_F(cache_hitpass, uint64_t, 1, 'a', - "Cache hits for pass", - "Count of hits for pass" - " A cache hit for pass indicates that Varnish is going to" - " pass the request to the backend and this decision has been " - " cached in it self. This counts how many times the cached " - " decision is being used." +VSC_F(cache_hitpass, uint64_t, 1, 'a', + "Cache hits for pass", + "Count of hits for pass" + " A cache hit for pass indicates that Varnish is going to" + " pass the request to the backend and this decision has been " + " cached in it self. This counts how many times the cached " + " decision is being used." ) VSC_F(cache_miss, uint64_t, 1, 'a', - "Cache misses", - "Count of misses" - " A cache miss indicates the object was fetched from the" - " backend before delivering it to the backend.") + "Cache misses", + "Count of misses" + " A cache miss indicates the object was fetched from the" + " backend before delivering it to the backend." +) -VSC_F(backend_conn, uint64_t, 0, 'a', - "Backend conn. success", - "") +VSC_F(backend_conn, uint64_t, 0, 'a', + "Backend conn. success", + "" +) VSC_F(backend_unhealthy, uint64_t, 0, 'a', - "Backend conn. not attempted", - "" -) -VSC_F(backend_busy, uint64_t, 0, 'a', "Backend conn. too many", "") -VSC_F(backend_fail, uint64_t, 0, 'a', "Backend conn. failures", "") -VSC_F(backend_reuse, uint64_t, 0, 'a', - "Backend conn. reuses", - "Count of backend connection reuses" - " This counter is increased whenever we reuse a recycled connection.") -VSC_F(backend_toolate, uint64_t, 0, 'a', "Backend conn. was closed", "") -VSC_F(backend_recycle, uint64_t, 0, 'a', - "Backend conn. recycles", - "Count of backend connection recycles" - " This counter is increased whenever we have a keep-alive" - " connection that is put back into the pool of connections." - " It has not yet been used, but it might be, unless the backend" - " closes it.") -VSC_F(backend_retry, uint64_t, 0, 'a', "Backend conn. retry", "") - -VSC_F(fetch_head, uint64_t, 1, 'a', "Fetch head", "") -VSC_F(fetch_length, uint64_t, 1, 'a', "Fetch with Length", "") -VSC_F(fetch_chunked, uint64_t, 1, 'a', "Fetch chunked", "") -VSC_F(fetch_eof, uint64_t, 1, 'a', "Fetch EOF", "") -VSC_F(fetch_bad, uint64_t, 1, 'a', "Fetch had bad headers", "") -VSC_F(fetch_close, uint64_t, 1, 'a', "Fetch wanted close", "") + "Backend conn. not attempted", + "" +) +VSC_F(backend_busy, uint64_t, 0, 'a', + "Backend conn. too many", + "" +) +VSC_F(backend_fail, uint64_t, 0, 'a', + "Backend conn. failures", + "" +) +VSC_F(backend_reuse, uint64_t, 0, 'a', + "Backend conn. reuses", + "Count of backend connection reuses" + " This counter is increased whenever we reuse a recycled connection." +) +VSC_F(backend_toolate, uint64_t, 0, 'a', + "Backend conn. was closed", + "" +) +VSC_F(backend_recycle, uint64_t, 0, 'a', + "Backend conn. recycles", + "Count of backend connection recycles" + " This counter is increased whenever we have a keep-alive" + " connection that is put back into the pool of connections." + " It has not yet been used, but it might be, unless the backend" + " closes it." +) +VSC_F(backend_retry, uint64_t, 0, 'a', + "Backend conn. retry", + "" +) + +VSC_F(fetch_head, uint64_t, 1, 'a', + "Fetch head", + "" +) +VSC_F(fetch_length, uint64_t, 1, 'a', + "Fetch with Length", + "" +) +VSC_F(fetch_chunked, uint64_t, 1, 'a', + "Fetch chunked", + "" +) +VSC_F(fetch_eof, uint64_t, 1, 'a', + "Fetch EOF", + "" +) +VSC_F(fetch_bad, uint64_t, 1, 'a', + "Fetch had bad headers", + "" +) +VSC_F(fetch_close, uint64_t, 1, 'a', + "Fetch wanted close", + "" +) VSC_F(fetch_oldhttp, uint64_t, 1, 'a', - "Fetch pre HTTP/1.1 closed", "") -VSC_F(fetch_zero, uint64_t, 1, 'a', "Fetch zero len", "") -VSC_F(fetch_failed, uint64_t, 1, 'a', "Fetch failed", "") -VSC_F(fetch_1xx, uint64_t, 1, 'a', "Fetch no body (1xx)", "") -VSC_F(fetch_204, uint64_t, 1, 'a', "Fetch no body (204)", "") -VSC_F(fetch_304, uint64_t, 1, 'a', "Fetch no body (304)", "") + "Fetch pre HTTP/1.1 closed", + "" +) +VSC_F(fetch_zero, uint64_t, 1, 'a', + "Fetch zero len", + "" +) +VSC_F(fetch_failed, uint64_t, 1, 'a', + "Fetch failed", + "" +) +VSC_F(fetch_1xx, uint64_t, 1, 'a', + "Fetch no body (1xx)", + "" +) +VSC_F(fetch_204, uint64_t, 1, 'a', + "Fetch no body (204)", + "" +) +VSC_F(fetch_304, uint64_t, 1, 'a', + "Fetch no body (304)", + "" +) /*--------------------------------------------------------------------- * Pools, threads, and sessions @@ -208,63 +260,171 @@ VSC_F(sess_dropped, uint64_t, 0, 'c', /*---------------------------------------------------------------------*/ -VSC_F(n_object, uint64_t, 1, 'i', "N struct object", "") -VSC_F(n_vampireobject, uint64_t, 1, 'i', "N unresurrected objects", "") -VSC_F(n_objectcore, uint64_t, 1, 'i', "N struct objectcore", "") -VSC_F(n_objecthead, uint64_t, 1, 'i', "N struct objecthead", "") -VSC_F(n_waitinglist, uint64_t, 1, 'i', "N struct waitinglist", "") - -VSC_F(n_backend, uint64_t, 0, 'i', "N backends", "") - -VSC_F(n_expired, uint64_t, 0, 'i', "N expired objects", "") -VSC_F(n_lru_nuked, uint64_t, 0, 'i', "N LRU nuked objects", "") -VSC_F(n_lru_moved, uint64_t, 0, 'i', "N LRU moved objects", "") - -VSC_F(losthdr, uint64_t, 0, 'a', "HTTP header overflows", "") - -VSC_F(n_objsendfile, uint64_t, 0, 'a', "Objects sent with sendfile", - "The number of objects sent with the sendfile system call. If enabled " - "sendfile will be used on object larger than a certain size.") -VSC_F(n_objwrite, uint64_t, 0, 'a', "Objects sent with write", - "The number of objects sent with regular write calls." - "Writes are used when the objects are too small for sendfile " - "or if the sendfile call has been disabled") -VSC_F(n_objoverflow, uint64_t, 1, 'a', - "Objects overflowing workspace", "") - -VSC_F(s_sess, uint64_t, 1, 'a', "Total Sessions", "") -VSC_F(s_req, uint64_t, 1, 'a', "Total Requests", "") -VSC_F(s_pipe, uint64_t, 1, 'a', "Total pipe", "") -VSC_F(s_pass, uint64_t, 1, 'a', "Total pass", "") -VSC_F(s_fetch, uint64_t, 1, 'a', "Total fetch", "") -VSC_F(s_hdrbytes, uint64_t, 1, 'a', "Total header bytes", "") -VSC_F(s_bodybytes, uint64_t, 1, 'a', "Total body bytes", "") - -VSC_F(sess_closed, uint64_t, 1, 'a', "Session Closed", "") -VSC_F(sess_pipeline, uint64_t, 1, 'a', "Session Pipeline", "") -VSC_F(sess_readahead, uint64_t, 1, 'a', "Session Read Ahead", "") -VSC_F(sess_linger, uint64_t, 1, 'a', "Session Linger", "") -VSC_F(sess_herd, uint64_t, 1, 'a', "Session herd", "") - -VSC_F(shm_records, uint64_t, 0, 'a', "SHM records", "") -VSC_F(shm_writes, uint64_t, 0, 'a', "SHM writes", "") +VSC_F(n_object, uint64_t, 1, 'i', + "N struct object", + "" +) +VSC_F(n_vampireobject, uint64_t, 1, 'i', + "N unresurrected objects", + "" +) +VSC_F(n_objectcore, uint64_t, 1, 'i', + "N struct objectcore", + "" +) +VSC_F(n_objecthead, uint64_t, 1, 'i', + "N struct objecthead", + "" +) +VSC_F(n_waitinglist, uint64_t, 1, 'i', + "N struct waitinglist", + "" +) + +VSC_F(n_backend, uint64_t, 0, 'i', + "N backends", + "" +) + +VSC_F(n_expired, uint64_t, 0, 'i', + "N expired objects", + "" +) +VSC_F(n_lru_nuked, uint64_t, 0, 'i', + "N LRU nuked objects", + "" +) +VSC_F(n_lru_moved, uint64_t, 0, 'i', + "N LRU moved objects", + "" +) + +VSC_F(losthdr, uint64_t, 0, 'a', + "HTTP header overflows", + "" +) + +VSC_F(n_objsendfile, uint64_t, 0, 'a', + "Objects sent with sendfile", + "The number of objects sent with the sendfile system call. If enabled " + "sendfile will be used on object larger than a certain size." +) +VSC_F(n_objwrite, uint64_t, 0, 'a', + "Objects sent with write", + "The number of objects sent with regular write calls." + "Writes are used when the objects are too small for sendfile " + "or if the sendfile call has been disabled" +) +VSC_F(n_objoverflow, uint64_t, 1, 'a', + "Objects overflowing workspace", + "" +) + +VSC_F(s_sess, uint64_t, 1, 'a', + "Total Sessions", + "" +) +VSC_F(s_req, uint64_t, 1, 'a', + "Total Requests", + "" +) +VSC_F(s_pipe, uint64_t, 1, 'a', + "Total pipe", + "" +) +VSC_F(s_pass, uint64_t, 1, 'a', + "Total pass", + "" +) +VSC_F(s_fetch, uint64_t, 1, 'a', + "Total fetch", + "" +) +VSC_F(s_hdrbytes, uint64_t, 1, 'a', + "Total header bytes", + "" +) +VSC_F(s_bodybytes, uint64_t, 1, 'a', + "Total body bytes", + "" +) + +VSC_F(sess_closed, uint64_t, 1, 'a', + "Session Closed", + "" +) +VSC_F(sess_pipeline, uint64_t, 1, 'a', + "Session Pipeline", + "" +) +VSC_F(sess_readahead, uint64_t, 1, 'a', + "Session Read Ahead", + "" +) +VSC_F(sess_herd, uint64_t, 1, 'a', + "Session herd", + "" +) + +VSC_F(shm_records, uint64_t, 0, 'a', + "SHM records", + "" +) +VSC_F(shm_writes, uint64_t, 0, 'a', + "SHM writes", + "" +) VSC_F(shm_flushes, uint64_t, 0, 'a', - "SHM flushes due to overflow", "") -VSC_F(shm_cont, uint64_t, 0, 'a', "SHM MTX contention", "") + "SHM flushes due to overflow", + "" +) +VSC_F(shm_cont, uint64_t, 0, 'a', + "SHM MTX contention", + "" +) VSC_F(shm_cycles, uint64_t, 0, 'a', - "SHM cycles through buffer", "") + "SHM cycles through buffer", + "" +) -VSC_F(sms_nreq, uint64_t, 0, 'a', "SMS allocator requests", "") -VSC_F(sms_nobj, uint64_t, 0, 'i', "SMS outstanding allocations", "") -VSC_F(sms_nbytes, uint64_t, 0, 'i', "SMS outstanding bytes", "") -VSC_F(sms_balloc, uint64_t, 0, 'i', "SMS bytes allocated", "") -VSC_F(sms_bfree, uint64_t, 0, 'i', "SMS bytes freed", "") +VSC_F(sms_nreq, uint64_t, 0, 'a', + "SMS allocator requests", + "" +) +VSC_F(sms_nobj, uint64_t, 0, 'i', + "SMS outstanding allocations", + "" +) +VSC_F(sms_nbytes, uint64_t, 0, 'i', + "SMS outstanding bytes", + "" +) +VSC_F(sms_balloc, uint64_t, 0, 'i', + "SMS bytes allocated", + "" +) +VSC_F(sms_bfree, uint64_t, 0, 'i', + "SMS bytes freed", + "" +) -VSC_F(backend_req, uint64_t, 0, 'a', "Backend requests made", "") +VSC_F(backend_req, uint64_t, 0, 'a', + "Backend requests made", + "" +) -VSC_F(n_vcl, uint64_t, 0, 'a', "N vcl total", "") -VSC_F(n_vcl_avail, uint64_t, 0, 'a', "N vcl available", "") -VSC_F(n_vcl_discard, uint64_t, 0, 'a', "N vcl discarded", "") +VSC_F(n_vcl, uint64_t, 0, 'a', + "N vcl total", + "" +) +VSC_F(n_vcl_avail, uint64_t, 0, 'a', + "N vcl available", + "" +) +VSC_F(n_vcl_discard, uint64_t, 0, 'a', + "N vcl discarded", + "" +) /**********************************************************************/ @@ -311,28 +471,65 @@ VSC_F(bans_dups, uint64_t, 0, 'c', /**********************************************************************/ VSC_F(hcb_nolock, uint64_t, 0, 'a', - "HCB Lookups without lock", "") -VSC_F(hcb_lock, uint64_t, 0, 'a', "HCB Lookups with lock", "") -VSC_F(hcb_insert, uint64_t, 0, 'a', "HCB Inserts", "") + "HCB Lookups without lock", + "" +) +VSC_F(hcb_lock, uint64_t, 0, 'a', + "HCB Lookups with lock", + "" +) +VSC_F(hcb_insert, uint64_t, 0, 'a', + "HCB Inserts", + "" +) VSC_F(esi_errors, uint64_t, 0, 'a', - "ESI parse errors (unlock)", "") + "ESI parse errors (unlock)", + "" +) VSC_F(esi_warnings, uint64_t, 0, 'a', - "ESI parse warnings (unlock)", "") -VSC_F(client_drop_late, uint64_t, 0, 'a', "Connection dropped late", "") -VSC_F(uptime, uint64_t, 0, 'a', "Client uptime", "") + "ESI parse warnings (unlock)", + "" +) +VSC_F(client_drop_late, uint64_t, 0, 'a', + "Connection dropped late", + "" +) +VSC_F(uptime, uint64_t, 0, 'a', + "Client uptime", + "" +) -VSC_F(dir_dns_lookups, uint64_t, 0, 'a', "DNS director lookups", "") -VSC_F(dir_dns_failed, uint64_t, 0, 'a', "DNS director failed lookups", "") +VSC_F(dir_dns_lookups, uint64_t, 0, 'a', + "DNS director lookups", + "" +) +VSC_F(dir_dns_failed, uint64_t, 0, 'a', + "DNS director failed lookups", + "" +) VSC_F(dir_dns_hit, uint64_t, 0, 'a', - "DNS director cached lookups hit", "") + "DNS director cached lookups hit", + "" +) VSC_F(dir_dns_cache_full, uint64_t, 0, 'a', - "DNS director full dnscache", "") + "DNS director full dnscache", + "" +) -VSC_F(vmods, uint64_t, 0, 'i', "Loaded VMODs", "") +VSC_F(vmods, uint64_t, 0, 'i', + "Loaded VMODs", + "" +) -VSC_F(n_gzip, uint64_t, 0, 'a', "Gzip operations", "") -VSC_F(n_gunzip, uint64_t, 0, 'a', "Gunzip operations", "") +VSC_F(n_gzip, uint64_t, 0, 'a', + "Gzip operations", + "" +) +VSC_F(n_gunzip, uint64_t, 0, 'a', + "Gunzip operations", + "" +) /**********************************************************************/ From geoff at varnish-cache.org Tue Feb 14 17:30:52 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 18:30:52 +0100 Subject: [experimental-ims] bf5b757 Force this one into the same consistent layout. Message-ID: commit bf5b757b2448ff6f84e2eae5168bd674e9e71677 Author: Poul-Henning Kamp Date: Tue Feb 14 14:27:00 2012 +0000 Force this one into the same consistent layout. diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index 2d83f69..ea70ffb 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -61,10 +61,22 @@ #ifdef VSC_DO_LCK -VSC_F(creat, uint64_t, 0, 'a', "Created locks", "") -VSC_F(destroy, uint64_t, 0, 'a', "Destroyed locks", "") -VSC_F(locks, uint64_t, 0, 'a', "Lock Operations", "") -VSC_F(colls, uint64_t, 0, 'a', "Collisions", "") +VSC_F(creat, uint64_t, 0, 'a', + "Created locks", + "" +) +VSC_F(destroy, uint64_t, 0, 'a', + "Destroyed locks", + "" +) +VSC_F(locks, uint64_t, 0, 'a', + "Lock Operations", + "" +) +VSC_F(colls, uint64_t, 0, 'a', + "Collisions", + "" +) #endif @@ -73,13 +85,34 @@ VSC_F(colls, uint64_t, 0, 'a', "Collisions", "") */ #if defined(VSC_DO_SMA) || defined (VSC_DO_SMF) -VSC_F(c_req, uint64_t, 0, 'a', "Allocator requests", "") -VSC_F(c_fail, uint64_t, 0, 'a', "Allocator failures", "") -VSC_F(c_bytes, uint64_t, 0, 'a', "Bytes allocated", "") -VSC_F(c_freed, uint64_t, 0, 'a', "Bytes freed", "") -VSC_F(g_alloc, uint64_t, 0, 'i', "Allocations outstanding", "") -VSC_F(g_bytes, uint64_t, 0, 'i', "Bytes outstanding", "") -VSC_F(g_space, uint64_t, 0, 'i', "Bytes available", "") +VSC_F(c_req, uint64_t, 0, 'a', + "Allocator requests", + "" +) +VSC_F(c_fail, uint64_t, 0, 'a', + "Allocator failures", + "" +) +VSC_F(c_bytes, uint64_t, 0, 'a', + "Bytes allocated", + "" +) +VSC_F(c_freed, uint64_t, 0, 'a', + "Bytes freed", + "" +) +VSC_F(g_alloc, uint64_t, 0, 'i', + "Allocations outstanding", + "" +) +VSC_F(g_bytes, uint64_t, 0, 'i', + "Bytes outstanding", + "" +) +VSC_F(g_space, uint64_t, 0, 'i', + "Bytes available", + "" +) #endif @@ -92,33 +125,81 @@ VSC_F(g_space, uint64_t, 0, 'i', "Bytes available", "") /**********************************************************************/ #ifdef VSC_DO_SMF -VSC_F(g_smf, uint64_t, 0, 'i', "N struct smf", "") -VSC_F(g_smf_frag, uint64_t, 0, 'i', "N small free smf", "") -VSC_F(g_smf_large, uint64_t, 0, 'i', "N large free smf", "") +VSC_F(g_smf, uint64_t, 0, 'i', + "N struct smf", + "" +) +VSC_F(g_smf_frag, uint64_t, 0, 'i', + "N small free smf", + "" +) +VSC_F(g_smf_large, uint64_t, 0, 'i', + "N large free smf", + "" +) #endif /**********************************************************************/ #ifdef VSC_DO_VBE -VSC_F(vcls, uint64_t, 0, 'i', "VCL references", "") -VSC_F(happy, uint64_t, 0, 'b', "Happy health probes", "") +VSC_F(vcls, uint64_t, 0, 'i', + "VCL references", + "" +) +VSC_F(happy, uint64_t, 0, 'b', + "Happy health probes", + "" +) #endif /**********************************************************************/ #ifdef VSC_DO_MEMPOOL -VSC_F(live, uint64_t, 0, 'g', "In use", "") -VSC_F(pool, uint64_t, 0, 'g', "In Pool", "") -VSC_F(sz_wanted, uint64_t, 0, 'g', "Size requested", "") -VSC_F(sz_needed, uint64_t, 0, 'g', "Size allocated", "") -VSC_F(allocs, uint64_t, 0, 'c', "Allocations", "") -VSC_F(frees, uint64_t, 0, 'c', "Frees", "") -VSC_F(recycle, uint64_t, 0, 'c', "Recycled from pool", "") -VSC_F(timeout, uint64_t, 0, 'c', "Timed out from pool", "") -VSC_F(toosmall, uint64_t, 0, 'c', "Too small to recycle", "") -VSC_F(surplus, uint64_t, 0, 'c', "Too many for pool", "") -VSC_F(randry, uint64_t, 0, 'c', "Pool ran dry", "") +VSC_F(live, uint64_t, 0, 'g', + "In use", + "" +) +VSC_F(pool, uint64_t, 0, 'g', + "In Pool", + "" +) +VSC_F(sz_wanted, uint64_t, 0, 'g', + "Size requested", + "" +) +VSC_F(sz_needed, uint64_t, 0, 'g', + "Size allocated", + "" +) +VSC_F(allocs, uint64_t, 0, 'c', + "Allocations", + "" +) +VSC_F(frees, uint64_t, 0, 'c', + "Frees", + "" +) +VSC_F(recycle, uint64_t, 0, 'c', + "Recycled from pool", + "" +) +VSC_F(timeout, uint64_t, 0, 'c', + "Timed out from pool", + "" +) +VSC_F(toosmall, uint64_t, 0, 'c', + "Too small to recycle", + "" +) +VSC_F(surplus, uint64_t, 0, 'c', + "Too many for pool", + "" +) +VSC_F(randry, uint64_t, 0, 'c', + "Pool ran dry", + "" +) #endif From geoff at varnish-cache.org Tue Feb 14 17:30:52 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 18:30:52 +0100 Subject: [experimental-ims] a434ce4 Honor remove-flag also when processing comments in ESI parsing. Message-ID: commit a434ce46a6362f1dc930d783982a8eda67cb99d6 Author: Martin Blix Grydeland Date: Tue Feb 14 15:02:32 2012 +0100 Honor remove-flag also when processing comments in ESI parsing. Fixes: #1092 diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 433208d..8e9429c 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -706,7 +706,6 @@ VEP_Parse(const struct busyobj *bo, const char *p, size_t l) vep->until_p = vep->until = "-->"; vep->until_s = VEP_NEXTTAG; vep->state = VEP_UNTIL; - vep_mark_verbatim(vep, p); break; } p++; diff --git a/bin/varnishtest/tests/r01092.vtc b/bin/varnishtest/tests/r01092.vtc new file mode 100644 index 0000000..26b0b9c --- /dev/null +++ b/bin/varnishtest/tests/r01092.vtc @@ -0,0 +1,34 @@ +varnishtest "Test case for #1092 - esi:remove and comments" + +server s1 { + rxreq + txresp -body { + + Keep-1 + + + + Remove-1 + + + Remove-4444 + + Keep-4444 + + } +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + set beresp.do_esi = true; + } +} -start -cliok "param.set esi_syntax 4" + +client c1 { + txreq + rxresp + expect resp.bodylen == 80 +} + +client c1 -run +varnish v1 -expect esi_errors == 1 From geoff at varnish-cache.org Tue Feb 14 17:30:52 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Tue, 14 Feb 2012 18:30:52 +0100 Subject: [experimental-ims] 28026e2 Merge master -> experimental-ims Message-ID: commit 28026e2befb7a5de4046bf2dd12269fd3132d3f2 Merge: ee03e4a a434ce4 Author: Geoff Simmons Date: Tue Feb 14 18:29:26 2012 +0100 Merge master -> experimental-ims diff --cc include/tbl/vsc_f_main.h index 4c795e3,36bb629..e8593f0 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@@ -82,69 -82,119 +82,123 @@@ VSC_F(sess_fail, uint64_t, 1, 'c' /*---------------------------------------------------------------------*/ VSC_F(client_req, uint64_t, 1, 'a', - "Client requests received", - "") + "Client requests received", + "" + ) VSC_F(cache_hit, uint64_t, 1, 'a', - "Cache hits", - "Count of cache hits. " - " A cache hit indicates that an object has been delivered to a" - " client without fetching it from a backend server." + "Cache hits", + "Count of cache hits. " + " A cache hit indicates that an object has been delivered to a" + " client without fetching it from a backend server." ) - VSC_F(cache_hitpass, uint64_t, 1, 'a', - "Cache hits for pass", - "Count of hits for pass" - " A cache hit for pass indicates that Varnish is going to" - " pass the request to the backend and this decision has been " - " cached in it self. This counts how many times the cached " - " decision is being used." + VSC_F(cache_hitpass, uint64_t, 1, 'a', + "Cache hits for pass", + "Count of hits for pass" + " A cache hit for pass indicates that Varnish is going to" + " pass the request to the backend and this decision has been " + " cached in it self. This counts how many times the cached " + " decision is being used." ) VSC_F(cache_miss, uint64_t, 1, 'a', - "Cache misses", - "Count of misses" - " A cache miss indicates the object was fetched from the" - " backend before delivering it to the backend.") + "Cache misses", + "Count of misses" + " A cache miss indicates the object was fetched from the" + " backend before delivering it to the backend." + ) - VSC_F(backend_conn, uint64_t, 0, 'a', - "Backend conn. success", - "") + VSC_F(backend_conn, uint64_t, 0, 'a', + "Backend conn. success", + "" + ) VSC_F(backend_unhealthy, uint64_t, 0, 'a', - "Backend conn. not attempted", - "" - ) - VSC_F(backend_busy, uint64_t, 0, 'a', "Backend conn. too many", "") - VSC_F(backend_fail, uint64_t, 0, 'a', "Backend conn. failures", "") - VSC_F(backend_reuse, uint64_t, 0, 'a', - "Backend conn. reuses", - "Count of backend connection reuses" - " This counter is increased whenever we reuse a recycled connection.") - VSC_F(backend_toolate, uint64_t, 0, 'a', "Backend conn. was closed", "") - VSC_F(backend_recycle, uint64_t, 0, 'a', - "Backend conn. recycles", - "Count of backend connection recycles" - " This counter is increased whenever we have a keep-alive" - " connection that is put back into the pool of connections." - " It has not yet been used, but it might be, unless the backend" - " closes it.") - VSC_F(backend_retry, uint64_t, 0, 'a', "Backend conn. retry", "") - - VSC_F(fetch_head, uint64_t, 1, 'a', "Fetch head", "") - VSC_F(fetch_length, uint64_t, 1, 'a', "Fetch with Length", "") - VSC_F(fetch_chunked, uint64_t, 1, 'a', "Fetch chunked", "") - VSC_F(fetch_eof, uint64_t, 1, 'a', "Fetch EOF", "") - VSC_F(fetch_bad, uint64_t, 1, 'a', "Fetch had bad headers", "") - VSC_F(fetch_close, uint64_t, 1, 'a', "Fetch wanted close", "") + "Backend conn. not attempted", + "" + ) + VSC_F(backend_busy, uint64_t, 0, 'a', + "Backend conn. too many", + "" + ) + VSC_F(backend_fail, uint64_t, 0, 'a', + "Backend conn. failures", + "" + ) + VSC_F(backend_reuse, uint64_t, 0, 'a', + "Backend conn. reuses", + "Count of backend connection reuses" + " This counter is increased whenever we reuse a recycled connection." + ) + VSC_F(backend_toolate, uint64_t, 0, 'a', + "Backend conn. was closed", + "" + ) + VSC_F(backend_recycle, uint64_t, 0, 'a', + "Backend conn. recycles", + "Count of backend connection recycles" + " This counter is increased whenever we have a keep-alive" + " connection that is put back into the pool of connections." + " It has not yet been used, but it might be, unless the backend" + " closes it." + ) + VSC_F(backend_retry, uint64_t, 0, 'a', + "Backend conn. retry", + "" + ) + + VSC_F(fetch_head, uint64_t, 1, 'a', + "Fetch head", + "" + ) + VSC_F(fetch_length, uint64_t, 1, 'a', + "Fetch with Length", + "" + ) + VSC_F(fetch_chunked, uint64_t, 1, 'a', + "Fetch chunked", + "" + ) + VSC_F(fetch_eof, uint64_t, 1, 'a', + "Fetch EOF", + "" + ) + VSC_F(fetch_bad, uint64_t, 1, 'a', + "Fetch had bad headers", + "" + ) + VSC_F(fetch_close, uint64_t, 1, 'a', + "Fetch wanted close", + "" + ) VSC_F(fetch_oldhttp, uint64_t, 1, 'a', - "Fetch pre HTTP/1.1 closed", "") - VSC_F(fetch_zero, uint64_t, 1, 'a', "Fetch zero len", "") - VSC_F(fetch_failed, uint64_t, 1, 'a', "Fetch failed", "") - VSC_F(fetch_1xx, uint64_t, 1, 'a', "Fetch no body (1xx)", "") - VSC_F(fetch_204, uint64_t, 1, 'a', "Fetch no body (204)", "") - VSC_F(fetch_304, uint64_t, 1, 'a', "Fetch no body (304)", "") - VSC_F(fetch_not_validated, uint64_t, 1, 'c', "Non-validating responses", - "Count of backend responses to conditional requests with status != 304") + "Fetch pre HTTP/1.1 closed", + "" + ) + VSC_F(fetch_zero, uint64_t, 1, 'a', + "Fetch zero len", + "" + ) + VSC_F(fetch_failed, uint64_t, 1, 'a', + "Fetch failed", + "" + ) + VSC_F(fetch_1xx, uint64_t, 1, 'a', + "Fetch no body (1xx)", + "" + ) + VSC_F(fetch_204, uint64_t, 1, 'a', + "Fetch no body (204)", + "" + ) + VSC_F(fetch_304, uint64_t, 1, 'a', + "Fetch no body (304)", + "" + ) ++VSC_F(fetch_not_validated, uint64_t, 1, 'c', ++ "Non-validating responses", ++ "Count of backend responses to conditional requests with status != 304" ++) /*--------------------------------------------------------------------- * Pools, threads, and sessions From tfheen at varnish-cache.org Wed Feb 15 07:37:15 2012 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 15 Feb 2012 08:37:15 +0100 Subject: [master] 71b981f Use %ju for uintmax_t printf Message-ID: commit 71b981f38663443db9b162caf2b13c2a367c2fd8 Author: Tollef Fog Heen Date: Wed Feb 15 08:37:10 2012 +0100 Use %ju for uintmax_t printf diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 475806d..a5cde62 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -288,7 +288,7 @@ fmt_bytes(struct cli *cli, uintmax_t t) const char *p; if (t & 0xff) { - VCLI_Out(cli, "%zub", t); + VCLI_Out(cli, "%jub", t); return; } for (p = "kMGTPEZY"; *p; p++) { From phk at varnish-cache.org Wed Feb 15 09:19:05 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2012 10:19:05 +0100 Subject: [master] f012e53 Make sure we have debug.sizeof in at least one test-case. Message-ID: commit f012e53da787b6cba1c19aab14ba30bf4612158a Author: Poul-Henning Kamp Date: Wed Feb 15 09:18:20 2012 +0000 Make sure we have debug.sizeof in at least one test-case. diff --git a/bin/varnishtest/tests/b00032.vtc b/bin/varnishtest/tests/b00032.vtc index 949bcfa..ced05bb 100644 --- a/bin/varnishtest/tests/b00032.vtc +++ b/bin/varnishtest/tests/b00032.vtc @@ -1,3 +1,12 @@ varnishtest "CLI coverage test" varnish v1 -cliok storage.list + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend {} -start + +varnish v1 -cliok debug.sizeof From phk at varnish-cache.org Wed Feb 15 09:38:15 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2012 10:38:15 +0100 Subject: [master] af2bfa9 Push struct worker further upwards Message-ID: commit af2bfa9445d385c316f64263b0320eae7a1f9fde Author: Poul-Henning Kamp Date: Wed Feb 15 09:37:57 2012 +0000 Push struct worker further upwards diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 42788c3..62b1202 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -753,7 +753,7 @@ void EXP_Inject(struct objcore *oc, struct lru *lru, double when); void EXP_Init(void); void EXP_Rearm(const struct object *o); int EXP_Touch(struct objcore *oc); -int EXP_NukeOne(struct worker *w, struct lru *lru); +int EXP_NukeOne(struct vsl_log *, struct dstat *, struct lru *lru); /* cache_fetch.c */ struct storage *FetchStorage(struct worker *w, ssize_t sz); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 0d8ffe1..9bdf25f 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -414,7 +414,7 @@ exp_timer(struct sess *sp, void *priv) */ int -EXP_NukeOne(struct worker *wrk, struct lru *lru) +EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru) { struct objcore *oc; @@ -445,8 +445,8 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru) return (-1); /* XXX: bad idea for -spersistent */ - WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(&wrk->stats, oc)); - (void)HSH_Deref(&wrk->stats, oc, NULL); + WSL(vsl, SLT_ExpKill, -1, "%u LRU", oc_getxid(ds, oc)); + (void)HSH_Deref(ds, oc, NULL); return (1); } diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index ae71f6e..50db0db 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -127,7 +127,7 @@ LRU_Free(struct lru *lru) */ static struct stevedore * -stv_pick_stevedore(struct worker *wrk, const char **hint) +stv_pick_stevedore(struct vsl_log *vsl, const char **hint) { struct stevedore *stv; @@ -141,8 +141,7 @@ stv_pick_stevedore(struct worker *wrk, const char **hint) return (stv_transient); /* Hint was not valid, nuke it */ - WSL(wrk->vsl, SLT_Debug, 0, /* XXX VSL_id ?? */ - "Storage hint not usable"); + WSL(vsl, SLT_Debug, -1, "Storage hint not usable"); *hint = NULL; } /* pick a stevedore and bump the head along */ @@ -189,7 +188,7 @@ stv_alloc(struct worker *w, const struct object *obj, size_t size) } /* no luck; try to free some space and keep trying */ - if (EXP_NukeOne(w, stv->lru) == -1) + if (EXP_NukeOne(w->vsl, &w->stats, stv->lru) == -1) break; /* Enough is enough: try another if we have one */ @@ -327,12 +326,12 @@ STV_NewObject(struct worker *wrk, const char *hint, unsigned wsl, ltot = sizeof *o + wsl + lhttp; - stv = stv0 = stv_pick_stevedore(wrk, &hint); + stv = stv0 = stv_pick_stevedore(wrk->vsl, &hint); AN(stv->allocobj); o = stv->allocobj(stv, wrk, ltot, &soc); if (o == NULL && hint == NULL) { do { - stv = stv_pick_stevedore(wrk, &hint); + stv = stv_pick_stevedore(wrk->vsl, &hint); AN(stv->allocobj); o = stv->allocobj(stv, wrk, ltot, &soc); } while (o == NULL && stv != stv0); @@ -340,7 +339,7 @@ STV_NewObject(struct worker *wrk, const char *hint, unsigned wsl, if (o == NULL) { /* no luck; try to free some space and keep trying */ for (i = 0; o == NULL && i < cache_param->nuke_limit; i++) { - if (EXP_NukeOne(wrk, stv->lru) == -1) + if (EXP_NukeOne(wrk->vsl, &wrk->stats, stv->lru) == -1) break; o = stv->allocobj(stv, wrk, ltot, &soc); } From martin at varnish-cache.org Wed Feb 15 10:05:02 2012 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 15 Feb 2012 11:05:02 +0100 Subject: [master] 60490c9 Increase backend_workspace of r01038.vtc from 7k to 8k. Message-ID: commit 60490c97e290e7abce77c0dbad88328604cf273d Author: Martin Blix Grydeland Date: Wed Feb 15 11:03:49 2012 +0100 Increase backend_workspace of r01038.vtc from 7k to 8k. diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc index 983b704..e10152f 100644 --- a/bin/varnishtest/tests/r01038.vtc +++ b/bin/varnishtest/tests/r01038.vtc @@ -45,7 +45,7 @@ server s1 { txresp -body "foo8" } -start -varnish v1 -arg "-p workspace_backend=7k" -vcl+backend { +varnish v1 -arg "-p workspace_backend=8k" -vcl+backend { sub vcl_fetch { set beresp.do_esi = true; } From phk at varnish-cache.org Wed Feb 15 11:02:43 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2012 12:02:43 +0100 Subject: [master] bd9df97 The VGZ api does not need a worker, it just needs a vsl_log Message-ID: commit bd9df9772158d3d7078243e211113551ecbcc292 Author: Poul-Henning Kamp 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); From phk at varnish-cache.org Wed Feb 15 11:02:43 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2012 12:02:43 +0100 Subject: [master] 071f86b Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit 071f86ba851c8022dbd6b0935b025b059257b56c Merge: bd9df97 60490c9 Author: Poul-Henning Kamp Date: Wed Feb 15 11:02:40 2012 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From phk at varnish-cache.org Wed Feb 15 11:44:09 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2012 12:44:09 +0100 Subject: [master] b5f1878 Remove the current "ping-pong" streaming code, it is in the way of the "real streaming" code we are working on. Message-ID: commit b5f187859ccb6b92d06a445ef7f6b17a476149f7 Author: Poul-Henning Kamp Date: Wed Feb 15 11:43:42 2012 +0000 Remove the current "ping-pong" streaming code, it is in the way of the "real streaming" code we are working on. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a76cc45..a9051bc 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -608,15 +608,6 @@ struct req { #define RES_ESI_CHILD (1<<5) #define RES_GUNZIP (1<<6) - /* Stream gunzip instance */ - struct vgz *stream_vgz; - - /* Next byte we will take from storage */ - ssize_t stream_next; - - /* First byte of storage if we free it as we go (pass) */ - ssize_t stream_front; - /* Transaction VSL buffer */ struct vsl_log vsl[1]; @@ -958,9 +949,6 @@ void WSL_Flush(struct vsl_log *, int overflow); /* cache_response.c */ 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(struct worker *); /* cache_vary.c */ struct vsb *VRY_Create(const struct sess *sp, const struct http *hp); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 0be9304..4b0429a 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -194,7 +194,6 @@ DOT ] DOT prepresp -> deliver [style=bold,color=green,label=deliver] DOT prepresp -> deliver [style=bold,color=red] DOT prepresp -> deliver [style=bold,color=blue] -DOT prepresp -> streambody [style=bold,color=cyan,label="deliver"] DOT } * */ @@ -300,12 +299,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) default: WRONG("Illegal action in vcl_deliver{}"); } - if (wrk->busyobj != NULL && wrk->busyobj->do_stream) { - AssertObjCorePassOrBusy(req->obj->objcore); - sp->step = STP_STREAMBODY; - } else { - sp->step = STP_DELIVER; - } + sp->step = STP_DELIVER; return (0); } @@ -858,13 +852,8 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) AssertObjCorePassOrBusy(req->obj->objcore); - if (bo->do_stream) { - sp->step = STP_PREPRESP; - return (0); - } else { - sp->step = STP_FETCHBODY; - return (0); - } + sp->step = STP_FETCHBODY; + return (0); } /*-------------------------------------------------------------------- @@ -925,63 +914,6 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req) } /*-------------------------------------------------------------------- - * Stream the body as we fetch it -DOT subgraph xstreambody { -DOT streambody [ -DOT shape=record -DOT label="{cnt_streambody:|ping_pong\nfetch/deliver}" -DOT ] -DOT } -DOT streambody -> DONE [style=bold,color=cyan] - */ - -static int -cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) -{ - int i; - - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - - RES_StreamStart(sp); - - AssertObjCorePassOrBusy(req->obj->objcore); - - i = FetchBody(wrk, req->obj); - - http_Teardown(wrk->busyobj->bereq); - http_Teardown(wrk->busyobj->beresp); - wrk->busyobj->vfp = NULL; - AZ(wrk->busyobj->vbc); - AN(req->director); - - if (!i && req->obj->objcore != NULL) { - EXP_Insert(req->obj); - AN(req->obj->objcore); - AN(req->obj->objcore->ban); - AZ(req->obj->ws_o->overflow); - HSH_Unbusy(req->obj->objcore); - } else { - req->doclose = "Stream error"; - } - wrk->acct_tmp.fetch++; - req->director = NULL; - req->restarts = 0; - - RES_StreamEnd(sp); - - assert(WRW_IsReleased(wrk)); - (void)HSH_Deref(&wrk->stats, NULL, &req->obj); - VBO_DerefBusyObj(wrk, &wrk->busyobj); - http_Teardown(req->resp); - sp->step = STP_DONE; - return (0); -} - -/*-------------------------------------------------------------------- * A freshly accepted socket * DOT subgraph xcluster_first { diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 2924130..cd01b59 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -126,8 +126,6 @@ vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) st->len += wl; wrk->busyobj->fetch_obj->len += wl; bytes -= wl; - if (wrk->busyobj->do_stream) - RES_StreamPoll(wrk); } return (1); } diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 38c323f..d16d4b1 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -472,8 +472,6 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) if (i != VGZ_OK && i != VGZ_END) return(FetchError(wrk->busyobj, "Gunzip data error")); wrk->busyobj->fetch_obj->len += dl; - if (wrk->busyobj->do_stream) - RES_StreamPoll(wrk); } assert(i == Z_OK || i == Z_STREAM_END); return (1); @@ -554,8 +552,6 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) i = VGZ_Gzip(vg, &dp, &dl, VGZ_NORMAL); assert(i == Z_OK); wrk->busyobj->fetch_obj->len += dl; - if (wrk->busyobj->do_stream) - RES_StreamPoll(wrk); } return (1); } @@ -584,8 +580,6 @@ vfp_gzip_end(struct worker *wrk) i = VGZ_Gzip(vg, &dp, &dl, VGZ_FINISH); wrk->busyobj->fetch_obj->len += dl; } while (i != Z_STREAM_END); - if (wrk->busyobj->do_stream) - RES_StreamPoll(wrk); VGZ_UpdateObj(vg, wrk->busyobj->fetch_obj); if (VGZ_Destroy(&vg) != VGZ_END) return(FetchError(wrk->busyobj, "Gzip error at the very end")); @@ -646,8 +640,6 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) VGZ_Ibuf(vg, st->ptr + st->len, wl); st->len += wl; wrk->busyobj->fetch_obj->len += wl; - if (wrk->busyobj->do_stream) - RES_StreamPoll(wrk); while (!VGZ_IbufEmpty(vg)) { VGZ_Obuf(vg, vg->m_buf, vg->m_sz); diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 125440b..bbb648c 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -305,115 +305,3 @@ RES_WriteObj(struct sess *sp) if (WRW_FlushRelease(sp->wrk) && sp->fd >= 0) SES_Close(sp, "remote closed"); } - -/*--------------------------------------------------------------------*/ - -void -RES_StreamStart(struct sess *sp) -{ - struct req *req; - - req = sp->req; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - - AZ(req->res_mode & RES_ESI_CHILD); - AN(req->wantbody); - AZ(req->stream_vgz); - AZ(req->stream_next); - AZ(req->stream_front); - - WRW_Reserve(sp->wrk, &sp->fd); - - if (req->res_mode & RES_GUNZIP) { - req->stream_vgz = VGZ_NewUngzip(sp->wrk->vsl, "U S -"); - AZ(VGZ_WrwInit(req->stream_vgz)); - http_Unset(req->resp, H_Content_Encoding); - } - - if (!(req->res_mode & RES_CHUNKED) && - sp->wrk->busyobj->h_content_length != NULL) - http_PrintfHeader(sp->req->resp, - "Content-Length: %s", sp->wrk->busyobj->h_content_length); - - sp->wrk->acct_tmp.hdrbytes += - http_Write(sp->wrk, sp->req->resp, 1); - - if (req->res_mode & RES_CHUNKED) - WRW_Chunked(sp->wrk); -} - -void -RES_StreamPoll(struct worker *wrk) -{ - struct storage *st; - struct busyobj *bo; - struct req *req; - ssize_t l, l2; - void *ptr; - - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - bo = wrk->busyobj; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->fetch_obj, OBJECT_MAGIC); - req = wrk->sp->req; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (bo->fetch_obj->len == req->stream_next) - return; - assert(bo->fetch_obj->len > req->stream_next); - l = req->stream_front; - VTAILQ_FOREACH(st, &bo->fetch_obj->store, list) { - if (st->len + l <= req->stream_next) { - l += st->len; - continue; - } - l2 = st->len + l - req->stream_next; - ptr = st->ptr + (req->stream_next - l); - if (wrk->sp->req->res_mode & RES_GUNZIP) - (void)VGZ_WrwGunzip(wrk, req->stream_vgz, ptr, l2); - else - (void)WRW_Write(wrk, ptr, l2); - l += st->len; - req->stream_next += l2; - } - if (!(wrk->sp->req->res_mode & RES_GUNZIP)) - (void)WRW_Flush(wrk); - - if (bo->fetch_obj->objcore == NULL || - (bo->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(&bo->fetch_obj->store); - if (st == NULL || - req->stream_front + st->len > req->stream_next) - break; - VTAILQ_REMOVE(&bo->fetch_obj->store, st, list); - req->stream_front += st->len; - STV_free(st); - } - } -} - -void -RES_StreamEnd(struct sess *sp) -{ - struct req *req; - - req = sp->req; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - - if (req->res_mode & RES_GUNZIP) { - AN(req->stream_vgz); - VGZ_WrwFlush(sp->wrk, req->stream_vgz); - (void)VGZ_Destroy(&req->stream_vgz); - } - if (req->res_mode & RES_CHUNKED && !(req->res_mode & RES_ESI_CHILD)) - WRW_EndChunk(sp->wrk); - if (WRW_FlushRelease(sp->wrk)) - SES_Close(sp, "remote closed"); - req->stream_vgz = NULL; - req->stream_next = 0; - req->stream_front = 0; -} diff --git a/bin/varnishtest/tests.disabled/r00929.vtc b/bin/varnishtest/tests.disabled/r00929.vtc new file mode 100644 index 0000000..3b2f7ca --- /dev/null +++ b/bin/varnishtest/tests.disabled/r00929.vtc @@ -0,0 +1,26 @@ +varnishtest "stream test" + + +server s1 { + rxreq + txresp -bodylen 400 +} -start + +varnish v1 -vcl+backend { + + sub vcl_fetch { + set beresp.do_stream = true; + } + +} -start + +client c1 { + txreq + rxresp + expect resp.bodylen == 400 + txreq + rxresp + expect resp.bodylen == 400 +} -run + + diff --git a/bin/varnishtest/tests.disabled/r00978.vtc b/bin/varnishtest/tests.disabled/r00978.vtc new file mode 100644 index 0000000..39b89cb --- /dev/null +++ b/bin/varnishtest/tests.disabled/r00978.vtc @@ -0,0 +1,40 @@ +varnishtest "r00978.vtc Test esi_level > 0 and do_stream" + +server s1 { + rxreq + expect req.url == "/" + txresp -body { + + Before include + + After include + } + rxreq + expect req.url == "/body1" + txresp -body { + Included file + } +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.esi_level > 0) { + set req.url = req.url + req.esi_level; + } + } + sub vcl_fetch { + if (req.url == "/") { + set beresp.do_esi = true; + } + set beresp.do_stream = true; + } +} -start + +client c1 { + txreq + rxresp + expect resp.bodylen == 65 + expect resp.status == 200 +} -run + +varnish v1 -expect esi_errors == 0 diff --git a/bin/varnishtest/tests.disabled/r00979.vtc b/bin/varnishtest/tests.disabled/r00979.vtc new file mode 100644 index 0000000..bc72efc --- /dev/null +++ b/bin/varnishtest/tests.disabled/r00979.vtc @@ -0,0 +1,29 @@ +varnishtest "r00979.vtc Test restart when do_stream in vcl_deliver" + +server s1 { + rxreq + txresp -status 200 -body "1" + expect_close + + accept + rxreq + txresp -status 200 -body "11" +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + set beresp.do_stream = true; + } + sub vcl_deliver { + if (req.restarts == 0) { + return (restart); + } + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.bodylen == 2 +} -run diff --git a/bin/varnishtest/tests.disabled/r00980.vtc b/bin/varnishtest/tests.disabled/r00980.vtc new file mode 100644 index 0000000..b7d307e --- /dev/null +++ b/bin/varnishtest/tests.disabled/r00980.vtc @@ -0,0 +1,29 @@ +varnishtest "r00980 test gzip on fetch with content_length and do_stream" + +server s1 { + rxreq + expect req.url == "/foobar" + expect req.http.accept-encoding == "gzip" + txresp -bodylen 43 +} -start + +varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend { + + sub vcl_fetch { + set beresp.do_gzip = true; + set beresp.do_stream = true; + } +} -start + +client c1 { + txreq -url /foobar -hdr "Accept-Encoding: gzip" + rxresp + expect resp.http.content-encoding == "gzip" + gunzip + expect resp.bodylen == 43 + + txreq -url /foobar + rxresp + expect resp.http.content-encoding == + expect resp.bodylen == 43 +} -run diff --git a/bin/varnishtest/tests.disabled/t00000.vtc b/bin/varnishtest/tests.disabled/t00000.vtc new file mode 100644 index 0000000..57ab7c7 --- /dev/null +++ b/bin/varnishtest/tests.disabled/t00000.vtc @@ -0,0 +1,48 @@ +varnishtest "Ticket #873" + +server s1 { + rxreq + txresp -nolen -hdr "Transfer-encoding: chunked" + chunked "<1>------------------------<1>\n" + sema r1 sync 2 + chunked "<2>------------------------<2>\n" + sema r2 sync 2 + chunked "<3>------------------------<3>\n" + sema r1 sync 2 + chunked "<4>------------------------<4>\n" + sema r2 sync 2 + chunkedlen 0 +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + set beresp.do_stream = true; + } +} -start + +varnish v1 -cliok "param.set diag_bitmap 1" + +client c1 { + txreq -hdr "foo: /foo" + rxresp -no_obj + + rxchunk + expect resp.chunklen == 31 + sema r1 sync 2 + + rxchunk + expect resp.chunklen == 31 + sema r2 sync 2 + + rxchunk + expect resp.chunklen == 31 + sema r1 sync 2 + + rxchunk + expect resp.chunklen == 31 + sema r2 sync 2 + + rxchunk + expect resp.chunklen == 0 + expect resp.bodylen == 124 +} -run diff --git a/bin/varnishtest/tests.disabled/t00001.vtc b/bin/varnishtest/tests.disabled/t00001.vtc new file mode 100644 index 0000000..2237466 --- /dev/null +++ b/bin/varnishtest/tests.disabled/t00001.vtc @@ -0,0 +1,50 @@ +varnishtest "Test stream/gunzip" + +server s1 { + rxreq + expect req.url == "/bar" + txresp -body "foobar" + + rxreq + expect req.url == "/bla" + expect req.http.accept-encoding == "gzip" + txresp -gzipbody blablabla + + rxreq + expect req.url == "/foo" + txresp -body "snafu" + + rxreq + expect req.url == "/barf" + expect req.http.accept-encoding == "gzip" + txresp -gzipbody Iamoutofnonsensewords + +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + if (req.url == "/foo") { + set beresp.do_gzip = true; + } + if (req.url == "/barf") { + set beresp.do_gunzip = true; + } + set beresp.do_stream = true; + } +} -start + +client c1 { + txreq -url /bar + rxresp + expect resp.http.content-length == 6 + expect resp.bodylen == 6 + txreq -url /bla + rxresp + expect resp.bodylen == 9 + txreq -url /foo + rxresp + expect resp.bodylen == 5 + txreq -url /barf + rxresp + expect resp.bodylen == 21 +} -run diff --git a/bin/varnishtest/tests/r00929.vtc b/bin/varnishtest/tests/r00929.vtc deleted file mode 100644 index 3b2f7ca..0000000 --- a/bin/varnishtest/tests/r00929.vtc +++ /dev/null @@ -1,26 +0,0 @@ -varnishtest "stream test" - - -server s1 { - rxreq - txresp -bodylen 400 -} -start - -varnish v1 -vcl+backend { - - sub vcl_fetch { - set beresp.do_stream = true; - } - -} -start - -client c1 { - txreq - rxresp - expect resp.bodylen == 400 - txreq - rxresp - expect resp.bodylen == 400 -} -run - - diff --git a/bin/varnishtest/tests/r00978.vtc b/bin/varnishtest/tests/r00978.vtc deleted file mode 100644 index 39b89cb..0000000 --- a/bin/varnishtest/tests/r00978.vtc +++ /dev/null @@ -1,40 +0,0 @@ -varnishtest "r00978.vtc Test esi_level > 0 and do_stream" - -server s1 { - rxreq - expect req.url == "/" - txresp -body { - - Before include - - After include - } - rxreq - expect req.url == "/body1" - txresp -body { - Included file - } -} -start - -varnish v1 -vcl+backend { - sub vcl_recv { - if (req.esi_level > 0) { - set req.url = req.url + req.esi_level; - } - } - sub vcl_fetch { - if (req.url == "/") { - set beresp.do_esi = true; - } - set beresp.do_stream = true; - } -} -start - -client c1 { - txreq - rxresp - expect resp.bodylen == 65 - expect resp.status == 200 -} -run - -varnish v1 -expect esi_errors == 0 diff --git a/bin/varnishtest/tests/r00979.vtc b/bin/varnishtest/tests/r00979.vtc deleted file mode 100644 index bc72efc..0000000 --- a/bin/varnishtest/tests/r00979.vtc +++ /dev/null @@ -1,29 +0,0 @@ -varnishtest "r00979.vtc Test restart when do_stream in vcl_deliver" - -server s1 { - rxreq - txresp -status 200 -body "1" - expect_close - - accept - rxreq - txresp -status 200 -body "11" -} -start - -varnish v1 -vcl+backend { - sub vcl_fetch { - set beresp.do_stream = true; - } - sub vcl_deliver { - if (req.restarts == 0) { - return (restart); - } - } -} -start - -client c1 { - txreq - rxresp - expect resp.status == 200 - expect resp.bodylen == 2 -} -run diff --git a/bin/varnishtest/tests/r00980.vtc b/bin/varnishtest/tests/r00980.vtc deleted file mode 100644 index b7d307e..0000000 --- a/bin/varnishtest/tests/r00980.vtc +++ /dev/null @@ -1,29 +0,0 @@ -varnishtest "r00980 test gzip on fetch with content_length and do_stream" - -server s1 { - rxreq - expect req.url == "/foobar" - expect req.http.accept-encoding == "gzip" - txresp -bodylen 43 -} -start - -varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend { - - sub vcl_fetch { - set beresp.do_gzip = true; - set beresp.do_stream = true; - } -} -start - -client c1 { - txreq -url /foobar -hdr "Accept-Encoding: gzip" - rxresp - expect resp.http.content-encoding == "gzip" - gunzip - expect resp.bodylen == 43 - - txreq -url /foobar - rxresp - expect resp.http.content-encoding == - expect resp.bodylen == 43 -} -run diff --git a/bin/varnishtest/tests/t00000.vtc b/bin/varnishtest/tests/t00000.vtc deleted file mode 100644 index 57ab7c7..0000000 --- a/bin/varnishtest/tests/t00000.vtc +++ /dev/null @@ -1,48 +0,0 @@ -varnishtest "Ticket #873" - -server s1 { - rxreq - txresp -nolen -hdr "Transfer-encoding: chunked" - chunked "<1>------------------------<1>\n" - sema r1 sync 2 - chunked "<2>------------------------<2>\n" - sema r2 sync 2 - chunked "<3>------------------------<3>\n" - sema r1 sync 2 - chunked "<4>------------------------<4>\n" - sema r2 sync 2 - chunkedlen 0 -} -start - -varnish v1 -vcl+backend { - sub vcl_fetch { - set beresp.do_stream = true; - } -} -start - -varnish v1 -cliok "param.set diag_bitmap 1" - -client c1 { - txreq -hdr "foo: /foo" - rxresp -no_obj - - rxchunk - expect resp.chunklen == 31 - sema r1 sync 2 - - rxchunk - expect resp.chunklen == 31 - sema r2 sync 2 - - rxchunk - expect resp.chunklen == 31 - sema r1 sync 2 - - rxchunk - expect resp.chunklen == 31 - sema r2 sync 2 - - rxchunk - expect resp.chunklen == 0 - expect resp.bodylen == 124 -} -run diff --git a/bin/varnishtest/tests/t00001.vtc b/bin/varnishtest/tests/t00001.vtc deleted file mode 100644 index 2237466..0000000 --- a/bin/varnishtest/tests/t00001.vtc +++ /dev/null @@ -1,50 +0,0 @@ -varnishtest "Test stream/gunzip" - -server s1 { - rxreq - expect req.url == "/bar" - txresp -body "foobar" - - rxreq - expect req.url == "/bla" - expect req.http.accept-encoding == "gzip" - txresp -gzipbody blablabla - - rxreq - expect req.url == "/foo" - txresp -body "snafu" - - rxreq - expect req.url == "/barf" - expect req.http.accept-encoding == "gzip" - txresp -gzipbody Iamoutofnonsensewords - -} -start - -varnish v1 -vcl+backend { - sub vcl_fetch { - if (req.url == "/foo") { - set beresp.do_gzip = true; - } - if (req.url == "/barf") { - set beresp.do_gunzip = true; - } - set beresp.do_stream = true; - } -} -start - -client c1 { - txreq -url /bar - rxresp - expect resp.http.content-length == 6 - expect resp.bodylen == 6 - txreq -url /bla - rxresp - expect resp.bodylen == 9 - txreq -url /foo - rxresp - expect resp.bodylen == 5 - txreq -url /barf - rxresp - expect resp.bodylen == 21 -} -run diff --git a/include/tbl/steps.h b/include/tbl/steps.h index 1e95529..e6738cb 100644 --- a/include/tbl/steps.h +++ b/include/tbl/steps.h @@ -41,7 +41,6 @@ STEP(hit, HIT, (sp, sp->wrk, sp->req)) STEP(fetch, FETCH, (sp, sp->wrk, sp->req)) STEP(prepfetch, PREPFETCH, (sp, sp->wrk, sp->req)) STEP(fetchbody, FETCHBODY, (sp, sp->wrk, sp->req)) -STEP(streambody, STREAMBODY, (sp, sp->wrk, sp->req)) STEP(prepresp, PREPRESP, (sp, sp->wrk, sp->req)) STEP(deliver, DELIVER, (sp, sp->wrk, sp->req)) STEP(error, ERROR, (sp, sp->wrk, sp->req)) From phk at varnish-cache.org Wed Feb 15 12:32:47 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2012 13:32:47 +0100 Subject: [master] 7703a5f Lend busyobj the workers dstat for the duration of Fetch_Body() Message-ID: commit 7703a5f82679f56e82cdff7a6f98dfb27dbdae31 Author: Poul-Henning Kamp Date: Wed Feb 15 12:32:28 2012 +0000 Lend busyobj the workers dstat for the duration of Fetch_Body() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a9051bc..f2f64d3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -494,6 +494,7 @@ struct busyobj { double between_bytes_timeout; struct vsl_log vsl[1]; + struct dstat *stats; }; /* Object structure --------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index cd01b59..928ecc4 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -506,6 +506,13 @@ FetchBody(struct worker *wrk, struct object *obj) CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(obj->http, HTTP_MAGIC); + /* + * XXX: The busyobj needs a dstat, but it is not obvious which one + * XXX: it should be (own/borrowed). For now borrow the wrk's. + */ + AZ(bo->stats); + bo->stats = &wrk->stats; + htc = &bo->htc; if (bo->vfp == NULL) @@ -578,6 +585,7 @@ FetchBody(struct worker *wrk, struct object *obj) if (bo->body_status == BS_ERROR) { VDI_CloseFd(wrk, &bo->vbc); + bo->stats = NULL; return (__LINE__); } @@ -585,6 +593,7 @@ FetchBody(struct worker *wrk, struct object *obj) wrk->stats.fetch_failed++; VDI_CloseFd(wrk, &bo->vbc); obj->len = 0; + bo->stats = NULL; return (__LINE__); } AZ(bo->fetch_failed); @@ -619,6 +628,7 @@ FetchBody(struct worker *wrk, struct object *obj) else VDI_RecycleFd(wrk, &bo->vbc); + bo->stats = NULL; return (0); } From phk at varnish-cache.org Wed Feb 15 12:49:52 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2012 13:49:52 +0100 Subject: [master] d387098 Make FetchStorage() take a busyobj instead of a worker as arg. Message-ID: commit d387098f00fabf8965ac47f1313cf63ac4d16a46 Author: Poul-Henning Kamp Date: Wed Feb 15 12:49:25 2012 +0000 Make FetchStorage() take a busyobj instead of a worker as arg. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f2f64d3..74a8b5d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -745,10 +745,10 @@ void EXP_Inject(struct objcore *oc, struct lru *lru, double when); void EXP_Init(void); void EXP_Rearm(const struct object *o); int EXP_Touch(struct objcore *oc); -int EXP_NukeOne(struct vsl_log *, struct dstat *, struct lru *lru); +int EXP_NukeOne(struct busyobj *, struct lru *lru); /* cache_fetch.c */ -struct storage *FetchStorage(struct worker *w, ssize_t sz); +struct storage *FetchStorage(struct busyobj *, ssize_t sz); int FetchError(struct busyobj *, const char *error); int FetchError2(struct busyobj *, const char *error, const char *more); int FetchHdr(struct sess *sp, int need_host_hdr, int sendbody); @@ -1013,7 +1013,7 @@ int RFC2616_Do_Cond(const struct sess *sp); /* stevedore.c */ struct object *STV_NewObject(struct worker *wrk, const char *hint, unsigned len, uint16_t nhttp); -struct storage *STV_alloc(struct worker *w, size_t size); +struct storage *STV_alloc(struct busyobj *, size_t size); void STV_trim(struct storage *st, size_t size); void STV_free(struct storage *st); void STV_open(void); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index c3ca15e..c16568a 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -94,7 +94,7 @@ vfp_esi_bytes_uu(struct worker *wrk, const struct vef_priv *vef, CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); while (bytes > 0) { - st = FetchStorage(wrk, 0); + st = FetchStorage(wrk->busyobj, 0); if (st == NULL) return (-1); wl = vef_read(htc, @@ -396,7 +396,7 @@ vfp_esi_end(struct worker *wrk) l = VSB_len(vsb); assert(l > 0); /* XXX: This is a huge waste of storage... */ - bo->fetch_obj->esidata = STV_alloc(wrk, l); + bo->fetch_obj->esidata = STV_alloc(bo, l); if (bo->fetch_obj->esidata != NULL) { memcpy(bo->fetch_obj->esidata->ptr, VSB_data(vsb), l); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 9bdf25f..060ed58 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -414,7 +414,7 @@ exp_timer(struct sess *sp, void *priv) */ int -EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru) +EXP_NukeOne(struct busyobj *bo, struct lru *lru) { struct objcore *oc; @@ -445,8 +445,8 @@ EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru) return (-1); /* XXX: bad idea for -spersistent */ - WSL(vsl, SLT_ExpKill, -1, "%u LRU", oc_getxid(ds, oc)); - (void)HSH_Deref(ds, oc, NULL); + WSL(bo->vsl, SLT_ExpKill, -1, "%u LRU", oc_getxid(bo->stats, oc)); + (void)HSH_Deref(bo->stats, oc, NULL); return (1); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 928ecc4..e520e6d 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -92,7 +92,7 @@ vfp_nop_begin(struct worker *wrk, size_t estimate) { if (estimate > 0) - (void)FetchStorage(wrk, estimate); + (void)FetchStorage(wrk->busyobj, estimate); } /*-------------------------------------------------------------------- @@ -114,7 +114,7 @@ vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) AZ(wrk->busyobj->fetch_failed); while (bytes > 0) { - st = FetchStorage(wrk, 0); + st = FetchStorage(wrk->busyobj, 0); if (st == NULL) return(-1); l = st->space - st->len; @@ -170,13 +170,14 @@ static struct vfp vfp_nop = { */ struct storage * -FetchStorage(struct worker *wrk, ssize_t sz) +FetchStorage(struct busyobj *bo, ssize_t sz) { ssize_t l; struct storage *st; struct object *obj; - obj = wrk->busyobj->fetch_obj; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + obj = bo->fetch_obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); st = VTAILQ_LAST(&obj->store, storagehead); if (st != NULL && st->len < st->space) @@ -187,9 +188,9 @@ FetchStorage(struct worker *wrk, ssize_t sz) l = sz; if (l == 0) l = cache_param->fetch_chunksize; - st = STV_alloc(wrk, l); + st = STV_alloc(bo, l); if (st == NULL) { - (void)FetchError(wrk->busyobj, "Could not get storage"); + (void)FetchError(bo, "Could not get storage"); return (NULL); } AZ(st->len); @@ -507,7 +508,7 @@ FetchBody(struct worker *wrk, struct object *obj) CHECK_OBJ_NOTNULL(obj->http, HTTP_MAGIC); /* - * XXX: The busyobj needs a dstat, but it is not obvious which one + * XXX: The busyobj needs a dstat, but it is not obvious which one * XXX: it should be (own/borrowed). For now borrow the wrk's. */ AZ(bo->stats); diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index d16d4b1..c2764b5 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -207,7 +207,7 @@ VGZ_ObufStorage(struct worker *wrk, struct vgz *vg) { struct storage *st; - st = FetchStorage(wrk, 0); + st = FetchStorage(wrk->busyobj, 0); if (st == NULL) return (-1); @@ -627,7 +627,7 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); AZ(vg->vz.avail_in); while (bytes > 0) { - st = FetchStorage(wrk, 0); + st = FetchStorage(wrk->busyobj, 0); if (st == NULL) return(-1); l = st->space - st->len; diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 50db0db..2fce063 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -157,18 +157,20 @@ stv_pick_stevedore(struct vsl_log *vsl, const char **hint) /*-------------------------------------------------------------------*/ static struct storage * -stv_alloc(struct worker *w, const struct object *obj, size_t size) +stv_alloc(struct busyobj *bo, size_t size) { struct storage *st; struct stevedore *stv; unsigned fail = 0; + struct object *obj; /* * Always use the stevedore which allocated the object in order to * keep an object inside the same stevedore. */ + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + obj = bo->fetch_obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - CHECK_OBJ_NOTNULL(w, WORKER_MAGIC); stv = obj->objstore->stevedore; CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); @@ -188,7 +190,7 @@ stv_alloc(struct worker *w, const struct object *obj, size_t size) } /* no luck; try to free some space and keep trying */ - if (EXP_NukeOne(w->vsl, &w->stats, stv->lru) == -1) + if (EXP_NukeOne(bo, stv->lru) == -1) break; /* Enough is enough: try another if we have one */ @@ -337,12 +339,16 @@ STV_NewObject(struct worker *wrk, const char *hint, unsigned wsl, } while (o == NULL && stv != stv0); } if (o == NULL) { + /* XXX: lend busyobj wrk's stats while we nuke */ + AZ(wrk->busyobj->stats); + wrk->busyobj->stats = &wrk->stats; /* no luck; try to free some space and keep trying */ for (i = 0; o == NULL && i < cache_param->nuke_limit; i++) { - if (EXP_NukeOne(wrk->vsl, &wrk->stats, stv->lru) == -1) + if (EXP_NukeOne(wrk->busyobj, stv->lru) == -1) break; o = stv->allocobj(stv, wrk, ltot, &soc); } + wrk->busyobj->stats = NULL; } if (o == NULL) @@ -373,10 +379,10 @@ STV_Freestore(struct object *o) /*-------------------------------------------------------------------*/ struct storage * -STV_alloc(struct worker *w, size_t size) +STV_alloc(struct busyobj *bo, size_t size) { - return (stv_alloc(w, w->busyobj->fetch_obj, size)); + return (stv_alloc(bo, size)); } void From phk at varnish-cache.org Wed Feb 15 12:58:01 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2012 13:58:01 +0100 Subject: [master] 5d4e2ce Move VGZ entirely to busyobj instead of worker Message-ID: commit 5d4e2cee84c088e52f4c79b11a11c305b4d49526 Author: Poul-Henning Kamp Date: Wed Feb 15 12:57:48 2012 +0000 Move VGZ entirely to busyobj instead of worker diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 74a8b5d..a47edf1 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -766,7 +766,7 @@ 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); int VGZ_ObufFull(const struct vgz *vg); -int VGZ_ObufStorage(struct worker *w, struct vgz *vg); +int VGZ_ObufStorage(struct busyobj *, 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 **); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index c16568a..a53ccc7 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -135,7 +135,7 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, VGZ_Ibuf(vg, vef->ibuf, wl); bytes -= wl; } - if (VGZ_ObufStorage(wrk, vg)) + if (VGZ_ObufStorage(wrk->busyobj, vg)) return(-1); i = VGZ_Gunzip(vg, &dp, &dl); xxxassert(i == VGZ_OK || i == VGZ_END); @@ -211,7 +211,7 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) VGZ_Ibuf(vef->vgz, vef->ibuf_o, l); do { - if (VGZ_ObufStorage(wrk, vef->vgz)) { + if (VGZ_ObufStorage(wrk->busyobj, vef->vgz)) { vef->error = ENOMEM; vef->tot += l; return (vef->tot); diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index c2764b5..1dd7942 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -203,11 +203,11 @@ VGZ_ObufFull(const struct vgz *vg) */ int -VGZ_ObufStorage(struct worker *wrk, struct vgz *vg) +VGZ_ObufStorage(struct busyobj *bo, struct vgz *vg) { struct storage *st; - st = FetchStorage(wrk->busyobj, 0); + st = FetchStorage(bo, 0); if (st == NULL) return (-1); @@ -466,7 +466,7 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) bytes -= wl; } - if (VGZ_ObufStorage(wrk, vg)) + if (VGZ_ObufStorage(wrk->busyobj, vg)) return(-1); i = VGZ_Gunzip(vg, &dp, &dl); if (i != VGZ_OK && i != VGZ_END) @@ -547,7 +547,7 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) VGZ_Ibuf(vg, vg->m_buf, wl); bytes -= wl; } - if (VGZ_ObufStorage(wrk, vg)) + if (VGZ_ObufStorage(wrk->busyobj, vg)) return(-1); i = VGZ_Gzip(vg, &dp, &dl, VGZ_NORMAL); assert(i == Z_OK); @@ -575,7 +575,7 @@ vfp_gzip_end(struct worker *wrk) } do { VGZ_Ibuf(vg, "", 0); - if (VGZ_ObufStorage(wrk, vg)) + if (VGZ_ObufStorage(wrk->busyobj, vg)) return(-1); i = VGZ_Gzip(vg, &dp, &dl, VGZ_FINISH); wrk->busyobj->fetch_obj->len += dl; From phk at varnish-cache.org Wed Feb 15 13:13:35 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2012 14:13:35 +0100 Subject: [master] 4076126 Push worker->busyobj change up through ESI Message-ID: commit 40761260036de1c36a19d0b56776bee945e742bf Author: Poul-Henning Kamp Date: Wed Feb 15 13:13:17 2012 +0000 Push worker->busyobj change up through ESI diff --git a/bin/varnishd/cache/cache_esi.h b/bin/varnishd/cache/cache_esi.h index bcc815b..c6c2376 100644 --- a/bin/varnishd/cache/cache_esi.h +++ b/bin/varnishd/cache/cache_esi.h @@ -39,10 +39,10 @@ #define VEC_S8 (0x60 + 8) #define VEC_INCL 'I' -typedef ssize_t vep_callback_t(struct worker *w, ssize_t l, enum vgz_flag flg); +typedef ssize_t vep_callback_t(struct busyobj *, ssize_t l, enum vgz_flag flg); -void VEP_Init(struct worker *w, vep_callback_t *cb); +void VEP_Init(struct busyobj *, vep_callback_t *cb); void VEP_Parse(const struct busyobj *, const char *p, size_t l); -struct vsb *VEP_Finish(const struct worker *w); +struct vsb *VEP_Finish(struct busyobj *); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index a53ccc7..6b57011 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -84,26 +84,26 @@ vef_read(struct http_conn *htc, void *buf, ssize_t buflen, */ static int -vfp_esi_bytes_uu(struct worker *wrk, const struct vef_priv *vef, +vfp_esi_bytes_uu(struct busyobj *bo, const struct vef_priv *vef, struct http_conn *htc, ssize_t bytes) { ssize_t wl; struct storage *st; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); while (bytes > 0) { - st = FetchStorage(wrk->busyobj, 0); + st = FetchStorage(bo, 0); if (st == NULL) return (-1); wl = vef_read(htc, st->ptr + st->len, st->space - st->len, bytes); if (wl <= 0) return (wl); - VEP_Parse(wrk->busyobj, (const char *)st->ptr + st->len, wl); + VEP_Parse(bo, (const char *)st->ptr + st->len, wl); st->len += wl; - wrk->busyobj->fetch_obj->len += wl; + bo->fetch_obj->len += wl; bytes -= wl; } return (1); @@ -114,7 +114,7 @@ vfp_esi_bytes_uu(struct worker *wrk, const struct vef_priv *vef, */ static int -vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, +vfp_esi_bytes_gu(struct busyobj *bo, const struct vef_priv *vef, struct http_conn *htc, ssize_t bytes) { struct vgz *vg; @@ -123,9 +123,9 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, size_t dl; const void *dp; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - vg = wrk->busyobj->vgz_rx; + vg = bo->vgz_rx; while (bytes > 0) { if (VGZ_IbufEmpty(vg) && bytes > 0) { @@ -135,12 +135,12 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, VGZ_Ibuf(vg, vef->ibuf, wl); bytes -= wl; } - if (VGZ_ObufStorage(wrk->busyobj, vg)) + if (VGZ_ObufStorage(bo, vg)) return(-1); i = VGZ_Gunzip(vg, &dp, &dl); xxxassert(i == VGZ_OK || i == VGZ_END); - VEP_Parse(wrk->busyobj, dp, dl); - wrk->busyobj->fetch_obj->len += dl; + VEP_Parse(bo, dp, dl); + bo->fetch_obj->len += dl; } return (1); } @@ -161,13 +161,13 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, */ static int -vfp_vep_inject(const struct worker *wrk, struct vef_priv *vef, ssize_t wl) +vfp_vep_inject(const struct busyobj *bo, struct vef_priv *vef, ssize_t wl) { - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - VEP_Parse(wrk->busyobj, vef->ibuf_i, wl); + VEP_Parse(bo, vef->ibuf_i, wl); vef->ibuf_i += wl; assert(vef->ibuf_o >= vef->ibuf && vef->ibuf_o <= vef->ibuf_i); if (vef->error) { @@ -183,16 +183,15 @@ vfp_vep_inject(const struct worker *wrk, struct vef_priv *vef, ssize_t wl) } static ssize_t -vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) +vfp_vep_callback(struct busyobj *bo, ssize_t l, enum vgz_flag flg) { struct vef_priv *vef; size_t dl; const void *dp; int i; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vef = wrk->busyobj->vef_priv; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vef = bo->vef_priv; CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); assert(l >= 0); @@ -211,14 +210,14 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) VGZ_Ibuf(vef->vgz, vef->ibuf_o, l); do { - if (VGZ_ObufStorage(wrk->busyobj, vef->vgz)) { + if (VGZ_ObufStorage(bo, vef->vgz)) { vef->error = ENOMEM; vef->tot += l; return (vef->tot); } i = VGZ_Gzip(vef->vgz, &dp, &dl, flg); vef->tot += dl; - wrk->busyobj->fetch_obj->len += dl; + bo->fetch_obj->len += dl; } while (!VGZ_IbufEmpty(vef->vgz) || (flg != VGZ_NORMAL && VGZ_ObufFull(vef->vgz))); assert(VGZ_IbufEmpty(vef->vgz)); @@ -235,14 +234,13 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) */ static int -vfp_esi_bytes_ug(const struct worker *wrk, struct vef_priv *vef, +vfp_esi_bytes_ug(const struct busyobj *bo, struct vef_priv *vef, struct http_conn *htc, ssize_t bytes) { ssize_t wl; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); while (bytes > 0) { wl = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf); @@ -250,7 +248,7 @@ vfp_esi_bytes_ug(const struct worker *wrk, struct vef_priv *vef, if (wl <= 0) return (wl); bytes -= wl; - if (vfp_vep_inject(wrk, vef, wl)) + if (vfp_vep_inject(bo, vef, wl)) return (-1); } return (1); @@ -261,7 +259,7 @@ vfp_esi_bytes_ug(const struct worker *wrk, struct vef_priv *vef, */ static int -vfp_esi_bytes_gg(const struct worker *wrk, struct vef_priv *vef, +vfp_esi_bytes_gg(const struct busyobj *bo, struct vef_priv *vef, struct http_conn *htc, size_t bytes) { ssize_t wl; @@ -269,9 +267,8 @@ vfp_esi_bytes_gg(const struct worker *wrk, struct vef_priv *vef, const void *dp; int i; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); while (bytes > 0) { wl = vef_read(htc, vef->ibuf2, vef->ibuf2_sz, bytes); @@ -279,16 +276,16 @@ vfp_esi_bytes_gg(const struct worker *wrk, struct vef_priv *vef, return (wl); bytes -= wl; - VGZ_Ibuf(wrk->busyobj->vgz_rx, vef->ibuf2, wl); + VGZ_Ibuf(bo->vgz_rx, vef->ibuf2, wl); do { wl = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf); - VGZ_Obuf(wrk->busyobj->vgz_rx, vef->ibuf_i, wl); - i = VGZ_Gunzip(wrk->busyobj->vgz_rx, &dp, &dl); + VGZ_Obuf(bo->vgz_rx, vef->ibuf_i, wl); + i = VGZ_Gunzip(bo->vgz_rx, &dp, &dl); /* XXX: check i */ assert(i >= VGZ_OK); - if (dl > 0 && vfp_vep_inject(wrk, vef, dl)) + if (dl > 0 && vfp_vep_inject(bo, vef, dl)) return (-1); - } while (!VGZ_IbufEmpty(wrk->busyobj->vgz_rx)); + } while (!VGZ_IbufEmpty(bo->vgz_rx)); } return (1); } @@ -314,20 +311,20 @@ 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->vsl, "U F E"); - VEP_Init(wrk, NULL); + VEP_Init(bo, NULL); vef->ibuf_sz = cache_param->gzip_buffer; } else if (bo->is_gunzip && bo->do_gzip) { vef->vgz = VGZ_NewGzip(wrk->vsl, "G F E"); - VEP_Init(wrk, vfp_vep_callback); + VEP_Init(bo, vfp_vep_callback); vef->ibuf_sz = cache_param->gzip_buffer; } else if (bo->is_gzip) { 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); + VEP_Init(bo, vfp_vep_callback); vef->ibuf_sz = cache_param->gzip_buffer; vef->ibuf2_sz = cache_param->gzip_buffer; } else { - VEP_Init(wrk, NULL); + VEP_Init(bo, NULL); } if (vef->ibuf_sz > 0) { vef->ibuf = calloc(1L, vef->ibuf_sz); @@ -359,13 +356,13 @@ vfp_esi_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) AN(bo->vep); assert(&bo->htc == htc); if (bo->is_gzip && bo->do_gunzip) - i = vfp_esi_bytes_gu(wrk, vef, htc, bytes); + i = vfp_esi_bytes_gu(bo, vef, htc, bytes); else if (bo->is_gunzip && bo->do_gzip) - i = vfp_esi_bytes_ug(wrk, vef, htc, bytes); + i = vfp_esi_bytes_ug(bo, vef, htc, bytes); else if (bo->is_gzip) - i = vfp_esi_bytes_gg(wrk, vef, htc, bytes); + i = vfp_esi_bytes_gg(bo, vef, htc, bytes); else - i = vfp_esi_bytes_uu(wrk, vef, htc, bytes); + i = vfp_esi_bytes_uu(bo, vef, htc, bytes); AN(bo->vep); return (i); } @@ -389,7 +386,7 @@ vfp_esi_end(struct worker *wrk) 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); + vsb = VEP_Finish(bo); if (vsb != NULL) { if (!retval) { diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 8e9429c..053f614 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -60,7 +60,6 @@ struct vep_state { #define VEP_MAGIC 0x55cb9b82 struct vsb *vsb; - struct worker *wrk; struct busyobj *bo; int dogzip; vep_callback_t *cb; @@ -329,7 +328,7 @@ vep_mark_common(struct vep_state *vep, const char *p, enum vep_mark mark) */ if (vep->last_mark != mark && (vep->o_wait > 0 || vep->startup)) { - lcb = vep->cb(vep->wrk, 0, + lcb = vep->cb(vep->bo, 0, mark == VERBATIM ? VGZ_RESET : VGZ_ALIGN); if (lcb - vep->o_last > 0) vep_emit_common(vep, lcb - vep->o_last, vep->last_mark); @@ -339,7 +338,7 @@ vep_mark_common(struct vep_state *vep, const char *p, enum vep_mark mark) /* Transfer pending bytes CRC into active mode CRC */ if (vep->o_pending) { - (void)vep->cb(vep->wrk, vep->o_pending, VGZ_NORMAL); + (void)vep->cb(vep->bo, vep->o_pending, VGZ_NORMAL); if (vep->o_crc == 0) { vep->crc = vep->crcp; vep->o_crc = vep->o_pending; @@ -363,7 +362,7 @@ vep_mark_common(struct vep_state *vep, const char *p, enum vep_mark mark) vep->o_wait += l; vep->last_mark = mark; - (void)vep->cb(vep->wrk, l, VGZ_NORMAL); + (void)vep->cb(vep->bo, l, VGZ_NORMAL); } static void @@ -500,7 +499,7 @@ vep_do_include(struct vep_state *vep, enum dowhat what) VSB_printf(vep->vsb, "%c", 0); } else { VSB_printf(vep->vsb, "%c", 0); - url = vep->wrk->busyobj->bereq->hd[HTTP_HDR_URL]; + url = vep->bo->bereq->hd[HTTP_HDR_URL]; /* Look for the last / before a '?' */ h = NULL; for (q = url.b; q < url.e && *q != '?'; q++) @@ -979,14 +978,14 @@ VEP_Parse(const struct busyobj *bo, const char *p, size_t l) */ static ssize_t __match_proto__() -vep_default_cb(struct worker *wrk, ssize_t l, enum vgz_flag flg) +vep_default_cb(struct busyobj *bo, ssize_t l, enum vgz_flag flg) { struct vep_state *vep; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vep = wrk->busyobj->vep; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vep = bo->vep; CHECK_OBJ_NOTNULL(vep, VEP_MAGIC); + assert(vep->bo == bo); (void)flg; vep->cb_x += l; return (vep->cb_x); @@ -996,23 +995,21 @@ vep_default_cb(struct worker *wrk, ssize_t l, enum vgz_flag flg) */ void -VEP_Init(struct worker *wrk, vep_callback_t *cb) +VEP_Init(struct busyobj *bo, vep_callback_t *cb) { struct vep_state *vep; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - AZ(wrk->busyobj->vep); - vep = (void*)WS_Alloc(wrk->busyobj->ws, sizeof *vep); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AZ(bo->vep); + vep = (void*)WS_Alloc(bo->ws, sizeof *vep); AN(vep); memset(vep, 0, sizeof *vep); vep->magic = VEP_MAGIC; - vep->wrk = wrk; - vep->bo = wrk->busyobj; + vep->bo = bo; vep->vsb = VSB_new_auto(); AN(vep->vsb); - wrk->busyobj->vep = vep; + bo->vep = vep; if (cb != NULL) { vep->dogzip = 1; @@ -1043,25 +1040,25 @@ VEP_Init(struct worker *wrk, vep_callback_t *cb) */ struct vsb * -VEP_Finish(const struct worker *wrk) +VEP_Finish(struct busyobj *bo) { struct vep_state *vep; ssize_t l, lcb; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vep = wrk->busyobj->vep; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vep = bo->vep; CHECK_OBJ_NOTNULL(vep, VEP_MAGIC); + assert(vep->bo == bo); if (vep->o_pending) vep_mark_common(vep, vep->ver_p, vep->last_mark); if (vep->o_wait > 0) { - lcb = vep->cb(vep->wrk, 0, VGZ_ALIGN); + lcb = vep->cb(vep->bo, 0, VGZ_ALIGN); vep_emit_common(vep, lcb - vep->o_last, vep->last_mark); } - (void)vep->cb(vep->wrk, 0, VGZ_FINISH); + (void)vep->cb(vep->bo, 0, VGZ_FINISH); - wrk->busyobj->vep = NULL; + bo->vep = NULL; AZ(VSB_finish(vep->vsb)); l = VSB_len(vep->vsb); if (vep->esi_found && l > 0) From phk at varnish-cache.org Wed Feb 15 13:29:47 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2012 14:29:47 +0100 Subject: [master] 9b65ebc Push worker->busyobj shift up through VFP's. Message-ID: commit 9b65ebca918039344ec7450c4de580a59547f4b6 Author: Poul-Henning Kamp Date: Wed Feb 15 13:29:31 2012 +0000 Push worker->busyobj shift up through VFP's. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a47edf1..daa01f4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -219,9 +219,9 @@ struct dstat { /* Fetch processors --------------------------------------------------*/ -typedef void vfp_begin_f(struct worker *, size_t ); -typedef int vfp_bytes_f(struct worker *, struct http_conn *, ssize_t); -typedef int vfp_end_f(struct worker *); +typedef void vfp_begin_f(struct busyobj *, size_t ); +typedef int vfp_bytes_f(struct busyobj *, struct http_conn *, ssize_t); +typedef int vfp_end_f(struct busyobj *); struct vfp { vfp_begin_f *begin; diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 6b57011..14ca31b 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -292,15 +292,12 @@ vfp_esi_bytes_gg(const struct busyobj *bo, struct vef_priv *vef, /*---------------------------------------------------------------------*/ -static void __match_proto__() -vfp_esi_begin(struct worker *wrk, size_t estimate) +static void __match_proto__(vfp_begin_f) +vfp_esi_begin(struct busyobj *bo, size_t estimate) { - struct busyobj *bo; struct vef_priv *vef; (void)estimate; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - bo = wrk->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); ALLOC_OBJ(vef, VEF_MAGIC); @@ -310,16 +307,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->vsl, "U F E"); + bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "U F E"); VEP_Init(bo, NULL); vef->ibuf_sz = cache_param->gzip_buffer; } else if (bo->is_gunzip && bo->do_gzip) { - vef->vgz = VGZ_NewGzip(wrk->vsl, "G F E"); + vef->vgz = VGZ_NewGzip(bo->vsl, "G F E"); VEP_Init(bo, vfp_vep_callback); vef->ibuf_sz = cache_param->gzip_buffer; } else if (bo->is_gzip) { - bo->vgz_rx = VGZ_NewUngzip(wrk->vsl, "U F E"); - vef->vgz = VGZ_NewGzip(wrk->vsl, "G F E"); + bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "U F E"); + vef->vgz = VGZ_NewGzip(bo->vsl, "G F E"); VEP_Init(bo, vfp_vep_callback); vef->ibuf_sz = cache_param->gzip_buffer; vef->ibuf2_sz = cache_param->gzip_buffer; @@ -339,15 +336,12 @@ vfp_esi_begin(struct worker *wrk, size_t estimate) AN(bo->vep); } -static int __match_proto__() -vfp_esi_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +static int __match_proto__(vfp_bytes_f) +vfp_esi_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) { - struct busyobj *bo; struct vef_priv *vef; int i; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - bo = wrk->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); vef = bo->vef_priv; CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); @@ -367,17 +361,14 @@ vfp_esi_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) return (i); } -static int __match_proto__() -vfp_esi_end(struct worker *wrk) +static int __match_proto__(vfp_end_f) +vfp_esi_end(struct busyobj *bo) { struct vsb *vsb; struct vef_priv *vef; - struct busyobj *bo; ssize_t l; int retval; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - bo = wrk->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AN(bo->vep); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index e520e6d..372ce08 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -87,12 +87,12 @@ FetchError(struct busyobj *bo, const char *error) * 'estimate' is the estimate of the number of bytes we expect to receive, * as seen on the socket, or zero if unknown. */ -static void __match_proto__() -vfp_nop_begin(struct worker *wrk, size_t estimate) +static void __match_proto__(vfp_begin_f) +vfp_nop_begin(struct busyobj *bo, size_t estimate) { if (estimate > 0) - (void)FetchStorage(wrk->busyobj, estimate); + (void)FetchStorage(bo, estimate); } /*-------------------------------------------------------------------- @@ -106,15 +106,15 @@ vfp_nop_begin(struct worker *wrk, size_t estimate) * Return 1 when 'bytes' have been processed. */ -static int __match_proto__() -vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +static int __match_proto__(vfp_bytes_f) +vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) { ssize_t l, wl; struct storage *st; - AZ(wrk->busyobj->fetch_failed); + AZ(bo->fetch_failed); while (bytes > 0) { - st = FetchStorage(wrk->busyobj, 0); + st = FetchStorage(bo, 0); if (st == NULL) return(-1); l = st->space - st->len; @@ -124,7 +124,7 @@ vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) if (wl <= 0) return (wl); st->len += wl; - wrk->busyobj->fetch_obj->len += wl; + bo->fetch_obj->len += wl; bytes -= wl; } return (1); @@ -139,17 +139,17 @@ vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) * Return 0 for OK */ -static int __match_proto__() -vfp_nop_end(struct worker *wrk) +static int __match_proto__(vfp_end_f) +vfp_nop_end(struct busyobj *bo) { struct storage *st; - st = VTAILQ_LAST(&wrk->busyobj->fetch_obj->store, storagehead); + st = VTAILQ_LAST(&bo->fetch_obj->store, storagehead); if (st == NULL) return (0); if (st->len == 0) { - VTAILQ_REMOVE(&wrk->busyobj->fetch_obj->store, st, list); + VTAILQ_REMOVE(&bo->fetch_obj->store, st, list); STV_free(st); return (0); } @@ -224,20 +224,20 @@ fetch_number(const char *nbr, int radix) /*--------------------------------------------------------------------*/ static int -fetch_straight(struct worker *wrk, struct http_conn *htc, ssize_t cl) +fetch_straight(struct busyobj *bo, struct http_conn *htc, ssize_t cl) { int i; - assert(wrk->busyobj->body_status == BS_LENGTH); + assert(bo->body_status == BS_LENGTH); if (cl < 0) { - return (FetchError(wrk->busyobj, "straight length field bogus")); + return (FetchError(bo, "straight length field bogus")); } else if (cl == 0) return (0); - i = wrk->busyobj->vfp->bytes(wrk, htc, cl); + i = bo->vfp->bytes(bo, htc, cl); if (i <= 0) - return (FetchError(wrk->busyobj, "straight insufficient bytes")); + return (FetchError(bo, "straight insufficient bytes")); return (0); } @@ -248,14 +248,14 @@ fetch_straight(struct worker *wrk, struct http_conn *htc, ssize_t cl) */ static int -fetch_chunked(struct worker *wrk, struct http_conn *htc) +fetch_chunked(struct busyobj *bo, struct http_conn *htc) { int i; char buf[20]; /* XXX: 20 is arbitrary */ unsigned u; ssize_t cl; - assert(wrk->busyobj->body_status == BS_CHUNKED); + assert(bo->body_status == BS_CHUNKED); do { /* Skip leading whitespace */ do { @@ -264,7 +264,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) } while (vct_islws(buf[0])); if (!vct_ishex(buf[0])) - return (FetchError(wrk->busyobj, "chunked header non-hex")); + return (FetchError(bo, "chunked header non-hex")); /* Collect hex digits, skipping leading zeros */ for (u = 1; u < sizeof buf; u++) { @@ -277,7 +277,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) } if (u >= sizeof buf) - return (FetchError(wrk->busyobj,"chunked header too long")); + return (FetchError(bo,"chunked header too long")); /* Skip trailing white space */ while(vct_islws(buf[u]) && buf[u] != '\n') @@ -285,14 +285,14 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) return (-1); if (buf[u] != '\n') - return (FetchError(wrk->busyobj,"chunked header no NL")); + return (FetchError(bo,"chunked header no NL")); buf[u] = '\0'; cl = fetch_number(buf, 16); if (cl < 0) - return (FetchError(wrk->busyobj,"chunked header number syntax")); + return (FetchError(bo,"chunked header number syntax")); - if (cl > 0 && wrk->busyobj->vfp->bytes(wrk, htc, cl) <= 0) + if (cl > 0 && bo->vfp->bytes(bo, htc, cl) <= 0) return (-1); i = HTC_Read(htc, buf, 1); @@ -301,7 +301,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) if (buf[0] == '\r' && HTC_Read( htc, buf, 1) <= 0) return (-1); if (buf[0] != '\n') - return (FetchError(wrk->busyobj,"chunked tail no NL")); + return (FetchError(bo,"chunked tail no NL")); } while (cl > 0); return (0); } @@ -309,12 +309,12 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) /*--------------------------------------------------------------------*/ static int -fetch_eof(struct worker *wrk, struct http_conn *htc) +fetch_eof(struct busyobj *bo, struct http_conn *htc) { int i; - assert(wrk->busyobj->body_status == BS_EOF); - i = wrk->busyobj->vfp->bytes(wrk, htc, SSIZE_MAX); + assert(bo->body_status == BS_EOF); + i = bo->vfp->bytes(bo, htc, SSIZE_MAX); if (i < 0) return (-1); return (0); @@ -540,24 +540,24 @@ FetchBody(struct worker *wrk, struct object *obj) break; case BS_LENGTH: cl = fetch_number(bo->h_content_length, 10); - bo->vfp->begin(wrk, cl > 0 ? cl : 0); - cls = fetch_straight(wrk, htc, cl); + bo->vfp->begin(bo, cl > 0 ? cl : 0); + cls = fetch_straight(bo, htc, cl); mklen = 1; - if (bo->vfp->end(wrk)) + if (bo->vfp->end(bo)) cls = -1; break; case BS_CHUNKED: - bo->vfp->begin(wrk, cl); - cls = fetch_chunked(wrk, htc); + bo->vfp->begin(bo, cl); + cls = fetch_chunked(bo, htc); mklen = 1; - if (bo->vfp->end(wrk)) + if (bo->vfp->end(bo)) cls = -1; break; case BS_EOF: - bo->vfp->begin(wrk, cl); - cls = fetch_eof(wrk, htc); + bo->vfp->begin(bo, cl); + cls = fetch_eof(bo, htc); mklen = 1; - if (bo->vfp->end(wrk)) + if (bo->vfp->end(bo)) cls = -1; break; case BS_ERROR: @@ -576,7 +576,7 @@ FetchBody(struct worker *wrk, struct object *obj) * sitting on wrk->storage, we will always call vfp_nop_end() * to get it trimmed or thrown out if empty. */ - AZ(vfp_nop_end(wrk)); + AZ(vfp_nop_end(bo)); bo->fetch_obj = NULL; diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 1dd7942..530d43b 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -428,19 +428,18 @@ VGZ_Destroy(struct vgz **vgp) * A VFP for gunzip'ing an object as we receive it from the backend */ -static void __match_proto__() -vfp_gunzip_begin(struct worker *wrk, size_t estimate) +static void __match_proto__(vfp_begin_f) +vfp_gunzip_begin(struct busyobj *bo, size_t estimate) { (void)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->vsl, "U F -"); - XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx)); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AZ(bo->vgz_rx); + bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "U F -"); + XXXAZ(vgz_getmbuf(bo->vgz_rx)); } -static int __match_proto__() -vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +static int __match_proto__(vfp_bytes_f) +vfp_gunzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) { struct vgz *vg; ssize_t l, wl; @@ -448,10 +447,9 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) size_t dl; const void *dp; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - AZ(wrk->busyobj->fetch_failed); - vg = wrk->busyobj->vgz_rx; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AZ(bo->fetch_failed); + vg = bo->vgz_rx; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); AZ(vg->vz.avail_in); while (bytes > 0 || vg->vz.avail_in > 0) { @@ -466,34 +464,32 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) bytes -= wl; } - if (VGZ_ObufStorage(wrk->busyobj, vg)) + if (VGZ_ObufStorage(bo, vg)) return(-1); i = VGZ_Gunzip(vg, &dp, &dl); if (i != VGZ_OK && i != VGZ_END) - return(FetchError(wrk->busyobj, "Gunzip data error")); - wrk->busyobj->fetch_obj->len += dl; + return(FetchError(bo, "Gunzip data error")); + bo->fetch_obj->len += dl; } assert(i == Z_OK || i == Z_STREAM_END); return (1); } -static int __match_proto__() -vfp_gunzip_end(struct worker *wrk) +static int __match_proto__(vfp_end_f) +vfp_gunzip_end(struct busyobj *bo) { struct vgz *vg; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vg = wrk->busyobj->vgz_rx; - wrk->busyobj->vgz_rx = NULL; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vg = bo->vgz_rx; + bo->vgz_rx = NULL; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - if (wrk->busyobj->fetch_failed) { + if (bo->fetch_failed) { (void)VGZ_Destroy(&vg); return(0); } if (VGZ_Destroy(&vg) != VGZ_END) - return(FetchError(wrk->busyobj, - "Gunzip error at the very end")); + return(FetchError(bo, "Gunzip error at the very end")); return (0); } @@ -509,20 +505,19 @@ struct vfp vfp_gunzip = { * A VFP for gzip'ing an object as we receive it from the backend */ -static void __match_proto__() -vfp_gzip_begin(struct worker *wrk, size_t estimate) +static void __match_proto__(vfp_begin_f) +vfp_gzip_begin(struct busyobj *bo, size_t estimate) { (void)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->vsl, "G F -"); - XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx)); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AZ(bo->vgz_rx); + bo->vgz_rx = VGZ_NewGzip(bo->vsl, "G F -"); + XXXAZ(vgz_getmbuf(bo->vgz_rx)); } -static int __match_proto__() -vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +static int __match_proto__(vfp_bytes_f) +vfp_gzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) { struct vgz *vg; ssize_t l, wl; @@ -530,10 +525,9 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) size_t dl; const void *dp; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - AZ(wrk->busyobj->fetch_failed); - vg = wrk->busyobj->vgz_rx; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AZ(bo->fetch_failed); + vg = bo->vgz_rx; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); AZ(vg->vz.avail_in); while (bytes > 0 || !VGZ_IbufEmpty(vg)) { @@ -547,42 +541,41 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) VGZ_Ibuf(vg, vg->m_buf, wl); bytes -= wl; } - if (VGZ_ObufStorage(wrk->busyobj, vg)) + if (VGZ_ObufStorage(bo, vg)) return(-1); i = VGZ_Gzip(vg, &dp, &dl, VGZ_NORMAL); assert(i == Z_OK); - wrk->busyobj->fetch_obj->len += dl; + bo->fetch_obj->len += dl; } return (1); } -static int __match_proto__() -vfp_gzip_end(struct worker *wrk) +static int __match_proto__(vfp_end_f) +vfp_gzip_end(struct busyobj *bo) { struct vgz *vg; size_t dl; const void *dp; int i; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vg = wrk->busyobj->vgz_rx; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vg = bo->vgz_rx; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - wrk->busyobj->vgz_rx = NULL; - if (wrk->busyobj->fetch_failed) { + bo->vgz_rx = NULL; + if (bo->fetch_failed) { (void)VGZ_Destroy(&vg); return(0); } do { VGZ_Ibuf(vg, "", 0); - if (VGZ_ObufStorage(wrk->busyobj, vg)) + if (VGZ_ObufStorage(bo, vg)) return(-1); i = VGZ_Gzip(vg, &dp, &dl, VGZ_FINISH); - wrk->busyobj->fetch_obj->len += dl; + bo->fetch_obj->len += dl; } while (i != Z_STREAM_END); - VGZ_UpdateObj(vg, wrk->busyobj->fetch_obj); + VGZ_UpdateObj(vg, bo->fetch_obj); if (VGZ_Destroy(&vg) != VGZ_END) - return(FetchError(wrk->busyobj, "Gzip error at the very end")); + return(FetchError(bo, "Gzip error at the very end")); return (0); } @@ -599,19 +592,18 @@ struct vfp vfp_gzip = { * collecting the magic bits while we're at it. */ -static void __match_proto__() -vfp_testgzip_begin(struct worker *wrk, size_t estimate) +static void __match_proto__(vfp_begin_f) +vfp_testgzip_begin(struct busyobj *bo, size_t estimate) { - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); (void)estimate; - 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)); + bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "u F -"); + CHECK_OBJ_NOTNULL(bo->vgz_rx, VGZ_MAGIC); + XXXAZ(vgz_getmbuf(bo->vgz_rx)); } -static int __match_proto__() -vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +static int __match_proto__(vfp_bytes_f) +vfp_testgzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) { struct vgz *vg; ssize_t l, wl; @@ -620,14 +612,13 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) const void *dp; struct storage *st; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - AZ(wrk->busyobj->fetch_failed); - vg = wrk->busyobj->vgz_rx; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AZ(bo->fetch_failed); + vg = bo->vgz_rx; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); AZ(vg->vz.avail_in); while (bytes > 0) { - st = FetchStorage(wrk->busyobj, 0); + st = FetchStorage(bo, 0); if (st == NULL) return(-1); l = st->space - st->len; @@ -639,16 +630,15 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) bytes -= wl; VGZ_Ibuf(vg, st->ptr + st->len, wl); st->len += wl; - wrk->busyobj->fetch_obj->len += wl; + bo->fetch_obj->len += wl; while (!VGZ_IbufEmpty(vg)) { VGZ_Obuf(vg, vg->m_buf, vg->m_sz); i = VGZ_Gunzip(vg, &dp, &dl); if (i == VGZ_END && !VGZ_IbufEmpty(vg)) - return(FetchError(wrk->busyobj, - "Junk after gzip data")); + return(FetchError(bo, "Junk after gzip data")); if (i != VGZ_OK && i != VGZ_END) - return(FetchError2(wrk->busyobj, + return(FetchError2(bo, "Invalid Gzip data", vg->vz.msg)); } } @@ -656,24 +646,22 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) return (1); } -static int __match_proto__() -vfp_testgzip_end(struct worker *wrk) +static int __match_proto__(vfp_end_f) +vfp_testgzip_end(struct busyobj *bo) { struct vgz *vg; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vg = wrk->busyobj->vgz_rx; - wrk->busyobj->vgz_rx = NULL; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vg = bo->vgz_rx; + bo->vgz_rx = NULL; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - if (wrk->busyobj->fetch_failed) { + if (bo->fetch_failed) { (void)VGZ_Destroy(&vg); return(0); } - VGZ_UpdateObj(vg, wrk->busyobj->fetch_obj); + VGZ_UpdateObj(vg, bo->fetch_obj); if (VGZ_Destroy(&vg) != VGZ_END) - return(FetchError(wrk->busyobj, - "TestGunzip error at the very end")); + return(FetchError(bo, "TestGunzip error at the very end")); return (0); } From apj at varnish-cache.org Thu Feb 16 18:54:34 2012 From: apj at varnish-cache.org (Andreas Plesner Jacobsen) Date: Thu, 16 Feb 2012 19:54:34 +0100 Subject: [master] 7d164e0 Most of these variables are not available in vcl_deliver Message-ID: commit 7d164e06e42dd6524b12acaa87a84c2aaf0404db Author: Andreas Plesner Jacobsen Date: Thu Feb 16 19:53:59 2012 +0100 Most of these variables are not available in vcl_deliver Fixes #1056 diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 1ef14d6..9e71fbd 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -842,7 +842,8 @@ beresp.storage After the object is entered into the cache, the following (mostly read-only) variables are available when the object has been located in -cache, typically in vcl_hit and vcl_deliver. +cache, typically in vcl_hit, or when constructing a synthetic reply in +vcl_error: obj.proto The HTTP protocol version used when the object was retrieved. @@ -858,11 +859,12 @@ obj.ttl obj.lastuse The approximate time elapsed since the object was last requests, in - seconds. + seconds. This variable is also available in vcl_deliver. obj.hits The approximate number of times the object has been delivered. A value - of 0 indicates a cache miss. + of 0 indicates a cache miss. This variable is also available in + vcl_deliver. obj.grace The object's grace period in seconds. obj.grace is writable. From geoff at varnish-cache.org Fri Feb 17 12:58:53 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:53 +0100 Subject: [experimental-ims] 71b981f Use %ju for uintmax_t printf Message-ID: commit 71b981f38663443db9b162caf2b13c2a367c2fd8 Author: Tollef Fog Heen Date: Wed Feb 15 08:37:10 2012 +0100 Use %ju for uintmax_t printf diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 475806d..a5cde62 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -288,7 +288,7 @@ fmt_bytes(struct cli *cli, uintmax_t t) const char *p; if (t & 0xff) { - VCLI_Out(cli, "%zub", t); + VCLI_Out(cli, "%jub", t); return; } for (p = "kMGTPEZY"; *p; p++) { From geoff at varnish-cache.org Fri Feb 17 12:58:53 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:53 +0100 Subject: [experimental-ims] f012e53 Make sure we have debug.sizeof in at least one test-case. Message-ID: commit f012e53da787b6cba1c19aab14ba30bf4612158a Author: Poul-Henning Kamp Date: Wed Feb 15 09:18:20 2012 +0000 Make sure we have debug.sizeof in at least one test-case. diff --git a/bin/varnishtest/tests/b00032.vtc b/bin/varnishtest/tests/b00032.vtc index 949bcfa..ced05bb 100644 --- a/bin/varnishtest/tests/b00032.vtc +++ b/bin/varnishtest/tests/b00032.vtc @@ -1,3 +1,12 @@ varnishtest "CLI coverage test" varnish v1 -cliok storage.list + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend {} -start + +varnish v1 -cliok debug.sizeof From geoff at varnish-cache.org Fri Feb 17 12:58:53 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:53 +0100 Subject: [experimental-ims] 60490c9 Increase backend_workspace of r01038.vtc from 7k to 8k. Message-ID: commit 60490c97e290e7abce77c0dbad88328604cf273d Author: Martin Blix Grydeland Date: Wed Feb 15 11:03:49 2012 +0100 Increase backend_workspace of r01038.vtc from 7k to 8k. diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc index 983b704..e10152f 100644 --- a/bin/varnishtest/tests/r01038.vtc +++ b/bin/varnishtest/tests/r01038.vtc @@ -45,7 +45,7 @@ server s1 { txresp -body "foo8" } -start -varnish v1 -arg "-p workspace_backend=7k" -vcl+backend { +varnish v1 -arg "-p workspace_backend=8k" -vcl+backend { sub vcl_fetch { set beresp.do_esi = true; } From geoff at varnish-cache.org Fri Feb 17 12:58:53 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:53 +0100 Subject: [experimental-ims] af2bfa9 Push struct worker further upwards Message-ID: commit af2bfa9445d385c316f64263b0320eae7a1f9fde Author: Poul-Henning Kamp Date: Wed Feb 15 09:37:57 2012 +0000 Push struct worker further upwards diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 42788c3..62b1202 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -753,7 +753,7 @@ void EXP_Inject(struct objcore *oc, struct lru *lru, double when); void EXP_Init(void); void EXP_Rearm(const struct object *o); int EXP_Touch(struct objcore *oc); -int EXP_NukeOne(struct worker *w, struct lru *lru); +int EXP_NukeOne(struct vsl_log *, struct dstat *, struct lru *lru); /* cache_fetch.c */ struct storage *FetchStorage(struct worker *w, ssize_t sz); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 0d8ffe1..9bdf25f 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -414,7 +414,7 @@ exp_timer(struct sess *sp, void *priv) */ int -EXP_NukeOne(struct worker *wrk, struct lru *lru) +EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru) { struct objcore *oc; @@ -445,8 +445,8 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru) return (-1); /* XXX: bad idea for -spersistent */ - WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(&wrk->stats, oc)); - (void)HSH_Deref(&wrk->stats, oc, NULL); + WSL(vsl, SLT_ExpKill, -1, "%u LRU", oc_getxid(ds, oc)); + (void)HSH_Deref(ds, oc, NULL); return (1); } diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index ae71f6e..50db0db 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -127,7 +127,7 @@ LRU_Free(struct lru *lru) */ static struct stevedore * -stv_pick_stevedore(struct worker *wrk, const char **hint) +stv_pick_stevedore(struct vsl_log *vsl, const char **hint) { struct stevedore *stv; @@ -141,8 +141,7 @@ stv_pick_stevedore(struct worker *wrk, const char **hint) return (stv_transient); /* Hint was not valid, nuke it */ - WSL(wrk->vsl, SLT_Debug, 0, /* XXX VSL_id ?? */ - "Storage hint not usable"); + WSL(vsl, SLT_Debug, -1, "Storage hint not usable"); *hint = NULL; } /* pick a stevedore and bump the head along */ @@ -189,7 +188,7 @@ stv_alloc(struct worker *w, const struct object *obj, size_t size) } /* no luck; try to free some space and keep trying */ - if (EXP_NukeOne(w, stv->lru) == -1) + if (EXP_NukeOne(w->vsl, &w->stats, stv->lru) == -1) break; /* Enough is enough: try another if we have one */ @@ -327,12 +326,12 @@ STV_NewObject(struct worker *wrk, const char *hint, unsigned wsl, ltot = sizeof *o + wsl + lhttp; - stv = stv0 = stv_pick_stevedore(wrk, &hint); + stv = stv0 = stv_pick_stevedore(wrk->vsl, &hint); AN(stv->allocobj); o = stv->allocobj(stv, wrk, ltot, &soc); if (o == NULL && hint == NULL) { do { - stv = stv_pick_stevedore(wrk, &hint); + stv = stv_pick_stevedore(wrk->vsl, &hint); AN(stv->allocobj); o = stv->allocobj(stv, wrk, ltot, &soc); } while (o == NULL && stv != stv0); @@ -340,7 +339,7 @@ STV_NewObject(struct worker *wrk, const char *hint, unsigned wsl, if (o == NULL) { /* no luck; try to free some space and keep trying */ for (i = 0; o == NULL && i < cache_param->nuke_limit; i++) { - if (EXP_NukeOne(wrk, stv->lru) == -1) + if (EXP_NukeOne(wrk->vsl, &wrk->stats, stv->lru) == -1) break; o = stv->allocobj(stv, wrk, ltot, &soc); } From geoff at varnish-cache.org Fri Feb 17 12:58:53 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:53 +0100 Subject: [experimental-ims] 071f86b Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit 071f86ba851c8022dbd6b0935b025b059257b56c Merge: bd9df97 60490c9 Author: Poul-Henning Kamp Date: Wed Feb 15 11:02:40 2012 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From geoff at varnish-cache.org Fri Feb 17 12:58:53 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:53 +0100 Subject: [experimental-ims] bd9df97 The VGZ api does not need a worker, it just needs a vsl_log Message-ID: commit bd9df9772158d3d7078243e211113551ecbcc292 Author: Poul-Henning Kamp 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); From geoff at varnish-cache.org Fri Feb 17 12:58:53 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:53 +0100 Subject: [experimental-ims] b5f1878 Remove the current "ping-pong" streaming code, it is in the way of the "real streaming" code we are working on. Message-ID: commit b5f187859ccb6b92d06a445ef7f6b17a476149f7 Author: Poul-Henning Kamp Date: Wed Feb 15 11:43:42 2012 +0000 Remove the current "ping-pong" streaming code, it is in the way of the "real streaming" code we are working on. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a76cc45..a9051bc 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -608,15 +608,6 @@ struct req { #define RES_ESI_CHILD (1<<5) #define RES_GUNZIP (1<<6) - /* Stream gunzip instance */ - struct vgz *stream_vgz; - - /* Next byte we will take from storage */ - ssize_t stream_next; - - /* First byte of storage if we free it as we go (pass) */ - ssize_t stream_front; - /* Transaction VSL buffer */ struct vsl_log vsl[1]; @@ -958,9 +949,6 @@ void WSL_Flush(struct vsl_log *, int overflow); /* cache_response.c */ 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(struct worker *); /* cache_vary.c */ struct vsb *VRY_Create(const struct sess *sp, const struct http *hp); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 0be9304..4b0429a 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -194,7 +194,6 @@ DOT ] DOT prepresp -> deliver [style=bold,color=green,label=deliver] DOT prepresp -> deliver [style=bold,color=red] DOT prepresp -> deliver [style=bold,color=blue] -DOT prepresp -> streambody [style=bold,color=cyan,label="deliver"] DOT } * */ @@ -300,12 +299,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) default: WRONG("Illegal action in vcl_deliver{}"); } - if (wrk->busyobj != NULL && wrk->busyobj->do_stream) { - AssertObjCorePassOrBusy(req->obj->objcore); - sp->step = STP_STREAMBODY; - } else { - sp->step = STP_DELIVER; - } + sp->step = STP_DELIVER; return (0); } @@ -858,13 +852,8 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) AssertObjCorePassOrBusy(req->obj->objcore); - if (bo->do_stream) { - sp->step = STP_PREPRESP; - return (0); - } else { - sp->step = STP_FETCHBODY; - return (0); - } + sp->step = STP_FETCHBODY; + return (0); } /*-------------------------------------------------------------------- @@ -925,63 +914,6 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req) } /*-------------------------------------------------------------------- - * Stream the body as we fetch it -DOT subgraph xstreambody { -DOT streambody [ -DOT shape=record -DOT label="{cnt_streambody:|ping_pong\nfetch/deliver}" -DOT ] -DOT } -DOT streambody -> DONE [style=bold,color=cyan] - */ - -static int -cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req) -{ - int i; - - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - - RES_StreamStart(sp); - - AssertObjCorePassOrBusy(req->obj->objcore); - - i = FetchBody(wrk, req->obj); - - http_Teardown(wrk->busyobj->bereq); - http_Teardown(wrk->busyobj->beresp); - wrk->busyobj->vfp = NULL; - AZ(wrk->busyobj->vbc); - AN(req->director); - - if (!i && req->obj->objcore != NULL) { - EXP_Insert(req->obj); - AN(req->obj->objcore); - AN(req->obj->objcore->ban); - AZ(req->obj->ws_o->overflow); - HSH_Unbusy(req->obj->objcore); - } else { - req->doclose = "Stream error"; - } - wrk->acct_tmp.fetch++; - req->director = NULL; - req->restarts = 0; - - RES_StreamEnd(sp); - - assert(WRW_IsReleased(wrk)); - (void)HSH_Deref(&wrk->stats, NULL, &req->obj); - VBO_DerefBusyObj(wrk, &wrk->busyobj); - http_Teardown(req->resp); - sp->step = STP_DONE; - return (0); -} - -/*-------------------------------------------------------------------- * A freshly accepted socket * DOT subgraph xcluster_first { diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 2924130..cd01b59 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -126,8 +126,6 @@ vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) st->len += wl; wrk->busyobj->fetch_obj->len += wl; bytes -= wl; - if (wrk->busyobj->do_stream) - RES_StreamPoll(wrk); } return (1); } diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 38c323f..d16d4b1 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -472,8 +472,6 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) if (i != VGZ_OK && i != VGZ_END) return(FetchError(wrk->busyobj, "Gunzip data error")); wrk->busyobj->fetch_obj->len += dl; - if (wrk->busyobj->do_stream) - RES_StreamPoll(wrk); } assert(i == Z_OK || i == Z_STREAM_END); return (1); @@ -554,8 +552,6 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) i = VGZ_Gzip(vg, &dp, &dl, VGZ_NORMAL); assert(i == Z_OK); wrk->busyobj->fetch_obj->len += dl; - if (wrk->busyobj->do_stream) - RES_StreamPoll(wrk); } return (1); } @@ -584,8 +580,6 @@ vfp_gzip_end(struct worker *wrk) i = VGZ_Gzip(vg, &dp, &dl, VGZ_FINISH); wrk->busyobj->fetch_obj->len += dl; } while (i != Z_STREAM_END); - if (wrk->busyobj->do_stream) - RES_StreamPoll(wrk); VGZ_UpdateObj(vg, wrk->busyobj->fetch_obj); if (VGZ_Destroy(&vg) != VGZ_END) return(FetchError(wrk->busyobj, "Gzip error at the very end")); @@ -646,8 +640,6 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) VGZ_Ibuf(vg, st->ptr + st->len, wl); st->len += wl; wrk->busyobj->fetch_obj->len += wl; - if (wrk->busyobj->do_stream) - RES_StreamPoll(wrk); while (!VGZ_IbufEmpty(vg)) { VGZ_Obuf(vg, vg->m_buf, vg->m_sz); diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 125440b..bbb648c 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -305,115 +305,3 @@ RES_WriteObj(struct sess *sp) if (WRW_FlushRelease(sp->wrk) && sp->fd >= 0) SES_Close(sp, "remote closed"); } - -/*--------------------------------------------------------------------*/ - -void -RES_StreamStart(struct sess *sp) -{ - struct req *req; - - req = sp->req; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - - AZ(req->res_mode & RES_ESI_CHILD); - AN(req->wantbody); - AZ(req->stream_vgz); - AZ(req->stream_next); - AZ(req->stream_front); - - WRW_Reserve(sp->wrk, &sp->fd); - - if (req->res_mode & RES_GUNZIP) { - req->stream_vgz = VGZ_NewUngzip(sp->wrk->vsl, "U S -"); - AZ(VGZ_WrwInit(req->stream_vgz)); - http_Unset(req->resp, H_Content_Encoding); - } - - if (!(req->res_mode & RES_CHUNKED) && - sp->wrk->busyobj->h_content_length != NULL) - http_PrintfHeader(sp->req->resp, - "Content-Length: %s", sp->wrk->busyobj->h_content_length); - - sp->wrk->acct_tmp.hdrbytes += - http_Write(sp->wrk, sp->req->resp, 1); - - if (req->res_mode & RES_CHUNKED) - WRW_Chunked(sp->wrk); -} - -void -RES_StreamPoll(struct worker *wrk) -{ - struct storage *st; - struct busyobj *bo; - struct req *req; - ssize_t l, l2; - void *ptr; - - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - bo = wrk->busyobj; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->fetch_obj, OBJECT_MAGIC); - req = wrk->sp->req; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (bo->fetch_obj->len == req->stream_next) - return; - assert(bo->fetch_obj->len > req->stream_next); - l = req->stream_front; - VTAILQ_FOREACH(st, &bo->fetch_obj->store, list) { - if (st->len + l <= req->stream_next) { - l += st->len; - continue; - } - l2 = st->len + l - req->stream_next; - ptr = st->ptr + (req->stream_next - l); - if (wrk->sp->req->res_mode & RES_GUNZIP) - (void)VGZ_WrwGunzip(wrk, req->stream_vgz, ptr, l2); - else - (void)WRW_Write(wrk, ptr, l2); - l += st->len; - req->stream_next += l2; - } - if (!(wrk->sp->req->res_mode & RES_GUNZIP)) - (void)WRW_Flush(wrk); - - if (bo->fetch_obj->objcore == NULL || - (bo->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(&bo->fetch_obj->store); - if (st == NULL || - req->stream_front + st->len > req->stream_next) - break; - VTAILQ_REMOVE(&bo->fetch_obj->store, st, list); - req->stream_front += st->len; - STV_free(st); - } - } -} - -void -RES_StreamEnd(struct sess *sp) -{ - struct req *req; - - req = sp->req; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - - if (req->res_mode & RES_GUNZIP) { - AN(req->stream_vgz); - VGZ_WrwFlush(sp->wrk, req->stream_vgz); - (void)VGZ_Destroy(&req->stream_vgz); - } - if (req->res_mode & RES_CHUNKED && !(req->res_mode & RES_ESI_CHILD)) - WRW_EndChunk(sp->wrk); - if (WRW_FlushRelease(sp->wrk)) - SES_Close(sp, "remote closed"); - req->stream_vgz = NULL; - req->stream_next = 0; - req->stream_front = 0; -} diff --git a/bin/varnishtest/tests.disabled/r00929.vtc b/bin/varnishtest/tests.disabled/r00929.vtc new file mode 100644 index 0000000..3b2f7ca --- /dev/null +++ b/bin/varnishtest/tests.disabled/r00929.vtc @@ -0,0 +1,26 @@ +varnishtest "stream test" + + +server s1 { + rxreq + txresp -bodylen 400 +} -start + +varnish v1 -vcl+backend { + + sub vcl_fetch { + set beresp.do_stream = true; + } + +} -start + +client c1 { + txreq + rxresp + expect resp.bodylen == 400 + txreq + rxresp + expect resp.bodylen == 400 +} -run + + diff --git a/bin/varnishtest/tests.disabled/r00978.vtc b/bin/varnishtest/tests.disabled/r00978.vtc new file mode 100644 index 0000000..39b89cb --- /dev/null +++ b/bin/varnishtest/tests.disabled/r00978.vtc @@ -0,0 +1,40 @@ +varnishtest "r00978.vtc Test esi_level > 0 and do_stream" + +server s1 { + rxreq + expect req.url == "/" + txresp -body { + + Before include + + After include + } + rxreq + expect req.url == "/body1" + txresp -body { + Included file + } +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.esi_level > 0) { + set req.url = req.url + req.esi_level; + } + } + sub vcl_fetch { + if (req.url == "/") { + set beresp.do_esi = true; + } + set beresp.do_stream = true; + } +} -start + +client c1 { + txreq + rxresp + expect resp.bodylen == 65 + expect resp.status == 200 +} -run + +varnish v1 -expect esi_errors == 0 diff --git a/bin/varnishtest/tests.disabled/r00979.vtc b/bin/varnishtest/tests.disabled/r00979.vtc new file mode 100644 index 0000000..bc72efc --- /dev/null +++ b/bin/varnishtest/tests.disabled/r00979.vtc @@ -0,0 +1,29 @@ +varnishtest "r00979.vtc Test restart when do_stream in vcl_deliver" + +server s1 { + rxreq + txresp -status 200 -body "1" + expect_close + + accept + rxreq + txresp -status 200 -body "11" +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + set beresp.do_stream = true; + } + sub vcl_deliver { + if (req.restarts == 0) { + return (restart); + } + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.bodylen == 2 +} -run diff --git a/bin/varnishtest/tests.disabled/r00980.vtc b/bin/varnishtest/tests.disabled/r00980.vtc new file mode 100644 index 0000000..b7d307e --- /dev/null +++ b/bin/varnishtest/tests.disabled/r00980.vtc @@ -0,0 +1,29 @@ +varnishtest "r00980 test gzip on fetch with content_length and do_stream" + +server s1 { + rxreq + expect req.url == "/foobar" + expect req.http.accept-encoding == "gzip" + txresp -bodylen 43 +} -start + +varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend { + + sub vcl_fetch { + set beresp.do_gzip = true; + set beresp.do_stream = true; + } +} -start + +client c1 { + txreq -url /foobar -hdr "Accept-Encoding: gzip" + rxresp + expect resp.http.content-encoding == "gzip" + gunzip + expect resp.bodylen == 43 + + txreq -url /foobar + rxresp + expect resp.http.content-encoding == + expect resp.bodylen == 43 +} -run diff --git a/bin/varnishtest/tests.disabled/t00000.vtc b/bin/varnishtest/tests.disabled/t00000.vtc new file mode 100644 index 0000000..57ab7c7 --- /dev/null +++ b/bin/varnishtest/tests.disabled/t00000.vtc @@ -0,0 +1,48 @@ +varnishtest "Ticket #873" + +server s1 { + rxreq + txresp -nolen -hdr "Transfer-encoding: chunked" + chunked "<1>------------------------<1>\n" + sema r1 sync 2 + chunked "<2>------------------------<2>\n" + sema r2 sync 2 + chunked "<3>------------------------<3>\n" + sema r1 sync 2 + chunked "<4>------------------------<4>\n" + sema r2 sync 2 + chunkedlen 0 +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + set beresp.do_stream = true; + } +} -start + +varnish v1 -cliok "param.set diag_bitmap 1" + +client c1 { + txreq -hdr "foo: /foo" + rxresp -no_obj + + rxchunk + expect resp.chunklen == 31 + sema r1 sync 2 + + rxchunk + expect resp.chunklen == 31 + sema r2 sync 2 + + rxchunk + expect resp.chunklen == 31 + sema r1 sync 2 + + rxchunk + expect resp.chunklen == 31 + sema r2 sync 2 + + rxchunk + expect resp.chunklen == 0 + expect resp.bodylen == 124 +} -run diff --git a/bin/varnishtest/tests.disabled/t00001.vtc b/bin/varnishtest/tests.disabled/t00001.vtc new file mode 100644 index 0000000..2237466 --- /dev/null +++ b/bin/varnishtest/tests.disabled/t00001.vtc @@ -0,0 +1,50 @@ +varnishtest "Test stream/gunzip" + +server s1 { + rxreq + expect req.url == "/bar" + txresp -body "foobar" + + rxreq + expect req.url == "/bla" + expect req.http.accept-encoding == "gzip" + txresp -gzipbody blablabla + + rxreq + expect req.url == "/foo" + txresp -body "snafu" + + rxreq + expect req.url == "/barf" + expect req.http.accept-encoding == "gzip" + txresp -gzipbody Iamoutofnonsensewords + +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + if (req.url == "/foo") { + set beresp.do_gzip = true; + } + if (req.url == "/barf") { + set beresp.do_gunzip = true; + } + set beresp.do_stream = true; + } +} -start + +client c1 { + txreq -url /bar + rxresp + expect resp.http.content-length == 6 + expect resp.bodylen == 6 + txreq -url /bla + rxresp + expect resp.bodylen == 9 + txreq -url /foo + rxresp + expect resp.bodylen == 5 + txreq -url /barf + rxresp + expect resp.bodylen == 21 +} -run diff --git a/bin/varnishtest/tests/r00929.vtc b/bin/varnishtest/tests/r00929.vtc deleted file mode 100644 index 3b2f7ca..0000000 --- a/bin/varnishtest/tests/r00929.vtc +++ /dev/null @@ -1,26 +0,0 @@ -varnishtest "stream test" - - -server s1 { - rxreq - txresp -bodylen 400 -} -start - -varnish v1 -vcl+backend { - - sub vcl_fetch { - set beresp.do_stream = true; - } - -} -start - -client c1 { - txreq - rxresp - expect resp.bodylen == 400 - txreq - rxresp - expect resp.bodylen == 400 -} -run - - diff --git a/bin/varnishtest/tests/r00978.vtc b/bin/varnishtest/tests/r00978.vtc deleted file mode 100644 index 39b89cb..0000000 --- a/bin/varnishtest/tests/r00978.vtc +++ /dev/null @@ -1,40 +0,0 @@ -varnishtest "r00978.vtc Test esi_level > 0 and do_stream" - -server s1 { - rxreq - expect req.url == "/" - txresp -body { - - Before include - - After include - } - rxreq - expect req.url == "/body1" - txresp -body { - Included file - } -} -start - -varnish v1 -vcl+backend { - sub vcl_recv { - if (req.esi_level > 0) { - set req.url = req.url + req.esi_level; - } - } - sub vcl_fetch { - if (req.url == "/") { - set beresp.do_esi = true; - } - set beresp.do_stream = true; - } -} -start - -client c1 { - txreq - rxresp - expect resp.bodylen == 65 - expect resp.status == 200 -} -run - -varnish v1 -expect esi_errors == 0 diff --git a/bin/varnishtest/tests/r00979.vtc b/bin/varnishtest/tests/r00979.vtc deleted file mode 100644 index bc72efc..0000000 --- a/bin/varnishtest/tests/r00979.vtc +++ /dev/null @@ -1,29 +0,0 @@ -varnishtest "r00979.vtc Test restart when do_stream in vcl_deliver" - -server s1 { - rxreq - txresp -status 200 -body "1" - expect_close - - accept - rxreq - txresp -status 200 -body "11" -} -start - -varnish v1 -vcl+backend { - sub vcl_fetch { - set beresp.do_stream = true; - } - sub vcl_deliver { - if (req.restarts == 0) { - return (restart); - } - } -} -start - -client c1 { - txreq - rxresp - expect resp.status == 200 - expect resp.bodylen == 2 -} -run diff --git a/bin/varnishtest/tests/r00980.vtc b/bin/varnishtest/tests/r00980.vtc deleted file mode 100644 index b7d307e..0000000 --- a/bin/varnishtest/tests/r00980.vtc +++ /dev/null @@ -1,29 +0,0 @@ -varnishtest "r00980 test gzip on fetch with content_length and do_stream" - -server s1 { - rxreq - expect req.url == "/foobar" - expect req.http.accept-encoding == "gzip" - txresp -bodylen 43 -} -start - -varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend { - - sub vcl_fetch { - set beresp.do_gzip = true; - set beresp.do_stream = true; - } -} -start - -client c1 { - txreq -url /foobar -hdr "Accept-Encoding: gzip" - rxresp - expect resp.http.content-encoding == "gzip" - gunzip - expect resp.bodylen == 43 - - txreq -url /foobar - rxresp - expect resp.http.content-encoding == - expect resp.bodylen == 43 -} -run diff --git a/bin/varnishtest/tests/t00000.vtc b/bin/varnishtest/tests/t00000.vtc deleted file mode 100644 index 57ab7c7..0000000 --- a/bin/varnishtest/tests/t00000.vtc +++ /dev/null @@ -1,48 +0,0 @@ -varnishtest "Ticket #873" - -server s1 { - rxreq - txresp -nolen -hdr "Transfer-encoding: chunked" - chunked "<1>------------------------<1>\n" - sema r1 sync 2 - chunked "<2>------------------------<2>\n" - sema r2 sync 2 - chunked "<3>------------------------<3>\n" - sema r1 sync 2 - chunked "<4>------------------------<4>\n" - sema r2 sync 2 - chunkedlen 0 -} -start - -varnish v1 -vcl+backend { - sub vcl_fetch { - set beresp.do_stream = true; - } -} -start - -varnish v1 -cliok "param.set diag_bitmap 1" - -client c1 { - txreq -hdr "foo: /foo" - rxresp -no_obj - - rxchunk - expect resp.chunklen == 31 - sema r1 sync 2 - - rxchunk - expect resp.chunklen == 31 - sema r2 sync 2 - - rxchunk - expect resp.chunklen == 31 - sema r1 sync 2 - - rxchunk - expect resp.chunklen == 31 - sema r2 sync 2 - - rxchunk - expect resp.chunklen == 0 - expect resp.bodylen == 124 -} -run diff --git a/bin/varnishtest/tests/t00001.vtc b/bin/varnishtest/tests/t00001.vtc deleted file mode 100644 index 2237466..0000000 --- a/bin/varnishtest/tests/t00001.vtc +++ /dev/null @@ -1,50 +0,0 @@ -varnishtest "Test stream/gunzip" - -server s1 { - rxreq - expect req.url == "/bar" - txresp -body "foobar" - - rxreq - expect req.url == "/bla" - expect req.http.accept-encoding == "gzip" - txresp -gzipbody blablabla - - rxreq - expect req.url == "/foo" - txresp -body "snafu" - - rxreq - expect req.url == "/barf" - expect req.http.accept-encoding == "gzip" - txresp -gzipbody Iamoutofnonsensewords - -} -start - -varnish v1 -vcl+backend { - sub vcl_fetch { - if (req.url == "/foo") { - set beresp.do_gzip = true; - } - if (req.url == "/barf") { - set beresp.do_gunzip = true; - } - set beresp.do_stream = true; - } -} -start - -client c1 { - txreq -url /bar - rxresp - expect resp.http.content-length == 6 - expect resp.bodylen == 6 - txreq -url /bla - rxresp - expect resp.bodylen == 9 - txreq -url /foo - rxresp - expect resp.bodylen == 5 - txreq -url /barf - rxresp - expect resp.bodylen == 21 -} -run diff --git a/include/tbl/steps.h b/include/tbl/steps.h index 1e95529..e6738cb 100644 --- a/include/tbl/steps.h +++ b/include/tbl/steps.h @@ -41,7 +41,6 @@ STEP(hit, HIT, (sp, sp->wrk, sp->req)) STEP(fetch, FETCH, (sp, sp->wrk, sp->req)) STEP(prepfetch, PREPFETCH, (sp, sp->wrk, sp->req)) STEP(fetchbody, FETCHBODY, (sp, sp->wrk, sp->req)) -STEP(streambody, STREAMBODY, (sp, sp->wrk, sp->req)) STEP(prepresp, PREPRESP, (sp, sp->wrk, sp->req)) STEP(deliver, DELIVER, (sp, sp->wrk, sp->req)) STEP(error, ERROR, (sp, sp->wrk, sp->req)) From geoff at varnish-cache.org Fri Feb 17 12:58:53 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:53 +0100 Subject: [experimental-ims] 7703a5f Lend busyobj the workers dstat for the duration of Fetch_Body() Message-ID: commit 7703a5f82679f56e82cdff7a6f98dfb27dbdae31 Author: Poul-Henning Kamp Date: Wed Feb 15 12:32:28 2012 +0000 Lend busyobj the workers dstat for the duration of Fetch_Body() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a9051bc..f2f64d3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -494,6 +494,7 @@ struct busyobj { double between_bytes_timeout; struct vsl_log vsl[1]; + struct dstat *stats; }; /* Object structure --------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index cd01b59..928ecc4 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -506,6 +506,13 @@ FetchBody(struct worker *wrk, struct object *obj) CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(obj->http, HTTP_MAGIC); + /* + * XXX: The busyobj needs a dstat, but it is not obvious which one + * XXX: it should be (own/borrowed). For now borrow the wrk's. + */ + AZ(bo->stats); + bo->stats = &wrk->stats; + htc = &bo->htc; if (bo->vfp == NULL) @@ -578,6 +585,7 @@ FetchBody(struct worker *wrk, struct object *obj) if (bo->body_status == BS_ERROR) { VDI_CloseFd(wrk, &bo->vbc); + bo->stats = NULL; return (__LINE__); } @@ -585,6 +593,7 @@ FetchBody(struct worker *wrk, struct object *obj) wrk->stats.fetch_failed++; VDI_CloseFd(wrk, &bo->vbc); obj->len = 0; + bo->stats = NULL; return (__LINE__); } AZ(bo->fetch_failed); @@ -619,6 +628,7 @@ FetchBody(struct worker *wrk, struct object *obj) else VDI_RecycleFd(wrk, &bo->vbc); + bo->stats = NULL; return (0); } From geoff at varnish-cache.org Fri Feb 17 12:58:53 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:53 +0100 Subject: [experimental-ims] 5d4e2ce Move VGZ entirely to busyobj instead of worker Message-ID: commit 5d4e2cee84c088e52f4c79b11a11c305b4d49526 Author: Poul-Henning Kamp Date: Wed Feb 15 12:57:48 2012 +0000 Move VGZ entirely to busyobj instead of worker diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 74a8b5d..a47edf1 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -766,7 +766,7 @@ 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); int VGZ_ObufFull(const struct vgz *vg); -int VGZ_ObufStorage(struct worker *w, struct vgz *vg); +int VGZ_ObufStorage(struct busyobj *, 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 **); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index c16568a..a53ccc7 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -135,7 +135,7 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, VGZ_Ibuf(vg, vef->ibuf, wl); bytes -= wl; } - if (VGZ_ObufStorage(wrk, vg)) + if (VGZ_ObufStorage(wrk->busyobj, vg)) return(-1); i = VGZ_Gunzip(vg, &dp, &dl); xxxassert(i == VGZ_OK || i == VGZ_END); @@ -211,7 +211,7 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) VGZ_Ibuf(vef->vgz, vef->ibuf_o, l); do { - if (VGZ_ObufStorage(wrk, vef->vgz)) { + if (VGZ_ObufStorage(wrk->busyobj, vef->vgz)) { vef->error = ENOMEM; vef->tot += l; return (vef->tot); diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index c2764b5..1dd7942 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -203,11 +203,11 @@ VGZ_ObufFull(const struct vgz *vg) */ int -VGZ_ObufStorage(struct worker *wrk, struct vgz *vg) +VGZ_ObufStorage(struct busyobj *bo, struct vgz *vg) { struct storage *st; - st = FetchStorage(wrk->busyobj, 0); + st = FetchStorage(bo, 0); if (st == NULL) return (-1); @@ -466,7 +466,7 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) bytes -= wl; } - if (VGZ_ObufStorage(wrk, vg)) + if (VGZ_ObufStorage(wrk->busyobj, vg)) return(-1); i = VGZ_Gunzip(vg, &dp, &dl); if (i != VGZ_OK && i != VGZ_END) @@ -547,7 +547,7 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) VGZ_Ibuf(vg, vg->m_buf, wl); bytes -= wl; } - if (VGZ_ObufStorage(wrk, vg)) + if (VGZ_ObufStorage(wrk->busyobj, vg)) return(-1); i = VGZ_Gzip(vg, &dp, &dl, VGZ_NORMAL); assert(i == Z_OK); @@ -575,7 +575,7 @@ vfp_gzip_end(struct worker *wrk) } do { VGZ_Ibuf(vg, "", 0); - if (VGZ_ObufStorage(wrk, vg)) + if (VGZ_ObufStorage(wrk->busyobj, vg)) return(-1); i = VGZ_Gzip(vg, &dp, &dl, VGZ_FINISH); wrk->busyobj->fetch_obj->len += dl; From geoff at varnish-cache.org Fri Feb 17 12:58:53 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:53 +0100 Subject: [experimental-ims] d387098 Make FetchStorage() take a busyobj instead of a worker as arg. Message-ID: commit d387098f00fabf8965ac47f1313cf63ac4d16a46 Author: Poul-Henning Kamp Date: Wed Feb 15 12:49:25 2012 +0000 Make FetchStorage() take a busyobj instead of a worker as arg. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f2f64d3..74a8b5d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -745,10 +745,10 @@ void EXP_Inject(struct objcore *oc, struct lru *lru, double when); void EXP_Init(void); void EXP_Rearm(const struct object *o); int EXP_Touch(struct objcore *oc); -int EXP_NukeOne(struct vsl_log *, struct dstat *, struct lru *lru); +int EXP_NukeOne(struct busyobj *, struct lru *lru); /* cache_fetch.c */ -struct storage *FetchStorage(struct worker *w, ssize_t sz); +struct storage *FetchStorage(struct busyobj *, ssize_t sz); int FetchError(struct busyobj *, const char *error); int FetchError2(struct busyobj *, const char *error, const char *more); int FetchHdr(struct sess *sp, int need_host_hdr, int sendbody); @@ -1013,7 +1013,7 @@ int RFC2616_Do_Cond(const struct sess *sp); /* stevedore.c */ struct object *STV_NewObject(struct worker *wrk, const char *hint, unsigned len, uint16_t nhttp); -struct storage *STV_alloc(struct worker *w, size_t size); +struct storage *STV_alloc(struct busyobj *, size_t size); void STV_trim(struct storage *st, size_t size); void STV_free(struct storage *st); void STV_open(void); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index c3ca15e..c16568a 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -94,7 +94,7 @@ vfp_esi_bytes_uu(struct worker *wrk, const struct vef_priv *vef, CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); while (bytes > 0) { - st = FetchStorage(wrk, 0); + st = FetchStorage(wrk->busyobj, 0); if (st == NULL) return (-1); wl = vef_read(htc, @@ -396,7 +396,7 @@ vfp_esi_end(struct worker *wrk) l = VSB_len(vsb); assert(l > 0); /* XXX: This is a huge waste of storage... */ - bo->fetch_obj->esidata = STV_alloc(wrk, l); + bo->fetch_obj->esidata = STV_alloc(bo, l); if (bo->fetch_obj->esidata != NULL) { memcpy(bo->fetch_obj->esidata->ptr, VSB_data(vsb), l); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 9bdf25f..060ed58 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -414,7 +414,7 @@ exp_timer(struct sess *sp, void *priv) */ int -EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru) +EXP_NukeOne(struct busyobj *bo, struct lru *lru) { struct objcore *oc; @@ -445,8 +445,8 @@ EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru) return (-1); /* XXX: bad idea for -spersistent */ - WSL(vsl, SLT_ExpKill, -1, "%u LRU", oc_getxid(ds, oc)); - (void)HSH_Deref(ds, oc, NULL); + WSL(bo->vsl, SLT_ExpKill, -1, "%u LRU", oc_getxid(bo->stats, oc)); + (void)HSH_Deref(bo->stats, oc, NULL); return (1); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 928ecc4..e520e6d 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -92,7 +92,7 @@ vfp_nop_begin(struct worker *wrk, size_t estimate) { if (estimate > 0) - (void)FetchStorage(wrk, estimate); + (void)FetchStorage(wrk->busyobj, estimate); } /*-------------------------------------------------------------------- @@ -114,7 +114,7 @@ vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) AZ(wrk->busyobj->fetch_failed); while (bytes > 0) { - st = FetchStorage(wrk, 0); + st = FetchStorage(wrk->busyobj, 0); if (st == NULL) return(-1); l = st->space - st->len; @@ -170,13 +170,14 @@ static struct vfp vfp_nop = { */ struct storage * -FetchStorage(struct worker *wrk, ssize_t sz) +FetchStorage(struct busyobj *bo, ssize_t sz) { ssize_t l; struct storage *st; struct object *obj; - obj = wrk->busyobj->fetch_obj; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + obj = bo->fetch_obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); st = VTAILQ_LAST(&obj->store, storagehead); if (st != NULL && st->len < st->space) @@ -187,9 +188,9 @@ FetchStorage(struct worker *wrk, ssize_t sz) l = sz; if (l == 0) l = cache_param->fetch_chunksize; - st = STV_alloc(wrk, l); + st = STV_alloc(bo, l); if (st == NULL) { - (void)FetchError(wrk->busyobj, "Could not get storage"); + (void)FetchError(bo, "Could not get storage"); return (NULL); } AZ(st->len); @@ -507,7 +508,7 @@ FetchBody(struct worker *wrk, struct object *obj) CHECK_OBJ_NOTNULL(obj->http, HTTP_MAGIC); /* - * XXX: The busyobj needs a dstat, but it is not obvious which one + * XXX: The busyobj needs a dstat, but it is not obvious which one * XXX: it should be (own/borrowed). For now borrow the wrk's. */ AZ(bo->stats); diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index d16d4b1..c2764b5 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -207,7 +207,7 @@ VGZ_ObufStorage(struct worker *wrk, struct vgz *vg) { struct storage *st; - st = FetchStorage(wrk, 0); + st = FetchStorage(wrk->busyobj, 0); if (st == NULL) return (-1); @@ -627,7 +627,7 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); AZ(vg->vz.avail_in); while (bytes > 0) { - st = FetchStorage(wrk, 0); + st = FetchStorage(wrk->busyobj, 0); if (st == NULL) return(-1); l = st->space - st->len; diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 50db0db..2fce063 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -157,18 +157,20 @@ stv_pick_stevedore(struct vsl_log *vsl, const char **hint) /*-------------------------------------------------------------------*/ static struct storage * -stv_alloc(struct worker *w, const struct object *obj, size_t size) +stv_alloc(struct busyobj *bo, size_t size) { struct storage *st; struct stevedore *stv; unsigned fail = 0; + struct object *obj; /* * Always use the stevedore which allocated the object in order to * keep an object inside the same stevedore. */ + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + obj = bo->fetch_obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - CHECK_OBJ_NOTNULL(w, WORKER_MAGIC); stv = obj->objstore->stevedore; CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); @@ -188,7 +190,7 @@ stv_alloc(struct worker *w, const struct object *obj, size_t size) } /* no luck; try to free some space and keep trying */ - if (EXP_NukeOne(w->vsl, &w->stats, stv->lru) == -1) + if (EXP_NukeOne(bo, stv->lru) == -1) break; /* Enough is enough: try another if we have one */ @@ -337,12 +339,16 @@ STV_NewObject(struct worker *wrk, const char *hint, unsigned wsl, } while (o == NULL && stv != stv0); } if (o == NULL) { + /* XXX: lend busyobj wrk's stats while we nuke */ + AZ(wrk->busyobj->stats); + wrk->busyobj->stats = &wrk->stats; /* no luck; try to free some space and keep trying */ for (i = 0; o == NULL && i < cache_param->nuke_limit; i++) { - if (EXP_NukeOne(wrk->vsl, &wrk->stats, stv->lru) == -1) + if (EXP_NukeOne(wrk->busyobj, stv->lru) == -1) break; o = stv->allocobj(stv, wrk, ltot, &soc); } + wrk->busyobj->stats = NULL; } if (o == NULL) @@ -373,10 +379,10 @@ STV_Freestore(struct object *o) /*-------------------------------------------------------------------*/ struct storage * -STV_alloc(struct worker *w, size_t size) +STV_alloc(struct busyobj *bo, size_t size) { - return (stv_alloc(w, w->busyobj->fetch_obj, size)); + return (stv_alloc(bo, size)); } void From geoff at varnish-cache.org Fri Feb 17 12:58:54 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:54 +0100 Subject: [experimental-ims] 9b65ebc Push worker->busyobj shift up through VFP's. Message-ID: commit 9b65ebca918039344ec7450c4de580a59547f4b6 Author: Poul-Henning Kamp Date: Wed Feb 15 13:29:31 2012 +0000 Push worker->busyobj shift up through VFP's. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a47edf1..daa01f4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -219,9 +219,9 @@ struct dstat { /* Fetch processors --------------------------------------------------*/ -typedef void vfp_begin_f(struct worker *, size_t ); -typedef int vfp_bytes_f(struct worker *, struct http_conn *, ssize_t); -typedef int vfp_end_f(struct worker *); +typedef void vfp_begin_f(struct busyobj *, size_t ); +typedef int vfp_bytes_f(struct busyobj *, struct http_conn *, ssize_t); +typedef int vfp_end_f(struct busyobj *); struct vfp { vfp_begin_f *begin; diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 6b57011..14ca31b 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -292,15 +292,12 @@ vfp_esi_bytes_gg(const struct busyobj *bo, struct vef_priv *vef, /*---------------------------------------------------------------------*/ -static void __match_proto__() -vfp_esi_begin(struct worker *wrk, size_t estimate) +static void __match_proto__(vfp_begin_f) +vfp_esi_begin(struct busyobj *bo, size_t estimate) { - struct busyobj *bo; struct vef_priv *vef; (void)estimate; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - bo = wrk->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); ALLOC_OBJ(vef, VEF_MAGIC); @@ -310,16 +307,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->vsl, "U F E"); + bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "U F E"); VEP_Init(bo, NULL); vef->ibuf_sz = cache_param->gzip_buffer; } else if (bo->is_gunzip && bo->do_gzip) { - vef->vgz = VGZ_NewGzip(wrk->vsl, "G F E"); + vef->vgz = VGZ_NewGzip(bo->vsl, "G F E"); VEP_Init(bo, vfp_vep_callback); vef->ibuf_sz = cache_param->gzip_buffer; } else if (bo->is_gzip) { - bo->vgz_rx = VGZ_NewUngzip(wrk->vsl, "U F E"); - vef->vgz = VGZ_NewGzip(wrk->vsl, "G F E"); + bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "U F E"); + vef->vgz = VGZ_NewGzip(bo->vsl, "G F E"); VEP_Init(bo, vfp_vep_callback); vef->ibuf_sz = cache_param->gzip_buffer; vef->ibuf2_sz = cache_param->gzip_buffer; @@ -339,15 +336,12 @@ vfp_esi_begin(struct worker *wrk, size_t estimate) AN(bo->vep); } -static int __match_proto__() -vfp_esi_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +static int __match_proto__(vfp_bytes_f) +vfp_esi_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) { - struct busyobj *bo; struct vef_priv *vef; int i; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - bo = wrk->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); vef = bo->vef_priv; CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); @@ -367,17 +361,14 @@ vfp_esi_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) return (i); } -static int __match_proto__() -vfp_esi_end(struct worker *wrk) +static int __match_proto__(vfp_end_f) +vfp_esi_end(struct busyobj *bo) { struct vsb *vsb; struct vef_priv *vef; - struct busyobj *bo; ssize_t l; int retval; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - bo = wrk->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AN(bo->vep); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index e520e6d..372ce08 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -87,12 +87,12 @@ FetchError(struct busyobj *bo, const char *error) * 'estimate' is the estimate of the number of bytes we expect to receive, * as seen on the socket, or zero if unknown. */ -static void __match_proto__() -vfp_nop_begin(struct worker *wrk, size_t estimate) +static void __match_proto__(vfp_begin_f) +vfp_nop_begin(struct busyobj *bo, size_t estimate) { if (estimate > 0) - (void)FetchStorage(wrk->busyobj, estimate); + (void)FetchStorage(bo, estimate); } /*-------------------------------------------------------------------- @@ -106,15 +106,15 @@ vfp_nop_begin(struct worker *wrk, size_t estimate) * Return 1 when 'bytes' have been processed. */ -static int __match_proto__() -vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +static int __match_proto__(vfp_bytes_f) +vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) { ssize_t l, wl; struct storage *st; - AZ(wrk->busyobj->fetch_failed); + AZ(bo->fetch_failed); while (bytes > 0) { - st = FetchStorage(wrk->busyobj, 0); + st = FetchStorage(bo, 0); if (st == NULL) return(-1); l = st->space - st->len; @@ -124,7 +124,7 @@ vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) if (wl <= 0) return (wl); st->len += wl; - wrk->busyobj->fetch_obj->len += wl; + bo->fetch_obj->len += wl; bytes -= wl; } return (1); @@ -139,17 +139,17 @@ vfp_nop_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) * Return 0 for OK */ -static int __match_proto__() -vfp_nop_end(struct worker *wrk) +static int __match_proto__(vfp_end_f) +vfp_nop_end(struct busyobj *bo) { struct storage *st; - st = VTAILQ_LAST(&wrk->busyobj->fetch_obj->store, storagehead); + st = VTAILQ_LAST(&bo->fetch_obj->store, storagehead); if (st == NULL) return (0); if (st->len == 0) { - VTAILQ_REMOVE(&wrk->busyobj->fetch_obj->store, st, list); + VTAILQ_REMOVE(&bo->fetch_obj->store, st, list); STV_free(st); return (0); } @@ -224,20 +224,20 @@ fetch_number(const char *nbr, int radix) /*--------------------------------------------------------------------*/ static int -fetch_straight(struct worker *wrk, struct http_conn *htc, ssize_t cl) +fetch_straight(struct busyobj *bo, struct http_conn *htc, ssize_t cl) { int i; - assert(wrk->busyobj->body_status == BS_LENGTH); + assert(bo->body_status == BS_LENGTH); if (cl < 0) { - return (FetchError(wrk->busyobj, "straight length field bogus")); + return (FetchError(bo, "straight length field bogus")); } else if (cl == 0) return (0); - i = wrk->busyobj->vfp->bytes(wrk, htc, cl); + i = bo->vfp->bytes(bo, htc, cl); if (i <= 0) - return (FetchError(wrk->busyobj, "straight insufficient bytes")); + return (FetchError(bo, "straight insufficient bytes")); return (0); } @@ -248,14 +248,14 @@ fetch_straight(struct worker *wrk, struct http_conn *htc, ssize_t cl) */ static int -fetch_chunked(struct worker *wrk, struct http_conn *htc) +fetch_chunked(struct busyobj *bo, struct http_conn *htc) { int i; char buf[20]; /* XXX: 20 is arbitrary */ unsigned u; ssize_t cl; - assert(wrk->busyobj->body_status == BS_CHUNKED); + assert(bo->body_status == BS_CHUNKED); do { /* Skip leading whitespace */ do { @@ -264,7 +264,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) } while (vct_islws(buf[0])); if (!vct_ishex(buf[0])) - return (FetchError(wrk->busyobj, "chunked header non-hex")); + return (FetchError(bo, "chunked header non-hex")); /* Collect hex digits, skipping leading zeros */ for (u = 1; u < sizeof buf; u++) { @@ -277,7 +277,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) } if (u >= sizeof buf) - return (FetchError(wrk->busyobj,"chunked header too long")); + return (FetchError(bo,"chunked header too long")); /* Skip trailing white space */ while(vct_islws(buf[u]) && buf[u] != '\n') @@ -285,14 +285,14 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) return (-1); if (buf[u] != '\n') - return (FetchError(wrk->busyobj,"chunked header no NL")); + return (FetchError(bo,"chunked header no NL")); buf[u] = '\0'; cl = fetch_number(buf, 16); if (cl < 0) - return (FetchError(wrk->busyobj,"chunked header number syntax")); + return (FetchError(bo,"chunked header number syntax")); - if (cl > 0 && wrk->busyobj->vfp->bytes(wrk, htc, cl) <= 0) + if (cl > 0 && bo->vfp->bytes(bo, htc, cl) <= 0) return (-1); i = HTC_Read(htc, buf, 1); @@ -301,7 +301,7 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) if (buf[0] == '\r' && HTC_Read( htc, buf, 1) <= 0) return (-1); if (buf[0] != '\n') - return (FetchError(wrk->busyobj,"chunked tail no NL")); + return (FetchError(bo,"chunked tail no NL")); } while (cl > 0); return (0); } @@ -309,12 +309,12 @@ fetch_chunked(struct worker *wrk, struct http_conn *htc) /*--------------------------------------------------------------------*/ static int -fetch_eof(struct worker *wrk, struct http_conn *htc) +fetch_eof(struct busyobj *bo, struct http_conn *htc) { int i; - assert(wrk->busyobj->body_status == BS_EOF); - i = wrk->busyobj->vfp->bytes(wrk, htc, SSIZE_MAX); + assert(bo->body_status == BS_EOF); + i = bo->vfp->bytes(bo, htc, SSIZE_MAX); if (i < 0) return (-1); return (0); @@ -540,24 +540,24 @@ FetchBody(struct worker *wrk, struct object *obj) break; case BS_LENGTH: cl = fetch_number(bo->h_content_length, 10); - bo->vfp->begin(wrk, cl > 0 ? cl : 0); - cls = fetch_straight(wrk, htc, cl); + bo->vfp->begin(bo, cl > 0 ? cl : 0); + cls = fetch_straight(bo, htc, cl); mklen = 1; - if (bo->vfp->end(wrk)) + if (bo->vfp->end(bo)) cls = -1; break; case BS_CHUNKED: - bo->vfp->begin(wrk, cl); - cls = fetch_chunked(wrk, htc); + bo->vfp->begin(bo, cl); + cls = fetch_chunked(bo, htc); mklen = 1; - if (bo->vfp->end(wrk)) + if (bo->vfp->end(bo)) cls = -1; break; case BS_EOF: - bo->vfp->begin(wrk, cl); - cls = fetch_eof(wrk, htc); + bo->vfp->begin(bo, cl); + cls = fetch_eof(bo, htc); mklen = 1; - if (bo->vfp->end(wrk)) + if (bo->vfp->end(bo)) cls = -1; break; case BS_ERROR: @@ -576,7 +576,7 @@ FetchBody(struct worker *wrk, struct object *obj) * sitting on wrk->storage, we will always call vfp_nop_end() * to get it trimmed or thrown out if empty. */ - AZ(vfp_nop_end(wrk)); + AZ(vfp_nop_end(bo)); bo->fetch_obj = NULL; diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 1dd7942..530d43b 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -428,19 +428,18 @@ VGZ_Destroy(struct vgz **vgp) * A VFP for gunzip'ing an object as we receive it from the backend */ -static void __match_proto__() -vfp_gunzip_begin(struct worker *wrk, size_t estimate) +static void __match_proto__(vfp_begin_f) +vfp_gunzip_begin(struct busyobj *bo, size_t estimate) { (void)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->vsl, "U F -"); - XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx)); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AZ(bo->vgz_rx); + bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "U F -"); + XXXAZ(vgz_getmbuf(bo->vgz_rx)); } -static int __match_proto__() -vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +static int __match_proto__(vfp_bytes_f) +vfp_gunzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) { struct vgz *vg; ssize_t l, wl; @@ -448,10 +447,9 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) size_t dl; const void *dp; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - AZ(wrk->busyobj->fetch_failed); - vg = wrk->busyobj->vgz_rx; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AZ(bo->fetch_failed); + vg = bo->vgz_rx; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); AZ(vg->vz.avail_in); while (bytes > 0 || vg->vz.avail_in > 0) { @@ -466,34 +464,32 @@ vfp_gunzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) bytes -= wl; } - if (VGZ_ObufStorage(wrk->busyobj, vg)) + if (VGZ_ObufStorage(bo, vg)) return(-1); i = VGZ_Gunzip(vg, &dp, &dl); if (i != VGZ_OK && i != VGZ_END) - return(FetchError(wrk->busyobj, "Gunzip data error")); - wrk->busyobj->fetch_obj->len += dl; + return(FetchError(bo, "Gunzip data error")); + bo->fetch_obj->len += dl; } assert(i == Z_OK || i == Z_STREAM_END); return (1); } -static int __match_proto__() -vfp_gunzip_end(struct worker *wrk) +static int __match_proto__(vfp_end_f) +vfp_gunzip_end(struct busyobj *bo) { struct vgz *vg; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vg = wrk->busyobj->vgz_rx; - wrk->busyobj->vgz_rx = NULL; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vg = bo->vgz_rx; + bo->vgz_rx = NULL; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - if (wrk->busyobj->fetch_failed) { + if (bo->fetch_failed) { (void)VGZ_Destroy(&vg); return(0); } if (VGZ_Destroy(&vg) != VGZ_END) - return(FetchError(wrk->busyobj, - "Gunzip error at the very end")); + return(FetchError(bo, "Gunzip error at the very end")); return (0); } @@ -509,20 +505,19 @@ struct vfp vfp_gunzip = { * A VFP for gzip'ing an object as we receive it from the backend */ -static void __match_proto__() -vfp_gzip_begin(struct worker *wrk, size_t estimate) +static void __match_proto__(vfp_begin_f) +vfp_gzip_begin(struct busyobj *bo, size_t estimate) { (void)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->vsl, "G F -"); - XXXAZ(vgz_getmbuf(wrk->busyobj->vgz_rx)); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AZ(bo->vgz_rx); + bo->vgz_rx = VGZ_NewGzip(bo->vsl, "G F -"); + XXXAZ(vgz_getmbuf(bo->vgz_rx)); } -static int __match_proto__() -vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +static int __match_proto__(vfp_bytes_f) +vfp_gzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) { struct vgz *vg; ssize_t l, wl; @@ -530,10 +525,9 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) size_t dl; const void *dp; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - AZ(wrk->busyobj->fetch_failed); - vg = wrk->busyobj->vgz_rx; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AZ(bo->fetch_failed); + vg = bo->vgz_rx; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); AZ(vg->vz.avail_in); while (bytes > 0 || !VGZ_IbufEmpty(vg)) { @@ -547,42 +541,41 @@ vfp_gzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) VGZ_Ibuf(vg, vg->m_buf, wl); bytes -= wl; } - if (VGZ_ObufStorage(wrk->busyobj, vg)) + if (VGZ_ObufStorage(bo, vg)) return(-1); i = VGZ_Gzip(vg, &dp, &dl, VGZ_NORMAL); assert(i == Z_OK); - wrk->busyobj->fetch_obj->len += dl; + bo->fetch_obj->len += dl; } return (1); } -static int __match_proto__() -vfp_gzip_end(struct worker *wrk) +static int __match_proto__(vfp_end_f) +vfp_gzip_end(struct busyobj *bo) { struct vgz *vg; size_t dl; const void *dp; int i; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vg = wrk->busyobj->vgz_rx; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vg = bo->vgz_rx; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - wrk->busyobj->vgz_rx = NULL; - if (wrk->busyobj->fetch_failed) { + bo->vgz_rx = NULL; + if (bo->fetch_failed) { (void)VGZ_Destroy(&vg); return(0); } do { VGZ_Ibuf(vg, "", 0); - if (VGZ_ObufStorage(wrk->busyobj, vg)) + if (VGZ_ObufStorage(bo, vg)) return(-1); i = VGZ_Gzip(vg, &dp, &dl, VGZ_FINISH); - wrk->busyobj->fetch_obj->len += dl; + bo->fetch_obj->len += dl; } while (i != Z_STREAM_END); - VGZ_UpdateObj(vg, wrk->busyobj->fetch_obj); + VGZ_UpdateObj(vg, bo->fetch_obj); if (VGZ_Destroy(&vg) != VGZ_END) - return(FetchError(wrk->busyobj, "Gzip error at the very end")); + return(FetchError(bo, "Gzip error at the very end")); return (0); } @@ -599,19 +592,18 @@ struct vfp vfp_gzip = { * collecting the magic bits while we're at it. */ -static void __match_proto__() -vfp_testgzip_begin(struct worker *wrk, size_t estimate) +static void __match_proto__(vfp_begin_f) +vfp_testgzip_begin(struct busyobj *bo, size_t estimate) { - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); (void)estimate; - 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)); + bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "u F -"); + CHECK_OBJ_NOTNULL(bo->vgz_rx, VGZ_MAGIC); + XXXAZ(vgz_getmbuf(bo->vgz_rx)); } -static int __match_proto__() -vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) +static int __match_proto__(vfp_bytes_f) +vfp_testgzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) { struct vgz *vg; ssize_t l, wl; @@ -620,14 +612,13 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) const void *dp; struct storage *st; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - AZ(wrk->busyobj->fetch_failed); - vg = wrk->busyobj->vgz_rx; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AZ(bo->fetch_failed); + vg = bo->vgz_rx; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); AZ(vg->vz.avail_in); while (bytes > 0) { - st = FetchStorage(wrk->busyobj, 0); + st = FetchStorage(bo, 0); if (st == NULL) return(-1); l = st->space - st->len; @@ -639,16 +630,15 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) bytes -= wl; VGZ_Ibuf(vg, st->ptr + st->len, wl); st->len += wl; - wrk->busyobj->fetch_obj->len += wl; + bo->fetch_obj->len += wl; while (!VGZ_IbufEmpty(vg)) { VGZ_Obuf(vg, vg->m_buf, vg->m_sz); i = VGZ_Gunzip(vg, &dp, &dl); if (i == VGZ_END && !VGZ_IbufEmpty(vg)) - return(FetchError(wrk->busyobj, - "Junk after gzip data")); + return(FetchError(bo, "Junk after gzip data")); if (i != VGZ_OK && i != VGZ_END) - return(FetchError2(wrk->busyobj, + return(FetchError2(bo, "Invalid Gzip data", vg->vz.msg)); } } @@ -656,24 +646,22 @@ vfp_testgzip_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) return (1); } -static int __match_proto__() -vfp_testgzip_end(struct worker *wrk) +static int __match_proto__(vfp_end_f) +vfp_testgzip_end(struct busyobj *bo) { struct vgz *vg; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vg = wrk->busyobj->vgz_rx; - wrk->busyobj->vgz_rx = NULL; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vg = bo->vgz_rx; + bo->vgz_rx = NULL; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - if (wrk->busyobj->fetch_failed) { + if (bo->fetch_failed) { (void)VGZ_Destroy(&vg); return(0); } - VGZ_UpdateObj(vg, wrk->busyobj->fetch_obj); + VGZ_UpdateObj(vg, bo->fetch_obj); if (VGZ_Destroy(&vg) != VGZ_END) - return(FetchError(wrk->busyobj, - "TestGunzip error at the very end")); + return(FetchError(bo, "TestGunzip error at the very end")); return (0); } From geoff at varnish-cache.org Fri Feb 17 12:58:54 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:54 +0100 Subject: [experimental-ims] 4076126 Push worker->busyobj change up through ESI Message-ID: commit 40761260036de1c36a19d0b56776bee945e742bf Author: Poul-Henning Kamp Date: Wed Feb 15 13:13:17 2012 +0000 Push worker->busyobj change up through ESI diff --git a/bin/varnishd/cache/cache_esi.h b/bin/varnishd/cache/cache_esi.h index bcc815b..c6c2376 100644 --- a/bin/varnishd/cache/cache_esi.h +++ b/bin/varnishd/cache/cache_esi.h @@ -39,10 +39,10 @@ #define VEC_S8 (0x60 + 8) #define VEC_INCL 'I' -typedef ssize_t vep_callback_t(struct worker *w, ssize_t l, enum vgz_flag flg); +typedef ssize_t vep_callback_t(struct busyobj *, ssize_t l, enum vgz_flag flg); -void VEP_Init(struct worker *w, vep_callback_t *cb); +void VEP_Init(struct busyobj *, vep_callback_t *cb); void VEP_Parse(const struct busyobj *, const char *p, size_t l); -struct vsb *VEP_Finish(const struct worker *w); +struct vsb *VEP_Finish(struct busyobj *); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index a53ccc7..6b57011 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -84,26 +84,26 @@ vef_read(struct http_conn *htc, void *buf, ssize_t buflen, */ static int -vfp_esi_bytes_uu(struct worker *wrk, const struct vef_priv *vef, +vfp_esi_bytes_uu(struct busyobj *bo, const struct vef_priv *vef, struct http_conn *htc, ssize_t bytes) { ssize_t wl; struct storage *st; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); while (bytes > 0) { - st = FetchStorage(wrk->busyobj, 0); + st = FetchStorage(bo, 0); if (st == NULL) return (-1); wl = vef_read(htc, st->ptr + st->len, st->space - st->len, bytes); if (wl <= 0) return (wl); - VEP_Parse(wrk->busyobj, (const char *)st->ptr + st->len, wl); + VEP_Parse(bo, (const char *)st->ptr + st->len, wl); st->len += wl; - wrk->busyobj->fetch_obj->len += wl; + bo->fetch_obj->len += wl; bytes -= wl; } return (1); @@ -114,7 +114,7 @@ vfp_esi_bytes_uu(struct worker *wrk, const struct vef_priv *vef, */ static int -vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, +vfp_esi_bytes_gu(struct busyobj *bo, const struct vef_priv *vef, struct http_conn *htc, ssize_t bytes) { struct vgz *vg; @@ -123,9 +123,9 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, size_t dl; const void *dp; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - vg = wrk->busyobj->vgz_rx; + vg = bo->vgz_rx; while (bytes > 0) { if (VGZ_IbufEmpty(vg) && bytes > 0) { @@ -135,12 +135,12 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, VGZ_Ibuf(vg, vef->ibuf, wl); bytes -= wl; } - if (VGZ_ObufStorage(wrk->busyobj, vg)) + if (VGZ_ObufStorage(bo, vg)) return(-1); i = VGZ_Gunzip(vg, &dp, &dl); xxxassert(i == VGZ_OK || i == VGZ_END); - VEP_Parse(wrk->busyobj, dp, dl); - wrk->busyobj->fetch_obj->len += dl; + VEP_Parse(bo, dp, dl); + bo->fetch_obj->len += dl; } return (1); } @@ -161,13 +161,13 @@ vfp_esi_bytes_gu(struct worker *wrk, const struct vef_priv *vef, */ static int -vfp_vep_inject(const struct worker *wrk, struct vef_priv *vef, ssize_t wl) +vfp_vep_inject(const struct busyobj *bo, struct vef_priv *vef, ssize_t wl) { - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - VEP_Parse(wrk->busyobj, vef->ibuf_i, wl); + VEP_Parse(bo, vef->ibuf_i, wl); vef->ibuf_i += wl; assert(vef->ibuf_o >= vef->ibuf && vef->ibuf_o <= vef->ibuf_i); if (vef->error) { @@ -183,16 +183,15 @@ vfp_vep_inject(const struct worker *wrk, struct vef_priv *vef, ssize_t wl) } static ssize_t -vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) +vfp_vep_callback(struct busyobj *bo, ssize_t l, enum vgz_flag flg) { struct vef_priv *vef; size_t dl; const void *dp; int i; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vef = wrk->busyobj->vef_priv; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vef = bo->vef_priv; CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); assert(l >= 0); @@ -211,14 +210,14 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) VGZ_Ibuf(vef->vgz, vef->ibuf_o, l); do { - if (VGZ_ObufStorage(wrk->busyobj, vef->vgz)) { + if (VGZ_ObufStorage(bo, vef->vgz)) { vef->error = ENOMEM; vef->tot += l; return (vef->tot); } i = VGZ_Gzip(vef->vgz, &dp, &dl, flg); vef->tot += dl; - wrk->busyobj->fetch_obj->len += dl; + bo->fetch_obj->len += dl; } while (!VGZ_IbufEmpty(vef->vgz) || (flg != VGZ_NORMAL && VGZ_ObufFull(vef->vgz))); assert(VGZ_IbufEmpty(vef->vgz)); @@ -235,14 +234,13 @@ vfp_vep_callback(struct worker *wrk, ssize_t l, enum vgz_flag flg) */ static int -vfp_esi_bytes_ug(const struct worker *wrk, struct vef_priv *vef, +vfp_esi_bytes_ug(const struct busyobj *bo, struct vef_priv *vef, struct http_conn *htc, ssize_t bytes) { ssize_t wl; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); while (bytes > 0) { wl = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf); @@ -250,7 +248,7 @@ vfp_esi_bytes_ug(const struct worker *wrk, struct vef_priv *vef, if (wl <= 0) return (wl); bytes -= wl; - if (vfp_vep_inject(wrk, vef, wl)) + if (vfp_vep_inject(bo, vef, wl)) return (-1); } return (1); @@ -261,7 +259,7 @@ vfp_esi_bytes_ug(const struct worker *wrk, struct vef_priv *vef, */ static int -vfp_esi_bytes_gg(const struct worker *wrk, struct vef_priv *vef, +vfp_esi_bytes_gg(const struct busyobj *bo, struct vef_priv *vef, struct http_conn *htc, size_t bytes) { ssize_t wl; @@ -269,9 +267,8 @@ vfp_esi_bytes_gg(const struct worker *wrk, struct vef_priv *vef, const void *dp; int i; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); while (bytes > 0) { wl = vef_read(htc, vef->ibuf2, vef->ibuf2_sz, bytes); @@ -279,16 +276,16 @@ vfp_esi_bytes_gg(const struct worker *wrk, struct vef_priv *vef, return (wl); bytes -= wl; - VGZ_Ibuf(wrk->busyobj->vgz_rx, vef->ibuf2, wl); + VGZ_Ibuf(bo->vgz_rx, vef->ibuf2, wl); do { wl = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf); - VGZ_Obuf(wrk->busyobj->vgz_rx, vef->ibuf_i, wl); - i = VGZ_Gunzip(wrk->busyobj->vgz_rx, &dp, &dl); + VGZ_Obuf(bo->vgz_rx, vef->ibuf_i, wl); + i = VGZ_Gunzip(bo->vgz_rx, &dp, &dl); /* XXX: check i */ assert(i >= VGZ_OK); - if (dl > 0 && vfp_vep_inject(wrk, vef, dl)) + if (dl > 0 && vfp_vep_inject(bo, vef, dl)) return (-1); - } while (!VGZ_IbufEmpty(wrk->busyobj->vgz_rx)); + } while (!VGZ_IbufEmpty(bo->vgz_rx)); } return (1); } @@ -314,20 +311,20 @@ 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->vsl, "U F E"); - VEP_Init(wrk, NULL); + VEP_Init(bo, NULL); vef->ibuf_sz = cache_param->gzip_buffer; } else if (bo->is_gunzip && bo->do_gzip) { vef->vgz = VGZ_NewGzip(wrk->vsl, "G F E"); - VEP_Init(wrk, vfp_vep_callback); + VEP_Init(bo, vfp_vep_callback); vef->ibuf_sz = cache_param->gzip_buffer; } else if (bo->is_gzip) { 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); + VEP_Init(bo, vfp_vep_callback); vef->ibuf_sz = cache_param->gzip_buffer; vef->ibuf2_sz = cache_param->gzip_buffer; } else { - VEP_Init(wrk, NULL); + VEP_Init(bo, NULL); } if (vef->ibuf_sz > 0) { vef->ibuf = calloc(1L, vef->ibuf_sz); @@ -359,13 +356,13 @@ vfp_esi_bytes(struct worker *wrk, struct http_conn *htc, ssize_t bytes) AN(bo->vep); assert(&bo->htc == htc); if (bo->is_gzip && bo->do_gunzip) - i = vfp_esi_bytes_gu(wrk, vef, htc, bytes); + i = vfp_esi_bytes_gu(bo, vef, htc, bytes); else if (bo->is_gunzip && bo->do_gzip) - i = vfp_esi_bytes_ug(wrk, vef, htc, bytes); + i = vfp_esi_bytes_ug(bo, vef, htc, bytes); else if (bo->is_gzip) - i = vfp_esi_bytes_gg(wrk, vef, htc, bytes); + i = vfp_esi_bytes_gg(bo, vef, htc, bytes); else - i = vfp_esi_bytes_uu(wrk, vef, htc, bytes); + i = vfp_esi_bytes_uu(bo, vef, htc, bytes); AN(bo->vep); return (i); } @@ -389,7 +386,7 @@ vfp_esi_end(struct worker *wrk) 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); + vsb = VEP_Finish(bo); if (vsb != NULL) { if (!retval) { diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 8e9429c..053f614 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -60,7 +60,6 @@ struct vep_state { #define VEP_MAGIC 0x55cb9b82 struct vsb *vsb; - struct worker *wrk; struct busyobj *bo; int dogzip; vep_callback_t *cb; @@ -329,7 +328,7 @@ vep_mark_common(struct vep_state *vep, const char *p, enum vep_mark mark) */ if (vep->last_mark != mark && (vep->o_wait > 0 || vep->startup)) { - lcb = vep->cb(vep->wrk, 0, + lcb = vep->cb(vep->bo, 0, mark == VERBATIM ? VGZ_RESET : VGZ_ALIGN); if (lcb - vep->o_last > 0) vep_emit_common(vep, lcb - vep->o_last, vep->last_mark); @@ -339,7 +338,7 @@ vep_mark_common(struct vep_state *vep, const char *p, enum vep_mark mark) /* Transfer pending bytes CRC into active mode CRC */ if (vep->o_pending) { - (void)vep->cb(vep->wrk, vep->o_pending, VGZ_NORMAL); + (void)vep->cb(vep->bo, vep->o_pending, VGZ_NORMAL); if (vep->o_crc == 0) { vep->crc = vep->crcp; vep->o_crc = vep->o_pending; @@ -363,7 +362,7 @@ vep_mark_common(struct vep_state *vep, const char *p, enum vep_mark mark) vep->o_wait += l; vep->last_mark = mark; - (void)vep->cb(vep->wrk, l, VGZ_NORMAL); + (void)vep->cb(vep->bo, l, VGZ_NORMAL); } static void @@ -500,7 +499,7 @@ vep_do_include(struct vep_state *vep, enum dowhat what) VSB_printf(vep->vsb, "%c", 0); } else { VSB_printf(vep->vsb, "%c", 0); - url = vep->wrk->busyobj->bereq->hd[HTTP_HDR_URL]; + url = vep->bo->bereq->hd[HTTP_HDR_URL]; /* Look for the last / before a '?' */ h = NULL; for (q = url.b; q < url.e && *q != '?'; q++) @@ -979,14 +978,14 @@ VEP_Parse(const struct busyobj *bo, const char *p, size_t l) */ static ssize_t __match_proto__() -vep_default_cb(struct worker *wrk, ssize_t l, enum vgz_flag flg) +vep_default_cb(struct busyobj *bo, ssize_t l, enum vgz_flag flg) { struct vep_state *vep; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vep = wrk->busyobj->vep; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vep = bo->vep; CHECK_OBJ_NOTNULL(vep, VEP_MAGIC); + assert(vep->bo == bo); (void)flg; vep->cb_x += l; return (vep->cb_x); @@ -996,23 +995,21 @@ vep_default_cb(struct worker *wrk, ssize_t l, enum vgz_flag flg) */ void -VEP_Init(struct worker *wrk, vep_callback_t *cb) +VEP_Init(struct busyobj *bo, vep_callback_t *cb) { struct vep_state *vep; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - AZ(wrk->busyobj->vep); - vep = (void*)WS_Alloc(wrk->busyobj->ws, sizeof *vep); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AZ(bo->vep); + vep = (void*)WS_Alloc(bo->ws, sizeof *vep); AN(vep); memset(vep, 0, sizeof *vep); vep->magic = VEP_MAGIC; - vep->wrk = wrk; - vep->bo = wrk->busyobj; + vep->bo = bo; vep->vsb = VSB_new_auto(); AN(vep->vsb); - wrk->busyobj->vep = vep; + bo->vep = vep; if (cb != NULL) { vep->dogzip = 1; @@ -1043,25 +1040,25 @@ VEP_Init(struct worker *wrk, vep_callback_t *cb) */ struct vsb * -VEP_Finish(const struct worker *wrk) +VEP_Finish(struct busyobj *bo) { struct vep_state *vep; ssize_t l, lcb; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vep = wrk->busyobj->vep; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + vep = bo->vep; CHECK_OBJ_NOTNULL(vep, VEP_MAGIC); + assert(vep->bo == bo); if (vep->o_pending) vep_mark_common(vep, vep->ver_p, vep->last_mark); if (vep->o_wait > 0) { - lcb = vep->cb(vep->wrk, 0, VGZ_ALIGN); + lcb = vep->cb(vep->bo, 0, VGZ_ALIGN); vep_emit_common(vep, lcb - vep->o_last, vep->last_mark); } - (void)vep->cb(vep->wrk, 0, VGZ_FINISH); + (void)vep->cb(vep->bo, 0, VGZ_FINISH); - wrk->busyobj->vep = NULL; + bo->vep = NULL; AZ(VSB_finish(vep->vsb)); l = VSB_len(vep->vsb); if (vep->esi_found && l > 0) From geoff at varnish-cache.org Fri Feb 17 12:58:54 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:54 +0100 Subject: [experimental-ims] 7d164e0 Most of these variables are not available in vcl_deliver Message-ID: commit 7d164e06e42dd6524b12acaa87a84c2aaf0404db Author: Andreas Plesner Jacobsen Date: Thu Feb 16 19:53:59 2012 +0100 Most of these variables are not available in vcl_deliver Fixes #1056 diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 1ef14d6..9e71fbd 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -842,7 +842,8 @@ beresp.storage After the object is entered into the cache, the following (mostly read-only) variables are available when the object has been located in -cache, typically in vcl_hit and vcl_deliver. +cache, typically in vcl_hit, or when constructing a synthetic reply in +vcl_error: obj.proto The HTTP protocol version used when the object was retrieved. @@ -858,11 +859,12 @@ obj.ttl obj.lastuse The approximate time elapsed since the object was last requests, in - seconds. + seconds. This variable is also available in vcl_deliver. obj.hits The approximate number of times the object has been delivered. A value - of 0 indicates a cache miss. + of 0 indicates a cache miss. This variable is also available in + vcl_deliver. obj.grace The object's grace period in seconds. obj.grace is writable. From geoff at varnish-cache.org Fri Feb 17 12:58:54 2012 From: geoff at varnish-cache.org (Geoff Simmons) Date: Fri, 17 Feb 2012 13:58:54 +0100 Subject: [experimental-ims] a18ff47 Merge master -> experimental-ims Since STV_alloc() was changed in master so that it assumes allocation is only for busyobj->fecthobj, there's a problem with the duplication of storage from stale_obj into the newly fetched obj -- for copying, it needs to allocate storage, and now just calls stv->alloc, without STV_alloc's logic to check for exhausted storage, nuke if necessary, etc. This is *not* safe now. Message-ID: commit a18ff477361a7fc69f8777e963921fc10ede1110 Merge: 28026e2 7d164e0 Author: Geoff Simmons Date: Fri Feb 17 12:50:07 2012 +0100 Merge master -> experimental-ims Since STV_alloc() was changed in master so that it assumes allocation is only for busyobj->fecthobj, there's a problem with the duplication of storage from stale_obj into the newly fetched obj -- for copying, it needs to allocate storage, and now just calls stv->alloc, without STV_alloc's logic to check for exhausted storage, nuke if necessary, etc. This is *not* safe now. All the more reason IMO to implement a solution with linking and refcounting the storage. IMS should not be messing around with stevedores. diff --cc bin/varnishd/cache/cache_center.c index 517ff3b,4b0429a..6dc84be --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@@ -920,25 -884,6 +909,25 @@@ cnt_fetchbody(struct sess *sp, struct w /* Use unmodified headers*/ i = FetchBody(wrk, req->obj); + /* + * If a stale_obj was found, dup its storage into the new obj, + * reset Content-Length from the size of the storage, and discard + * the stale_obj. + */ + if (bo->stale_obj) { - STV_dup(sp, bo->stale_obj, req->obj); ++ STV_dup(bo->stale_obj, req->obj); + assert(bo->stale_obj->len == req->obj->len); + + http_Unset(req->obj->http, H_Content_Length); + http_PrintfHeader(req->obj->http, "Content-Length: %lu", + req->obj->len); + + EXP_Clr(&bo->stale_obj->exp); + EXP_Rearm(bo->stale_obj); + HSH_Deref(&sp->wrk->stats, NULL, &bo->stale_obj); + AZ(bo->stale_obj); + } + http_Teardown(bo->bereq); http_Teardown(bo->beresp); bo->vfp = NULL; diff --cc bin/varnishd/storage/stevedore.c index 8ecab24,2fce063..46c3332 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@@ -374,13 -379,10 +379,9 @@@ STV_Freestore(struct object *o /*-------------------------------------------------------------------*/ struct storage * - STV_alloc(struct worker *w, size_t size) + STV_alloc(struct busyobj *bo, size_t size) { - struct object *obj = w->busyobj->fetch_obj; - if (obj == NULL) - obj = w->sp->req->obj; -- - return (stv_alloc(w, obj, size)); + return (stv_alloc(bo, size)); } void @@@ -393,30 -395,6 +394,30 @@@ STV_trim(struct storage *st, size_t siz st->stevedore->trim(st, size); } +/* + * Duplicate the object storage (HTML body) from src into target, using a + * stevedore-specific dup method for src's stevedore. + * + * Currently, every method just copies storage from one object to the other, + * but this method of encapsulation opens the path to future techniques of + * sharing storage together with reference counting. + */ +void - STV_dup(const struct sess *sp, struct object *src, struct object *target) ++STV_dup(struct object *src, struct object *target) +{ + struct stevedore *stv; + + CHECK_OBJ_NOTNULL(src, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(target, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(src->objstore, STORAGE_MAGIC); + CHECK_OBJ_NOTNULL(src->objstore->stevedore, STEVEDORE_MAGIC); + + stv = src->objstore->stevedore; + AN(stv->dup); + - stv->dup(sp, src, target); ++ stv->dup(src, target); +} + void STV_free(struct storage *st) { @@@ -501,24 -479,3 +502,35 @@@ VRT_Stv_##nm(const char *nm) #include "tbl/vrt_stv_var.h" #undef VRTSTVVAR + +/* + * Default object store dup just copies the storage. + */ +void - default_dup(const struct sess *sp, struct object *src, struct object *target) ++default_dup(struct object *src, struct object *target) +{ + struct storage *st, *st2; + unsigned cl; ++ struct stevedore *stv = target->objstore->stevedore; ++ ++ CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); ++ AN(stv->alloc); + ++ /* ++ * XXX: This should use the logic of STV_alloc() instead of just ++ * stv->alloc, to check if space is exhausted, nuke if necessary, ++ * etc. This is *not* safe; it risks running out of storage with ++ * no recovery. But STV_alloc() now assumes that allocs are only ++ * for busyobj->fetchobj. ++ */ + VTAILQ_FOREACH(st2, &src->store, list) { + cl = st2->len; - st = STV_alloc(sp->wrk, cl); ++ st = stv->alloc(stv, cl); + XXXAN(st); + assert(st->space >= cl); + VTAILQ_INSERT_TAIL(&target->store, st, list); + st->len = cl; + target->len += cl; + memcpy(st->ptr, st2->ptr, cl); + } +} diff --cc bin/varnishd/storage/storage.h index 70468be,c8c3689..79d75a3 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@@ -40,7 -40,6 +40,7 @@@ struct lru typedef void storage_init_f(struct stevedore *, int ac, char * const *av); typedef void storage_open_f(const struct stevedore *); typedef struct storage *storage_alloc_f(struct stevedore *, size_t size); - typedef void storage_dup_f(const struct sess *sp, struct object *src, struct object *target); ++typedef void storage_dup_f(struct object *src, struct object *target); typedef void storage_trim_f(struct storage *, size_t size); typedef void storage_free_f(struct storage *); typedef struct object *storage_allocobj_f(struct stevedore *, @@@ -105,7 -103,3 +105,7 @@@ extern const struct stevedore smp_steve #ifdef HAVE_LIBUMEM extern const struct stevedore smu_stevedore; #endif + +/* Default dup method */ - void STV_dup(const struct sess *sp, struct object *src, struct object *target); - void default_dup(const struct sess *sp, struct object *src, struct object *target); ++void STV_dup(struct object *src, struct object *target); ++void default_dup(struct object *src, struct object *target); From phk at varnish-cache.org Sun Feb 19 07:44:23 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 08:44:23 +0100 Subject: [master] a9d35b4 Clarify comment, add assert + comment Message-ID: commit a9d35b4759edc0034e1241ec47943bb18937a9db Author: Poul-Henning Kamp Date: Sun Feb 19 07:44:10 2012 +0000 Clarify comment, add assert + comment diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 372ce08..a8b3dcb 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -572,9 +572,8 @@ FetchBody(struct worker *wrk, struct object *obj) AZ(bo->vgz_rx); /* - * It is OK for ->end to just leave the last storage segment - * sitting on wrk->storage, we will always call vfp_nop_end() - * to get it trimmed or thrown out if empty. + * We always call vfp_nop_end() to ditch or trim the last storage + * segment, to avoid having to replicate that code in all vfp's. */ AZ(vfp_nop_end(bo)); diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 2fce063..dd517be 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -177,6 +177,8 @@ stv_alloc(struct busyobj *bo, size_t size) if (size > cache_param->fetch_maxchunksize) size = cache_param->fetch_maxchunksize; + assert(size <= UINT_MAX); /* field limit in struct storage */ + for (;;) { /* try to allocate from it */ AN(stv->alloc); From phk at varnish-cache.org Sun Feb 19 07:51:39 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 08:51:39 +0100 Subject: [master] d647764 Eliminate a single-use macro Message-ID: commit d647764b9c1657e329ab632d5e81f1dd5e127b33 Author: Poul-Henning Kamp Date: Sun Feb 19 07:51:30 2012 +0000 Eliminate a single-use macro diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index daa01f4..d441fca 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -935,9 +935,6 @@ void WSL_Flush(struct vsl_log *, int overflow); #define WSP(sess, tag, ...) \ WSL((sess)->wrk->vsl, tag, (sess)->vsl_id, __VA_ARGS__) -#define WSPR(sess, tag, txt) \ - WSLR((sess)->wrk->vsl, tag, (sess)->vsl_id, txt) - #define INCOMPL() do { \ VSL(SLT_Debug, 0, "INCOMPLETE AT: %s(%d)", __func__, __LINE__); \ fprintf(stderr, \ diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index de71ada..71533ef 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -677,7 +677,7 @@ http_DissectRequest(const struct sess *sp) retval = http_splitline(hp, htc, HTTP_HDR_REQ, HTTP_HDR_URL, HTTP_HDR_PROTO); if (retval != 0) { - WSPR(sp, SLT_HttpGarbage, htc->rxbuf); + WSLR(sp->req->vsl, SLT_HttpGarbage, -1, htc->rxbuf); return (retval); } http_ProtoVer(hp); From phk at varnish-cache.org Sun Feb 19 08:42:05 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 09:42:05 +0100 Subject: [master] 9a63616 Cleanup all the easy bits of the VSL api in varnishd. Message-ID: commit 9a63616cb869286a0a3f8139f8f0f1205ad87e80 Author: Poul-Henning Kamp Date: Sun Feb 19 08:40:55 2012 +0000 Cleanup all the easy bits of the VSL api in varnishd. We now have: VSL() -> send directly to global VSL buffer VSLb() -> send to buffered VSL VSLbt() -> send txt to buffered VSL diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index d441fca..2dd32bf 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -918,13 +918,13 @@ void VSM_Free(void *ptr); #ifdef VSL_ENDMARKER void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) __printflike(3, 4); -void WSLR(struct vsl_log *, enum VSL_tag_e tag, int id, txt t); void WSL(struct vsl_log *, enum VSL_tag_e tag, int id, const char *fmt, ...) __printflike(4, 5); -void VSLB(struct busyobj *, enum VSL_tag_e tag, const char *fmt, ...) +void VSLb(struct vsl_log *, enum VSL_tag_e tag, const char *fmt, ...) __printflike(3, 4); +void VSLbt(struct vsl_log *, enum VSL_tag_e tag, txt t); -void WSL_Flush(struct vsl_log *, int overflow); +void VSL_Flush(struct vsl_log *, int overflow); #define DSL(flag, tag, id, ...) \ do { \ @@ -932,9 +932,6 @@ void WSL_Flush(struct vsl_log *, int overflow); VSL((tag), (id), __VA_ARGS__); \ } while (0) -#define WSP(sess, tag, ...) \ - WSL((sess)->wrk->vsl, tag, (sess)->vsl_id, __VA_ARGS__) - #define INCOMPL() do { \ VSL(SLT_Debug, 0, "INCOMPLETE AT: %s(%d)", __func__, __LINE__); \ fprintf(stderr, \ diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 6e86538..085c7a7 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -183,7 +183,7 @@ bes_conn_try(const struct sess *sp, struct vbc *vc, const struct vdi_simple *vs) } else { vc->vsl_id = s | VSL_BACKENDMARKER; VTCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1); - WSL(sp->wrk->vsl, SLT_BackendOpen, vc->vsl_id, "%s %s %s ", + WSL(sp->req->vsl, SLT_BackendOpen, vc->vsl_id, "%s %s %s ", vs->backend->display_name, abuf1, pbuf1); } @@ -346,7 +346,7 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs) if (vbe_CheckFd(vc->fd)) { /* XXX locking of stats */ VSC_C_main->backend_reuse += 1; - WSP(sp, SLT_Backend, "%d %s %s", + VSLb(sp->req->vsl, SLT_Backend, "%d %s %s", vc->fd, sp->req->director->vcl_name, bp->display_name); vc->vdis = vs; @@ -359,7 +359,7 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs) /* Checkpoint log to flush all info related to this connection before the OS reuses the FD */ - WSL_Flush(sp->wrk->vsl, 0); + VSL_Flush(sp->wrk->vsl, 0); VTCP_close(&vc->fd); VBE_DropRefConn(bp); @@ -389,7 +389,7 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs) } vc->backend = bp; VSC_C_main->backend_conn++; - WSP(sp, SLT_Backend, "%d %s %s", + VSLb(sp->req->vsl, SLT_Backend, "%d %s %s", vc->fd, sp->req->director->vcl_name, bp->display_name); vc->vdis = vs; return (vc); diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 24a150e..a9ff554 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -761,7 +761,8 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req) oc->ban = NULL; oc_updatemeta(oc); /* BAN also changed, but that is not important any more */ - WSP(sp, SLT_ExpBan, "%u was banned", o->xid); + /* XXX: no req in lurker */ + VSLb(sp->wrk->vsl, SLT_ExpBan, "%u was banned", o->xid); EXP_Rearm(o); return (1); } @@ -954,7 +955,7 @@ ban_lurker(struct sess *sp, void *priv) } i = ban_lurker_work(sp, pass); - WSL_Flush(sp->wrk->vsl, 0); + VSL_Flush(sp->wrk->vsl, 0); WRK_SumStat(sp->wrk); if (i) { pass += (1 << LURK_SHIFT); diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 8f0f31e..32ae7c8 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -183,7 +183,7 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) if (r) return; - WSL_Flush(vbo->bo.vsl, 0); + VSL_Flush(vbo->bo.vsl, 0); /* XXX: Sanity checks & cleanup */ memset(&vbo->bo, 0, sizeof vbo->bo); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 4b0429a..9619a6e 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -394,14 +394,14 @@ cnt_done(struct sess *sp, struct worker *wrk, struct req *req) /* XXX: Add StatReq == StatSess */ /* XXX: Workaround for pipe */ if (sp->fd >= 0) { - WSP(sp, SLT_Length, "%ju", + VSLb(sp->req->vsl, SLT_Length, "%ju", (uintmax_t)req->req_bodybytes); } - WSP(sp, SLT_ReqEnd, "%u %.9f %.9f %.9f %.9f %.9f", + VSLb(sp->req->vsl, SLT_ReqEnd, "%u %.9f %.9f %.9f %.9f %.9f", req->xid, sp->t_req, sp->t_idle, dh, dp, da); } req->xid = 0; - WSL_Flush(wrk->vsl, 0); + VSL_Flush(wrk->vsl, 0); sp->t_req = NAN; req->t_resp = NAN; @@ -941,10 +941,12 @@ cnt_first(struct sess *sp, struct worker *wrk) &sp->mysockaddrlen)); VTCP_name(&sp->mysockaddr, sp->mysockaddrlen, laddr, sizeof laddr, lport, sizeof lport); - WSP(sp, SLT_SessionOpen, "%s %s %s %s", + /* XXX: have no req yet */ + VSLb(sp->wrk->vsl, SLT_SessionOpen, "%s %s %s %s", sp->addr, sp->port, laddr, lport); } else { - WSP(sp, SLT_SessionOpen, "%s %s %s", + /* XXX: have no req yet */ + VSLb(sp->wrk->vsl, SLT_SessionOpen, "%s %s %s", sp->addr, sp->port, sp->mylsock->name); } @@ -1116,7 +1118,7 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req) if (oc->flags & OC_F_PASS) { wrk->stats.cache_hitpass++; - WSP(sp, SLT_HitPass, "%u", req->obj->xid); + VSLb(sp->req->vsl, SLT_HitPass, "%u", req->obj->xid); (void)HSH_Deref(&wrk->stats, NULL, &req->obj); AZ(req->objcore); sp->step = STP_PASS; @@ -1124,7 +1126,7 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req) } wrk->stats.cache_hit++; - WSP(sp, SLT_Hit, "%u", req->obj->xid); + VSLb(sp->req->vsl, SLT_Hit, "%u", req->obj->xid); sp->step = STP_HIT; return (0); } @@ -1450,7 +1452,8 @@ cnt_start(struct sess *sp, struct worker *wrk, struct req *req) /* Assign XID and log */ req->xid = ++xids; /* XXX not locked */ - WSP(sp, SLT_ReqStart, "%s %s %u", sp->addr, sp->port, req->xid); + VSLb(sp->req->vsl, SLT_ReqStart, "%s %s %u", + sp->addr, sp->port, req->xid); /* Borrow VCL reference from worker thread */ VCL_Refresh(&wrk->vcl); @@ -1521,10 +1524,11 @@ cnt_diag(struct sess *sp, const char *state) obj = sp->req->obj; } - if (sp->wrk != NULL) { - WSP(sp, SLT_Debug, "vsl_id %u STP_%s sp %p obj %p vcl %p", + if (sp->req != NULL) { + VSLb(sp->req->vsl, SLT_Debug, + "vsl_id %u STP_%s sp %p obj %p vcl %p", sp->vsl_id, state, sp, obj, vcl); - WSL_Flush(sp->wrk->vsl, 0); + VSL_Flush(sp->req->vsl, 0); } else { VSL(SLT_Debug, sp->vsl_id, "vsl_id %u STP_%s sp %p obj %p vcl %p", @@ -1605,7 +1609,7 @@ CNT_Session(struct sess *sp) WS_Assert(wrk->aws); CHECK_OBJ_ORNULL(wrk->nobjhead, OBJHEAD_MAGIC); } - WSL_Flush(wrk->vsl, 0); + VSL_Flush(wrk->vsl, 0); #define ACCT(foo) AZ(wrk->acct_tmp.foo); #include "tbl/acct_fields.h" #undef ACCT diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index b1359e3..ab74b59 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -59,8 +59,8 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp) /* Checkpoint log to flush all info related to this connection before the OS reuses the FD */ - WSL_Flush(wrk->vsl, 0); - WSL_Flush(vc->vsl, 0); + VSL_Flush(wrk->vsl, 0); + VSL_Flush(vc->vsl, 0); vc->vsl->wid = vc->orig_vsl_id; vc->vsl = NULL; vc->orig_vsl_id = 0; @@ -95,8 +95,8 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp) * Flush the shmlog, so that another session reusing this backend * will log chronologically later than our use of it. */ - WSL_Flush(wrk->vsl, 0); - WSL_Flush(vc->vsl, 0); + VSL_Flush(wrk->vsl, 0); + VSL_Flush(vc->vsl, 0); vc->vsl->wid = vc->orig_vsl_id; vc->vsl = NULL; vc->orig_vsl_id = 0; diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 54302c8..2c4d3d0 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -98,7 +98,7 @@ ved_include(struct sess *sp, const char *src, const char *host) if (sp->step == STP_DONE) break; AZ(sp->wrk); - WSL_Flush(w->vsl, 0); + VSL_Flush(w->vsl, 0); DSL(0x20, SLT_Debug, sp->vsl_id, "loop waiting for ESI"); (void)usleep(10000); } diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 053f614..6eac8d3 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -186,7 +186,7 @@ vep_error(const struct vep_state *vep, const char *p) VSC_C_main->esi_errors++; l = (intmax_t)(vep->ver_p - vep->hack_p); - VSLB(vep->bo, SLT_ESI_xmlerror, "ERR at %jd %s", l, p); + VSLb(vep->bo->vsl, SLT_ESI_xmlerror, "ERR at %jd %s", l, p); } @@ -202,7 +202,7 @@ vep_warn(const struct vep_state *vep, const char *p) VSC_C_main->esi_warnings++; l = (intmax_t)(vep->ver_p - vep->hack_p); printf("WARNING at %jd %s\n", l, p); - VSLB(vep->bo, SLT_ESI_xmlerror, "WARN at %jd %s", l, p); + VSLb(vep->bo->vsl, SLT_ESI_xmlerror, "WARN at %jd %s", l, p); } @@ -601,7 +601,7 @@ VEP_Parse(const struct busyobj *bo, const char *p, size_t l) p++; vep->state = VEP_STARTTAG; } else if (p < e) { - VSLB(vep->bo, SLT_ESI_xmlerror, + VSLb(vep->bo->vsl, SLT_ESI_xmlerror, "No ESI processing, first char not '<'"); vep->state = VEP_NOTXML; } diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 060ed58..e0f3d27 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -342,7 +342,7 @@ exp_timer(struct sess *sp, void *priv) oc = NULL; while (1) { if (oc == NULL) { - WSL_Flush(sp->wrk->vsl, 0); + VSL_Flush(sp->wrk->vsl, 0); WRK_SumStat(sp->wrk); VTIM_sleep(cache_param->expiry_sleep); t = VTIM_real(); @@ -445,7 +445,7 @@ EXP_NukeOne(struct busyobj *bo, struct lru *lru) return (-1); /* XXX: bad idea for -spersistent */ - WSL(bo->vsl, SLT_ExpKill, -1, "%u LRU", oc_getxid(bo->stats, oc)); + VSLb(bo->vsl, SLT_ExpKill, "%u LRU", oc_getxid(bo->stats, oc)); (void)HSH_Deref(bo->stats, oc, NULL); return (1); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index a8b3dcb..48db272 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -58,9 +58,9 @@ FetchError2(struct busyobj *bo, const char *error, const char *more) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); if (!bo->fetch_failed) { if (more == NULL) - VSLB(bo, SLT_FetchError, "%s", error); + VSLb(bo->vsl, SLT_FetchError, "%s", error); else - VSLB(bo, SLT_FetchError, "%s: %s", error, more); + VSLb(bo->vsl, SLT_FetchError, "%s: %s", error, more); } bo->fetch_failed = 1; return (-1); @@ -364,7 +364,7 @@ FetchReqBody(const struct sess *sp, int sendbody) } if (http_GetHdr(sp->req->http, H_Transfer_Encoding, NULL)) { /* XXX: Handle chunked encoding. */ - WSP(sp, SLT_Debug, "Transfer-Encoding in request"); + VSLb(sp->req->vsl, SLT_Debug, "Transfer-Encoding in request"); return (1); } return (0); @@ -408,7 +408,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) wrk->busyobj->vbc = VDI_GetFd(NULL, sp); if (wrk->busyobj->vbc == NULL) { - WSP(sp, SLT_FetchError, "no backend connection"); + VSLb(sp->req->vsl, SLT_FetchError, "no backend connection"); return (-1); } vc = wrk->busyobj->vbc; @@ -430,7 +430,8 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) /* Deal with any message-body the request might have */ i = FetchReqBody(sp, sendbody); if (WRW_FlushRelease(wrk) || i > 0) { - WSP(sp, SLT_FetchError, "backend write error: %d (%s)", + VSLb(sp->req->vsl, SLT_FetchError, + "backend write error: %d (%s)", errno, strerror(errno)); VDI_CloseFd(wrk, &wrk->busyobj->vbc); /* XXX: other cleanup ? */ @@ -438,7 +439,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) } /* Checkpoint the vsl.here */ - WSL_Flush(wrk->vsl, 0); + VSL_Flush(wrk->vsl, 0); /* XXX is this the right place? */ VSC_C_main->backend_req++; @@ -454,7 +455,8 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) i = HTC_Rx(htc); if (i < 0) { - WSP(sp, SLT_FetchError, "http first read error: %d %d (%s)", + VSLb(sp->req->vsl, SLT_FetchError, + "http first read error: %d %d (%s)", i, errno, strerror(errno)); VDI_CloseFd(wrk, &wrk->busyobj->vbc); /* XXX: other cleanup ? */ @@ -467,7 +469,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) while (i == 0) { i = HTC_Rx(htc); if (i < 0) { - WSP(sp, SLT_FetchError, + VSLb(sp->req->vsl, SLT_FetchError, "http first read error: %d %d (%s)", i, errno, strerror(errno)); VDI_CloseFd(wrk, &wrk->busyobj->vbc); @@ -479,7 +481,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) hp = wrk->busyobj->beresp; if (http_DissectResponse(hp, htc)) { - WSP(sp, SLT_FetchError, "http format error"); + VSLb(sp->req->vsl, SLT_FetchError, "http format error"); VDI_CloseFd(wrk, &wrk->busyobj->vbc); /* XXX: other cleanup ? */ return (-1); @@ -579,7 +581,7 @@ FetchBody(struct worker *wrk, struct object *obj) bo->fetch_obj = NULL; - VSLB(bo, SLT_Fetch_Body, "%u(%s) cls %d mklen %d", + VSLb(bo->vsl, SLT_Fetch_Body, "%u(%s) cls %d mklen %d", bo->body_status, body_status(bo->body_status), cls, mklen); @@ -601,7 +603,7 @@ FetchBody(struct worker *wrk, struct object *obj) if (cls == 0 && bo->should_close) cls = 1; - VSLB(bo, SLT_Length, "%zd", obj->len); + VSLb(bo->vsl, SLT_Length, "%zd", obj->len); { /* Sanity check fetch methods accounting */ diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 530d43b..d4511bc 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -395,7 +395,7 @@ VGZ_Destroy(struct vgz **vgp) CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); *vgp = NULL; - WSL(vg->vsl, SLT_Gzip, -1, "%s %jd %jd %jd %jd %jd", + VSLb(vg->vsl, SLT_Gzip, "%s %jd %jd %jd %jd %jd", vg->id, (intmax_t)vg->vz.total_in, (intmax_t)vg->vz.total_out, diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 7188ff4..3d44cc4 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -163,7 +163,7 @@ HSH_AddString(const struct sess *sp, const char *str) SHA256_Update(sp->req->sha256ctx, "#", 1); if (cache_param->log_hash) - WSP(sp, SLT_Hash, "%s", str); + VSLb(sp->req->vsl, SLT_Hash, "%s", str); } /*--------------------------------------------------------------------- @@ -431,7 +431,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh) VTAILQ_INSERT_TAIL(&oh->waitinglist->list, sp, list); } if (cache_param->diag_bitmap & 0x20) - WSP(sp, SLT_Debug, + VSLb(sp->req->vsl, SLT_Debug, "on waiting list <%p>", oh); SES_Charge(sp); /* diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 71533ef..f721ea2 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -78,7 +78,7 @@ http_VSLH(const struct http *hp, unsigned hdr) AN(hp->vsl); AN(hp->vsl->wid & (VSL_CLIENTMARKER|VSL_BACKENDMARKER)); - WSLR(hp->vsl, http2shmlog(hp, hdr), -1, hp->hd[hdr]); + VSLbt(hp->vsl, http2shmlog(hp, hdr), hp->hd[hdr]); } /*--------------------------------------------------------------------*/ @@ -528,7 +528,7 @@ http_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) if (q - p > htc->maxhdr) { VSC_C_main->losthdr++; - WSL(hp->vsl, SLT_LostHeader, -1, "%.*s", + VSLb(hp->vsl, SLT_LostHeader, "%.*s", (int)(q - p > 20 ? 20 : q - p), p); return (413); } @@ -554,7 +554,7 @@ http_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) hp->nhd++; } else { VSC_C_main->losthdr++; - WSL(hp->vsl, SLT_LostHeader, -1, "%.*s", + VSLb(hp->vsl, SLT_LostHeader, "%.*s", (int)(q - p > 20 ? 20 : q - p), p); return (413); } @@ -677,7 +677,7 @@ http_DissectRequest(const struct sess *sp) retval = http_splitline(hp, htc, HTTP_HDR_REQ, HTTP_HDR_URL, HTTP_HDR_PROTO); if (retval != 0) { - WSLR(sp->req->vsl, SLT_HttpGarbage, -1, htc->rxbuf); + VSLbt(sp->req->vsl, SLT_HttpGarbage, htc->rxbuf); return (retval); } http_ProtoVer(hp); @@ -724,7 +724,7 @@ http_DissectResponse(struct http *hp, const struct http_conn *htc) } if (retval != 0) { - WSLR(hp->vsl, SLT_HttpGarbage, -1, htc->rxbuf); + VSLbt(hp->vsl, SLT_HttpGarbage, htc->rxbuf); assert(retval >= 100 && retval <= 999); hp->status = retval; } else { @@ -842,7 +842,7 @@ http_filterfields(struct http *to, const struct http *fm, unsigned how) to->nhd++; } else { VSC_C_main->losthdr++; - WSLR(to->vsl, SLT_LostHeader, -1, fm->hd[u]); + VSLbt(to->vsl, SLT_LostHeader, fm->hd[u]); } } } @@ -910,7 +910,7 @@ http_CopyHome(const struct http *hp) } else { /* XXX This leaves a slot empty */ VSC_C_main->losthdr++; - WSLR(hp->vsl, SLT_LostHeader, -1, hp->hd[u]); + VSLbt(hp->vsl, SLT_LostHeader, hp->hd[u]); hp->hd[u].b = NULL; hp->hd[u].e = NULL; } @@ -940,7 +940,7 @@ http_SetHeader(struct http *to, const char *hdr) CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); if (to->nhd >= to->shd) { VSC_C_main->losthdr++; - WSL(to->vsl, SLT_LostHeader, -1, "%s", hdr); + VSLb(to->vsl, SLT_LostHeader, "%s", hdr); return; } http_SetH(to, to->nhd++, hdr); @@ -958,7 +958,7 @@ http_PutField(const struct http *to, int field, const char *string) l = strlen(string); p = WS_Alloc(to->ws, l + 1); if (p == NULL) { - WSL(to->vsl, SLT_LostHeader, -1, "%s", string); + VSLb(to->vsl, SLT_LostHeader, "%s", string); to->hd[field].b = NULL; to->hd[field].e = NULL; to->hdf[field] = 0; @@ -1011,7 +1011,7 @@ http_PrintfHeader(struct http *to, const char *fmt, ...) va_end(ap); if (n + 1 >= l || to->nhd >= to->shd) { VSC_C_main->losthdr++; - WSL(to->vsl, SLT_LostHeader, -1, "%s", to->ws->f); + VSLb(to->vsl, SLT_LostHeader, "%s", to->ws->f); WS_Release(to->ws, 0); } else { to->hd[to->nhd].b = to->ws->f; diff --git a/bin/varnishd/cache/cache_httpconn.c b/bin/varnishd/cache/cache_httpconn.c index d0b7199..890dfd3 100644 --- a/bin/varnishd/cache/cache_httpconn.c +++ b/bin/varnishd/cache/cache_httpconn.c @@ -224,7 +224,7 @@ HTC_Read(struct http_conn *htc, void *d, size_t len) return (l); i = read(htc->fd, p, len); if (i < 0) { - WSL(htc->vsl, SLT_FetchError, -1, "%s", strerror(errno)); + VSLb(htc->vsl, SLT_FetchError, "%s", strerror(errno)); return (i); } return (i + l); diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 1b67d81..2c3a368 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -167,7 +167,7 @@ RFC2616_Ttl(const struct sess *sp) } /* calculated TTL, Our time, Date, Expires, max-age, age */ - WSP(sp, SLT_TTL, + VSLb(sp->req->vsl, SLT_TTL, /* XXX Bo->vsl ? */ "%u RFC %.0f %.0f %.0f %.0f %.0f %.0f %.0f %u", sp->req->xid, expp->ttl, -1., -1., expp->entered, expp->age, h_date, h_expires, max_age); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 1bd74fe..15efc5f 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -375,7 +375,7 @@ SES_ReleaseReq(struct sess *sp) AN(pp->pool); CHECK_OBJ_NOTNULL(sp->req, REQ_MAGIC); MPL_AssertSane(sp->req); - WSL_Flush(sp->req->vsl, 0); + VSL_Flush(sp->req->vsl, 0); MPL_Free(pp->mpl_req, sp->req); sp->req = NULL; } diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index d4dae9d..6a54101 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -133,7 +133,7 @@ vsl_get(unsigned len, unsigned records, unsigned flushes) */ static void -VSLR(enum VSL_tag_e tag, int id, const char *b, unsigned len) +vslr(enum VSL_tag_e tag, int id, const char *b, unsigned len) { uint32_t *p; unsigned mlen; @@ -161,18 +161,18 @@ VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) /* * XXX: consider formatting into a stack buffer then move into - * XXX: shmlog with VSLR(). + * XXX: shmlog with vslr(). */ AN(fmt); va_start(ap, fmt); if (strchr(fmt, '%') == NULL) { - VSLR(tag, id, fmt, strlen(fmt)); + vslr(tag, id, fmt, strlen(fmt)); } else { n = vsnprintf(buf, mlen, fmt, ap); if (n > mlen) n = mlen; - VSLR(tag, id, buf, n); + vslr(tag, id, buf, n); } va_end(ap); } @@ -180,7 +180,7 @@ VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) /*--------------------------------------------------------------------*/ void -WSL_Flush(struct vsl_log *vsl, int overflow) +VSL_Flush(struct vsl_log *vsl, int overflow) { uint32_t *p; unsigned l; @@ -202,8 +202,8 @@ WSL_Flush(struct vsl_log *vsl, int overflow) /*--------------------------------------------------------------------*/ -void -WSLR(struct vsl_log *vsl, enum VSL_tag_e tag, int id, txt t) +static void +wslr(struct vsl_log *vsl, enum VSL_tag_e tag, int id, txt t) { unsigned l, mlen; @@ -223,7 +223,7 @@ WSLR(struct vsl_log *vsl, enum VSL_tag_e tag, int id, txt t) /* Wrap if necessary */ if (VSL_END(vsl->wlp, l) >= vsl->wle) - WSL_Flush(vsl, 1); + VSL_Flush(vsl, 1); assert (VSL_END(vsl->wlp, l) < vsl->wle); memcpy(VSL_DATA(vsl->wlp), t.b, l); vsl_hdr(tag, vsl->wlp, l, id); @@ -231,7 +231,7 @@ WSLR(struct vsl_log *vsl, enum VSL_tag_e tag, int id, txt t) assert(vsl->wlp < vsl->wle); vsl->wlr++; if (cache_param->diag_bitmap & 0x10000) - WSL_Flush(vsl, 0); + VSL_Flush(vsl, 0); } /*--------------------------------------------------------------------*/ @@ -253,13 +253,13 @@ wsl(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, va_list ap if (strchr(fmt, '%') == NULL) { t.b = TRUST_ME(fmt); t.e = strchr(t.b, '\0'); - WSLR(vsl, tag, id, t); + wslr(vsl, tag, id, t); } else { assert(vsl->wlp < vsl->wle); /* Wrap if we cannot fit a full size record */ if (VSL_END(vsl->wlp, mlen) >= vsl->wle) - WSL_Flush(vsl, 1); + VSL_Flush(vsl, 1); p = VSL_DATA(vsl->wlp); n = vsnprintf(p, mlen, fmt, ap); @@ -271,7 +271,7 @@ wsl(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, va_list ap vsl->wlr++; } if (cache_param->diag_bitmap & 0x10000) - WSL_Flush(vsl, 0); + VSL_Flush(vsl, 0); } /*--------------------------------------------------------------------*/ @@ -290,20 +290,31 @@ WSL(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, ...) } -/*--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * VSL-buffered + */ void -VSLB(struct busyobj *bo, enum VSL_tag_e tag, const char *fmt, ...) +VSLb(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...) { va_list ap; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AN(fmt); va_start(ap, fmt); - wsl(bo->vsl, tag, bo->vsl->wid, fmt, ap); + wsl(vsl, tag, vsl->wid, fmt, ap); va_end(ap); } +/*-------------------------------------------------------------------- + * VSL-buffered-txt + */ + +void +VSLbt(struct vsl_log *vsl, enum VSL_tag_e tag, txt t) +{ + wslr(vsl, tag, -1, t); +} + /*--------------------------------------------------------------------*/ void diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index 9ad41d0..7ba9c60 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -79,7 +79,8 @@ VRY_Create(const struct sess *sp, const struct http *hp) AN(sbh); if (*v == ':') { - WSP(sp, SLT_Error, "Vary header had extra ':', fix backend"); + VSLb(sp->req->vsl, SLT_Error, + "Vary header had extra ':', fix backend"); v++; } for (p = v; *p; p++) { diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index ad5acf0..b68627b 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -335,9 +335,10 @@ VCL_##func##_method(struct sess *sp) \ \ sp->req->handling = 0; \ sp->req->cur_method = VCL_MET_ ## upper; \ - WSP(sp, SLT_VCL_call, "%s", #func); \ + VSLb(sp->req->vsl, SLT_VCL_call, "%s", #func); \ (void)sp->req->vcl->func##_func(sp); \ - WSP(sp, SLT_VCL_return, "%s", VCL_Return_Name(sp->req->handling)); \ + VSLb(sp->req->vsl, SLT_VCL_return, "%s", \ + VCL_Return_Name(sp->req->handling)); \ sp->req->cur_method = 0; \ assert((1U << sp->req->handling) & bitmap); \ assert(!((1U << sp->req->handling) & ~bitmap)); \ diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 6271e49..c9135dc 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -56,7 +56,7 @@ VRT_error(const struct sess *sp, unsigned code, const char *reason) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - WSL(sp->wrk->vsl, SLT_Debug, 0, "VCL_error(%u, %s)", code, reason ? + VSLb(sp->req->vsl, SLT_Debug, "VCL_error(%u, %s)", code, reason ? reason : "(null)"); if (code < 100 || code > 999) code = 503; @@ -75,7 +75,7 @@ VRT_count(const struct sess *sp, unsigned u) return; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); if (cache_param->vcl_trace) - WSP(sp, SLT_VCL_trace, "%u %u.%u", u, + VSLb(sp->req->vsl, SLT_VCL_trace, "%u %u.%u", u, sp->req->vcl->ref[u].line, sp->req->vcl->ref[u].pos); } @@ -85,7 +85,7 @@ void VRT_acl_log(const struct sess *sp, const char *msg) { - WSP(sp, SLT_VCL_acl, "%s", msg); + VSLb(sp->req->vsl, SLT_VCL_acl, "%s", msg); } /*--------------------------------------------------------------------*/ @@ -228,7 +228,7 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr, } else { b = VRT_String(hp->ws, hdr + 1, p, ap); if (b == NULL) { - WSP(sp, SLT_LostHeader, "%s", hdr + 1); + VSLb(sp->req->vsl, SLT_LostHeader, "%s", hdr + 1); } else { http_Unset(hp, hdr); http_SetHeader(hp, b); diff --git a/bin/varnishd/cache/cache_vrt_re.c b/bin/varnishd/cache/cache_vrt_re.c index 867ec86..765cd27 100644 --- a/bin/varnishd/cache/cache_vrt_re.c +++ b/bin/varnishd/cache/cache_vrt_re.c @@ -75,7 +75,8 @@ VRT_re_match(const struct sess *sp, const char *s, void *re) if (i >= 0) return (1); if (i < VRE_ERROR_NOMATCH ) - WSP(sp, SLT_VCL_Error, "Regexp matching returned %d", i); + VSLb(sp->req->vsl, SLT_VCL_Error, + "Regexp matching returned %d", i); return (0); } @@ -108,7 +109,8 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re, if (i == VRE_ERROR_NOMATCH) return(str); if (i < VRE_ERROR_NOMATCH ) { - WSP(sp, SLT_VCL_Error, "Regexp matching returned %d", i); + VSLb(sp->req->vsl, SLT_VCL_Error, + "Regexp matching returned %d", i); return(str); } @@ -146,7 +148,7 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re, &cache_param->vre_limits); if (i < VRE_ERROR_NOMATCH ) { WS_Release(sp->req->http->ws, 0); - WSP(sp, SLT_VCL_Error, + VSLb(sp->req->vsl, SLT_VCL_Error, "Regexp matching returned %d", i); return(str); } diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 417fcee..50f4411 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -46,16 +46,15 @@ static char vrt_hostname[255] = ""; /*--------------------------------------------------------------------*/ static void -vrt_do_string(struct worker *w, int fd, const struct http *hp, int fld, +vrt_do_string(const struct http *hp, int fld, const char *err, const char *p, va_list ap) { char *b; - // AN(p); AN(hp); b = VRT_String(hp->ws, NULL, p, ap); if (b == NULL || *b == '\0') { - WSL(w->vsl, SLT_LostHeader, fd, "%s", err); + VSLb(hp->vsl, SLT_LostHeader, "%s", err); } else { http_SetH(hp, fld, b); } @@ -68,9 +67,9 @@ VRT_l_##obj##_##hdr(const struct sess *sp, const char *p, ...) \ { \ va_list ap; \ \ + (void)sp; \ va_start(ap, p); \ - vrt_do_string(sp->wrk, sp->fd, \ - http, fld, #obj "." #hdr, p, ap); \ + vrt_do_string(http, fld, #obj "." #hdr, p, ap); \ va_end(ap); \ } \ \ @@ -399,7 +398,7 @@ VRT_r_##which##_##fld(struct sess *sp) \ static void vrt_wsp_exp(const struct sess *sp, unsigned xid, const struct exp *e) { - WSP(sp, SLT_TTL, "%u VCL %.0f %.0f %.0f %.0f %.0f", + VSLb(sp->req->vsl, SLT_TTL, "%u VCL %.0f %.0f %.0f %.0f %.0f", xid, e->ttl - (sp->t_req - e->entered), e->grace, e->keep, sp->t_req, e->age + (sp->t_req - e->entered)); } diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index dd517be..3a9f614 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -141,7 +141,7 @@ stv_pick_stevedore(struct vsl_log *vsl, const char **hint) return (stv_transient); /* Hint was not valid, nuke it */ - WSL(vsl, SLT_Debug, -1, "Storage hint not usable"); + VSLb(vsl, SLT_Debug, "Storage hint not usable"); *hint = NULL; } /* pick a stevedore and bump the head along */ diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index e363b2d..5774cfb 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -152,7 +152,7 @@ vmod_log(struct sess *sp, const char *fmt, ...) p = VRT_StringList(buf, sizeof buf, fmt, ap); va_end(ap); if (p != NULL) - WSP(sp, SLT_VCL_Log, "%s", buf); + VSLb(sp->req->vsl, SLT_VCL_Log, "%s", buf); } void From phk at varnish-cache.org Sun Feb 19 09:04:38 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 10:04:38 +0100 Subject: [master] a34c900 Eliminate some wrk->sp usage. Message-ID: commit a34c900c15f9b751bf18b4ac26b0991e9fbd0d5a Author: Poul-Henning Kamp Date: Sun Feb 19 09:04:30 2012 +0000 Eliminate some wrk->sp usage. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 2dd32bf..c9cef7b 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -673,7 +673,7 @@ struct sess { void VCA_Init(void); void VCA_Shutdown(void); int VCA_Accept(struct listen_sock *ls, struct wrk_accept *wa); -void VCA_SetupSess(struct worker *w); +void VCA_SetupSess(struct worker *w, struct sess *sp); void VCA_FailSess(struct worker *w); /* cache_backend.c */ diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 4d7b771..8848682 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -233,6 +233,7 @@ VCA_FailSess(struct worker *wrk) AZ(close(wa->acceptsock)); wrk->stats.sess_drop++; vca_pace_bad(); + WS_Release(wrk->aws, 0); } /*-------------------------------------------------------------------- @@ -240,15 +241,13 @@ VCA_FailSess(struct worker *wrk) */ void -VCA_SetupSess(struct worker *wrk) +VCA_SetupSess(struct worker *wrk, struct sess *sp) { - struct sess *sp; struct wrk_accept *wa; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC); - sp = wrk->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC); sp->vxid = wa->vxid; sp->vseq = 0; sp->fd = wa->acceptsock; @@ -262,6 +261,7 @@ VCA_SetupSess(struct worker *wrk) sp->sockaddrlen = wa->acceptaddrlen; vca_pace_good(); wrk->stats.sess_conn++; + WS_Release(wrk->aws, 0); if (need_test) sock_test(sp->fd); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 9619a6e..bb01b52 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -285,7 +285,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) if (wrk->busyobj != NULL) { AN(wrk->busyobj->do_stream); VDI_CloseFd(wrk, &wrk->busyobj->vbc); - HSH_Drop(wrk); + HSH_Drop(wrk, &sp->req->obj); VBO_DerefBusyObj(wrk, &wrk->busyobj); } else { (void)HSH_Deref(&wrk->stats, NULL, &req->obj); @@ -509,7 +509,7 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) if (req->handling == VCL_RET_RESTART && req->restarts < cache_param->max_restarts) { - HSH_Drop(wrk); + HSH_Drop(wrk, &sp->req->obj); VBO_DerefBusyObj(wrk, &wrk->busyobj); req->director = NULL; req->restarts++; @@ -892,7 +892,7 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req) AN(req->director); if (i) { - HSH_Drop(wrk); + HSH_Drop(wrk, &sp->req->obj); VBO_DerefBusyObj(wrk, &wrk->busyobj); AZ(req->obj); req->err_code = 503; diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 3d44cc4..eff6357 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -577,18 +577,17 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace) */ void -HSH_Drop(struct worker *wrk) +HSH_Drop(struct worker *wrk, struct object **oo) { - struct object *o; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - o = wrk->sp->req->obj; - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - AssertObjCorePassOrBusy(o->objcore); - o->exp.ttl = -1.; - if (o->objcore != NULL) /* Pass has no objcore */ - HSH_Unbusy(o->objcore); - (void)HSH_Deref(&wrk->stats, NULL, &wrk->sp->req->obj); + AN(oo); + CHECK_OBJ_NOTNULL(*oo, OBJECT_MAGIC); + AssertObjCorePassOrBusy((*oo)->objcore); + (*oo)->exp.ttl = -1.; + if ((*oo)->objcore != NULL) /* Pass has no objcore */ + HSH_Unbusy((*oo)->objcore); + (void)HSH_Deref(&wrk->stats, NULL, oo); } void diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 15efc5f..542ec2e 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -181,12 +181,11 @@ SES_pool_accept_task(struct worker *wrk, void *arg) wrk->sp = ses_new(pp); if (wrk->sp == NULL) { VCA_FailSess(wrk); - return; + } else { + VCA_SetupSess(wrk, wrk->sp); + wrk->sp->step = STP_FIRST; + ses_pool_task(wrk, wrk->sp); } - VCA_SetupSess(wrk); - wrk->sp->step = STP_FIRST; - WS_Release(wrk->aws, 0); - ses_pool_task(wrk, wrk->sp); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index ac8ce7e..f2b41e2 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -56,7 +56,7 @@ void HSH_Cleanup(struct worker *w); struct objcore *HSH_Lookup(struct sess *sp, struct objhead **poh); void HSH_Unbusy(struct objcore *); void HSH_Ref(struct objcore *o); -void HSH_Drop(struct worker *wrk); +void HSH_Drop(struct worker *, struct object **); void HSH_Init(const struct hash_slinger *slinger); void HSH_AddString(const struct sess *sp, const char *str); struct objcore *HSH_Insert(const struct sess *sp); From phk at varnish-cache.org Sun Feb 19 09:39:54 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 10:39:54 +0100 Subject: [master] 33a2242 Push struct worker out of STV_NewObject() Message-ID: commit 33a22425a74a3fd670f0f3e4cc20362aaa70541b Author: Poul-Henning Kamp Date: Sun Feb 19 09:39:38 2012 +0000 Push struct worker out of STV_NewObject() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index c9cef7b..3797047 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1005,8 +1005,8 @@ unsigned RFC2616_Req_Gzip(const struct sess *sp); int RFC2616_Do_Cond(const struct sess *sp); /* stevedore.c */ -struct object *STV_NewObject(struct worker *wrk, const char *hint, unsigned len, - uint16_t nhttp); +struct object *STV_NewObject(struct busyobj *, struct objcore **, + const char *hint, unsigned len, uint16_t nhttp); struct storage *STV_alloc(struct busyobj *, size_t size); void STV_trim(struct storage *st, size_t size); void STV_free(struct storage *st); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index bb01b52..338b3ab 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -475,9 +475,12 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) wrk->busyobj = VBO_GetBusyObj(wrk); wrk->busyobj->vsl->wid = sp->vsl_id; - req->obj = STV_NewObject(wrk, TRANSIENT_STORAGE, - cache_param->http_resp_size, + AZ(wrk->busyobj->stats); + wrk->busyobj->stats = &wrk->stats; + req->obj = STV_NewObject(wrk->busyobj, &req->objcore, + TRANSIENT_STORAGE, cache_param->http_resp_size, (uint16_t)cache_param->http_max_hdr); + wrk->busyobj->stats = NULL; if (req->obj == NULL) { req->doclose = "Out of objects"; req->director = NULL; @@ -786,18 +789,24 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) req->objcore == NULL) req->storage_hint = TRANSIENT_STORAGE; - req->obj = STV_NewObject(wrk, req->storage_hint, l, nhttp); + assert(bo == wrk->busyobj); + AZ(bo->stats); + bo->stats = &wrk->stats; + req->obj = STV_NewObject(bo, &req->objcore, req->storage_hint, l, + nhttp); if (req->obj == NULL) { /* * Try to salvage the transaction by allocating a * shortlived object on Transient storage. */ - req->obj = STV_NewObject(wrk, TRANSIENT_STORAGE, l, nhttp); + req->obj = STV_NewObject(bo, &req->objcore, TRANSIENT_STORAGE, + l, nhttp); if (bo->exp.ttl > cache_param->shortlived) bo->exp.ttl = cache_param->shortlived; bo->exp.grace = 0.0; bo->exp.keep = 0.0; } + bo->stats = NULL; if (req->obj == NULL) { req->err_code = 503; sp->step = STP_ERROR; diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 3a9f614..3c62d8d 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -227,13 +227,15 @@ struct stv_objsecrets { */ struct object * -STV_MkObject(struct worker *wrk, void *ptr, unsigned ltot, +STV_MkObject(struct busyobj *bo, struct objcore **ocp, void *ptr, unsigned ltot, const struct stv_objsecrets *soc) { struct object *o; unsigned l; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(soc, STV_OBJ_SECRETES_MAGIC); + AN(ocp); assert(PAOK(ptr)); assert(PAOK(soc->wsl)); @@ -253,17 +255,17 @@ STV_MkObject(struct worker *wrk, void *ptr, unsigned ltot, WS_Assert(o->ws_o); assert(o->ws_o->e <= (char*)ptr + ltot); - http_Setup(o->http, o->ws_o, wrk->busyobj->vsl); + http_Setup(o->http, o->ws_o, bo->vsl); o->http->magic = HTTP_MAGIC; - o->exp = wrk->busyobj->exp; + o->exp = bo->exp; VTAILQ_INIT(&o->store); - wrk->stats.n_object++; + bo->stats->n_object++; - if (wrk->sp->req->objcore != NULL) { - CHECK_OBJ_NOTNULL(wrk->sp->req->objcore, OBJCORE_MAGIC); + if (*ocp != NULL) { + CHECK_OBJ_NOTNULL((*ocp), OBJCORE_MAGIC); - o->objcore = wrk->sp->req->objcore; - wrk->sp->req->objcore = NULL; /* refcnt follows pointer. */ + o->objcore = *ocp; + *ocp = NULL; /* refcnt follows pointer. */ BAN_NewObjCore(o->objcore); o->objcore->methods = &default_oc_methods; @@ -278,13 +280,15 @@ STV_MkObject(struct worker *wrk, void *ptr, unsigned ltot, */ struct object * -stv_default_allocobj(struct stevedore *stv, struct worker *wrk, unsigned ltot, - const struct stv_objsecrets *soc) +stv_default_allocobj(struct stevedore *stv, struct busyobj *bo, + struct objcore **ocp, unsigned ltot, const struct stv_objsecrets *soc) { struct object *o; struct storage *st; CHECK_OBJ_NOTNULL(soc, STV_OBJ_SECRETES_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AN(ocp); st = stv->alloc(stv, ltot); if (st == NULL) return (NULL); @@ -293,7 +297,7 @@ stv_default_allocobj(struct stevedore *stv, struct worker *wrk, unsigned ltot, return (NULL); } ltot = st->len = st->space; - o = STV_MkObject(wrk, st->ptr, ltot, soc); + o = STV_MkObject(bo, ocp, st->ptr, ltot, soc); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); o->objstore = st; return (o); @@ -306,8 +310,8 @@ stv_default_allocobj(struct stevedore *stv, struct worker *wrk, unsigned ltot, */ struct object * -STV_NewObject(struct worker *wrk, const char *hint, unsigned wsl, - uint16_t nhttp) +STV_NewObject(struct busyobj *bo, struct objcore **ocp, const char *hint, + unsigned wsl, uint16_t nhttp) { struct object *o; struct stevedore *stv, *stv0; @@ -315,7 +319,8 @@ STV_NewObject(struct worker *wrk, const char *hint, unsigned wsl, struct stv_objsecrets soc; int i; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AN(ocp); assert(wsl > 0); wsl = PRNDUP(wsl); @@ -330,27 +335,23 @@ STV_NewObject(struct worker *wrk, const char *hint, unsigned wsl, ltot = sizeof *o + wsl + lhttp; - stv = stv0 = stv_pick_stevedore(wrk->vsl, &hint); + stv = stv0 = stv_pick_stevedore(bo->vsl, &hint); AN(stv->allocobj); - o = stv->allocobj(stv, wrk, ltot, &soc); + o = stv->allocobj(stv, bo, ocp, ltot, &soc); if (o == NULL && hint == NULL) { do { - stv = stv_pick_stevedore(wrk->vsl, &hint); + stv = stv_pick_stevedore(bo->vsl, &hint); AN(stv->allocobj); - o = stv->allocobj(stv, wrk, ltot, &soc); + o = stv->allocobj(stv, bo, ocp, ltot, &soc); } while (o == NULL && stv != stv0); } if (o == NULL) { - /* XXX: lend busyobj wrk's stats while we nuke */ - AZ(wrk->busyobj->stats); - wrk->busyobj->stats = &wrk->stats; /* no luck; try to free some space and keep trying */ for (i = 0; o == NULL && i < cache_param->nuke_limit; i++) { - if (EXP_NukeOne(wrk->busyobj, stv->lru) == -1) + if (EXP_NukeOne(bo, stv->lru) == -1) break; - o = stv->allocobj(stv, wrk, ltot, &soc); + o = stv->allocobj(stv, bo, ocp, ltot, &soc); } - wrk->busyobj->stats = NULL; } if (o == NULL) diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index c8c3689..80839a6 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -34,6 +34,8 @@ struct stv_objsecrets; struct stevedore; struct sess; +struct busyobj; +struct objcore; struct worker; struct lru; @@ -42,8 +44,8 @@ typedef void storage_open_f(const struct stevedore *); typedef struct storage *storage_alloc_f(struct stevedore *, size_t size); typedef void storage_trim_f(struct storage *, size_t size); typedef void storage_free_f(struct storage *); -typedef struct object *storage_allocobj_f(struct stevedore *, - struct worker *wrk, unsigned ltot, const struct stv_objsecrets *); +typedef struct object *storage_allocobj_f(struct stevedore *, struct busyobj *, + struct objcore **, unsigned ltot, const struct stv_objsecrets *); typedef void storage_close_f(const struct stevedore *); /* Prototypes for VCL variable responders */ @@ -90,8 +92,8 @@ extern struct stevedore *stv_transient; int STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx); uintmax_t STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx); -struct object *STV_MkObject(struct worker *wrk, void *ptr, unsigned ltot, - const struct stv_objsecrets *soc); +struct object *STV_MkObject(struct busyobj *bo, struct objcore **ocp, + void *ptr, unsigned ltot, const struct stv_objsecrets *soc); struct lru *LRU_Alloc(void); void LRU_Free(struct lru *lru); diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index ff01838..c49ceac 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -460,8 +460,8 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size, */ static struct object * -smp_allocobj(struct stevedore *stv, struct worker *wrk, unsigned ltot, - const struct stv_objsecrets *soc) +smp_allocobj(struct stevedore *stv, struct busyobj *bo, struct objcore **ocp, + unsigned ltot, const struct stv_objsecrets *soc) { struct object *o; struct storage *st; @@ -471,11 +471,11 @@ smp_allocobj(struct stevedore *stv, struct worker *wrk, unsigned ltot, struct objcore *oc; unsigned objidx; - if (wrk->sp->req->objcore == NULL) + AN(ocp); + if (*ocp == NULL) return (NULL); /* from cnt_error */ CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC); - AN(wrk->sp->req->objcore); - AN(wrk->busyobj->exp.ttl > 0.); + AN(bo->exp.ttl > 0.); ltot = IRNUP(sc, ltot); @@ -486,7 +486,7 @@ smp_allocobj(struct stevedore *stv, struct worker *wrk, unsigned ltot, assert(st->space >= ltot); ltot = st->len = st->space; - o = STV_MkObject(wrk, st->ptr, ltot, soc); + o = STV_MkObject(bo, ocp, st->ptr, ltot, soc); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); o->objstore = st; From phk at varnish-cache.org Sun Feb 19 10:01:09 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 11:01:09 +0100 Subject: [master] ce3ca92 Fix a detail I didn't catch during code review: Message-ID: commit ce3ca9285b1987203674a4445e058ce30ac750b6 Author: Poul-Henning Kamp Date: Sun Feb 19 09:59:59 2012 +0000 Fix a detail I didn't catch during code review: When WRW is used to send stuff to the backend 'req->t_resp' is not an appropriate base for the timeouts. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 3797047..7eb3372 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -889,7 +889,7 @@ int Pool_Task(struct pool *pp, struct pool_task *task, enum pool_how how); int WRW_Error(const struct worker *w); void WRW_Chunked(struct worker *w); void WRW_EndChunk(struct worker *w); -void WRW_Reserve(struct worker *w, int *fd); +void WRW_Reserve(struct worker *w, int *fd, double t0); unsigned WRW_Flush(struct worker *w); unsigned WRW_FlushRelease(struct worker *w); unsigned WRW_Write(struct worker *w, const void *ptr, int len); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 2c4d3d0..00279c2 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -113,7 +113,7 @@ ved_include(struct sess *sp, const char *src, const char *host) WS_Reset(sp->req->ws, sp_ws_wm); WS_Reset(w->aws, wrk_ws_wm); /* XXX ? */ - WRW_Reserve(sp->wrk, &sp->fd); + WRW_Reserve(sp->wrk, &sp->fd, sp->req->t_resp); if (sp->req->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 48db272..adc5af3 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -424,7 +424,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) VDI_AddHostHeader(wrk->busyobj->bereq, vc); (void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */ - WRW_Reserve(wrk, &vc->fd); + WRW_Reserve(wrk, &vc->fd, sp->t_req); /* XXX t_resp ? */ (void)http_Write(wrk, hp, 0); /* XXX: stats ? */ /* Deal with any message-body the request might have */ diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c index 6f1fbcb..688d87d 100644 --- a/bin/varnishd/cache/cache_pipe.c +++ b/bin/varnishd/cache/cache_pipe.c @@ -78,7 +78,7 @@ PipeSession(struct sess *sp) sp->wrk->busyobj->vbc = vc; /* For panic dumping */ (void)VTCP_blocking(vc->fd); - WRW_Reserve(w, &vc->fd); + WRW_Reserve(w, &vc->fd, sp->t_req); sp->wrk->acct_tmp.hdrbytes += http_Write(w, sp->wrk->busyobj->bereq, 0); diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index bbb648c..f1e0553 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -237,7 +237,7 @@ RES_WriteObj(struct sess *sp) req = sp->req; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - WRW_Reserve(sp->wrk, &sp->fd); + WRW_Reserve(sp->wrk, &sp->fd, sp->req->t_resp); if (req->obj->response == 200 && req->http->conds && diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index 3685bec..a8140f5 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -56,6 +56,7 @@ struct wrw { ssize_t liov; ssize_t cliov; unsigned ciov; /* Chunked header marker */ + double t0; }; /*-------------------------------------------------------------------- @@ -69,7 +70,7 @@ WRW_Error(const struct worker *wrk) } void -WRW_Reserve(struct worker *wrk, int *fd) +WRW_Reserve(struct worker *wrk, int *fd, double t0) { struct wrw *wrw; unsigned u; @@ -93,6 +94,7 @@ WRW_Reserve(struct worker *wrk, int *fd) wrw->liov = 0; wrw->niov = 0; wrw->wfd = fd; + wrw->t0 = t0; wrk->wrw = wrw; } @@ -176,8 +178,7 @@ WRW_Flush(struct worker *wrk) * counter to prevent slowlaris attacks */ - if (VTIM_real() - wrk->sp->req->t_resp > - cache_param->send_timeout) { + if (VTIM_real() - wrw->t0 > cache_param->send_timeout) { WSL(wrk->vsl, SLT_Debug, *wrw->wfd, "Hit total send timeout, " "wrote = %zd/%zd; not retrying", From phk at varnish-cache.org Sun Feb 19 10:08:46 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 11:08:46 +0100 Subject: [master] 91d192c Eliminate wrk->sp Message-ID: commit 91d192cd2963dcd1e5ccbeaa5aee7bd9a3ab6cf2 Author: Poul-Henning Kamp Date: Sun Feb 19 10:08:32 2012 +0000 Eliminate wrk->sp diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 7eb3372..9a560c3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -310,8 +310,6 @@ struct worker { pthread_cond_t cond; - struct sess *sp; - struct VCL_conf *vcl; struct vsl_log vsl[1]; diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 8848682..07e7f5e 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -229,7 +229,6 @@ VCA_FailSess(struct worker *wrk) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC); - AZ(wrk->sp); AZ(close(wa->acceptsock)); wrk->stats.sess_drop++; vca_pace_bad(); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 338b3ab..ad0817e 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -1552,10 +1552,6 @@ CNT_Session(struct sess *sp) struct worker *wrk; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); -#if 0 - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - MPL_AssertSane(req); -#endif wrk = sp->wrk; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -1590,10 +1586,6 @@ CNT_Session(struct sess *sp) */ for (done = 0; !done; ) { assert(sp->wrk == wrk); -#if 0 - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - MPL_AssertSane(req); -#endif /* * This is a good place to be paranoid about the various * pointers still pointing to the things we expect. diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index c6253b2..29d467c 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -438,7 +438,6 @@ pool_herder(void *priv) VSC_C_main->threads--; VSC_C_main->threads_destroyed++; Lck_Unlock(&pool_mtx); - AZ(wrk->sp); wrk->task.func = NULL; wrk->task.priv = NULL; AZ(pthread_cond_signal(&wrk->cond)); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 542ec2e..10a8182 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -142,17 +142,11 @@ ses_pool_task(struct worker *wrk, void *arg) AZ(wrk->aws->r); wrk->lastused = NAN; THR_SetSession(sp); - if (wrk->sp == NULL) - wrk->sp = sp; - else - assert(wrk->sp == sp); AZ(sp->wrk); sp->wrk = wrk; CNT_Session(sp); - sp = NULL; - /* Cannot access sp now */ + sp = NULL; /* Cannot access sp any longer */ THR_SetSession(NULL); - wrk->sp = NULL; WS_Assert(wrk->aws); AZ(wrk->busyobj); AZ(wrk->wrw); @@ -171,20 +165,20 @@ void SES_pool_accept_task(struct worker *wrk, void *arg) { struct sesspool *pp; + struct sess *sp; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CAST_OBJ_NOTNULL(pp, arg, SESSPOOL_MAGIC); /* Turn accepted socket into a session */ - AZ(wrk->sp); AN(wrk->aws->r); - wrk->sp = ses_new(pp); - if (wrk->sp == NULL) { + sp = ses_new(pp); + if (sp == NULL) { VCA_FailSess(wrk); } else { - VCA_SetupSess(wrk, wrk->sp); - wrk->sp->step = STP_FIRST; - ses_pool_task(wrk, wrk->sp); + VCA_SetupSess(wrk, sp); + sp->step = STP_FIRST; + ses_pool_task(wrk, sp); } } From phk at varnish-cache.org Sun Feb 19 10:23:01 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 11:23:01 +0100 Subject: [master] 6633013 Make RFC2616_Ttl() take a busyobj Message-ID: commit 66330133c7c9bf3f454e2bea5140d8fbf29c9baa Author: Poul-Henning Kamp Date: Sun Feb 19 10:21:44 2012 +0000 Make RFC2616_Ttl() take a busyobj diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 9a560c3..a8cf350 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -997,7 +997,7 @@ char *WS_Alloc(struct ws *ws, unsigned bytes); char *WS_Snapshot(struct ws *ws); /* rfc2616.c */ -void RFC2616_Ttl(const struct sess *sp); +void RFC2616_Ttl(struct busyobj *, unsigned xid); enum body_status RFC2616_Body(const struct sess *sp); unsigned RFC2616_Req_Gzip(const struct sess *sp); int RFC2616_Do_Cond(const struct sess *sp); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index ad0817e..a58b834 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -606,7 +606,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) */ EXP_Clr(&wrk->busyobj->exp); wrk->busyobj->exp.entered = W_TIM_real(wrk); - RFC2616_Ttl(sp); + RFC2616_Ttl(wrk->busyobj, sp->req->xid); /* pass from vclrecv{} has negative TTL */ if (req->objcore == NULL) diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 2c3a368..2dafbd2 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -63,7 +63,7 @@ */ void -RFC2616_Ttl(const struct sess *sp) +RFC2616_Ttl(struct busyobj *bo, unsigned xid) { unsigned max_age, age; double h_date, h_expires; @@ -71,9 +71,10 @@ RFC2616_Ttl(const struct sess *sp) const struct http *hp; struct exp *expp; - expp = &sp->wrk->busyobj->exp; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + expp = &bo->exp; - hp = sp->wrk->busyobj->beresp; + hp = bo->beresp; assert(expp->entered != 0.0 && !isnan(expp->entered)); /* If all else fails, cache using default ttl */ @@ -98,7 +99,7 @@ RFC2616_Ttl(const struct sess *sp) if (http_GetHdr(hp, H_Date, &p)) h_date = VTIM_parse(p); - switch (sp->req->err_code) { + switch (http_GetStatus(hp)) { default: expp->ttl = -1.; break; @@ -167,9 +168,9 @@ RFC2616_Ttl(const struct sess *sp) } /* calculated TTL, Our time, Date, Expires, max-age, age */ - VSLb(sp->req->vsl, SLT_TTL, /* XXX Bo->vsl ? */ + VSLb(bo->vsl, SLT_TTL, "%u RFC %.0f %.0f %.0f %.0f %.0f %.0f %.0f %u", - sp->req->xid, expp->ttl, -1., -1., expp->entered, + xid, expp->ttl, -1., -1., expp->entered, expp->age, h_date, h_expires, max_age); } From phk at varnish-cache.org Sun Feb 19 10:34:46 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 11:34:46 +0100 Subject: [master] 3544388 More RFC2616 related argument cleanup Message-ID: commit 354438810d1eed7111647cf3ba4ec997e173b86a Author: Poul-Henning Kamp Date: Sun Feb 19 10:34:33 2012 +0000 More RFC2616 related argument cleanup diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a8cf350..f722e7e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -998,8 +998,8 @@ char *WS_Snapshot(struct ws *ws); /* rfc2616.c */ void RFC2616_Ttl(struct busyobj *, unsigned xid); -enum body_status RFC2616_Body(const struct sess *sp); -unsigned RFC2616_Req_Gzip(const struct sess *sp); +enum body_status RFC2616_Body(struct busyobj *, struct dstat *); +unsigned RFC2616_Req_Gzip(const struct http *); int RFC2616_Do_Cond(const struct sess *sp); /* stevedore.c */ diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index a58b834..b921fee 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -238,7 +238,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) } if (cache_param->http_gzip_support && req->obj->gziped && - !RFC2616_Req_Gzip(sp)) { + !RFC2616_Req_Gzip(req->http)) { /* * We don't know what it uncompresses to * XXX: we could cache that @@ -552,22 +552,24 @@ static int cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) { int i, need_host_hdr; + struct busyobj *bo; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); + bo = wrk->busyobj; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AN(req->director); - AZ(wrk->busyobj->vbc); - AZ(wrk->busyobj->should_close); + AZ(bo->vbc); + AZ(bo->should_close); AZ(req->storage_hint); - http_Setup(wrk->busyobj->beresp, wrk->busyobj->ws, wrk->busyobj->vsl); + http_Setup(bo->beresp, bo->ws, bo->vsl); - need_host_hdr = !http_GetHdr(wrk->busyobj->bereq, H_Host, NULL); + need_host_hdr = !http_GetHdr(bo->bereq, H_Host, NULL); i = FetchHdr(sp, need_host_hdr, req->objcore == NULL); /* @@ -589,35 +591,35 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) * and we rely on their content outside of VCL, so collect them * into one line here. */ - http_CollectHdr(wrk->busyobj->beresp, H_Cache_Control); - http_CollectHdr(wrk->busyobj->beresp, H_Vary); + http_CollectHdr(bo->beresp, H_Cache_Control); + http_CollectHdr(bo->beresp, H_Vary); /* * Figure out how the fetch is supposed to happen, before the * headers are adultered by VCL * NB: Also sets other wrk variables */ - wrk->busyobj->body_status = RFC2616_Body(sp); + bo->body_status = RFC2616_Body(bo, &wrk->stats); - req->err_code = http_GetStatus(wrk->busyobj->beresp); + req->err_code = http_GetStatus(bo->beresp); /* * What does RFC2616 think about TTL ? */ - EXP_Clr(&wrk->busyobj->exp); - wrk->busyobj->exp.entered = W_TIM_real(wrk); - RFC2616_Ttl(wrk->busyobj, sp->req->xid); + EXP_Clr(&bo->exp); + bo->exp.entered = W_TIM_real(wrk); + RFC2616_Ttl(bo, sp->req->xid); /* pass from vclrecv{} has negative TTL */ if (req->objcore == NULL) - wrk->busyobj->exp.ttl = -1.; + bo->exp.ttl = -1.; - AZ(wrk->busyobj->do_esi); - AZ(wrk->busyobj->do_pass); + AZ(bo->do_esi); + AZ(bo->do_pass); VCL_fetch_method(sp); - if (req->objcore != NULL && wrk->busyobj->do_pass) + if (req->objcore != NULL && bo->do_pass) req->objcore->flags |= OC_F_PASS; switch (req->handling) { @@ -630,11 +632,11 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) } /* We are not going to fetch the body, Close the connection */ - VDI_CloseFd(wrk, &wrk->busyobj->vbc); + VDI_CloseFd(wrk, &bo->vbc); } /* Clean up partial fetch */ - AZ(wrk->busyobj->vbc); + AZ(bo->vbc); if (req->objcore != NULL) { CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); @@ -1384,7 +1386,7 @@ cnt_recv(struct sess *sp, const struct worker *wrk, struct req *req) if (cache_param->http_gzip_support && (recv_handling != VCL_RET_PIPE) && (recv_handling != VCL_RET_PASS)) { - if (RFC2616_Req_Gzip(sp)) { + if (RFC2616_Req_Gzip(req->http)) { http_Unset(req->http, H_Accept_Encoding); http_SetHeader(req->http, "Accept-Encoding: gzip"); } else { diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 2dafbd2..60bb6a9 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -179,27 +179,27 @@ RFC2616_Ttl(struct busyobj *bo, unsigned xid) */ enum body_status -RFC2616_Body(const struct sess *sp) +RFC2616_Body(struct busyobj *bo, struct dstat *stats) { struct http *hp; char *b; - hp = sp->wrk->busyobj->beresp; + hp = bo->beresp; if (hp->protover < 11 && !http_HdrIs(hp, H_Connection, "keep-alive")) - sp->wrk->busyobj->should_close = 1; + bo->should_close = 1; else if (http_HdrIs(hp, H_Connection, "close")) - sp->wrk->busyobj->should_close = 1; + bo->should_close = 1; else - sp->wrk->busyobj->should_close = 0; + bo->should_close = 0; - if (!strcasecmp(http_GetReq(sp->wrk->busyobj->bereq), "head")) { + if (!strcasecmp(http_GetReq(bo->bereq), "head")) { /* * A HEAD request can never have a body in the reply, * no matter what the headers might say. * [RFC2516 4.3 p33] */ - sp->wrk->stats.fetch_head++; + stats->fetch_head++; return (BS_NONE); } @@ -208,7 +208,7 @@ RFC2616_Body(const struct sess *sp) * 1xx responses never have a body. * [RFC2616 4.3 p33] */ - sp->wrk->stats.fetch_1xx++; + stats->fetch_1xx++; return (BS_NONE); } @@ -217,7 +217,7 @@ RFC2616_Body(const struct sess *sp) * 204 is "No Content", obviously don't expect a body. * [RFC2616 10.2.5 p60] */ - sp->wrk->stats.fetch_204++; + stats->fetch_204++; return (BS_NONE); } @@ -226,23 +226,23 @@ RFC2616_Body(const struct sess *sp) * 304 is "Not Modified" it has no body. * [RFC2616 10.3.5 p63] */ - sp->wrk->stats.fetch_304++; + stats->fetch_304++; return (BS_NONE); } if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) { - sp->wrk->stats.fetch_chunked++; + stats->fetch_chunked++; return (BS_CHUNKED); } if (http_GetHdr(hp, H_Transfer_Encoding, &b)) { - sp->wrk->stats.fetch_bad++; + stats->fetch_bad++; return (BS_ERROR); } if (http_GetHdr(hp, H_Content_Length, - &sp->wrk->busyobj->h_content_length)) { - sp->wrk->stats.fetch_length++; + &bo->h_content_length)) { + stats->fetch_length++; return (BS_LENGTH); } @@ -251,7 +251,7 @@ RFC2616_Body(const struct sess *sp) * Keep alive with neither TE=Chunked or C-Len is impossible. * We assume a zero length body. */ - sp->wrk->stats.fetch_zero++; + stats->fetch_zero++; return (BS_ZERO); } @@ -259,7 +259,7 @@ RFC2616_Body(const struct sess *sp) /* * In this case, it is safe to just read what comes. */ - sp->wrk->stats.fetch_close++; + stats->fetch_close++; return (BS_EOF); } @@ -267,14 +267,14 @@ RFC2616_Body(const struct sess *sp) /* * With no Connection header, assume EOF. */ - sp->wrk->stats.fetch_oldhttp++; + stats->fetch_oldhttp++; return (BS_EOF); } /* * Fall back to EOF transfer. */ - sp->wrk->stats.fetch_eof++; + stats->fetch_eof++; return (BS_EOF); } @@ -283,7 +283,7 @@ RFC2616_Body(const struct sess *sp) */ unsigned -RFC2616_Req_Gzip(const struct sess *sp) +RFC2616_Req_Gzip(const struct http *hp) { @@ -292,7 +292,7 @@ RFC2616_Req_Gzip(const struct sess *sp) * p104 says to not do q values for x-gzip, so we just test * for its existence. */ - if (http_GetHdrData(sp->req->http, H_Accept_Encoding, "x-gzip", NULL)) + if (http_GetHdrData(hp, H_Accept_Encoding, "x-gzip", NULL)) return (1); /* @@ -300,7 +300,7 @@ RFC2616_Req_Gzip(const struct sess *sp) * We do not care a hoot if the client prefers some other * compression more than gzip: Varnish only does gzip. */ - if (http_GetHdrQ(sp->req->http, H_Accept_Encoding, "gzip") > 0.) + if (http_GetHdrQ(hp, H_Accept_Encoding, "gzip") > 0.) return (1); /* Bad client, no gzip. */ diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 50f4411..82aeb9c 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -355,7 +355,7 @@ VRT_r_req_can_gzip(struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - return (RFC2616_Req_Gzip(sp)); + return (RFC2616_Req_Gzip(sp->req->http)); } From phk at varnish-cache.org Sun Feb 19 11:05:24 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 12:05:24 +0100 Subject: [master] 06b6c78 Detect client crashing during startup Message-ID: commit 06b6c7882458b9ffecede17f4b66f5aca1d4a3b4 Author: Poul-Henning Kamp Date: Sun Feb 19 11:05:09 2012 +0000 Detect client crashing during startup diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 880f966..c00a143 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -156,6 +156,12 @@ wait_running(const struct varnish *v) if (st != CLIS_OK) vtc_log(v->vl, 0, "CLI status command failed: %u %s", st, r); + if (!strcmp(r, "Child in state stopped")) { + vtc_log(v->vl, 0, + "Child stopped before running: %u %s", st, r); + free(r); + break; + } if (!strcmp(r, "Child in state running")) { free(r); break; From phk at varnish-cache.org Sun Feb 19 11:41:37 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 12:41:37 +0100 Subject: [master] 1bda658 Hide the hash preallocation in cache_hash.c again, by tasking persistent with allocating its own objcores. Message-ID: commit 1bda6584df023d47c6a6715089310c72b3ba2ccf Author: Poul-Henning Kamp Date: Sun Feb 19 11:41:08 2012 +0000 Hide the hash preallocation in cache_hash.c again, by tasking persistent with allocating its own objcores. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index eff6357..ce596df 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -65,17 +65,14 @@ static const struct hash_slinger *hash; /*---------------------------------------------------------------------*/ /* Precreate an objhead and object for later use */ -void -HSH_Prealloc(const struct sess *sp) +static void +hsh_prealloc(struct worker *wrk) { - struct worker *wrk; struct objhead *oh; struct objcore *oc; struct waitinglist *wl; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); - wrk = sp->wrk; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); if (wrk->nobjcore == NULL) { ALLOC_OBJ(oc, OBJCORE_MAGIC); @@ -107,7 +104,7 @@ HSH_Prealloc(const struct sess *sp) CHECK_OBJ_NOTNULL(wrk->nwaitinglist, WAITINGLIST_MAGIC); if (hash->prep != NULL) - hash->prep(sp); + hash->prep(wrk); } void @@ -247,24 +244,26 @@ hsh_testmagic(void *result) * Return it with a reference held. */ -struct objcore * -HSH_Insert(const struct sess *sp) +void +HSH_Insert(const struct sess *sp, const void *digest, struct objcore *oc) { struct worker *wrk; struct objhead *oh; - struct objcore *oc; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); - AN(hash); + AN(digest); + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + wrk = sp->wrk; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - HSH_Prealloc(sp); + hsh_prealloc(wrk); if (cache_param->diag_bitmap & 0x80000000) - hsh_testmagic(sp->wrk->nobjhead->digest); + hsh_testmagic(wrk->nobjhead->digest); AZ(sp->req); AN(wrk->nobjhead); + memcpy(wrk->nobjhead->digest, digest, SHA256_LEN); oh = hash->lookup(sp, wrk->nobjhead); CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); if (oh == wrk->nobjhead) @@ -273,8 +272,6 @@ HSH_Insert(const struct sess *sp) assert(oh->refcnt > 0); /* Insert (precreated) objcore in objecthead */ - oc = wrk->nobjcore; - wrk->nobjcore = NULL; oc->refcnt = 1; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AZ(oc->flags & OC_F_BUSY); @@ -283,8 +280,8 @@ HSH_Insert(const struct sess *sp) /* NB: do not deref objhead the new object inherits our reference */ oc->objhead = oh; Lck_Unlock(&oh->mtx); - sp->wrk->stats.n_vampireobject++; - return (oc); + wrk->stats.n_objectcore++; + wrk->stats.n_vampireobject++; } /*--------------------------------------------------------------------- @@ -307,7 +304,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh) AN(hash); wrk = sp->wrk; - HSH_Prealloc(sp); + hsh_prealloc(wrk); memcpy(sp->wrk->nobjhead->digest, sp->req->digest, sizeof sp->req->digest); if (cache_param->diag_bitmap & 0x80000000) diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 97ff04a..0c9f5d0 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -116,6 +116,7 @@ -emacro(527, NEEDLESS_RETURN) // unreachable code +-sem(EXP_Inject, custodial(1)) -sem(WS_Init, custodial(2)) -sem(http_Setup, custodial(2)) diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index 069a1c2..fbdc906 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -469,13 +469,14 @@ hcb_lookup(const struct sess *sp, struct objhead *noh) } static void -hcb_prep(const struct sess *sp) +hcb_prep(struct worker *wrk) { struct hcb_y *y; - if (sp->wrk->nhashpriv == NULL) { + if (wrk->nhashpriv == NULL) { ALLOC_OBJ(y, HCB_Y_MAGIC); - sp->wrk->nhashpriv = y; + AN(y); + wrk->nhashpriv = y; } } diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index f2b41e2..9add938 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -34,7 +34,7 @@ struct object; typedef void hash_init_f(int ac, char * const *av); typedef void hash_start_f(void); -typedef void hash_prep_f(const struct sess *sp); +typedef void hash_prep_f(struct worker *); typedef struct objhead * hash_lookup_f(const struct sess *sp, struct objhead *nobj); typedef int hash_deref_f(struct objhead *obj); @@ -51,7 +51,6 @@ struct hash_slinger { }; /* cache_hash.c */ -void HSH_Prealloc(const struct sess *sp); void HSH_Cleanup(struct worker *w); struct objcore *HSH_Lookup(struct sess *sp, struct objhead **poh); void HSH_Unbusy(struct objcore *); @@ -59,7 +58,7 @@ void HSH_Ref(struct objcore *o); void HSH_Drop(struct worker *, struct object **); void HSH_Init(const struct hash_slinger *slinger); void HSH_AddString(const struct sess *sp, const char *str); -struct objcore *HSH_Insert(const struct sess *sp); +void HSH_Insert(const struct sess *sp, const void *hash, struct objcore *); void HSH_Purge(const struct sess *, struct objhead *, double ttl, double grace); void HSH_config(const char *h_arg); diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index a6a02e6..4d6fd9a 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -150,15 +150,13 @@ smp_load_seg(const struct sess *sp, const struct smp_sc *sc, for (;no > 0; so++,no--) { if (so->ttl == 0 || so->ttl < t_now) continue; - HSH_Prealloc(sp); - oc = sp->wrk->nobjcore; + ALLOC_OBJ(oc, OBJCORE_MAGIC); + AN(oc); oc->flags |= OC_F_NEEDFIXUP | OC_F_LRUDONTMOVE; oc->flags &= ~OC_F_BUSY; smp_init_oc(oc, sg, no); oc->ban = BAN_RefBan(oc, so->ban, sc->tailban); - memcpy(sp->wrk->nobjhead->digest, so->hash, SHA256_LEN); - (void)HSH_Insert(sp); - AZ(sp->wrk->nobjcore); + HSH_Insert(sp, so->hash, oc); EXP_Inject(oc, sg->lru, so->ttl); sg->nobj++; } From phk at varnish-cache.org Sun Feb 19 11:58:34 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 12:58:34 +0100 Subject: [master] 219aa02 Eliminate struct sess from HSH_Insert() Message-ID: commit 219aa0297024653698319efa5750a19f3dccc116 Author: Poul-Henning Kamp Date: Sun Feb 19 11:58:19 2012 +0000 Eliminate struct sess from HSH_Insert() diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index a9ff554..a022cbe 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -800,7 +800,7 @@ ban_CheckLast(void) * Ban lurker thread */ -static int +static int __match_proto__(bgthread_t) ban_lurker_work(const struct sess *sp, unsigned pass) { struct ban *b, *b0, *b2; diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index e0f3d27..90702f8 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -329,7 +329,7 @@ EXP_Rearm(const struct object *o) * object expires, accounting also for graceability, it is killed. */ -static void * __match_proto__(void *start_routine(void *)) +static void * __match_proto__(bgthread_t) exp_timer(struct sess *sp, void *priv) { struct objcore *oc; diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index ce596df..15b0a2a 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -245,26 +245,21 @@ hsh_testmagic(void *result) */ void -HSH_Insert(const struct sess *sp, const void *digest, struct objcore *oc) +HSH_Insert(struct worker *wrk, const void *digest, struct objcore *oc) { - struct worker *wrk; struct objhead *oh; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); AN(digest); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - wrk = sp->wrk; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - hsh_prealloc(wrk); if (cache_param->diag_bitmap & 0x80000000) hsh_testmagic(wrk->nobjhead->digest); - AZ(sp->req); AN(wrk->nobjhead); memcpy(wrk->nobjhead->digest, digest, SHA256_LEN); - oh = hash->lookup(sp, wrk->nobjhead); + oh = hash->lookup(wrk, wrk->nobjhead); CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); if (oh == wrk->nobjhead) wrk->nobjhead = NULL; @@ -320,7 +315,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh) sp->req->hash_objhead = NULL; } else { AN(wrk->nobjhead); - oh = hash->lookup(sp, wrk->nobjhead); + oh = hash->lookup(wrk, wrk->nobjhead); if (oh == wrk->nobjhead) wrk->nobjhead = NULL; } diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c index b530f25..c84238a 100644 --- a/bin/varnishd/hash/hash_classic.c +++ b/bin/varnishd/hash/hash_classic.c @@ -54,7 +54,7 @@ static struct hcl_hd *hcl_head; * The ->init method allows the management process to pass arguments */ -static void +static void __match_proto__(hash_init_f) hcl_init(int ac, char * const *av) { int i; @@ -86,7 +86,7 @@ hcl_init(int ac, char * const *av) * initialization to happen before the first lookup. */ -static void +static void __match_proto__(hash_start_f) hcl_start(void) { unsigned u; @@ -110,15 +110,15 @@ hcl_start(void) * rare and collisions even rarer. */ -static struct objhead * -hcl_lookup(const struct sess *sp, struct objhead *noh) +static struct objhead * __match_proto__(hash_lookup_f) +hcl_lookup(struct worker *wrk, struct objhead *noh) { struct objhead *oh; struct hcl_hd *hp; unsigned u1, digest; int i; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC); assert(sizeof noh->digest > sizeof digest); @@ -153,7 +153,7 @@ hcl_lookup(const struct sess *sp, struct objhead *noh) * Dereference and if no references are left, free. */ -static int +static int __match_proto__(hash_deref_f) hcl_deref(struct objhead *oh) { struct hcl_hd *hp; diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index fbdc906..9edef51 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -373,7 +373,7 @@ hcb_cleaner(struct sess *sp, void *priv) /*--------------------------------------------------------------------*/ -static void +static void __match_proto__(hash_start_f) hcb_start(void) { struct objhead *oh = NULL; @@ -387,7 +387,7 @@ hcb_start(void) hcb_build_bittbl(); } -static int +static int __match_proto__(hash_deref_f) hcb_deref(struct objhead *oh) { int r; @@ -412,28 +412,28 @@ hcb_deref(struct objhead *oh) return (r); } -static struct objhead * -hcb_lookup(const struct sess *sp, struct objhead *noh) +static struct objhead * __match_proto__(hash_lookup_f) +hcb_lookup(struct worker *wrk, struct objhead *noh) { struct objhead *oh; struct hcb_y *y; unsigned u; unsigned with_lock; - (void)sp; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); with_lock = 0; while (1) { if (with_lock) { - CAST_OBJ_NOTNULL(y, sp->wrk->nhashpriv, HCB_Y_MAGIC); + CAST_OBJ_NOTNULL(y, wrk->nhashpriv, HCB_Y_MAGIC); Lck_Lock(&hcb_mtx); VSC_C_main->hcb_lock++; assert(noh->refcnt == 1); - oh = hcb_insert(sp->wrk, &hcb_root, noh, 1); + oh = hcb_insert(wrk, &hcb_root, noh, 1); Lck_Unlock(&hcb_mtx); } else { VSC_C_main->hcb_nolock++; - oh = hcb_insert(sp->wrk, &hcb_root, noh, 0); + oh = hcb_insert(wrk, &hcb_root, noh, 0); } if (oh != NULL && oh == noh) { @@ -468,7 +468,7 @@ hcb_lookup(const struct sess *sp, struct objhead *noh) } } -static void +static void __match_proto__(hash_prep_f) hcb_prep(struct worker *wrk) { struct hcb_y *y; diff --git a/bin/varnishd/hash/hash_simple_list.c b/bin/varnishd/hash/hash_simple_list.c index c1cc9c8..fef2b65 100644 --- a/bin/varnishd/hash/hash_simple_list.c +++ b/bin/varnishd/hash/hash_simple_list.c @@ -45,7 +45,7 @@ static struct lock hsl_mtx; * initialization to happen before the first lookup. */ -static void +static void __match_proto__(hash_start_f) hsl_start(void) { @@ -59,13 +59,13 @@ hsl_start(void) * A reference to the returned object is held. */ -static struct objhead * -hsl_lookup(const struct sess *sp, struct objhead *noh) +static struct objhead * __match_proto__(hash_lookup_f) +hsl_lookup(struct worker *wrk, struct objhead *noh) { struct objhead *oh; int i; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC); Lck_Lock(&hsl_mtx); VTAILQ_FOREACH(oh, &hsl_head, hoh_list) { @@ -92,7 +92,7 @@ hsl_lookup(const struct sess *sp, struct objhead *noh) * Dereference and if no references are left, free. */ -static int +static int __match_proto__(hash_deref_f) hsl_deref(struct objhead *oh) { int ret; diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 9add938..b15d9df 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -36,7 +36,7 @@ typedef void hash_init_f(int ac, char * const *av); typedef void hash_start_f(void); typedef void hash_prep_f(struct worker *); typedef struct objhead * - hash_lookup_f(const struct sess *sp, struct objhead *nobj); + hash_lookup_f(struct worker *wrk, struct objhead *nobj); typedef int hash_deref_f(struct objhead *obj); struct hash_slinger { @@ -58,7 +58,7 @@ void HSH_Ref(struct objcore *o); void HSH_Drop(struct worker *, struct object **); void HSH_Init(const struct hash_slinger *slinger); void HSH_AddString(const struct sess *sp, const char *str); -void HSH_Insert(const struct sess *sp, const void *hash, struct objcore *); +void HSH_Insert(struct worker *, const void *hash, struct objcore *); void HSH_Purge(const struct sess *, struct objhead *, double ttl, double grace); void HSH_config(const char *h_arg); diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index c49ceac..5e2db82 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -267,19 +267,19 @@ smp_open_segs(struct smp_sc *sc, struct smp_signctx *ctx) * Silo worker thread */ -static void * +static void * __match_proto__(bgthread_t) smp_thread(struct sess *sp, void *priv) { struct smp_sc *sc; struct smp_seg *sg; - (void)sp; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CAST_OBJ_NOTNULL(sc, priv, SMP_SC_MAGIC); /* First, load all the objects from all segments */ VTAILQ_FOREACH(sg, &sc->segments, list) if (sg->flags & SMP_SEG_MUSTLOAD) - smp_load_seg(sp, sc, sg); + smp_load_seg(sp->wrk, sc, sg); sc->flags |= SMP_SC_LOADED; BAN_TailDeref(&sc->tailban); diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h index 84f3d21..a755b89 100644 --- a/bin/varnishd/storage/storage_persistent.h +++ b/bin/varnishd/storage/storage_persistent.h @@ -167,8 +167,7 @@ void smp_mgt_init(struct stevedore *parent, int ac, char * const *av); /* storage_persistent_silo.c */ -void smp_load_seg(const struct sess *sp, const struct smp_sc *sc, - struct smp_seg *sg); +void smp_load_seg(struct worker *, const struct smp_sc *sc, struct smp_seg *sg); void smp_new_seg(struct smp_sc *sc); void smp_close_seg(struct smp_sc *sc, struct smp_seg *sg); void smp_init_oc(struct objcore *oc, struct smp_seg *sg, unsigned objidx); diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 4d6fd9a..09b2497 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -118,7 +118,7 @@ smp_save_segs(struct smp_sc *sc) */ void -smp_load_seg(const struct sess *sp, const struct smp_sc *sc, +smp_load_seg(struct worker *wrk, const struct smp_sc *sc, struct smp_seg *sg) { struct smp_object *so; @@ -128,7 +128,7 @@ smp_load_seg(const struct sess *sp, const struct smp_sc *sc, struct smp_signctx ctx[1]; ASSERT_SILO_THREAD(sc); - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sg, SMP_SEG_MAGIC); CHECK_OBJ_NOTNULL(sg->lru, LRU_MAGIC); assert(sg->flags & SMP_SEG_MUSTLOAD); @@ -156,11 +156,11 @@ smp_load_seg(const struct sess *sp, const struct smp_sc *sc, oc->flags &= ~OC_F_BUSY; smp_init_oc(oc, sg, no); oc->ban = BAN_RefBan(oc, so->ban, sc->tailban); - HSH_Insert(sp, so->hash, oc); + HSH_Insert(wrk, so->hash, oc); EXP_Inject(oc, sg->lru, so->ttl); sg->nobj++; } - WRK_SumStat(sp->wrk); + WRK_SumStat(wrk); sg->flags |= SMP_SEG_LOADED; } From phk at varnish-cache.org Sun Feb 19 12:07:44 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 13:07:44 +0100 Subject: [master] e632739 Eliminate the ban-lurkers need for struct sess Message-ID: commit e63273932d7d5945e20eb44f506ae8c005593f2c Author: Poul-Henning Kamp Date: Sun Feb 19 12:07:32 2012 +0000 Eliminate the ban-lurkers need for struct sess diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index a022cbe..e72343b 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -677,16 +677,17 @@ ban_evaluate(const uint8_t *bs, const struct http *objhttp, */ static int -ban_check_object(struct object *o, const struct sess *sp, int has_req) +ban_check_object(struct object *o, struct worker *wrk, + const struct http *req_http) { struct ban *b; struct objcore *oc; struct ban * volatile b0; unsigned tests, skipped; - struct http *http; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_ORNULL(req_http, HTTP_MAGIC); oc = o->objcore; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(oc->ban, BAN_MAGIC); @@ -697,11 +698,6 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req) if (b0 == oc->ban) return (0); - if (has_req) - http = sp->req->http; - else - http = NULL; - /* * This loop is safe without locks, because we know we hold * a refcount on a ban somewhere in the list and we do not @@ -719,13 +715,13 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req) /* Lurker already tested this */ continue; } - if (!has_req && (b->flags & BAN_F_REQ)) { + if (req_http == NULL && (b->flags & BAN_F_REQ)) { /* * We cannot test this one, but there might * be other bans that match, so we soldier on */ skipped++; - } else if (ban_evaluate(b->spec, o->http, http, &tests)) + } else if (ban_evaluate(b->spec, o->http, req_http, &tests)) break; } @@ -734,7 +730,7 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req) VSC_C_main->bans_tests_tested += tests; if (b == oc->ban && skipped > 0) { - AZ(has_req); + AZ(req_http); Lck_Unlock(&ban_mtx); /* * Not banned, but some tests were skipped, so we cannot know @@ -762,7 +758,7 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req) oc_updatemeta(oc); /* BAN also changed, but that is not important any more */ /* XXX: no req in lurker */ - VSLb(sp->wrk->vsl, SLT_ExpBan, "%u was banned", o->xid); + VSLb(wrk->vsl, SLT_ExpBan, "%u was banned", o->xid); EXP_Rearm(o); return (1); } @@ -772,7 +768,7 @@ int BAN_CheckObject(struct object *o, const struct sess *sp) { - return (ban_check_object(o, sp, 1) > 0); + return (ban_check_object(o, sp->wrk, sp->req->http) > 0); } static struct ban * @@ -800,8 +796,8 @@ ban_CheckLast(void) * Ban lurker thread */ -static int __match_proto__(bgthread_t) -ban_lurker_work(const struct sess *sp, unsigned pass) +static int +ban_lurker_work(struct worker *wrk, unsigned pass) { struct ban *b, *b0, *b2; struct objhead *oh; @@ -892,8 +888,8 @@ ban_lurker_work(const struct sess *sp, unsigned pass) /* * Get the object and check it against all relevant bans */ - o = oc_getobj(&sp->wrk->stats, oc); - i = ban_check_object(o, sp, 0); + o = oc_getobj(&wrk->stats, oc); + i = ban_check_object(o, wrk, NULL); if (cache_param->diag_bitmap & 0x80000) VSL(SLT_Debug, 0, "lurker got: %p %d", oc, i); @@ -909,7 +905,7 @@ ban_lurker_work(const struct sess *sp, unsigned pass) if (cache_param->diag_bitmap & 0x80000) VSL(SLT_Debug, 0, "lurker done: %p %u %u", oc, oc->flags & OC_F_LURK, pass); - (void)HSH_Deref(&sp->wrk->stats, NULL, &o); + (void)HSH_Deref(&wrk->stats, NULL, &o); VTIM_sleep(cache_param->ban_lurker_sleep); } Lck_AssertHeld(&ban_mtx); @@ -954,7 +950,7 @@ ban_lurker(struct sess *sp, void *priv) VTIM_sleep(1.0); } - i = ban_lurker_work(sp, pass); + i = ban_lurker_work(sp->wrk, pass); VSL_Flush(sp->wrk->vsl, 0); WRK_SumStat(sp->wrk); if (i) { From phk at varnish-cache.org Sun Feb 19 12:16:49 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 13:16:49 +0100 Subject: [master] a1cdab1 Remove struct sess entirely from bgthreads Message-ID: commit a1cdab139ba08adcd6703aa96042036b1fa39a6a Author: Poul-Henning Kamp Date: Sun Feb 19 12:16:38 2012 +0000 Remove struct sess entirely from bgthreads diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f722e7e..c4efc49 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -981,7 +981,7 @@ void WRK_Init(void); int WRK_TrySumStat(struct worker *w); void WRK_SumStat(struct worker *w); void *WRK_thread(void *priv); -typedef void *bgthread_t(struct sess *, void *priv); +typedef void *bgthread_t(struct worker *, void *priv); void WRK_BgThread(pthread_t *thr, const char *name, bgthread_t *func, void *priv); diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index e72343b..2c95f61 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -927,7 +927,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass) } static void * __match_proto__(bgthread_t) -ban_lurker(struct sess *sp, void *priv) +ban_lurker(struct worker *wrk, void *priv) { struct ban *bf; unsigned pass = (1 << LURK_SHIFT); @@ -950,9 +950,9 @@ ban_lurker(struct sess *sp, void *priv) VTIM_sleep(1.0); } - i = ban_lurker_work(sp->wrk, pass); - VSL_Flush(sp->wrk->vsl, 0); - WRK_SumStat(sp->wrk); + i = ban_lurker_work(wrk, pass); + VSL_Flush(wrk->vsl, 0); + WRK_SumStat(wrk); if (i) { pass += (1 << LURK_SHIFT); pass &= BAN_F_LURK; diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 90702f8..8eedb71 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -330,7 +330,7 @@ EXP_Rearm(const struct object *o) */ static void * __match_proto__(bgthread_t) -exp_timer(struct sess *sp, void *priv) +exp_timer(struct worker *wrk, void *priv) { struct objcore *oc; struct lru *lru; @@ -342,8 +342,8 @@ exp_timer(struct sess *sp, void *priv) oc = NULL; while (1) { if (oc == NULL) { - VSL_Flush(sp->wrk->vsl, 0); - WRK_SumStat(sp->wrk); + VSL_Flush(wrk->vsl, 0); + WRK_SumStat(wrk); VTIM_sleep(cache_param->expiry_sleep); t = VTIM_real(); } @@ -399,10 +399,10 @@ exp_timer(struct sess *sp, void *priv) VSC_C_main->n_expired++; CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC); - o = oc_getobj(&sp->wrk->stats, oc); - WSL(sp->wrk->vsl, SLT_ExpKill, 0, "%u %.0f", - oc_getxid(&sp->wrk->stats, oc), EXP_Ttl(NULL, o) - t); - (void)HSH_Deref(&sp->wrk->stats, oc, NULL); + o = oc_getobj(&wrk->stats, oc); + WSL(wrk->vsl, SLT_ExpKill, 0, "%u %.0f", + oc_getxid(&wrk->stats, oc), EXP_Ttl(NULL, o) - t); + (void)HSH_Deref(&wrk->stats, oc, NULL); } NEEDLESS_RETURN(NULL); } diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 6862a1f..d28a58c 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -94,19 +94,15 @@ wrk_bgthread(void *arg) { struct bgthread *bt; struct worker wrk; - struct sess *sp; uint32_t logbuf[1024]; /* XXX: size ? */ CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC); THR_SetName(bt->name); - sp = SES_Alloc(); - XXXAN(sp); memset(&wrk, 0, sizeof wrk); - sp->wrk = &wrk; wrk.magic = WORKER_MAGIC; VSL_Setup(wrk.vsl, logbuf, sizeof logbuf); - (void)bt->func(sp, bt->priv); + (void)bt->func(&wrk, bt->priv); WRONG("BgThread terminated"); diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index 9edef51..535661e 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -345,10 +345,9 @@ static struct cli_proto hcb_cmds[] = { /*--------------------------------------------------------------------*/ static void * __match_proto__(bgthread_t) -hcb_cleaner(struct sess *sp, void *priv) +hcb_cleaner(struct worker *wrk, void *priv) { struct hcb_y *y, *y2; - struct worker *wrk = sp->wrk; struct objhead *oh, *oh2; (void)priv; diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 5e2db82..58c6f29 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -268,18 +268,18 @@ smp_open_segs(struct smp_sc *sc, struct smp_signctx *ctx) */ static void * __match_proto__(bgthread_t) -smp_thread(struct sess *sp, void *priv) +smp_thread(struct worker *wrk, void *priv) { struct smp_sc *sc; struct smp_seg *sg; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CAST_OBJ_NOTNULL(sc, priv, SMP_SC_MAGIC); /* First, load all the objects from all segments */ VTAILQ_FOREACH(sg, &sc->segments, list) if (sg->flags & SMP_SEG_MUSTLOAD) - smp_load_seg(sp->wrk, sc, sg); + smp_load_seg(wrk, sc, sg); sc->flags |= SMP_SC_LOADED; BAN_TailDeref(&sc->tailban); @@ -288,8 +288,7 @@ smp_thread(struct sess *sp, void *priv) while (1) { (void)sleep (1); sg = VTAILQ_FIRST(&sc->segments); - if (sg != NULL && sg -> sc->cur_seg && - sg->nobj == 0) { + if (sg != NULL && sg -> sc->cur_seg && sg->nobj == 0) { Lck_Lock(&sc->mtx); smp_save_segs(sc); Lck_Unlock(&sc->mtx); From phk at varnish-cache.org Sun Feb 19 12:51:54 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 13:51:54 +0100 Subject: [master] ef74b85 Move the busyobj reference from worker to req Message-ID: commit ef74b856eaac7944960a0af957de842519f9d22e Author: Poul-Henning Kamp Date: Sun Feb 19 12:51:42 2012 +0000 Move the busyobj reference from worker to req diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index c4efc49..4b5fcd8 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -316,7 +316,6 @@ struct worker { struct ws aws[1]; - struct busyobj *busyobj; /* Temporary accounting */ struct acct acct_tmp; @@ -551,6 +550,7 @@ struct req { /* The busy objhead we sleep on */ struct objhead *hash_objhead; + struct busyobj *busyobj; /* Built Vary string */ uint8_t *vary_b; @@ -750,7 +750,7 @@ struct storage *FetchStorage(struct busyobj *, ssize_t sz); int FetchError(struct busyobj *, const char *error); int FetchError2(struct busyobj *, const char *error, const char *more); int FetchHdr(struct sess *sp, int need_host_hdr, int sendbody); -int FetchBody(struct worker *w, struct object *obj); +int FetchBody(struct worker *w, struct busyobj *bo, struct object *obj); int FetchReqBody(const struct sess *sp, int sendbody); void Fetch_Init(void); @@ -894,7 +894,6 @@ unsigned WRW_Write(struct worker *w, const void *ptr, int len); unsigned WRW_WriteH(struct worker *w, const txt *hh, const char *suf); /* cache_session.c [SES] */ -struct sess *SES_Alloc(void); void SES_Close(struct sess *sp, const char *reason); void SES_Delete(struct sess *sp, const char *reason, double now); void SES_Charge(struct sess *sp); diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 085c7a7..cfe86ec 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -89,8 +89,8 @@ VBE_ReleaseConn(struct vbc *vc) #define FIND_TMO(tmx, dst, sp, be) \ do { \ - CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); \ - dst = sp->wrk->busyobj->tmx; \ + CHECK_OBJ_NOTNULL(sp->req->busyobj, BUSYOBJ_MAGIC); \ + dst = sp->req->busyobj->tmx; \ if (dst == 0.0) \ dst = be->tmx; \ if (dst == 0.0) \ diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 2c95f61..0058c3c 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -796,7 +796,7 @@ ban_CheckLast(void) * Ban lurker thread */ -static int +static int ban_lurker_work(struct worker *wrk, unsigned pass) { struct ban *b, *b0, *b2; diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index b921fee..a56e016 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -201,29 +201,32 @@ DOT } static int cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) { + struct busyobj *bo; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + bo = req->busyobj; + CHECK_OBJ_ORNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); - if (wrk->busyobj != NULL) { - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - AN(wrk->busyobj->do_stream); + if (bo != NULL) { + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AN(bo->do_stream); AssertObjCorePassOrBusy(req->obj->objcore); } req->res_mode = 0; - if (wrk->busyobj == NULL) + if (bo == NULL) req->res_mode |= RES_LEN; - if (wrk->busyobj != NULL && - (wrk->busyobj->h_content_length != NULL || - !wrk->busyobj->do_stream) && - !wrk->busyobj->do_gzip && !wrk->busyobj->do_gunzip) + if (bo != NULL && + (bo->h_content_length != NULL || + !bo->do_stream) && + !bo->do_gzip && !bo->do_gunzip) req->res_mode |= RES_LEN; if (!req->disable_esi && req->obj->esidata != NULL) { @@ -249,7 +252,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) if (!(req->res_mode & (RES_LEN|RES_CHUNKED|RES_EOF))) { if (req->obj->len == 0 && - (wrk->busyobj == NULL || !wrk->busyobj->do_stream)) + (bo == NULL || !bo->do_stream)) /* * If the object is empty, neither ESI nor GUNZIP * can make it any different size @@ -282,11 +285,11 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) case VCL_RET_RESTART: if (req->restarts >= cache_param->max_restarts) break; - if (wrk->busyobj != NULL) { - AN(wrk->busyobj->do_stream); - VDI_CloseFd(wrk, &wrk->busyobj->vbc); + if (bo != NULL) { + AN(bo->do_stream); + VDI_CloseFd(wrk, &bo->vbc); HSH_Drop(wrk, &sp->req->obj); - VBO_DerefBusyObj(wrk, &wrk->busyobj); + VBO_DerefBusyObj(wrk, &bo); } else { (void)HSH_Deref(&wrk->stats, NULL, &req->obj); } @@ -325,7 +328,7 @@ cnt_deliver(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - AZ(sp->wrk->busyobj); + AZ(req->busyobj); req->director = NULL; req->restarts = 0; @@ -364,12 +367,10 @@ cnt_done(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_ORNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->obj); - AZ(wrk->busyobj); + AZ(req->busyobj); req->director = NULL; req->restarts = 0; - wrk->busyobj = NULL; - SES_Charge(sp); /* If we did an ESI include, don't mess up our state */ @@ -464,6 +465,7 @@ static int cnt_error(struct sess *sp, struct worker *wrk, struct req *req) { struct http *h; + struct busyobj *bo; char date[40]; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); @@ -471,21 +473,22 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); AZ(req->objcore); AZ(req->obj); - AZ(wrk->busyobj); + AZ(req->busyobj); - wrk->busyobj = VBO_GetBusyObj(wrk); - wrk->busyobj->vsl->wid = sp->vsl_id; - AZ(wrk->busyobj->stats); - wrk->busyobj->stats = &wrk->stats; - req->obj = STV_NewObject(wrk->busyobj, &req->objcore, + bo = VBO_GetBusyObj(wrk); + req->busyobj = bo; + bo->vsl->wid = sp->vsl_id; + AZ(bo->stats); + bo->stats = &wrk->stats; + req->obj = STV_NewObject(bo, &req->objcore, TRANSIENT_STORAGE, cache_param->http_resp_size, (uint16_t)cache_param->http_max_hdr); - wrk->busyobj->stats = NULL; + bo->stats = NULL; if (req->obj == NULL) { req->doclose = "Out of objects"; req->director = NULL; - http_Teardown(wrk->busyobj->beresp); - http_Teardown(wrk->busyobj->bereq); + http_Teardown(bo->beresp); + http_Teardown(bo->bereq); sp->step = STP_DONE; return(0); } @@ -513,7 +516,7 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) if (req->handling == VCL_RET_RESTART && req->restarts < cache_param->max_restarts) { HSH_Drop(wrk, &sp->req->obj); - VBO_DerefBusyObj(wrk, &wrk->busyobj); + VBO_DerefBusyObj(wrk, &req->busyobj); req->director = NULL; req->restarts++; sp->step = STP_RECV; @@ -529,8 +532,8 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req) assert(req->handling == VCL_RET_DELIVER); req->err_code = 0; req->err_reason = NULL; - http_Teardown(wrk->busyobj->bereq); - VBO_DerefBusyObj(wrk, &wrk->busyobj); + http_Teardown(bo->bereq); + VBO_DerefBusyObj(wrk, &req->busyobj); sp->step = STP_PREPRESP; return (0); } @@ -559,7 +562,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); - bo = wrk->busyobj; + bo = req->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AN(req->director); @@ -643,7 +646,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) AZ(HSH_Deref(&wrk->stats, req->objcore, NULL)); req->objcore = NULL; } - VBO_DerefBusyObj(wrk, &wrk->busyobj); + VBO_DerefBusyObj(wrk, &req->busyobj); req->director = NULL; req->storage_hint = NULL; @@ -688,7 +691,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - bo = wrk->busyobj; + bo = req->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); assert(req->handling == VCL_RET_DELIVER); @@ -791,7 +794,6 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) req->objcore == NULL) req->storage_hint = TRANSIENT_STORAGE; - assert(bo == wrk->busyobj); AZ(bo->stats); bo->stats = &wrk->stats; req->obj = STV_NewObject(bo, &req->objcore, req->storage_hint, l, @@ -813,7 +815,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) req->err_code = 503; sp->step = STP_ERROR; VDI_CloseFd(wrk, &bo->vbc); - VBO_DerefBusyObj(wrk, &wrk->busyobj); + VBO_DerefBusyObj(wrk, &req->busyobj); return (0); } CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); @@ -889,11 +891,11 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - bo = wrk->busyobj; + bo = req->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); /* Use unmodified headers*/ - i = FetchBody(wrk, req->obj); + i = FetchBody(wrk, bo, req->obj); http_Teardown(bo->bereq); http_Teardown(bo->beresp); @@ -904,7 +906,7 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req) if (i) { HSH_Drop(wrk, &sp->req->obj); - VBO_DerefBusyObj(wrk, &wrk->busyobj); + VBO_DerefBusyObj(wrk, &req->busyobj); AZ(req->obj); req->err_code = 503; sp->step = STP_ERROR; @@ -918,7 +920,7 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req) AZ(req->obj->ws_o->overflow); HSH_Unbusy(req->obj->objcore); } - VBO_DerefBusyObj(wrk, &wrk->busyobj); + VBO_DerefBusyObj(wrk, &req->busyobj); wrk->acct_tmp.fetch++; sp->step = STP_PREPRESP; return (0); @@ -997,15 +999,15 @@ cnt_hit(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->objcore); - AZ(wrk->busyobj); + AZ(req->busyobj); assert(!(req->obj->objcore->flags & OC_F_PASS)); VCL_hit_method(sp); if (req->handling == VCL_RET_DELIVER) { - //AZ(wrk->busyobj->bereq->ws); - //AZ(wrk->busyobj->beresp->ws); + //AZ(req->busyobj->bereq->ws); + //AZ(req->busyobj->beresp->ws); (void)FetchReqBody(sp, 0); sp->step = STP_PREPRESP; return (0); @@ -1064,7 +1066,7 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req) AZ(req->objcore); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); - AZ(wrk->busyobj); + AZ(req->busyobj); if (req->hash_objhead == NULL) { /* Not a waiting list return */ @@ -1113,7 +1115,7 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req) req->vary_e = NULL; req->objcore = oc; - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC); sp->step = STP_MISS; return (0); } @@ -1159,40 +1161,42 @@ DOT static int cnt_miss(struct sess *sp, struct worker *wrk, struct req *req) { + struct busyobj *bo; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); + bo = req->busyobj; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AZ(req->obj); - http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl); + http_Setup(bo->bereq, bo->ws, bo->vsl); http_FilterReq(sp, HTTPH_R_FETCH); - http_ForceGet(wrk->busyobj->bereq); + http_ForceGet(bo->bereq); if (cache_param->http_gzip_support) { /* * We always ask the backend for gzip, even if the * client doesn't grok it. We will uncompress for * the minority of clients which don't. */ - http_Unset(wrk->busyobj->bereq, H_Accept_Encoding); - http_SetHeader(wrk->busyobj->bereq, "Accept-Encoding: gzip"); + http_Unset(bo->bereq, H_Accept_Encoding); + http_SetHeader(bo->bereq, "Accept-Encoding: gzip"); } VCL_miss_method(sp); if (req->handling == VCL_RET_FETCH) { - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); sp->step = STP_FETCH; return (0); } AZ(HSH_Deref(&wrk->stats, req->objcore, NULL)); req->objcore = NULL; - http_Teardown(wrk->busyobj->bereq); - VBO_DerefBusyObj(wrk, &wrk->busyobj); + http_Teardown(bo->bereq); + VBO_DerefBusyObj(wrk, &req->busyobj); switch(req->handling) { case VCL_RET_ERROR: @@ -1230,7 +1234,7 @@ XDOT err_pass [label="ERROR",shape=plaintext] */ static int -cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req) +cnt_pass(struct sess *sp, struct worker *wrk, struct req *req) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -1238,18 +1242,18 @@ cnt_pass(struct sess *sp, struct worker *wrk, const struct req *req) CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->objcore); AZ(req->obj); - AZ(wrk->busyobj); + AZ(req->busyobj); - wrk->busyobj = VBO_GetBusyObj(wrk); - wrk->busyobj->vsl->wid = sp->vsl_id; - http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl); + req->busyobj = VBO_GetBusyObj(wrk); + req->busyobj->vsl->wid = sp->vsl_id; + http_Setup(req->busyobj->bereq, req->busyobj->ws, req->busyobj->vsl); http_FilterReq(sp, HTTPH_R_PASS); VCL_pass_method(sp); if (req->handling == VCL_RET_ERROR) { - http_Teardown(wrk->busyobj->bereq); - VBO_DerefBusyObj(wrk, &wrk->busyobj); + http_Teardown(req->busyobj->bereq); + VBO_DerefBusyObj(wrk, &req->busyobj); sp->step = STP_ERROR; return (0); } @@ -1285,19 +1289,19 @@ DOT err_pipe [label="ERROR",shape=plaintext] */ static int -cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req) +cnt_pipe(struct sess *sp, struct worker *wrk, struct req *req) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); - AZ(wrk->busyobj); + AZ(req->busyobj); wrk->acct_tmp.pipe++; - wrk->busyobj = VBO_GetBusyObj(wrk); - wrk->busyobj->vsl->wid = sp->vsl_id; - http_Setup(wrk->busyobj->bereq, wrk->busyobj->ws, wrk->busyobj->vsl); + req->busyobj = VBO_GetBusyObj(wrk); + req->busyobj->vsl->wid = sp->vsl_id; + http_Setup(req->busyobj->bereq, req->busyobj->ws, req->busyobj->vsl); http_FilterReq(sp, 0); VCL_pipe_method(sp); @@ -1308,8 +1312,8 @@ cnt_pipe(struct sess *sp, struct worker *wrk, const struct req *req) PipeSession(sp); assert(WRW_IsReleased(wrk)); - http_Teardown(wrk->busyobj->bereq); - VBO_DerefBusyObj(wrk, &wrk->busyobj); + http_Teardown(req->busyobj->bereq); + VBO_DerefBusyObj(wrk, &req->busyobj); sp->step = STP_DONE; return (0); } @@ -1354,7 +1358,7 @@ cnt_recv(struct sess *sp, const struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->obj); - AZ(wrk->busyobj); + AZ(req->busyobj); /* By default we use the first backend */ AZ(req->director); diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index ab74b59..3f70cb7 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -120,7 +120,7 @@ VDI_GetFd(const struct director *d, struct sess *sp) CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); vc = d->getfd(d, sp); if (vc != NULL) { - vc->vsl = sp->wrk->busyobj->vsl; + vc->vsl = sp->req->busyobj->vsl; vc->orig_vsl_id = vc->vsl->wid; vc->vsl->wid = vc->vsl_id; } diff --git a/bin/varnishd/cache/cache_dir_dns.c b/bin/varnishd/cache/cache_dir_dns.c index 80310b9..9cad3f6 100644 --- a/bin/varnishd/cache/cache_dir_dns.c +++ b/bin/varnishd/cache/cache_dir_dns.c @@ -347,8 +347,8 @@ vdi_dns_find_backend(const struct sess *sp, struct vdi_dns *vs) /* bereq is only present after recv et. al, otherwise use req (ie: * use req for health checks in vcl_recv and such). */ - if (sp->wrk->busyobj != NULL && sp->wrk->busyobj->bereq) - hp = sp->wrk->busyobj->bereq; + if (sp->req->busyobj != NULL && sp->req->busyobj->bereq) + hp = sp->req->busyobj->bereq; else hp = sp->req->http; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index adc5af3..24abc7a 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -46,7 +46,7 @@ static unsigned fetchfrag; * We want to issue the first error we encounter on fetching and * supress the rest. This function does that. * - * Other code is allowed to look at wrk->busyobj->fetch_failed to bail out + * Other code is allowed to look at sp->req->busyobj->fetch_failed to bail out * * For convenience, always return -1 */ @@ -385,33 +385,37 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) { struct vbc *vc; struct worker *wrk; + struct req *req; + struct busyobj *bo; struct http *hp; int retry = -1; int i; struct http_conn *htc; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); wrk = sp->wrk; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - htc = &wrk->busyobj->htc; + req = sp->req; + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + bo = req->busyobj; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + htc = &bo->htc; - AN(sp->req->director); - AZ(sp->req->obj); + AN(req->director); + AZ(req->obj); - if (sp->req->objcore != NULL) { /* pass has no objcore */ - CHECK_OBJ_NOTNULL(sp->req->objcore, OBJCORE_MAGIC); - AN(sp->req->objcore->flags & OC_F_BUSY); + if (req->objcore != NULL) { /* pass has no objcore */ + CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); + AN(req->objcore->flags & OC_F_BUSY); } - hp = wrk->busyobj->bereq; + hp = bo->bereq; - wrk->busyobj->vbc = VDI_GetFd(NULL, sp); - if (wrk->busyobj->vbc == NULL) { - VSLb(sp->req->vsl, SLT_FetchError, "no backend connection"); + bo->vbc = VDI_GetFd(NULL, sp); + if (bo->vbc == NULL) { + VSLb(req->vsl, SLT_FetchError, "no backend connection"); return (-1); } - vc = wrk->busyobj->vbc; + vc = bo->vbc; if (vc->recycled) retry = 1; @@ -421,7 +425,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) * because the backend may be chosen by a director. */ if (need_host_hdr) - VDI_AddHostHeader(wrk->busyobj->bereq, vc); + VDI_AddHostHeader(bo->bereq, vc); (void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */ WRW_Reserve(wrk, &vc->fd, sp->t_req); /* XXX t_resp ? */ @@ -430,10 +434,10 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) /* Deal with any message-body the request might have */ i = FetchReqBody(sp, sendbody); if (WRW_FlushRelease(wrk) || i > 0) { - VSLb(sp->req->vsl, SLT_FetchError, + VSLb(req->vsl, SLT_FetchError, "backend write error: %d (%s)", errno, strerror(errno)); - VDI_CloseFd(wrk, &wrk->busyobj->vbc); + VDI_CloseFd(wrk, &bo->vbc); /* XXX: other cleanup ? */ return (retry); } @@ -446,7 +450,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) /* Receive response */ - HTC_Init(htc, wrk->busyobj->ws, vc->fd, vc->vsl, + HTC_Init(htc, bo->ws, vc->fd, vc->vsl, cache_param->http_resp_size, cache_param->http_resp_hdr_len); @@ -455,10 +459,10 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) i = HTC_Rx(htc); if (i < 0) { - VSLb(sp->req->vsl, SLT_FetchError, + VSLb(req->vsl, SLT_FetchError, "http first read error: %d %d (%s)", i, errno, strerror(errno)); - VDI_CloseFd(wrk, &wrk->busyobj->vbc); + VDI_CloseFd(wrk, &bo->vbc); /* XXX: other cleanup ? */ /* Retryable if we never received anything */ return (i == -1 ? retry : -1); @@ -469,20 +473,20 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) while (i == 0) { i = HTC_Rx(htc); if (i < 0) { - VSLb(sp->req->vsl, SLT_FetchError, + VSLb(req->vsl, SLT_FetchError, "http first read error: %d %d (%s)", i, errno, strerror(errno)); - VDI_CloseFd(wrk, &wrk->busyobj->vbc); + VDI_CloseFd(wrk, &bo->vbc); /* XXX: other cleanup ? */ return (-1); } } - hp = wrk->busyobj->beresp; + hp = bo->beresp; if (http_DissectResponse(hp, htc)) { - VSLb(sp->req->vsl, SLT_FetchError, "http format error"); - VDI_CloseFd(wrk, &wrk->busyobj->vbc); + VSLb(req->vsl, SLT_FetchError, "http format error"); + VDI_CloseFd(wrk, &bo->vbc); /* XXX: other cleanup ? */ return (-1); } @@ -492,17 +496,15 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) /*--------------------------------------------------------------------*/ int -FetchBody(struct worker *wrk, struct object *obj) +FetchBody(struct worker *wrk, struct busyobj *bo, struct object *obj) { int cls; struct storage *st; int mklen; ssize_t cl; struct http_conn *htc; - struct busyobj *bo; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - bo = wrk->busyobj; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AZ(bo->fetch_obj); CHECK_OBJ_NOTNULL(bo->vbc, VBC_MAGIC); diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 15b0a2a..1e21214 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -443,16 +443,16 @@ HSH_Lookup(struct sess *sp, struct objhead **poh) AN(oc->flags & OC_F_BUSY); oc->refcnt = 1; - AZ(wrk->busyobj); - wrk->busyobj = VBO_GetBusyObj(wrk); - wrk->busyobj->vsl->wid = sp->vsl_id; + AZ(sp->req->busyobj); + sp->req->busyobj = VBO_GetBusyObj(wrk); + sp->req->busyobj->vsl->wid = sp->vsl_id; VRY_Validate(sp->req->vary_b); if (sp->req->vary_l != NULL) - wrk->busyobj->vary = sp->req->vary_b; + sp->req->busyobj->vary = sp->req->vary_b; else - wrk->busyobj->vary = NULL; - oc->busyobj = wrk->busyobj; + sp->req->busyobj->vary = NULL; + oc->busyobj = sp->req->busyobj; /* * Busy objects go on the tail, so they will not trip up searches. diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index f721ea2..02ab94f 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -854,7 +854,7 @@ http_FilterReq(const struct sess *sp, unsigned how) { struct http *hp; - hp = sp->wrk->busyobj->bereq; + hp = sp->req->busyobj->bereq; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); hp->logtag = HTTP_Tx; diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 5a2a805..2689cc8 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -197,10 +197,6 @@ pan_wrk(const struct worker *wrk) VSB_printf(pan_vsp, " worker = %p {\n", wrk); pan_ws(wrk->aws, 4); - if (wrk->busyobj != NULL && wrk->busyobj->bereq->ws != NULL) - pan_http("bereq", wrk->busyobj->bereq, 4); - if (wrk->busyobj != NULL && wrk->busyobj->beresp->ws != NULL) - pan_http("beresp", wrk->busyobj->beresp, 4); VSB_printf(pan_vsp, " },\n"); } @@ -221,6 +217,10 @@ pan_busyobj(const struct busyobj *bo) VSB_printf(pan_vsp, " },\n"); if (VALID_OBJ(bo->vbc, BACKEND_MAGIC)) pan_vbc(bo->vbc); + if (bo->bereq->ws != NULL) + pan_http("bereq", bo->bereq, 4); + if (bo->beresp->ws != NULL) + pan_http("beresp", bo->beresp, 4); } @@ -261,8 +261,8 @@ pan_sess(const struct sess *sp) VSB_printf(pan_vsp, " restarts = %d, esi_level = %d\n", sp->req->restarts, sp->req->esi_level); - if (sp->wrk->busyobj != NULL) - pan_busyobj(sp->wrk->busyobj); + if (sp->req->busyobj != NULL) + pan_busyobj(sp->req->busyobj); pan_ws(sp->req->ws, 2); pan_http("req", sp->req->http, 2); diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c index 688d87d..3f7cadf 100644 --- a/bin/varnishd/cache/cache_pipe.c +++ b/bin/varnishd/cache/cache_pipe.c @@ -63,31 +63,33 @@ void PipeSession(struct sess *sp) { struct vbc *vc; - struct worker *w; + struct worker *wrk; struct pollfd fds[2]; + struct busyobj *bo; int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); - w = sp->wrk; + bo = sp->req->busyobj; + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + wrk = sp->wrk; vc = VDI_GetFd(NULL, sp); if (vc == NULL) return; - sp->wrk->busyobj->vbc = vc; /* For panic dumping */ + bo->vbc = vc; /* For panic dumping */ (void)VTCP_blocking(vc->fd); - WRW_Reserve(w, &vc->fd, sp->t_req); + WRW_Reserve(wrk, &vc->fd, sp->t_req); sp->wrk->acct_tmp.hdrbytes += - http_Write(w, sp->wrk->busyobj->bereq, 0); + http_Write(wrk, bo->bereq, 0); if (sp->req->htc->pipeline.b != NULL) sp->wrk->acct_tmp.bodybytes += - WRW_Write(w, sp->req->htc->pipeline.b, + WRW_Write(wrk, sp->req->htc->pipeline.b, Tlen(sp->req->htc->pipeline)); - i = WRW_FlushRelease(w); + i = WRW_FlushRelease(wrk); if (i) { SES_Close(sp, "pipe"); @@ -132,5 +134,5 @@ PipeSession(struct sess *sp) } SES_Close(sp, "pipe"); VDI_CloseFd(sp->wrk, &vc); - sp->wrk->busyobj->vbc = NULL; + bo->vbc = NULL; } diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 10a8182..f41b7ec 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -112,22 +112,6 @@ ses_new(struct sesspool *pp) } /*-------------------------------------------------------------------- - * Allocate a session for use by background threads. - */ - -struct sess * -SES_Alloc(void) -{ - struct sess *sp; - - ALLOC_OBJ(sp, SESS_MAGIC); - AN(sp); - ses_setup(sp); - /* XXX: sp->req ? */ - return (sp); -} - -/*-------------------------------------------------------------------- * The pool-task function for sessions */ @@ -148,7 +132,6 @@ ses_pool_task(struct worker *wrk, void *arg) sp = NULL; /* Cannot access sp any longer */ THR_SetSession(NULL); WS_Assert(wrk->aws); - AZ(wrk->busyobj); AZ(wrk->wrw); assert(wrk->vsl->wlp == wrk->vsl->wlb); if (cache_param->diag_bitmap & 0x00040000) { diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index c9135dc..cbe5637 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -101,10 +101,10 @@ vrt_selecthttp(const struct sess *sp, enum gethdr_e where) hp = sp->req->http; break; case HDR_BEREQ: - hp = sp->wrk->busyobj->bereq; + hp = sp->req->busyobj->bereq; break; case HDR_BERESP: - hp = sp->wrk->busyobj->beresp; + hp = sp->req->busyobj->beresp; break; case HDR_RESP: hp = sp->req->resp; diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 82aeb9c..72fa4dc 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -84,15 +84,15 @@ VRT_r_##obj##_##hdr(const struct sess *sp) \ VRT_DO_HDR(req, request, sp->req->http, HTTP_HDR_REQ) VRT_DO_HDR(req, url, sp->req->http, HTTP_HDR_URL) VRT_DO_HDR(req, proto, sp->req->http, HTTP_HDR_PROTO) -VRT_DO_HDR(bereq, request, sp->wrk->busyobj->bereq, HTTP_HDR_REQ) -VRT_DO_HDR(bereq, url, sp->wrk->busyobj->bereq, HTTP_HDR_URL) -VRT_DO_HDR(bereq, proto, sp->wrk->busyobj->bereq, HTTP_HDR_PROTO) +VRT_DO_HDR(bereq, request, sp->req->busyobj->bereq, HTTP_HDR_REQ) +VRT_DO_HDR(bereq, url, sp->req->busyobj->bereq, HTTP_HDR_URL) +VRT_DO_HDR(bereq, proto, sp->req->busyobj->bereq, HTTP_HDR_PROTO) VRT_DO_HDR(obj, proto, sp->req->obj->http, HTTP_HDR_PROTO) VRT_DO_HDR(obj, response, sp->req->obj->http, HTTP_HDR_RESPONSE) VRT_DO_HDR(resp, proto, sp->req->resp, HTTP_HDR_PROTO) VRT_DO_HDR(resp, response, sp->req->resp, HTTP_HDR_RESPONSE) -VRT_DO_HDR(beresp, proto, sp->wrk->busyobj->beresp, HTTP_HDR_PROTO) -VRT_DO_HDR(beresp, response, sp->wrk->busyobj->beresp, HTTP_HDR_RESPONSE) +VRT_DO_HDR(beresp, proto, sp->req->busyobj->beresp, HTTP_HDR_PROTO) +VRT_DO_HDR(beresp, response, sp->req->busyobj->beresp, HTTP_HDR_RESPONSE) /*--------------------------------------------------------------------*/ @@ -114,7 +114,7 @@ VRT_r_##obj##_status(const struct sess *sp) \ } VRT_DO_STATUS(obj, sp->req->obj->http) -VRT_DO_STATUS(beresp, sp->wrk->busyobj->beresp) +VRT_DO_STATUS(beresp, sp->req->busyobj->beresp) VRT_DO_STATUS(resp, sp->req->resp) /*--------------------------------------------------------------------*/ @@ -130,14 +130,11 @@ VRT_l_beresp_saintmode(const struct sess *sp, double a) struct trouble *new; struct trouble *tr; struct trouble *tr2; - struct worker *wrk; struct vbc *vbc; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); - wrk = sp->wrk; - CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC); - vbc = wrk->busyobj->vbc; + CHECK_OBJ_NOTNULL(sp->req->busyobj, BUSYOBJ_MAGIC); + vbc = sp->req->busyobj->vbc; if (!vbc) return; CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC); @@ -187,14 +184,14 @@ void \ VRT_l_##dir##_##onm(const struct sess *sp, type a) \ { \ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ - sp->wrk->field = a; \ + sp->req->field = a; \ } \ \ type \ VRT_r_##dir##_##onm(const struct sess *sp) \ { \ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ - return (sp->wrk->field); \ + return (sp->req->field); \ } VBERESP(beresp, unsigned, do_esi, busyobj->do_esi) @@ -235,8 +232,8 @@ VRT_l_bereq_##which(struct sess *sp, double num) \ { \ \ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ - CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); \ - sp->wrk->busyobj->which = (num > 0.0 ? num : 0.0); \ + CHECK_OBJ_NOTNULL(sp->req->busyobj, BUSYOBJ_MAGIC); \ + sp->req->busyobj->which = (num > 0.0 ? num : 0.0); \ } \ \ double __match_proto__() \ @@ -244,8 +241,8 @@ VRT_r_bereq_##which(struct sess *sp) \ { \ \ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ - CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); \ - return(sp->wrk->busyobj->which); \ + CHECK_OBJ_NOTNULL(sp->req->busyobj, BUSYOBJ_MAGIC); \ + return(sp->req->busyobj->which); \ } BEREQ_TIMEOUT(connect_timeout) @@ -259,8 +256,8 @@ VRT_r_beresp_backend_name(const struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->wrk->busyobj->vbc, VBC_MAGIC); - return(sp->wrk->busyobj->vbc->backend->vcl_name); + CHECK_OBJ_NOTNULL(sp->req->busyobj->vbc, VBC_MAGIC); + return(sp->req->busyobj->vbc->backend->vcl_name); } struct sockaddr_storage * @@ -268,8 +265,8 @@ VRT_r_beresp_backend_ip(const struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->wrk->busyobj->vbc, VBC_MAGIC); - return(sp->wrk->busyobj->vbc->addr); + CHECK_OBJ_NOTNULL(sp->req->busyobj->vbc, VBC_MAGIC); + return(sp->req->busyobj->vbc->addr); } int @@ -277,8 +274,8 @@ VRT_r_beresp_backend_port(const struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->wrk->busyobj->vbc, VBC_MAGIC); - return (VTCP_port(sp->wrk->busyobj->vbc->addr)); + CHECK_OBJ_NOTNULL(sp->req->busyobj->vbc, VBC_MAGIC); + return (VTCP_port(sp->req->busyobj->vbc->addr)); } const char * __match_proto__() @@ -298,7 +295,7 @@ VRT_l_beresp_storage(struct sess *sp, const char *str, ...) char *b; va_start(ap, str); - b = VRT_String(sp->wrk->busyobj->ws, NULL, str, ap); + b = VRT_String(sp->req->busyobj->ws, NULL, str, ap); va_end(ap); sp->req->storage_hint = b; } @@ -417,12 +414,12 @@ VRT_DO_EXP(obj, sp->req->obj->exp, keep, 0, EXP_Rearm(sp->req->obj); vrt_wsp_exp(sp, sp->req->obj->xid, &sp->req->obj->exp);) -VRT_DO_EXP(beresp, sp->wrk->busyobj->exp, grace, 0, - vrt_wsp_exp(sp, sp->req->xid, &sp->wrk->busyobj->exp);) -VRT_DO_EXP(beresp, sp->wrk->busyobj->exp, ttl, 0, - vrt_wsp_exp(sp, sp->req->xid, &sp->wrk->busyobj->exp);) -VRT_DO_EXP(beresp, sp->wrk->busyobj->exp, keep, 0, - vrt_wsp_exp(sp, sp->req->xid, &sp->wrk->busyobj->exp);) +VRT_DO_EXP(beresp, sp->req->busyobj->exp, grace, 0, + vrt_wsp_exp(sp, sp->req->xid, &sp->req->busyobj->exp);) +VRT_DO_EXP(beresp, sp->req->busyobj->exp, ttl, 0, + vrt_wsp_exp(sp, sp->req->xid, &sp->req->busyobj->exp);) +VRT_DO_EXP(beresp, sp->req->busyobj->exp, keep, 0, + vrt_wsp_exp(sp, sp->req->xid, &sp->req->busyobj->exp);) /*-------------------------------------------------------------------- * req.xid From phk at varnish-cache.org Sun Feb 19 12:53:25 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2012 13:53:25 +0100 Subject: [master] e65be4b Belive it or not, I'm still not used to the guts of varnishd being exposed. Message-ID: commit e65be4b12a6bbc2bd3a15b240437bf3b1dd7d96c Author: Poul-Henning Kamp Date: Sun Feb 19 12:52:59 2012 +0000 Belive it or not, I'm still not used to the guts of varnishd being exposed. diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 5774cfb..4b9fd5f 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -192,7 +192,7 @@ vmod_collect(struct sess *sp, enum gethdr_e e, const char *h) (void)h; if (e == HDR_REQ) http_CollectHdr(sp->req->http, h); - else if (e == HDR_BERESP && sp->wrk->busyobj != NULL) - http_CollectHdr(sp->wrk->busyobj->beresp, h); + else if (e == HDR_BERESP && sp->req->busyobj != NULL) + http_CollectHdr(sp->req->busyobj->beresp, h); } From phk at varnish-cache.org Mon Feb 20 08:12:17 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 20 Feb 2012 09:12:17 +0100 Subject: [master] 2608703 Give WRW a hint about which vsl to log to. Message-ID: commit 2608703ba1891b61de94074489b03bfa4a91165a Author: Poul-Henning Kamp Date: Mon Feb 20 08:11:52 2012 +0000 Give WRW a hint about which vsl to log to. Consequent Constification diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 4b5fcd8..bba390e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -773,7 +773,7 @@ void VGZ_UpdateObj(const struct vgz*, struct object *); int VGZ_WrwInit(struct vgz *vg); int VGZ_WrwGunzip(struct worker *w, struct vgz *, const void *ibuf, ssize_t ibufl); -void VGZ_WrwFlush(struct worker *wrk, struct vgz *vg); +void VGZ_WrwFlush(const struct worker *wrk, struct vgz *vg); /* Return values */ #define VGZ_ERROR -1 @@ -789,7 +789,7 @@ const char *http_StatusMessage(unsigned); unsigned http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd); void HTTP_Init(void); void http_ClrHeader(struct http *to); -unsigned http_Write(struct worker *w, const struct http *hp, int resp); +unsigned http_Write(const struct worker *w, const struct http *hp, int resp); void http_SetResp(struct http *to, const char *proto, uint16_t status, const char *response); void http_FilterReq(const struct sess *sp, unsigned how); @@ -885,13 +885,13 @@ int Pool_Task(struct pool *pp, struct pool_task *task, enum pool_how how); #define WRW_IsReleased(w) ((w)->wrw == NULL) int WRW_Error(const struct worker *w); -void WRW_Chunked(struct worker *w); -void WRW_EndChunk(struct worker *w); -void WRW_Reserve(struct worker *w, int *fd, double t0); -unsigned WRW_Flush(struct worker *w); +void WRW_Chunked(const struct worker *w); +void WRW_EndChunk(const struct worker *w); +void WRW_Reserve(struct worker *w, int *fd, struct vsl_log *, double t0); +unsigned WRW_Flush(const struct worker *w); unsigned WRW_FlushRelease(struct worker *w); -unsigned WRW_Write(struct worker *w, const void *ptr, int len); -unsigned WRW_WriteH(struct worker *w, const txt *hh, const char *suf); +unsigned WRW_Write(const struct worker *w, const void *ptr, int len); +unsigned WRW_WriteH(const struct worker *w, const txt *hh, const char *suf); /* cache_session.c [SES] */ void SES_Close(struct sess *sp, const char *reason); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 00279c2..2d697cb 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -113,7 +113,7 @@ ved_include(struct sess *sp, const char *src, const char *host) WS_Reset(sp->req->ws, sp_ws_wm); WS_Reset(w->aws, wrk_ws_wm); /* XXX ? */ - WRW_Reserve(sp->wrk, &sp->fd, sp->req->t_resp); + WRW_Reserve(sp->wrk, &sp->fd, sp->req->vsl, sp->req->t_resp); if (sp->req->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 24abc7a..05ac8a3 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -428,7 +428,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) VDI_AddHostHeader(bo->bereq, vc); (void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */ - WRW_Reserve(wrk, &vc->fd, sp->t_req); /* XXX t_resp ? */ + WRW_Reserve(wrk, &vc->fd, bo->vsl, sp->t_req); /* XXX t_resp ? */ (void)http_Write(wrk, hp, 0); /* XXX: stats ? */ /* Deal with any message-body the request might have */ diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index d4511bc..ec1b7cd 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -356,7 +356,7 @@ VGZ_WrwGunzip(struct worker *wrk, struct vgz *vg, const void *ibuf, /*--------------------------------------------------------------------*/ void -VGZ_WrwFlush(struct worker *wrk, struct vgz *vg) +VGZ_WrwFlush(const struct worker *wrk, struct vgz *vg) { CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 02ab94f..4d2a9fa 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -1061,7 +1061,7 @@ HTTP_Copy(struct http *to, const struct http * const fm) /*--------------------------------------------------------------------*/ unsigned -http_Write(struct worker *w, const struct http *hp, int resp) +http_Write(const struct worker *w, const struct http *hp, int resp) { unsigned u, l; diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c index 3f7cadf..8815c68 100644 --- a/bin/varnishd/cache/cache_pipe.c +++ b/bin/varnishd/cache/cache_pipe.c @@ -80,7 +80,7 @@ PipeSession(struct sess *sp) bo->vbc = vc; /* For panic dumping */ (void)VTCP_blocking(vc->fd); - WRW_Reserve(wrk, &vc->fd, sp->t_req); + WRW_Reserve(wrk, &vc->fd, bo->vsl, sp->t_req); sp->wrk->acct_tmp.hdrbytes += http_Write(wrk, bo->bereq, 0); diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index f1e0553..5a33d08 100644 --- a/bin/varnishd/cache/cache_response.c +++ b/bin/varnishd/cache/cache_response.c @@ -237,7 +237,7 @@ RES_WriteObj(struct sess *sp) req = sp->req; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - WRW_Reserve(sp->wrk, &sp->fd, sp->req->t_resp); + WRW_Reserve(sp->wrk, &sp->fd, sp->req->vsl, sp->req->t_resp); if (req->obj->response == 200 && req->http->conds && diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c index a8140f5..3a38305 100644 --- a/bin/varnishd/cache/cache_wrw.c +++ b/bin/varnishd/cache/cache_wrw.c @@ -57,6 +57,7 @@ struct wrw { ssize_t cliov; unsigned ciov; /* Chunked header marker */ double t0; + struct vsl_log *vsl; }; /*-------------------------------------------------------------------- @@ -70,7 +71,7 @@ WRW_Error(const struct worker *wrk) } void -WRW_Reserve(struct worker *wrk, int *fd, double t0) +WRW_Reserve(struct worker *wrk, int *fd, struct vsl_log *vsl, double t0) { struct wrw *wrw; unsigned u; @@ -95,6 +96,7 @@ WRW_Reserve(struct worker *wrk, int *fd, double t0) wrw->niov = 0; wrw->wfd = fd; wrw->t0 = t0; + wrw->vsl = vsl; wrk->wrw = wrw; } @@ -136,7 +138,7 @@ wrw_prune(struct wrw *wrw, ssize_t bytes) } unsigned -WRW_Flush(struct worker *wrk) +WRW_Flush(const struct worker *wrk) { ssize_t i; struct wrw *wrw; @@ -179,7 +181,7 @@ WRW_Flush(struct worker *wrk) */ if (VTIM_real() - wrw->t0 > cache_param->send_timeout) { - WSL(wrk->vsl, SLT_Debug, *wrw->wfd, + VSLb(wrw->vsl, SLT_Debug, "Hit total send timeout, " "wrote = %zd/%zd; not retrying", i, wrw->liov); @@ -187,7 +189,7 @@ WRW_Flush(struct worker *wrk) break; } - WSL(wrk->vsl, SLT_Debug, *wrw->wfd, + VSLb(wrw->vsl, SLT_Debug, "Hit send timeout, wrote = %zd/%zd; retrying", i, wrw->liov); @@ -196,7 +198,7 @@ WRW_Flush(struct worker *wrk) } if (i <= 0) { wrw->werr++; - WSL(wrk->vsl, SLT_Debug, *wrw->wfd, + VSLb(wrw->vsl, SLT_Debug, "Write error, retval = %zd, len = %zd, errno = %s", i, wrw->liov, strerror(errno)); } @@ -222,7 +224,7 @@ WRW_FlushRelease(struct worker *wrk) } unsigned -WRW_WriteH(struct worker *wrk, const txt *hh, const char *suf) +WRW_WriteH(const struct worker *wrk, const txt *hh, const char *suf) { unsigned u; @@ -239,7 +241,7 @@ WRW_WriteH(struct worker *wrk, const txt *hh, const char *suf) } unsigned -WRW_Write(struct worker *wrk, const void *ptr, int len) +WRW_Write(const struct worker *wrk, const void *ptr, int len) { struct wrw *wrw; @@ -265,7 +267,7 @@ WRW_Write(struct worker *wrk, const void *ptr, int len) } void -WRW_Chunked(struct worker *wrk) +WRW_Chunked(const struct worker *wrk) { struct wrw *wrw; @@ -294,7 +296,7 @@ WRW_Chunked(struct worker *wrk) */ void -WRW_EndChunk(struct worker *wrk) +WRW_EndChunk(const struct worker *wrk) { struct wrw *wrw; From phk at varnish-cache.org Mon Feb 20 08:25:43 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 20 Feb 2012 09:25:43 +0100 Subject: [master] 4ba2faf Eliminate WSL() usage. Message-ID: commit 4ba2fafe6fcca34b05732e464b776b1a5ccb6ea6 Author: Poul-Henning Kamp Date: Mon Feb 20 08:25:27 2012 +0000 Eliminate WSL() usage. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index cfe86ec..961cb8d 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -183,8 +183,8 @@ bes_conn_try(const struct sess *sp, struct vbc *vc, const struct vdi_simple *vs) } else { vc->vsl_id = s | VSL_BACKENDMARKER; VTCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1); - WSL(sp->req->vsl, SLT_BackendOpen, vc->vsl_id, "%s %s %s ", - vs->backend->display_name, abuf1, pbuf1); + VSLb(sp->req->vsl, SLT_BackendOpen, "%d %s %s %s ", + vc->fd, vs->backend->display_name, abuf1, pbuf1); } } @@ -354,12 +354,12 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs) return (vc); } VSC_C_main->backend_toolate++; - WSL(sp->wrk->vsl, SLT_BackendClose, vc->vsl_id, "%s", - bp->display_name); + VSLb(sp->req->vsl, SLT_BackendClose, "%d %s toolate", + vc->fd, bp->display_name); /* Checkpoint log to flush all info related to this connection before the OS reuses the FD */ - VSL_Flush(sp->wrk->vsl, 0); + VSL_Flush(sp->req->vsl, 0); VTCP_close(&vc->fd); VBE_DropRefConn(bp); diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index 3f70cb7..5275680 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -55,7 +55,7 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp) bp = vc->backend; - WSL(vc->vsl, SLT_BackendClose, vc->vsl_id, "%s", bp->display_name); + VSLb(vc->vsl, SLT_BackendClose, "%s", bp->display_name); /* Checkpoint log to flush all info related to this connection before the OS reuses the FD */ @@ -89,7 +89,7 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp) bp = vc->backend; - WSL(vc->vsl, SLT_BackendReuse, vc->vsl_id, "%s", bp->display_name); + VSLb(vc->vsl, SLT_BackendReuse, "%s", bp->display_name); /* * Flush the shmlog, so that another session reusing this backend From phk at varnish-cache.org Mon Feb 20 08:30:49 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 20 Feb 2012 09:30:49 +0100 Subject: [master] 42f4e95 Give the expiry thread its own VSL, and get rid of WSL() entirely. Message-ID: commit 42f4e9572cf14ca2b1e385e4b4e487475fb1e15d Author: Poul-Henning Kamp Date: Mon Feb 20 08:30:33 2012 +0000 Give the expiry thread its own VSL, and get rid of WSL() entirely. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index bba390e..028abe9 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -915,8 +915,6 @@ void VSM_Free(void *ptr); #ifdef VSL_ENDMARKER void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) __printflike(3, 4); -void WSL(struct vsl_log *, enum VSL_tag_e tag, int id, const char *fmt, ...) - __printflike(4, 5); void VSLb(struct vsl_log *, enum VSL_tag_e tag, const char *fmt, ...) __printflike(3, 4); void VSLbt(struct vsl_log *, enum VSL_tag_e tag, txt t); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 8eedb71..98b664f 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -336,13 +336,15 @@ exp_timer(struct worker *wrk, void *priv) struct lru *lru; double t; struct object *o; + struct vsl_log vsl; (void)priv; + VSL_Setup(&vsl, NULL, 0); t = VTIM_real(); oc = NULL; while (1) { if (oc == NULL) { - VSL_Flush(wrk->vsl, 0); + VSL_Flush(&vsl, 0); WRK_SumStat(wrk); VTIM_sleep(cache_param->expiry_sleep); t = VTIM_real(); @@ -400,7 +402,7 @@ exp_timer(struct worker *wrk, void *priv) CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC); o = oc_getobj(&wrk->stats, oc); - WSL(wrk->vsl, SLT_ExpKill, 0, "%u %.0f", + VSLb(&vsl, SLT_ExpKill, "%u %.0f", oc_getxid(&wrk->stats, oc), EXP_Ttl(NULL, o) - t); (void)HSH_Deref(&wrk->stats, oc, NULL); } diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 6a54101..bcdfa6d 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -274,22 +274,6 @@ wsl(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, va_list ap VSL_Flush(vsl, 0); } -/*--------------------------------------------------------------------*/ - -void -WSL(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, ...) -{ - va_list ap; - - if (id == -1) - id = vsl->wid; - AN(fmt); - va_start(ap, fmt); - wsl(vsl, tag, id, fmt, ap); - va_end(ap); -} - - /*-------------------------------------------------------------------- * VSL-buffered */ @@ -320,6 +304,12 @@ VSLbt(struct vsl_log *vsl, enum VSL_tag_e tag, txt t) void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len) { + + if (ptr == NULL) { + len = cache_param->vsl_buffer; + ptr = malloc(len); + AN(ptr); + } vsl->wlp = ptr; vsl->wlb = ptr; vsl->wle = ptr; From phk at varnish-cache.org Mon Feb 20 09:13:58 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 20 Feb 2012 10:13:58 +0100 Subject: [master] 8140011 Renovate the ban lurkers usage of VSL to cause less synchronous VSL activity. Message-ID: commit 8140011132afcd0dfbe47ec7cd1e8ba07785c3b9 Author: Poul-Henning Kamp Date: Mon Feb 20 09:13:40 2012 +0000 Renovate the ban lurkers usage of VSL to cause less synchronous VSL activity. diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 0058c3c..cba6fd1 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -677,7 +677,7 @@ ban_evaluate(const uint8_t *bs, const struct http *objhttp, */ static int -ban_check_object(struct object *o, struct worker *wrk, +ban_check_object(struct object *o, struct vsl_log *vsl, const struct http *req_http) { struct ban *b; @@ -686,7 +686,6 @@ ban_check_object(struct object *o, struct worker *wrk, unsigned tests, skipped; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_ORNULL(req_http, HTTP_MAGIC); oc = o->objcore; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); @@ -758,7 +757,7 @@ ban_check_object(struct object *o, struct worker *wrk, oc_updatemeta(oc); /* BAN also changed, but that is not important any more */ /* XXX: no req in lurker */ - VSLb(wrk->vsl, SLT_ExpBan, "%u was banned", o->xid); + VSLb(vsl, SLT_ExpBan, "%u was banned", o->xid); EXP_Rearm(o); return (1); } @@ -768,7 +767,7 @@ int BAN_CheckObject(struct object *o, const struct sess *sp) { - return (ban_check_object(o, sp->wrk, sp->req->http) > 0); + return (ban_check_object(o, sp->req->vsl, sp->req->http) > 0); } static struct ban * @@ -803,11 +802,14 @@ ban_lurker_work(struct worker *wrk, unsigned pass) struct objhead *oh; struct objcore *oc, *oc2; struct object *o; + struct vsl_log vsl; int i; AN(pass & BAN_F_LURK); AZ(pass & ~BAN_F_LURK); + VSL_Setup(&vsl, NULL, 0); + /* First route the last ban(s) */ do { Lck_Lock(&ban_mtx); @@ -837,13 +839,13 @@ ban_lurker_work(struct worker *wrk, unsigned pass) b->flags |= pass; } if (cache_param->diag_bitmap & 0x80000) - VSL(SLT_Debug, 0, "lurker: %d actionable bans", i); + VSLb(&vsl, SLT_Debug, "lurker: %d actionable bans", i); if (i == 0) return (0); VTAILQ_FOREACH_REVERSE(b, &ban_head, banhead_s, list) { if (cache_param->diag_bitmap & 0x80000) - VSL(SLT_Debug, 0, "lurker doing %f %d", + VSLb(&vsl, SLT_Debug, "lurker doing %f %d", ban_time(b->spec), b->refcount); while (1) { Lck_Lock(&ban_mtx); @@ -852,7 +854,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass) break; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); if (cache_param->diag_bitmap & 0x80000) - VSL(SLT_Debug, 0, "test: %p %u %u", + VSLb(&vsl, SLT_Debug, "test: %p %u %u", oc, oc->flags & OC_F_LURK, pass); if ((oc->flags & OC_F_LURK) == pass) break; @@ -860,6 +862,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass) CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); if (Lck_Trylock(&oh->mtx)) { Lck_Unlock(&ban_mtx); + VSL_Flush(&vsl, 0); VTIM_sleep(cache_param->ban_lurker_sleep); continue; } @@ -889,9 +892,9 @@ ban_lurker_work(struct worker *wrk, unsigned pass) * Get the object and check it against all relevant bans */ o = oc_getobj(&wrk->stats, oc); - i = ban_check_object(o, wrk, NULL); + i = ban_check_object(o, &vsl, NULL); if (cache_param->diag_bitmap & 0x80000) - VSL(SLT_Debug, 0, "lurker got: %p %d", + VSLb(&vsl, SLT_Debug, "lurker got: %p %d", oc, i); if (i == -1) { /* Not banned, not moved */ @@ -903,7 +906,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass) } Lck_Unlock(&oh->mtx); if (cache_param->diag_bitmap & 0x80000) - VSL(SLT_Debug, 0, "lurker done: %p %u %u", + VSLb(&vsl, SLT_Debug, "lurker done: %p %u %u", oc, oc->flags & OC_F_LURK, pass); (void)HSH_Deref(&wrk->stats, NULL, &o); VTIM_sleep(cache_param->ban_lurker_sleep); @@ -915,7 +918,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass) VSC_C_main->bans_gone++; } if (cache_param->diag_bitmap & 0x80000) - VSL(SLT_Debug, 0, "lurker BAN %f now gone", + VSLb(&vsl, SLT_Debug, "lurker BAN %f now gone", ban_time(b->spec)); } Lck_Unlock(&ban_mtx); From phk at varnish-cache.org Mon Feb 20 09:19:59 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 20 Feb 2012 10:19:59 +0100 Subject: [master] 41a719c Urg, forgot the outher loop of the ban-lurker: Message-ID: commit 41a719c98079f44afbf1229be7fb02062dcef5f9 Author: Poul-Henning Kamp Date: Mon Feb 20 09:19:03 2012 +0000 Urg, forgot the outher loop of the ban-lurker: Fix previous change to not madly leak memory. diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index cba6fd1..6e6eafb 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -796,20 +796,17 @@ ban_CheckLast(void) */ static int -ban_lurker_work(struct worker *wrk, unsigned pass) +ban_lurker_work(struct worker *wrk, struct vsl_log *vsl, unsigned pass) { struct ban *b, *b0, *b2; struct objhead *oh; struct objcore *oc, *oc2; struct object *o; - struct vsl_log vsl; int i; AN(pass & BAN_F_LURK); AZ(pass & ~BAN_F_LURK); - VSL_Setup(&vsl, NULL, 0); - /* First route the last ban(s) */ do { Lck_Lock(&ban_mtx); @@ -839,13 +836,13 @@ ban_lurker_work(struct worker *wrk, unsigned pass) b->flags |= pass; } if (cache_param->diag_bitmap & 0x80000) - VSLb(&vsl, SLT_Debug, "lurker: %d actionable bans", i); + VSLb(vsl, SLT_Debug, "lurker: %d actionable bans", i); if (i == 0) return (0); VTAILQ_FOREACH_REVERSE(b, &ban_head, banhead_s, list) { if (cache_param->diag_bitmap & 0x80000) - VSLb(&vsl, SLT_Debug, "lurker doing %f %d", + VSLb(vsl, SLT_Debug, "lurker doing %f %d", ban_time(b->spec), b->refcount); while (1) { Lck_Lock(&ban_mtx); @@ -854,7 +851,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass) break; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); if (cache_param->diag_bitmap & 0x80000) - VSLb(&vsl, SLT_Debug, "test: %p %u %u", + VSLb(vsl, SLT_Debug, "test: %p %u %u", oc, oc->flags & OC_F_LURK, pass); if ((oc->flags & OC_F_LURK) == pass) break; @@ -862,7 +859,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass) CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); if (Lck_Trylock(&oh->mtx)) { Lck_Unlock(&ban_mtx); - VSL_Flush(&vsl, 0); + VSL_Flush(vsl, 0); VTIM_sleep(cache_param->ban_lurker_sleep); continue; } @@ -892,9 +889,9 @@ ban_lurker_work(struct worker *wrk, unsigned pass) * Get the object and check it against all relevant bans */ o = oc_getobj(&wrk->stats, oc); - i = ban_check_object(o, &vsl, NULL); + i = ban_check_object(o, vsl, NULL); if (cache_param->diag_bitmap & 0x80000) - VSLb(&vsl, SLT_Debug, "lurker got: %p %d", + VSLb(vsl, SLT_Debug, "lurker got: %p %d", oc, i); if (i == -1) { /* Not banned, not moved */ @@ -906,7 +903,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass) } Lck_Unlock(&oh->mtx); if (cache_param->diag_bitmap & 0x80000) - VSLb(&vsl, SLT_Debug, "lurker done: %p %u %u", + VSLb(vsl, SLT_Debug, "lurker done: %p %u %u", oc, oc->flags & OC_F_LURK, pass); (void)HSH_Deref(&wrk->stats, NULL, &o); VTIM_sleep(cache_param->ban_lurker_sleep); @@ -918,7 +915,7 @@ ban_lurker_work(struct worker *wrk, unsigned pass) VSC_C_main->bans_gone++; } if (cache_param->diag_bitmap & 0x80000) - VSLb(&vsl, SLT_Debug, "lurker BAN %f now gone", + VSLb(vsl, SLT_Debug, "lurker BAN %f now gone", ban_time(b->spec)); } Lck_Unlock(&ban_mtx); @@ -934,8 +931,11 @@ ban_lurker(struct worker *wrk, void *priv) { struct ban *bf; unsigned pass = (1 << LURK_SHIFT); + struct vsl_log vsl; int i = 0; + VSL_Setup(&vsl, NULL, 0); + (void)priv; while (1) { @@ -953,8 +953,8 @@ ban_lurker(struct worker *wrk, void *priv) VTIM_sleep(1.0); } - i = ban_lurker_work(wrk, pass); - VSL_Flush(wrk->vsl, 0); + i = ban_lurker_work(wrk, &vsl, pass); + VSL_Flush(&vsl, 0); WRK_SumStat(wrk); if (i) { pass += (1 << LURK_SHIFT); From phk at varnish-cache.org Mon Feb 20 09:19:59 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 20 Feb 2012 10:19:59 +0100 Subject: [master] efb159e Put delivery G(un)zip VSL on req->vsl Message-ID: commit efb159e0829aab387ca2cfd2528a4ec30a08bf02 Author: Poul-Henning Kamp Date: Mon Feb 20 09:19:45 2012 +0000 Put delivery G(un)zip VSL on req->vsl diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 2d697cb..669a594 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->vsl, "U D E"); + vgz = VGZ_NewUngzip(sp->req->vsl, "U D E"); AZ(VGZ_WrwInit(vgz)); /* Feed a gzip header to gunzip to make it happy */ diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c index 5a33d08..4760c12 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->vsl, "U D -"); + vg = VGZ_NewUngzip(sp->req->vsl, "U D -"); AZ(VGZ_WrwInit(vg)); VTAILQ_FOREACH(st, &sp->req->obj->store, list) { From phk at varnish-cache.org Mon Feb 20 09:35:20 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 20 Feb 2012 10:35:20 +0100 Subject: [master] 89558df Allocate the req early and VSL the SessionOpen there. Message-ID: commit 89558df47dd227bbf3ae145bb00274df5465da29 Author: Poul-Henning Kamp Date: Mon Feb 20 09:35:03 2012 +0000 Allocate the req early and VSL the SessionOpen there. diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index a56e016..9aaa117 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -947,6 +947,13 @@ cnt_first(struct sess *sp, struct worker *wrk) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + /* Allocate a request already now, so we can VSL to it */ + SES_GetReq(sp); + CHECK_OBJ_NOTNULL(sp->req, REQ_MAGIC); + HTC_Init(sp->req->htc, sp->req->ws, sp->fd, sp->req->vsl, + cache_param->http_req_size, + cache_param->http_req_hdr_len); + VTCP_name(&sp->sockaddr, sp->sockaddrlen, sp->addr, sizeof sp->addr, sp->port, sizeof sp->port); if (cache_param->log_local_addr) { @@ -955,11 +962,11 @@ cnt_first(struct sess *sp, struct worker *wrk) VTCP_name(&sp->mysockaddr, sp->mysockaddrlen, laddr, sizeof laddr, lport, sizeof lport); /* XXX: have no req yet */ - VSLb(sp->wrk->vsl, SLT_SessionOpen, "%s %s %s %s", + VSLb(sp->req->vsl, SLT_SessionOpen, "%s %s %s %s", sp->addr, sp->port, laddr, lport); } else { /* XXX: have no req yet */ - VSLb(sp->wrk->vsl, SLT_SessionOpen, "%s %s %s", + VSLb(sp->req->vsl, SLT_SessionOpen, "%s %s %s", sp->addr, sp->port, sp->mylsock->name); } From phk at varnish-cache.org Mon Feb 20 09:43:53 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 20 Feb 2012 10:43:53 +0100 Subject: [master] c53ab05 Get rid of the workthread VSL buffer. Message-ID: commit c53ab05e9bc6f892d1823a3378bb47f054018906 Author: Poul-Henning Kamp Date: Mon Feb 20 09:43:41 2012 +0000 Get rid of the workthread VSL buffer. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 028abe9..45f36f2 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -312,8 +312,6 @@ struct worker { struct VCL_conf *vcl; - struct vsl_log vsl[1]; - struct ws aws[1]; diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 9aaa117..57a7e05 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -402,7 +402,7 @@ cnt_done(struct sess *sp, struct worker *wrk, struct req *req) req->xid, sp->t_req, sp->t_idle, dh, dp, da); } req->xid = 0; - VSL_Flush(wrk->vsl, 0); + VSL_Flush(sp->req->vsl, 0); sp->t_req = NAN; req->t_resp = NAN; @@ -1623,7 +1623,6 @@ CNT_Session(struct sess *sp) WS_Assert(wrk->aws); CHECK_OBJ_ORNULL(wrk->nobjhead, OBJHEAD_MAGIC); } - VSL_Flush(wrk->vsl, 0); #define ACCT(foo) AZ(wrk->acct_tmp.foo); #include "tbl/acct_fields.h" #undef ACCT diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index 5275680..6554b18 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -57,9 +57,10 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp) VSLb(vc->vsl, SLT_BackendClose, "%s", bp->display_name); - /* Checkpoint log to flush all info related to this connection - before the OS reuses the FD */ - VSL_Flush(wrk->vsl, 0); + /* + * Checkpoint log to flush all info related to this connection + * before the OS reuses the FD + */ VSL_Flush(vc->vsl, 0); vc->vsl->wid = vc->orig_vsl_id; vc->vsl = NULL; @@ -91,11 +92,7 @@ VDI_RecycleFd(struct worker *wrk, struct vbc **vbp) VSLb(vc->vsl, SLT_BackendReuse, "%s", bp->display_name); - /* - * Flush the shmlog, so that another session reusing this backend - * will log chronologically later than our use of it. - */ - VSL_Flush(wrk->vsl, 0); + /* XXX: revisit this hack */ VSL_Flush(vc->vsl, 0); vc->vsl->wid = vc->orig_vsl_id; vc->vsl = NULL; diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 669a594..dd3d98a 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -45,18 +45,18 @@ static void ved_include(struct sess *sp, const char *src, const char *host) { struct object *obj; - struct worker *w; + struct worker *wrk; char *sp_ws_wm; char *wrk_ws_wm; unsigned sxid, res_mode; - w = sp->wrk; + wrk = sp->wrk; if (sp->req->esi_level >= cache_param->max_esi_depth) return; sp->req->esi_level++; - (void)WRW_FlushRelease(w); + (void)WRW_FlushRelease(wrk); obj = sp->req->obj; sp->req->obj = NULL; @@ -67,7 +67,7 @@ ved_include(struct sess *sp, const char *src, const char *host) /* Take a workspace snapshot */ sp_ws_wm = WS_Snapshot(sp->req->ws); - wrk_ws_wm = WS_Snapshot(w->aws); /* XXX ? */ + wrk_ws_wm = WS_Snapshot(wrk->aws); /* XXX ? */ http_SetH(sp->req->http, HTTP_HDR_URL, src); if (host != NULL && *host != '\0') { @@ -93,12 +93,11 @@ ved_include(struct sess *sp, const char *src, const char *host) sxid = sp->req->xid; while (1) { - sp->wrk = w; + sp->wrk = wrk; CNT_Session(sp); if (sp->step == STP_DONE) break; AZ(sp->wrk); - VSL_Flush(w->vsl, 0); DSL(0x20, SLT_Debug, sp->vsl_id, "loop waiting for ESI"); (void)usleep(10000); } @@ -111,7 +110,7 @@ ved_include(struct sess *sp, const char *src, const char *host) /* Reset the workspace */ WS_Reset(sp->req->ws, sp_ws_wm); - WS_Reset(w->aws, wrk_ws_wm); /* XXX ? */ + WS_Reset(wrk->aws, wrk_ws_wm); /* XXX ? */ WRW_Reserve(sp->wrk, &sp->fd, sp->req->vsl, sp->req->t_resp); if (sp->req->res_mode & RES_CHUNKED) diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 05ac8a3..8f76c24 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -442,9 +442,6 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) return (retry); } - /* Checkpoint the vsl.here */ - VSL_Flush(wrk->vsl, 0); - /* XXX is this the right place? */ VSC_C_main->backend_req++; diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index f41b7ec..ba52ad3 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -133,7 +133,6 @@ ses_pool_task(struct worker *wrk, void *arg) THR_SetSession(NULL); WS_Assert(wrk->aws); AZ(wrk->wrw); - assert(wrk->vsl->wlp == wrk->vsl->wlb); if (cache_param->diag_bitmap & 0x00040000) { if (wrk->vcl != NULL) VCL_Rel(&wrk->vcl); diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index d28a58c..cc3a061 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -94,13 +94,11 @@ wrk_bgthread(void *arg) { struct bgthread *bt; struct worker wrk; - uint32_t logbuf[1024]; /* XXX: size ? */ CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC); THR_SetName(bt->name); memset(&wrk, 0, sizeof wrk); wrk.magic = WORKER_MAGIC; - VSL_Setup(wrk.vsl, logbuf, sizeof logbuf); (void)bt->func(&wrk, bt->priv); @@ -126,10 +124,9 @@ WRK_BgThread(pthread_t *thr, const char *name, bgthread_t *func, void *priv) /*--------------------------------------------------------------------*/ static void * -wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace) +wrk_thread_real(void *priv, unsigned thread_workspace) { struct worker *w, ww; - uint32_t wlog[shm_workspace / 4]; unsigned char ws[thread_workspace]; THR_SetName("cache-worker"); @@ -137,7 +134,6 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned thread_workspace) memset(w, 0, sizeof *w); w->magic = WORKER_MAGIC; w->lastused = NAN; - VSL_Setup(w->vsl, wlog, sizeof wlog); AZ(pthread_cond_init(&w->cond, NULL)); WS_Init(w->aws, "wrk", ws, thread_workspace); @@ -162,9 +158,7 @@ void * WRK_thread(void *priv) { - return (wrk_thread_real(priv, - cache_param->shm_workspace, - cache_param->workspace_thread)); + return (wrk_thread_real(priv, cache_param->workspace_thread)); } void diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index a5cde62..255a3ef 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -778,16 +778,6 @@ static const struct parspec input_parspec[] = { "Minimum is 1k bytes.", 0, "4k", "bytes" }, - { "shm_workspace", - tweak_bytes_u, &mgt_param.shm_workspace, 4096, UINT_MAX, - "Bytes of shmlog workspace allocated for worker threads. " - "If too big, it wastes some ram, if too small it causes " - "needless flushes of the SHM workspace.\n" - "These flushes show up in stats as " - "\"SHM flushes due to overflow\".\n" - "Minimum is 4096 bytes.", - DELAYED_EFFECT, - "8k", "bytes" }, { "shm_reclen", tweak_bytes_u, &mgt_param.shm_reclen, 16, 65535, "Maximum number of bytes in SHM log record.\n" From phk at varnish-cache.org Mon Feb 20 10:24:08 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 20 Feb 2012 11:24:08 +0100 Subject: [master] 27fd76a Don't use 8k stackbuffer, now that thread-stacks get smaller. Message-ID: commit 27fd76aa7d9c613bb020da8d4a6e5ea5d808d9fc Author: Poul-Henning Kamp Date: Mon Feb 20 10:23:53 2012 +0000 Don't use 8k stackbuffer, now that thread-stacks get smaller. diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 4b9fd5f..a6f348b 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -145,28 +145,39 @@ vmod_random(struct sess *sp, double lo, double hi) void __match_proto__() vmod_log(struct sess *sp, const char *fmt, ...) { - char buf[8192], *p; + char *p; + unsigned u; va_list ap; + txt t; + u = WS_Reserve(sp->req->ws, 0); + p = sp->req->ws->f; va_start(ap, fmt); - p = VRT_StringList(buf, sizeof buf, fmt, ap); + p = VRT_StringList(p, u, fmt, ap); va_end(ap); - if (p != NULL) - VSLb(sp->req->vsl, SLT_VCL_Log, "%s", buf); + if (p != NULL) { + t.b = p; + t.e = strchr(p, '\0'); + VSLbt(sp->req->vsl, SLT_VCL_Log, t); + } + WS_Release(sp->req->ws, 0); } void vmod_syslog(struct sess *sp, int fac, const char *fmt, ...) { - char buf[8192], *p; + char *p; + unsigned u; va_list ap; - (void)sp; + u = WS_Reserve(sp->req->ws, 0); + p = sp->req->ws->f; va_start(ap, fmt); - p = VRT_StringList(buf, sizeof buf, fmt, ap); + p = VRT_StringList(p, u, fmt, ap); va_end(ap); if (p != NULL) - syslog(fac, "%s", buf); + syslog(fac, "%s", p); + WS_Release(sp->req->ws, 0); } const char * __match_proto__() From phk at varnish-cache.org Mon Feb 20 11:01:04 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 20 Feb 2012 12:01:04 +0100 Subject: [master] a6de126 Use tweak_bytes() for wthread params. Message-ID: commit a6de1269903d07c0550ebf1cf465d0760ff849f1 Author: Poul-Henning Kamp Date: Mon Feb 20 11:00:37 2012 +0000 Use tweak_bytes() for wthread params. Reduce stacksize to 32k. diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 916fad8..5c65f6e 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -69,7 +69,7 @@ struct params { unsigned wthread_fail_delay; unsigned wthread_purge_delay; unsigned wthread_stats_rate; - unsigned wthread_stacksize; + ssize_t wthread_stacksize; unsigned queue_max; diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index a74fd17..97ac5da 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -406,22 +406,19 @@ main(int argc, char * const *argv) * Adjust default parameters for 32 bit systems to conserve * VM space. */ - MCF_ParamSet(cli, "workspace_client", "16384"); + MCF_ParamSet(cli, "workspace_client", "16k"); cli_check(cli); - MCF_ParamSet(cli, "workspace_backend", "16384"); + MCF_ParamSet(cli, "workspace_backend", "16k"); cli_check(cli); - MCF_ParamSet(cli, "http_resp_size", "8192"); + MCF_ParamSet(cli, "http_resp_size", "8k"); cli_check(cli); - MCF_ParamSet(cli, "http_req_size", "12288"); + MCF_ParamSet(cli, "http_req_size", "12k"); cli_check(cli); - MCF_ParamSet(cli, "thread_pool_stack", "32bit"); - cli_check(cli); - - MCF_ParamSet(cli, "gzip_buffer", "4096"); + MCF_ParamSet(cli, "gzip_buffer", "4k"); cli_check(cli); } diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 255a3ef..9e42e06 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -350,7 +350,7 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, /*--------------------------------------------------------------------*/ -static void +void tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg) { volatile ssize_t *dest; diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h index 275dfe6..a5d4d75 100644 --- a/bin/varnishd/mgt/mgt_param.h +++ b/bin/varnishd/mgt/mgt_param.h @@ -54,6 +54,7 @@ int tweak_generic_uint(struct cli *cli, void tweak_uint(struct cli *cli, const struct parspec *par, const char *arg); void tweak_timeout(struct cli *cli, const struct parspec *par, const char *arg); +void tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg); /* mgt_pool.c */ extern const struct parspec WRK_parspec[]; diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index a6f020c..e5d5cd0 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -73,21 +73,13 @@ static void tweak_stack_size(struct cli *cli, const struct parspec *par, const char *arg) { - unsigned low, u; - char buf[12]; + ssize_t low; low = sysconf(_SC_THREAD_STACK_MIN); - if (arg != NULL && !strcmp(arg, "32bit")) { - u = 65536; - if (u < low) - u = low; - sprintf(buf, "%u", u); - arg = buf; - } - - (void)tweak_generic_uint(cli, &mgt_param.wthread_stacksize, arg, - low, (uint)par->max); + tweak_bytes(cli, par, arg); + if (mgt_param.wthread_stacksize < low) + mgt_param.wthread_stacksize = low; } /*--------------------------------------------------------------------*/ @@ -221,9 +213,8 @@ const struct parspec WRK_parspec[] = { tweak_stack_size, &mgt_param.wthread_stacksize, 0, UINT_MAX, "Worker thread stack size.\n" "This is likely rounded up to a multiple of 4k by the kernel.\n" - "On 32bit systems you may need to tweak this down to fit " - "many threads into the limited address space.\n", + "The kernel/OS has a lower limit which will be enforced.\n", EXPERIMENTAL, - "-1", "bytes" }, + "32k", "bytes" }, { NULL, NULL, NULL } }; From phk at varnish-cache.org Mon Feb 20 11:10:23 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 20 Feb 2012 12:10:23 +0100 Subject: [master] cdcaade Remove unused worker arguments to VDI/close/recycle Message-ID: commit cdcaade761df7c804c42817aa8947d3c037c0f98 Author: Poul-Henning Kamp Date: Mon Feb 20 11:10:08 2012 +0000 Remove unused worker arguments to VDI/close/recycle diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 45f36f2..bdc3659 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -677,8 +677,8 @@ void VBE_UseHealth(const struct director *vdi); struct vbc *VDI_GetFd(const struct director *, struct sess *sp); int VDI_Healthy(const struct director *, const struct sess *sp); -void VDI_CloseFd(struct worker *wrk, struct vbc **vbp); -void VDI_RecycleFd(struct worker *wrk, struct vbc **vbp); +void VDI_CloseFd(struct vbc **vbp); +void VDI_RecycleFd(struct vbc **vbp); void VDI_AddHostHeader(struct http *to, const struct vbc *vbc); void VBE_Poll(void); void VDI_Init(void); diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 57a7e05..b6ee5a5 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -287,7 +287,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req) break; if (bo != NULL) { AN(bo->do_stream); - VDI_CloseFd(wrk, &bo->vbc); + VDI_CloseFd(&bo->vbc); HSH_Drop(wrk, &sp->req->obj); VBO_DerefBusyObj(wrk, &bo); } else { @@ -635,7 +635,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) } /* We are not going to fetch the body, Close the connection */ - VDI_CloseFd(wrk, &bo->vbc); + VDI_CloseFd(&bo->vbc); } /* Clean up partial fetch */ @@ -814,7 +814,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req) if (req->obj == NULL) { req->err_code = 503; sp->step = STP_ERROR; - VDI_CloseFd(wrk, &bo->vbc); + VDI_CloseFd(&bo->vbc); VBO_DerefBusyObj(wrk, &req->busyobj); return (0); } diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c index 6554b18..6dda80d 100644 --- a/bin/varnishd/cache/cache_dir.c +++ b/bin/varnishd/cache/cache_dir.c @@ -40,12 +40,11 @@ /* Close a connection ------------------------------------------------*/ void -VDI_CloseFd(struct worker *wrk, struct vbc **vbp) +VDI_CloseFd(struct vbc **vbp) { struct backend *bp; struct vbc *vc; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); AN(vbp); vc = *vbp; *vbp = NULL; @@ -75,12 +74,11 @@ VDI_CloseFd(struct worker *wrk, struct vbc **vbp) /* Recycle a connection ----------------------------------------------*/ void -VDI_RecycleFd(struct worker *wrk, struct vbc **vbp) +VDI_RecycleFd(struct vbc **vbp) { struct backend *bp; struct vbc *vc; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); AN(vbp); vc = *vbp; *vbp = NULL; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 8f76c24..bb725a2 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -437,7 +437,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) VSLb(req->vsl, SLT_FetchError, "backend write error: %d (%s)", errno, strerror(errno)); - VDI_CloseFd(wrk, &bo->vbc); + VDI_CloseFd(&bo->vbc); /* XXX: other cleanup ? */ return (retry); } @@ -459,7 +459,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) VSLb(req->vsl, SLT_FetchError, "http first read error: %d %d (%s)", i, errno, strerror(errno)); - VDI_CloseFd(wrk, &bo->vbc); + VDI_CloseFd(&bo->vbc); /* XXX: other cleanup ? */ /* Retryable if we never received anything */ return (i == -1 ? retry : -1); @@ -473,7 +473,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) VSLb(req->vsl, SLT_FetchError, "http first read error: %d %d (%s)", i, errno, strerror(errno)); - VDI_CloseFd(wrk, &bo->vbc); + VDI_CloseFd(&bo->vbc); /* XXX: other cleanup ? */ return (-1); } @@ -483,7 +483,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody) if (http_DissectResponse(hp, htc)) { VSLb(req->vsl, SLT_FetchError, "http format error"); - VDI_CloseFd(wrk, &bo->vbc); + VDI_CloseFd(&bo->vbc); /* XXX: other cleanup ? */ return (-1); } @@ -585,14 +585,14 @@ FetchBody(struct worker *wrk, struct busyobj *bo, struct object *obj) cls, mklen); if (bo->body_status == BS_ERROR) { - VDI_CloseFd(wrk, &bo->vbc); + VDI_CloseFd(&bo->vbc); bo->stats = NULL; return (__LINE__); } if (cls < 0) { wrk->stats.fetch_failed++; - VDI_CloseFd(wrk, &bo->vbc); + VDI_CloseFd(&bo->vbc); obj->len = 0; bo->stats = NULL; return (__LINE__); @@ -625,9 +625,9 @@ FetchBody(struct worker *wrk, struct busyobj *bo, struct object *obj) } if (cls) - VDI_CloseFd(wrk, &bo->vbc); + VDI_CloseFd(&bo->vbc); else - VDI_RecycleFd(wrk, &bo->vbc); + VDI_RecycleFd(&bo->vbc); bo->stats = NULL; return (0); diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c index 8815c68..c486a23 100644 --- a/bin/varnishd/cache/cache_pipe.c +++ b/bin/varnishd/cache/cache_pipe.c @@ -93,7 +93,7 @@ PipeSession(struct sess *sp) if (i) { SES_Close(sp, "pipe"); - VDI_CloseFd(sp->wrk, &vc); + VDI_CloseFd(&vc); return; } @@ -133,6 +133,6 @@ PipeSession(struct sess *sp) } } SES_Close(sp, "pipe"); - VDI_CloseFd(sp->wrk, &vc); + VDI_CloseFd(&vc); bo->vbc = NULL; } From phk at varnish-cache.org Mon Feb 20 11:11:37 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 20 Feb 2012 12:11:37 +0100 Subject: [master] ea9d288 silence flexelint Message-ID: commit ea9d288d868859c0a28258e2953913482e5583e4 Author: Poul-Henning Kamp Date: Mon Feb 20 11:11:30 2012 +0000 silence flexelint diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index a6f348b..d1f6771 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -163,7 +163,7 @@ vmod_log(struct sess *sp, const char *fmt, ...) WS_Release(sp->req->ws, 0); } -void +void __match_proto__() vmod_syslog(struct sess *sp, int fac, const char *fmt, ...) { char *p; From drwilco at varnish-cache.org Thu Feb 23 06:58:44 2012 From: drwilco at varnish-cache.org (Rogier Mulhuijzen) Date: Thu, 23 Feb 2012 07:58:44 +0100 Subject: [master] e090127 Add Cookie and Set-Cookie to the HTTP headers list Message-ID: commit e09012719af89bfb04a7759250349f63e7f4fd92 Author: Rogier 'DocWilco' Mulhuijzen Date: Wed Feb 22 22:52:06 2012 -0800 Add Cookie and Set-Cookie to the HTTP headers list Requested by: Federico G. Schwindt diff --git a/include/tbl/http_headers.h b/include/tbl/http_headers.h index 503c5c3..3f2c50a 100644 --- a/include/tbl/http_headers.h +++ b/include/tbl/http_headers.h @@ -62,6 +62,7 @@ HTTPH("Content-Location", H_Content_Location, 0 ) /* RFC2616 14.14 */ HTTPH("Content-MD5", H_Content_MD5, 0 ) /* RFC2616 14.15 */ HTTPH("Content-Range", H_Content_Range, HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.16 */ HTTPH("Content-Type", H_Content_Type, 0 ) /* RFC2616 14.17 */ +HTTPH("Cookie", H_Cookie, 0 ) /* RFC6265 4.2 */ HTTPH("Date", H_Date, 0 ) /* RFC2616 14.18 */ HTTPH("ETag", H_ETag, 0 ) /* RFC2616 14.19 */ HTTPH("Expect", H_Expect, 0 ) /* RFC2616 14.20 */ @@ -83,6 +84,7 @@ HTTPH("Range", H_Range, HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.35 HTTPH("Referer", H_Referer, 0 ) /* RFC2616 14.36 */ HTTPH("Retry-After", H_Retry_After, 0 ) /* RFC2616 14.37 */ HTTPH("Server", H_Server, 0 ) /* RFC2616 14.38 */ +HTTPH("Set-Cookie", H_Set_Cookie, 0 ) /* RFC6265 4.1 */ HTTPH("TE", H_TE, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.39 */ HTTPH("Trailer", H_Trailer, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.40 */ HTTPH("Transfer-Encoding", H_Transfer_Encoding, HTTPH_R_PASS | HTTPH_R_FETCH | HTTPH_A_INS) /* RFC2616 14.41 */ From apj at varnish-cache.org Thu Feb 23 16:59:18 2012 From: apj at varnish-cache.org (Andreas Plesner Jacobsen) Date: Thu, 23 Feb 2012 17:59:18 +0100 Subject: [master] edf72b4 Documentation fixes from Federico G. Schwindt Message-ID: commit edf72b4ed1b9365ef71a017050c1a269f52cc260 Author: Andreas Plesner Jacobsen Date: Thu Feb 23 17:57:50 2012 +0100 Documentation fixes from Federico G. Schwindt - mention vmod_std(7) - HEADER is released and used by vmod_std(7) so put it in its own line. The explanation is still needed though. - for consistency replace leading tabs with spaces - *fallback* are not strings so avoid mentioning the type - use ascii characters in vmod_std(7) And a few style changes from me to vmod_std.rst diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 57163c5..a76dee1 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -22,7 +22,7 @@ For instance:: The "std" vmod is one you get with Varnish, it will always be there and we will put "boutique" functions in it, such as the "toupper" function shown above. The full contents of the "std" module is -documented in XXX:TBW. +documented in vmod_std(7). This part of the manual is about how you go about writing your own VMOD, how the language interface between C and VCC works etc. This @@ -185,7 +185,12 @@ VOID Can only be used for return-value, which makes the function a VCL procedure. -IP, BOOL, HEADER +HEADER + C-type: ``enum gethdr_e, const char *`` + + XXX: explain me + +IP, BOOL XXX: these types are not released for use in vmods yet. diff --git a/doc/sphinx/reference/vmod_std.rst b/doc/sphinx/reference/vmod_std.rst index 1ea8193..9c28a3c 100644 --- a/doc/sphinx/reference/vmod_std.rst +++ b/doc/sphinx/reference/vmod_std.rst @@ -31,31 +31,31 @@ toupper ------- Prototype - toupper(STRING S) + toupper(STRING s) Return value - String + String Description - Converts the STRING S to upper case. + Converts the string *s* to upper case. Example set beresp.http.x-scream = std.toupper("yes!"); tolower ------- Prototype - tolower(STRING S) + tolower(STRING s) Return value - String + String Description - Converts the STRING to lower case. + Converts the string *s* to lower case. Example - set beresp.http.x-nice = std.tolower("VerY"); + set beresp.http.x-nice = std.tolower("VerY"); set_up_tos ---------- Prototype - set_ip_tos(INT I) + set_ip_tos(INT i) Return value - Void + Void Description Sets the Type-of-Service flag for the current session. Please note that the TOS flag is not removed by the end of the @@ -71,7 +71,7 @@ random Prototype random(REAL a, REAL b) Return value - Real + Real Description Returns a random REAL number between *a* and *b*. Example @@ -82,9 +82,9 @@ log Prototype log(STRING string) Return value - Void + Void Description - Logs string to the shared memory log. + Logs *string* to the shared memory log. Example std.log("Something fishy is going on with the vhost " + req.host); @@ -93,7 +93,7 @@ syslog Prototype syslog(INT priority, STRING string) Return value - Void + Void Description Logs *string* to syslog marked with *priority*. Example @@ -104,7 +104,7 @@ fileread Prototype fileread(STRING filename) Return value - String + String Description Reads a file and returns a string with the content. Please note that it is not recommended to send variables to this @@ -118,12 +118,11 @@ duration Prototype duration(STRING s, DURATION fallback) Return value - Duration + Duration Description - Converts the string s to seconds. s can be quantified with the - usual s (seconds), m (minutes), h (hours), d (days) and w - (weeks) units. If it fails to parse the string *fallback* - will be used + Converts the string *s* to seconds. *s* can be quantified with + the usual s (seconds), m (minutes), h (hours), d (days) and w + (weeks) units. If *s* fails to parse, *fallback* will be used. Example set beresp.ttl = std.duration("1w", 3600); @@ -132,19 +131,19 @@ integer Prototype integer(STRING s, INT fallback) Return value - Int + Int Description - Converts the string s to an integer. If it fails to parse the - string *fallback* will be used + Converts the string *s* to an integer. If *s* fails to parse, + *fallback* will be used Example - if (std.integer(beresp.http.x-foo, 0) > 5) { ? } + if (std.integer(beresp.http.x-foo, 0) > 5) { ... } collect ------- Prototype collect(HEADER header) Return value - Void + Void Description Collapses the header, joining the headers into one. Example From lkarsten at varnish-cache.org Fri Feb 24 10:06:22 2012 From: lkarsten at varnish-cache.org (Lasse Karstensen) Date: Fri, 24 Feb 2012 11:06:22 +0100 Subject: [master] 9a9a9cd typo Message-ID: commit 9a9a9cd9fe48668b31d7427c02896c34c45e9ee7 Author: Lasse Karstensen Date: Mon Feb 6 14:42:10 2012 +0100 typo diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index c175f10..08d8eb6 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -157,7 +157,7 @@ VSM_Delete(struct VSM_data *vd) * The internal VSM open function * * Return: - * 0 = sucess + * 0 = success * <0 = failure * */ From lkarsten at varnish-cache.org Fri Feb 24 10:06:22 2012 From: lkarsten at varnish-cache.org (Lasse Karstensen) Date: Fri, 24 Feb 2012 11:06:22 +0100 Subject: [master] db8b1d3 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit db8b1d33707e6bab430c983d22024f9a684e98a9 Merge: 9a9a9cd 512dddc Author: Lasse Karstensen Date: Tue Feb 7 11:06:12 2012 +0100 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From lkarsten at varnish-cache.org Fri Feb 24 10:06:22 2012 From: lkarsten at varnish-cache.org (Lasse Karstensen) Date: Fri, 24 Feb 2012 11:06:22 +0100 Subject: [master] 21beea8 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit 21beea85fff9f6b645f4d35b93bafba2ace9d411 Merge: db8b1d3 edf72b4 Author: Lasse Karstensen Date: Fri Feb 24 11:04:26 2012 +0100 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From lkarsten at varnish-cache.org Fri Feb 24 10:07:59 2012 From: lkarsten at varnish-cache.org (Lasse Karstensen) Date: Fri, 24 Feb 2012 11:07:59 +0100 Subject: [master] 4e529da Use american english Message-ID: commit 4e529daddf4be75948d70f41f71d2c02e84eae70 Author: Lasse Karstensen Date: Fri Feb 24 11:08:03 2012 +0100 Use american english diff --git a/doc/sphinx/tutorial/virtualized.rst b/doc/sphinx/tutorial/virtualized.rst new file mode 100644 index 0000000..317d3e2 --- /dev/null +++ b/doc/sphinx/tutorial/virtualized.rst @@ -0,0 +1,23 @@ + +Running Varnish in a virtualized environment +-------------------------------------------- + +It is possible, but not recommended for high performance, to run +Varnish on virtualized hardware. Reduced disk- and network performance +will reduce the performance a bit so make sure your system has good IO +performance. + +OpenVZ +~~~~~~ + +If you are running on 64bit OpenVZ (or Parallels VPS), you must reduce +the maximum stack size before starting Varnish. The default allocates +to much memory per thread, which will make varnish fail as soon as the +number of threads (==traffic) increases. + +Reduce the maximum stack size by running:: + + ulimit -s 256 + +in the startup script. + From lkarsten at varnish-cache.org Fri Feb 24 10:07:59 2012 From: lkarsten at varnish-cache.org (Lasse Karstensen) Date: Fri, 24 Feb 2012 11:07:59 +0100 Subject: [master] a502bae Use american english Message-ID: commit a502bae63c0f3b1d4c26c8108bc964369d85458d Author: Lasse Karstensen Date: Fri Feb 24 11:08:31 2012 +0100 Use american english diff --git a/doc/sphinx/tutorial/index.rst b/doc/sphinx/tutorial/index.rst index c3a05f5..c8eb2c2 100644 --- a/doc/sphinx/tutorial/index.rst +++ b/doc/sphinx/tutorial/index.rst @@ -28,7 +28,7 @@ separate topic. Good luck. purging compression esi - virtualised + virtualized advanced_backend_servers handling_misbehaving_servers advanced_topics From apj at varnish-cache.org Fri Feb 24 11:18:16 2012 From: apj at varnish-cache.org (Andreas Plesner Jacobsen) Date: Fri, 24 Feb 2012 12:18:16 +0100 Subject: [master] cd0f595 Add more info about changes from 2.1 to 3.0. Thanks to xcir.net for inspiration. Message-ID: commit cd0f595b7bd511078fd5f0d9ec536bb22f7a95a7 Author: Andreas Plesner Jacobsen Date: Fri Feb 24 12:16:25 2012 +0100 Add more info about changes from 2.1 to 3.0. Thanks to xcir.net for inspiration. diff --git a/doc/sphinx/installation/upgrade.rst b/doc/sphinx/installation/upgrade.rst index 0ed4f9f..cee17b8 100644 --- a/doc/sphinx/installation/upgrade.rst +++ b/doc/sphinx/installation/upgrade.rst @@ -60,10 +60,10 @@ becomes:: } } -``beresp.cacheable`` is gone -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``beresp.cacheable`` and ``obj.cacheable``is gone +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -``beresp.cacheable`` is gone, and can be replaced with ``beresp.ttl > 0s`` +``beresp.cacheable`` is gone, and can be replaced with ``beresp.ttl > 0s``. Similarly ``obj.cacheable`` can be replaced with ``obj.ttl > 0s``. returns are now done with the ``return()`` function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -111,6 +111,56 @@ The difference in behaviour of ``pass`` in ``vcl_recv`` and different, you must now do ``return(hit_for_pass)`` when doing a pass in ``vcl_fetch``. +Changes to runtime parameters +============================= + +Deleted parameters +~~~~~~~~~~~~~~~~~~ + +``cache_vbe_conns`` and ``err_ttl`` has been removed. + +New parameters +~~~~~~~~~~~~~~ + +The following parameters have been added, see man varnishd for reference: +* ``default_keep`` +* ``expiry_sleep`` +* ``fetch_maxchunksize`` +* ``gzip_level`` +* ``gzip_memlevel`` +* ``gzip_stack_buffer`` +* ``gzip_tmp_space`` +* ``gzip_window`` +* ``http_gzip_support`` +* ``http_req_hdr_len`` +* ``http_req_size`` +* ``http_resp_hdr_len`` +* ``http_resp_size`` +* ``shortlived`` +* ``thread_pool_workspace`` +* ``vcc_err_unref`` +* ``vcl_dir`` +* ``vmod_dir`` + +Changed default values +~~~~~~~~~~~~~~~~~~~~~~ + +The following parameters have new defaults: + +* ``ban_lurker_sleep`` changed from 0 to 0.01 seconds, enabling the ban lurker by default. +* ``connect_timeout`` changed from 0.4 to 0.7 seconds. +* ``log_hashstring`` changed from off to on. +* ``send_timeout`` changed from 60 to 60 seconds. +* ``thread_pool_add_delay`` changed from 20 to 2 ms. + +Changed parameter names +~~~~~~~~~~~~~~~~~~~~~~~ + +The following parameters have new names: +* ``http_headers`` has been renamed to ``http_max_hdr``. +* ``max_esi_includes`` has been renamed to ``max_esi_depth``. +* ``overflow_max`` has been renamed to ``queue_max``. +* ``purge_dups`` has been renamed to ``ban_dups``. Changes to behaviour ==================== From apj at varnish-cache.org Fri Feb 24 11:20:48 2012 From: apj at varnish-cache.org (Andreas Plesner Jacobsen) Date: Fri, 24 Feb 2012 12:20:48 +0100 Subject: [master] 9f8a77d Fix syntax Message-ID: commit 9f8a77dc60d5a68b419ab97b9a2ada9aa3a397f3 Author: Andreas Plesner Jacobsen Date: Fri Feb 24 12:20:37 2012 +0100 Fix syntax diff --git a/doc/sphinx/installation/upgrade.rst b/doc/sphinx/installation/upgrade.rst index cee17b8..2402af0 100644 --- a/doc/sphinx/installation/upgrade.rst +++ b/doc/sphinx/installation/upgrade.rst @@ -123,6 +123,7 @@ New parameters ~~~~~~~~~~~~~~ The following parameters have been added, see man varnishd for reference: + * ``default_keep`` * ``expiry_sleep`` * ``fetch_maxchunksize`` @@ -157,6 +158,7 @@ Changed parameter names ~~~~~~~~~~~~~~~~~~~~~~~ The following parameters have new names: + * ``http_headers`` has been renamed to ``http_max_hdr``. * ``max_esi_includes`` has been renamed to ``max_esi_depth``. * ``overflow_max`` has been renamed to ``queue_max``. From lkarsten at varnish-cache.org Fri Feb 24 13:10:45 2012 From: lkarsten at varnish-cache.org (Lasse Karstensen) Date: Fri, 24 Feb 2012 14:10:45 +0100 Subject: [master] bf2da4e forgot to delete, thank you scoof Message-ID: commit bf2da4e11f7a27e057b1174eec1cab2c2b375d89 Author: Lasse Karstensen Date: Fri Feb 24 14:11:06 2012 +0100 forgot to delete, thank you scoof diff --git a/doc/sphinx/tutorial/virtualised.rst b/doc/sphinx/tutorial/virtualised.rst deleted file mode 100644 index ea8ade5..0000000 --- a/doc/sphinx/tutorial/virtualised.rst +++ /dev/null @@ -1,23 +0,0 @@ - -Running Varnish in a virtualized environment --------------------------------------------- - -It is possible, but not recommended for high performance, to run -Varnish on virtualised hardware. Reduced disk- and network performance -will reduce the performance a bit so make sure your system has good IO -performance. - -OpenVZ -~~~~~~ - -If you are running on 64bit OpenVZ (or Parallels VPS), you must reduce -the maximum stack size before starting Varnish. The default allocates -to much memory per thread, which will make varnish fail as soon as the -number of threads (==traffic) increases. - -Reduce the maximum stack size by running:: - - ulimit -s 256 - -in the startup script. - From lkarsten at varnish-cache.org Fri Feb 24 13:10:45 2012 From: lkarsten at varnish-cache.org (Lasse Karstensen) Date: Fri, 24 Feb 2012 14:10:45 +0100 Subject: [master] 3a00261 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit 3a002613f7bbd0a39ac97d5d223ea299803f9133 Merge: bf2da4e 9f8a77d Author: Lasse Karstensen Date: Fri Feb 24 14:11:17 2012 +0100 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From apj at varnish-cache.org Fri Feb 24 13:52:49 2012 From: apj at varnish-cache.org (Andreas Plesner Jacobsen) Date: Fri, 24 Feb 2012 14:52:49 +0100 Subject: [master] db0f3b2 Grammar Message-ID: commit db0f3b2044252f2eefe4b4b0296ae5f29c3aa6af Author: Andreas Plesner Jacobsen Date: Fri Feb 24 14:52:38 2012 +0100 Grammar diff --git a/doc/sphinx/installation/upgrade.rst b/doc/sphinx/installation/upgrade.rst index 2402af0..2c06a3f 100644 --- a/doc/sphinx/installation/upgrade.rst +++ b/doc/sphinx/installation/upgrade.rst @@ -60,8 +60,8 @@ becomes:: } } -``beresp.cacheable`` and ``obj.cacheable``is gone -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``beresp.cacheable`` and ``obj.cacheable`` are gone +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``beresp.cacheable`` is gone, and can be replaced with ``beresp.ttl > 0s``. Similarly ``obj.cacheable`` can be replaced with ``obj.ttl > 0s``. From lkarsten at varnish-cache.org Fri Feb 24 14:12:27 2012 From: lkarsten at varnish-cache.org (Lasse Karstensen) Date: Fri, 24 Feb 2012 15:12:27 +0100 Subject: [master] e995b1a Add short example on how to get Websockets to work Message-ID: commit e995b1a518b4c6d89424eb8cdc6deb091ea04787 Author: Lasse Karstensen Date: Fri Feb 24 15:12:44 2012 +0100 Add short example on how to get Websockets to work diff --git a/doc/sphinx/tutorial/websockets.rst b/doc/sphinx/tutorial/websockets.rst new file mode 100644 index 0000000..a74353e --- /dev/null +++ b/doc/sphinx/tutorial/websockets.rst @@ -0,0 +1,20 @@ + +Using Websockets +---------------- + +Websockets is a technology for creating a bidirectional stream-based channel over HTTP. + +To run websockets through Varnish you need to pipe it, and copy the Upgrade header. Use the following +VCL config to do so:: + + sub vcl_pipe { + if (req.http.upgrade) { + set bereq.http.upgrade = req.http.upgrade; + } + } + sub vcl_recv { + if (req.http.Upgrade ~ "(?i)websocket") { + return (pipe); + } + } + From lkarsten at varnish-cache.org Fri Feb 24 14:12:27 2012 From: lkarsten at varnish-cache.org (Lasse Karstensen) Date: Fri, 24 Feb 2012 15:12:27 +0100 Subject: [master] 064077f Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit 064077f0d17e28aaca5b471c3f339fa18724c30d Merge: e995b1a db0f3b2 Author: Lasse Karstensen Date: Fri Feb 24 15:12:54 2012 +0100 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From lkarsten at varnish-cache.org Fri Feb 24 14:13:39 2012 From: lkarsten at varnish-cache.org (Lasse Karstensen) Date: Fri, 24 Feb 2012 15:13:39 +0100 Subject: [master] 36fca1e Add short example on how to get Websockets to work (#2) Message-ID: commit 36fca1e9b0475e141cdd82447148b5d8ab63ac24 Author: Lasse Karstensen Date: Fri Feb 24 15:14:12 2012 +0100 Add short example on how to get Websockets to work (#2) diff --git a/doc/sphinx/tutorial/index.rst b/doc/sphinx/tutorial/index.rst index c8eb2c2..4949aa0 100644 --- a/doc/sphinx/tutorial/index.rst +++ b/doc/sphinx/tutorial/index.rst @@ -29,6 +29,7 @@ separate topic. Good luck. compression esi virtualized + websockets advanced_backend_servers handling_misbehaving_servers advanced_topics From apj at varnish-cache.org Fri Feb 24 14:16:22 2012 From: apj at varnish-cache.org (Andreas Plesner Jacobsen) Date: Fri, 24 Feb 2012 15:16:22 +0100 Subject: [master] 195b601 Correct value for 2.1 Message-ID: commit 195b601710ae556f3bcb6c27b73f6d60c3986bde Author: Andreas Plesner Jacobsen Date: Fri Feb 24 15:16:15 2012 +0100 Correct value for 2.1 diff --git a/doc/sphinx/installation/upgrade.rst b/doc/sphinx/installation/upgrade.rst index 2c06a3f..93446ea 100644 --- a/doc/sphinx/installation/upgrade.rst +++ b/doc/sphinx/installation/upgrade.rst @@ -151,7 +151,7 @@ The following parameters have new defaults: * ``ban_lurker_sleep`` changed from 0 to 0.01 seconds, enabling the ban lurker by default. * ``connect_timeout`` changed from 0.4 to 0.7 seconds. * ``log_hashstring`` changed from off to on. -* ``send_timeout`` changed from 60 to 60 seconds. +* ``send_timeout`` changed from 600 to 60 seconds. * ``thread_pool_add_delay`` changed from 20 to 2 ms. Changed parameter names From phk at varnish-cache.org Mon Feb 27 08:32:39 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 27 Feb 2012 09:32:39 +0100 Subject: [master] c082835 Drop the body of hit-for-pass objects once we have delivered them to the original requester. Message-ID: commit c082835a88462548bddf78fa7c88fb948fc1f1d2 Author: Poul-Henning Kamp Date: Mon Feb 27 08:31:41 2012 +0000 Drop the body of hit-for-pass objects once we have delivered them to the original requester. Submitted by: DocWilco diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index b6ee5a5..6e6d54f 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -327,6 +327,7 @@ cnt_deliver(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); AZ(req->busyobj); req->director = NULL; @@ -334,6 +335,13 @@ cnt_deliver(struct sess *sp, struct worker *wrk, struct req *req) RES_WriteObj(sp); + /* No point in saving the body if it is hit-for-pass */ + if (req->obj->objcore != NULL) { + CHECK_OBJ_NOTNULL(req->obj->objcore, OBJCORE_MAGIC); + if (req->obj->objcore->flags & OC_F_PASS) + STV_Freestore(req->obj); + } + assert(WRW_IsReleased(wrk)); (void)HSH_Deref(&wrk->stats, NULL, &req->obj); http_Teardown(req->resp); From phk at varnish-cache.org Mon Feb 27 08:49:01 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 27 Feb 2012 09:49:01 +0100 Subject: [master] 96e2a95 Avoid taking the saintmode lock if the list empty. Message-ID: commit 96e2a95ee17b19b35ec880b08a23696cc8a16f36 Author: Poul-Henning Kamp Date: Mon Feb 27 08:47:12 2012 +0000 Avoid taking the saintmode lock if the list empty. Submitted by: DocWilco diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 961cb8d..52f1c38 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -261,16 +261,15 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp) /* VRT/VCC sets threshold to UINT_MAX to mark that it's not * specified by VCL (thus use param). */ - if (vs->vrt->saintmode_threshold == UINT_MAX) + threshold = vs->vrt->saintmode_threshold; + if (threshold == UINT_MAX) threshold = cache_param->saintmode_threshold; - else - threshold = vs->vrt->saintmode_threshold; if (backend->admin_health == ah_healthy) threshold = UINT_MAX; - /* Saintmode is disabled */ - if (threshold == 0) + /* Saintmode is disabled, or list is empty */ + if (threshold == 0 || VTAILQ_EMPTY(&backend->troublelist)) return (1); if (sp->req->objcore == NULL) From phk at varnish-cache.org Mon Feb 27 11:16:04 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 27 Feb 2012 12:16:04 +0100 Subject: [master] 4d047a9 Accept-filters on FreeBSD has been broken for ages, fix them. Message-ID: commit 4d047a90b19f8821262567b793e535639b1b701a Author: Poul-Henning Kamp Date: Mon Feb 27 11:14:45 2012 +0000 Accept-filters on FreeBSD has been broken for ages, fix them. Add accept-filter param which controls if we attempt kernel filteringer. Apply filters after listen() when we do. Report failuers with VSL(SLT_Error) Disable filters in pipe-lining test-case. Fixes #1101 diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 07e7f5e..3ca79c1 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -292,6 +292,7 @@ vca_acct(void *arg) #endif struct listen_sock *ls; double t0, now; + int i; THR_SetName("cache-acceptor"); (void)arg; @@ -302,6 +303,13 @@ vca_acct(void *arg) AZ(listen(ls->sock, cache_param->listen_depth)); AZ(setsockopt(ls->sock, SOL_SOCKET, SO_LINGER, &linger, sizeof linger)); + if (cache_param->accept_filter) { + i = VTCP_filter_http(ls->sock); + if (i) + VSL(SLT_Error, ls->sock, + "Kernel filtering: sock=%d, ret=%d %s\n", + ls->sock, i, strerror(errno)); + } } hack_ready = 1; diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 5c65f6e..6e502fd 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -108,6 +108,8 @@ struct params { /* VCL traces */ unsigned vcl_trace; + unsigned accept_filter; + /* Listen address */ char *listen_address; diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 0f91d05..8661b73 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -53,7 +53,6 @@ #include "vev.h" #include "vlu.h" #include "vss.h" -#include "vtcp.h" #include "vtim.h" #include "mgt_cli.h" @@ -239,12 +238,6 @@ open_sockets(void) mgt_child_inherit(ls->sock, "sock"); - /* - * Set nonblocking mode to avoid a race where a client - * closes before we call accept(2) and nobody else are in - * the listen queue to release us. - */ - (void)VTCP_filter_http(ls->sock); good++; } if (!good) diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 9e42e06..31ef010 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -877,6 +877,10 @@ static const struct parspec input_parspec[] = { "default.", 0, "off", "bool" }, + { "accept_filter", tweak_bool, &mgt_param.accept_filter, 0, 0, + "Enable kernel accept-filters, if supported by the kernel.", + MUST_RESTART, + "on", "bool" }, { "listen_address", tweak_listen_address, NULL, 0, 0, "Whitespace separated list of network endpoints where " "Varnish will accept requests.\n" diff --git a/bin/varnishtest/tests/b00013.vtc b/bin/varnishtest/tests/b00013.vtc index 57250ad..8ae90c4 100644 --- a/bin/varnishtest/tests/b00013.vtc +++ b/bin/varnishtest/tests/b00013.vtc @@ -9,10 +9,10 @@ server s1 { txresp -body "foobar" } -start -varnish v1 -vcl+backend {} -start +varnish v1 -arg "-p accept_filter=false" -vcl+backend {} -start client c1 { - send "GET /foo HTTP/1.1\n\nGET " + send "GET /foo HTTP/1.1\r\n\r\nGET " rxresp expect resp.status == 200 expect resp.http.content-length == 3 diff --git a/configure.ac b/configure.ac index 952b71b..7e5e57e 100644 --- a/configure.ac +++ b/configure.ac @@ -328,6 +328,15 @@ fi AM_MISSING_HAS_RUN AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build Varnish, please install python.])]) +AC_CHECK_DECL([SO_ACCEPTFILTER], + AC_DEFINE(HAVE_ACCEPT_FILTERS,1,[Define to 1 if you have accept filters]), + , + [ +#include +#include + ] +) + # Older Solaris versions define SO_{RCV,SND}TIMEO, but do not # implement them. # diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index e361738..8bb19d4 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -130,33 +130,46 @@ VTCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen) /*--------------------------------------------------------------------*/ +#ifdef HAVE_ACCEPT_FILTERS + int VTCP_filter_http(int sock) { -#ifdef HAVE_ACCEPT_FILTERS + int retval; struct accept_filter_arg afa; - int i; memset(&afa, 0, sizeof(afa)); strcpy(afa.af_name, "httpready"); - errno = 0; - i = setsockopt(sock, SOL_SOCKET, SO_ACCEPTFILTER, - &afa, sizeof(afa)); - /* XXX ugly */ - if (i) - printf("Acceptfilter(%d, httpready): %d %s\n", - sock, i, strerror(errno)); - return (i); + retval = setsockopt(sock, SOL_SOCKET, SO_ACCEPTFILTER, + &afa, sizeof afa ); + return (retval); +} + #elif defined(__linux) + +int +VTCP_filter_http(int sock) +{ + int retval; int defer = 1; - setsockopt(sock, SOL_TCP,TCP_DEFER_ACCEPT,(char *) &defer, sizeof(int)); - return (0); + + retval = setsockopt(sock, SOL_TCP,TCP_DEFER_ACCEPT, + &defer, sizeof defer); + return (retval); +} + #else + +int +VTCP_filter_http(int sock) +{ + errno = EOPNOTSUPP; (void)sock; - return (0); -#endif + return (-1); } +#endif + /*-------------------------------------------------------------------- * Functions for controlling NONBLOCK mode. * From phk at varnish-cache.org Mon Feb 27 12:42:33 2012 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 27 Feb 2012 13:42:33 +0100 Subject: [master] 21e653c Use the hash digest as identification instead of the neutered objhead pointer, in order to not have dependency between trouble entry and objhead lifetime. Message-ID: commit 21e653c3a3e0686232646b9f933de72b6536fb50 Author: Poul-Henning Kamp Date: Mon Feb 27 12:41:33 2012 +0000 Use the hash digest as identification instead of the neutered objhead pointer, in order to not have dependency between trouble entry and objhead lifetime. Fixes #1091 diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 52f1c38..dcb87dd 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -244,7 +244,6 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp) unsigned i = 0, retval; unsigned int threshold; struct backend *backend; - uintptr_t target; double now; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); @@ -276,7 +275,6 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp) return (1); now = sp->t_req; - target = (uintptr_t)(sp->req->objcore->objhead); old = NULL; retval = 1; @@ -291,7 +289,7 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp) break; } - if (tr->target == target) { + if (!memcmp(tr->digest, sp->req->digest, sizeof tr->digest)) { retval = 0; break; } diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index b1688f9..96f0a63 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -97,7 +97,7 @@ struct director { struct trouble { unsigned magic; #define TROUBLE_MAGIC 0x4211ab21 - uintptr_t target; + unsigned char digest[DIGEST_LEN]; double timeout; VTAILQ_ENTRY(trouble) list; }; diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 72fa4dc..2e56666 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -152,7 +152,7 @@ VRT_l_beresp_saintmode(const struct sess *sp, double a) ALLOC_OBJ(new, TROUBLE_MAGIC); AN(new); - new->target = (uintptr_t)(sp->req->objcore->objhead); + memcpy(new->digest, sp->req->digest, sizeof new->digest); new->timeout = sp->t_req + a; /* Insert the new item on the list before the first item with a diff --git a/bin/varnishtest/tests/r01091.vtc b/bin/varnishtest/tests/r01091.vtc new file mode 100644 index 0000000..9234ffc --- /dev/null +++ b/bin/varnishtest/tests/r01091.vtc @@ -0,0 +1,36 @@ +varnishtest "Test fallback director with saint mode" + +server s1 { + rxreq + txresp -hdr "Foo: 1" + accept + rxreq + txresp -hdr "Foo: 1" +} -start + +server s2 { + rxreq + txresp -hdr "Foo: 2" -bodylen 1 +} -start + +varnish v1 -vcl+backend { + director f1 fallback { + { .backend = s1; } + { .backend = s2; } + } + sub vcl_recv { + set req.backend = f1; + } + sub vcl_fetch { + if(req.restarts < 1) { + set beresp.saintmode = 1h; + return(restart); + } + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.foo == "2" +} -run From perbu at varnish-cache.org Wed Feb 29 15:17:12 2012 From: perbu at varnish-cache.org (Per Buer) Date: Wed, 29 Feb 2012 16:17:12 +0100 Subject: [master] 09b77e3 backend cookies Message-ID: commit 09b77e3ab021536cbfd893d602c51dfec7a8eb4a Author: Per Buer Date: Wed Feb 29 16:17:09 2012 +0100 backend cookies diff --git a/doc/sphinx/tutorial/cookies.rst b/doc/sphinx/tutorial/cookies.rst index 0278712..20fd302 100644 --- a/doc/sphinx/tutorial/cookies.rst +++ b/doc/sphinx/tutorial/cookies.rst @@ -13,6 +13,9 @@ This can be overly conservative. A lot of sites use Google Analytics cookie is used by the client side javascript and is therefore of no interest to the server. +Cookies from the client +~~~~~~~~~~~~~~~~~~~~~~~ + For a lot of web application it makes sense to completely disregard the cookies unless you are accessing a special part of the web site. This VCL snippet in vcl_recv will disregard cookies unless you are @@ -63,3 +66,12 @@ cookies named COOKIE1 and COOKIE2 and you can marvel at it:: The example is taken from the Varnish Wiki, where you can find other scary examples of what can be done in VCL. + +Cookies coming from the backend +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If your backend server sets a cookie using the Set-Cookie header +Varnish will not cache the page. A hit-for-pass object (see +:ref:`tutorial_vcl_fetch_actions`) is created. So, if the backend +server acts silly and sets unwanted cookies just unset the Set-Cookie +header and all should be fine.