From phk at FreeBSD.org Tue Aug 5 07:29:13 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 05 Aug 2014 09:29:13 +0200 Subject: [master] 321c2e3 Wean HSH_Lookup from struct object Message-ID: commit 321c2e30f83d020f387831d94473ff98f533d60c Author: Poul-Henning Kamp Date: Tue Aug 5 07:28:53 2014 +0000 Wean HSH_Lookup from struct object diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e171d66..af290cd 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -490,7 +490,7 @@ struct busyobj { enum busyobj_state_e state; struct ws ws[1]; - char *ws_bo; + char *ws_bo; struct vbc *vbc; struct http *bereq0; struct http *bereq; diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index ad1b874..712243b 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -343,10 +343,10 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, struct objhead *oh; struct objcore *oc; struct objcore *exp_oc; - struct object *o, *exp_o; double exp_t_origin; int busy_found; enum lookup_e retval; + uint8_t *vary; AN(ocp); *ocp = NULL; @@ -391,10 +391,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, assert(oh->refcnt > 0); busy_found = 0; - exp_o = NULL; exp_oc = NULL; exp_t_origin = 0.0; - o = NULL; VTAILQ_FOREACH(oc, &oh->objcs, list) { /* Must be at least our own ref + the objcore we examine */ assert(oh->refcnt > 1); @@ -426,10 +424,9 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, if (BAN_CheckObject(wrk, oc, req)) continue; - o = ObjGetObj(oc, &wrk->stats); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + vary = ObjGetattr(oc, &wrk->stats, OA_VARY, NULL); - if (o->vary != NULL && !VRY_Match(req, o->vary)) + if (vary != NULL && !VRY_Match(req, vary)) continue; if (EXP_Ttl(req, &oc->exp) >= req->t_req) { @@ -448,13 +445,11 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, !(oc->flags & OC_F_PASS)) { /* record the newest object */ exp_oc = oc; - exp_o = o; exp_t_origin = oc->exp.t_origin; } } if (exp_oc != NULL) { - AN(exp_o); assert(oh->refcnt > 1); assert(exp_oc->objhead == oh); exp_oc->refcnt++; diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index b5a0faa..495599a 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -219,27 +219,32 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, ssize_t *len) { struct object *o; + ssize_t dummy; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(ds); - AN(len); + if (len == NULL) + len = &dummy; o = ObjGetObj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); switch (attr) { - case OA_VXID: - *len = sizeof o->oa_vxid; - return (o->oa_vxid); - case OA_LASTMODIFIED: - *len = sizeof o->oa_lastmodified; - return (o->oa_lastmodified); - case OA_GZIPBITS: - *len = sizeof o->oa_gzipbits; - return (o->oa_gzipbits); case OA_ESIDATA: if (o->esidata == NULL) return (NULL); *len = o->esidata->len; return (o->esidata->ptr); + case OA_GZIPBITS: + *len = sizeof o->oa_gzipbits; + return (o->oa_gzipbits); + case OA_LASTMODIFIED: + *len = sizeof o->oa_lastmodified; + return (o->oa_lastmodified); + case OA_VARY: + *len = 4; // XXX: hack + return (o->vary); + case OA_VXID: + *len = sizeof o->oa_vxid; + return (o->oa_vxid); default: break; } @@ -256,15 +261,15 @@ ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, o = ObjGetObj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); switch (attr) { - case OA_VXID: - assert(len == sizeof o->oa_vxid); - return (o->oa_vxid); case OA_GZIPBITS: assert(len == sizeof o->oa_gzipbits); return (o->oa_gzipbits); case OA_LASTMODIFIED: assert(len == sizeof o->oa_lastmodified); return (o->oa_lastmodified); + case OA_VXID: + assert(len == sizeof o->oa_vxid); + return (o->oa_vxid); default: break; } From phk at FreeBSD.org Tue Aug 5 10:07:39 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 05 Aug 2014 12:07:39 +0200 Subject: [master] 2d8b964 Keep req->objcore around. Message-ID: commit 2d8b9645be9c021475a3d683229f401e53f6910d Author: Poul-Henning Kamp Date: Tue Aug 5 08:42:22 2014 +0000 Keep req->objcore around. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 7b4b2f5..ccb837c 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -140,6 +140,7 @@ cnt_deliver(struct worker *wrk, struct req *req) if (wrk->handling != VCL_RET_DELIVER) { (void)HSH_DerefObj(&wrk->stats, &req->obj); AZ(req->obj); + req->objcore = NULL; http_Teardown(req->resp); switch (wrk->handling) { @@ -191,6 +192,7 @@ cnt_deliver(struct worker *wrk, struct req *req) assert(WRW_IsReleased(wrk)); VSLb(req->vsl, SLT_Debug, "XXX REF %d", req->obj->objcore->refcnt); (void)HSH_DerefObj(&wrk->stats, &req->obj); + req->objcore = NULL; http_Teardown(req->resp); return (REQ_FSM_DONE); } @@ -299,12 +301,11 @@ cnt_fetch(struct worker *wrk, struct req *req) req->err_code = 503; req->req_step = R_STP_SYNTH; (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); - req->objcore = NULL; + AZ(req->objcore); return (REQ_FSM_MORE); } req->obj = ObjGetObj(req->objcore, &wrk->stats); - req->objcore = NULL; req->err_code = http_GetStatus(req->obj->http); req->req_step = R_STP_DELIVER; return (REQ_FSM_MORE); @@ -441,6 +442,7 @@ cnt_lookup(struct worker *wrk, struct req *req) req->req_step = R_STP_MISS; else { (void)HSH_DerefObj(&wrk->stats, &req->obj); + req->objcore = NULL; /* * We don't have a busy object, so treat this * like a pass @@ -508,7 +510,8 @@ cnt_miss(struct worker *wrk, struct req *req) switch (wrk->handling) { case VCL_RET_FETCH: wrk->stats.cache_miss++; - VBF_Fetch(wrk, req, req->objcore, o == NULL ? NULL : o->objcore, VBF_NORMAL); + VBF_Fetch(wrk, req, req->objcore, + o == NULL ? NULL : o->objcore, VBF_NORMAL); req->req_step = R_STP_FETCH; if (o != NULL) (void)HSH_DerefObj(&wrk->stats, &o); @@ -703,7 +706,6 @@ cnt_recv(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->objcore); AZ(req->obj); - AZ(req->objcore); AZ(isnan(req->t_first)); AZ(isnan(req->t_prev)); From phk at FreeBSD.org Tue Aug 5 10:07:39 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 05 Aug 2014 12:07:39 +0200 Subject: [master] 9588e2d Do a "backend.list" to try to provoke any pending panics better, this CLI command goes to the varnish worker process if it is running and gives an error (which we ignore) if it isn't. Message-ID: commit 9588e2d3ff33c250e3f9d4172cadd26c41c2fb3f Author: Poul-Henning Kamp Date: Tue Aug 5 10:06:16 2014 +0000 Do a "backend.list" to try to provoke any pending panics better, this CLI command goes to the varnish worker process if it is running and gives an error (which we ignore) if it isn't. diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index c559810..469effd 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -576,11 +576,13 @@ varnish_wait(struct varnish *v) void *p; int status, r; struct rusage ru; + char *resp; if (v->cli_fd < 0) return; if (vtc_error) (void)sleep(1); /* give panic messages a chance */ + varnish_ask_cli(v, "backend.list", &resp); varnish_stop(v); vtc_log(v->vl, 2, "Wait"); AZ(close(v->cli_fd)); From martin at varnish-software.com Tue Aug 5 10:34:56 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 05 Aug 2014 12:34:56 +0200 Subject: [4.0] 69aecb8 Fix a race spotted by Nils: We have to hold a ref to the busyobj if we want to examine it in any detail. Message-ID: commit 69aecb867a0899607c79f41c0cb031c79e071d04 Author: Poul-Henning Kamp Date: Mon Jun 30 19:34:47 2014 +0000 Fix a race spotted by Nils: We have to hold a ref to the busyobj if we want to examine it in any detail. Hold that ref over all of V1D_Deliver() (different from Nils patch) to make sure we have a consistent view on streaming vs. no streaming throughout. Also use the bo to clean up a hack related to ESI includes. Diagnosed by: Nils Goroll diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index dc7e6f1..b95bc65 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -871,7 +871,7 @@ HTTP1_Chunked(struct http_conn *htc, intptr_t *priv, const char **error, /* cache_http1_deliver.c */ unsigned V1D_FlushReleaseAcct(struct req *req); -void V1D_Deliver(struct req *); +void V1D_Deliver(struct req *, struct busyobj *); void V1D_Deliver_Synth(struct req *req); diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 1bdcef7..73aea69 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -87,7 +87,7 @@ v1d_range_bytes(struct req *req, enum vdp_action act, const void *ptr, /*--------------------------------------------------------------------*/ static void -v1d_dorange(struct req *req, const char *r) +v1d_dorange(struct req *req, struct busyobj *bo, const char *r) { ssize_t len, low, high, has_low; @@ -96,8 +96,8 @@ v1d_dorange(struct req *req, const char *r) assert(http_GetStatus(req->obj->http) == 200); /* We must snapshot the length if we're streaming from the backend */ - if (req->obj->objcore->busyobj != NULL) - len = VBO_waitlen(req->obj->objcore->busyobj, -1); + if (bo != NULL) + len = VBO_waitlen(bo, -1); else len = req->obj->len; @@ -228,10 +228,11 @@ V1D_FlushReleaseAcct(struct req *req) } void -V1D_Deliver(struct req *req) +V1D_Deliver(struct req *req, struct busyobj *bo) { char *r; enum objiter_status ois; + ssize_t l; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); @@ -247,7 +248,7 @@ V1D_Deliver(struct req *req) req->res_mode &= ~RES_LEN; http_Unset(req->resp, H_Content_Length); req->wantbody = 0; - } else if (req->obj->objcore->busyobj == NULL) { + } else if (bo == NULL) { /* XXX: Not happy with this convoluted test */ req->res_mode |= RES_LEN; if (!(req->obj->objcore->flags & OC_F_PASS) || @@ -310,7 +311,7 @@ V1D_Deliver(struct req *req) http_GetStatus(req->resp) == 200) { http_SetHeader(req->resp, "Accept-Ranges: bytes"); if (http_GetHdr(req->http, H_Range, &r)) - v1d_dorange(req, r); + v1d_dorange(req, bo, r); } if (req->res_mode & RES_ESI) @@ -334,8 +335,11 @@ V1D_Deliver(struct req *req) } else if (req->res_mode & RES_ESI) { ESI_Deliver(req); } else if (req->res_mode & RES_ESI_CHILD && req->gzip_resp) { - while (req->obj->objcore->busyobj) - (void)usleep(10000); + l = -1; + while (req->obj->objcore->busyobj) { + assert(bo != NULL); + l = VBO_waitlen(bo, l); + } ESI_DeliverChild(req); } else if (req->res_mode & RES_GUNZIP || (req->res_mode & RES_ESI_CHILD && @@ -421,7 +425,7 @@ V1D_Deliver_Synth(struct req *req) http_GetStatus(req->resp) == 200) { http_SetHeader(req->resp, "Accept-Ranges: bytes"); if (http_GetHdr(req->http, H_Range, &r)) - v1d_dorange(req, r); + v1d_dorange(req, NULL, r); } WRW_Reserve(req->wrk, &req->sp->fd, req->vsl, req->t_prev); @@ -441,8 +445,6 @@ V1D_Deliver_Synth(struct req *req) #if 0 XXX: Missing pretend GZIP for esi-children } else if (req->res_mode & RES_ESI_CHILD && req->gzip_resp) { - while (req->obj->objcore->busyobj) - (void)usleep(10000); ESI_DeliverChild(req); #endif } else { diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 401ebf1..858406d 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -87,6 +87,7 @@ DOT deliver:deliver:s -> DONE [style=bold,color=blue] static enum req_fsm_nxt cnt_deliver(struct worker *wrk, struct req *req) { + struct busyobj *bo; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -154,7 +155,12 @@ cnt_deliver(struct worker *wrk, struct req *req) req->wantbody = 0; } - V1D_Deliver(req); + /* Grab a ref to the bo if there is one, and hand it down */ + bo = HSH_RefBusy(req->obj->objcore); + V1D_Deliver(req, bo); + if (bo != NULL) + VBO_DerefBusyObj(req->wrk, &bo); + VSLb_ts_req(req, "Resp", W_TIM_real(wrk)); if (http_HdrIs(req->resp, H_Connection, "close")) From martin at varnish-software.com Tue Aug 5 10:39:43 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 05 Aug 2014 12:39:43 +0200 Subject: [4.0] 1d05050 Fix memory leak on ESI Message-ID: commit 1d050505dfc6479849b1969a84647f6b87dae657 Author: Martin Blix Grydeland Date: Fri Jun 27 15:08:32 2014 +0200 Fix memory leak on ESI diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 3eb4c49..41bea3b 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -136,6 +136,7 @@ vfp_esi_end(struct busyobj *bo, struct vef_priv *vef, enum vfp_status retval) "ESI+Gzip Failed at the very end"); } if (vef->ibuf != NULL) + free(vef->ibuf); FREE_OBJ(vef); return (retval); } From phk at FreeBSD.org Tue Aug 5 10:50:24 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 05 Aug 2014 12:50:24 +0200 Subject: [master] 82f20ae Shift focus from object to objcore Message-ID: commit 82f20ae9ead143060694b8dc0ff657271742d8c5 Author: Poul-Henning Kamp Date: Tue Aug 5 10:50:04 2014 +0000 Shift focus from object to objcore diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index ccb837c..bc29e89 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -92,7 +92,9 @@ cnt_deliver(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(req->obj->objcore, OBJCORE_MAGIC); + assert(req->obj->objcore == req->objcore); CHECK_OBJ_NOTNULL(req->obj->objcore->objhead, OBJHEAD_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); assert(WRW_IsReleased(wrk)); @@ -138,9 +140,9 @@ cnt_deliver(struct worker *wrk, struct req *req) wrk->handling = VCL_RET_DELIVER; if (wrk->handling != VCL_RET_DELIVER) { - (void)HSH_DerefObj(&wrk->stats, &req->obj); - AZ(req->obj); - req->objcore = NULL; + assert(req->obj->objcore == req->objcore); + (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); + req->obj = NULL; http_Teardown(req->resp); switch (wrk->handling) { @@ -191,8 +193,9 @@ cnt_deliver(struct worker *wrk, struct req *req) assert(WRW_IsReleased(wrk)); VSLb(req->vsl, SLT_Debug, "XXX REF %d", req->obj->objcore->refcnt); - (void)HSH_DerefObj(&wrk->stats, &req->obj); - req->objcore = NULL; + assert(req->obj->objcore == req->objcore); + (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); + req->obj = NULL; http_Teardown(req->resp); return (REQ_FSM_DONE); } @@ -396,7 +399,7 @@ cnt_lookup(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AZ(oc->flags & OC_F_BUSY); - AZ(req->objcore); + req->objcore = oc; o = ObjGetObj(oc, &wrk->stats); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); @@ -408,8 +411,9 @@ cnt_lookup(struct worker *wrk, struct req *req) VSLb(req->vsl, SLT_HitPass, "%u", VXID(ObjGetXID(req->obj->objcore, &wrk->stats))); AZ(boc); - (void)HSH_DerefObj(&wrk->stats, &req->obj); - req->objcore = NULL; + assert(req->obj->objcore == req->objcore); + (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); + req->obj = NULL; wrk->stats.cache_hitpass++; req->req_step = R_STP_PASS; return (REQ_FSM_MORE); @@ -437,12 +441,13 @@ cnt_lookup(struct worker *wrk, struct req *req) req->req_step = R_STP_DELIVER; return (REQ_FSM_MORE); case VCL_RET_FETCH: - req->objcore = boc; - if (req->objcore != NULL) + if (boc != NULL) { + req->objcore = boc; req->req_step = R_STP_MISS; - else { - (void)HSH_DerefObj(&wrk->stats, &req->obj); - req->objcore = NULL; + } else { + assert(req->obj->objcore == req->objcore); + (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); + req->obj = NULL; /* * We don't have a busy object, so treat this * like a pass @@ -468,8 +473,9 @@ cnt_lookup(struct worker *wrk, struct req *req) } /* Drop our object, we won't need it */ - (void)HSH_DerefObj(&wrk->stats, &req->obj); - req->objcore = NULL; + assert(req->obj->objcore == req->objcore); + (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); + req->obj = NULL; if (boc != NULL) { (void)HSH_DerefObjCore(&wrk->stats, &boc); From nils.goroll at uplex.de Tue Aug 5 11:08:27 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 05 Aug 2014 13:08:27 +0200 Subject: [master] 73351be Fix errnous dates in the old specfile entries that give warnings on fedora. Message-ID: commit 73351bed8f437ea4e2b1651827dad586f412b889 Author: Nils Goroll Date: Tue Aug 5 13:06:59 2014 +0200 Fix errnous dates in the old specfile entries that give warnings on fedora. Patch by ingvar at redpill-linpro.com https://www.varnish-cache.org/patchwork/patch/145/ diff --git a/redhat/varnish.spec b/redhat/varnish.spec index 8b8eaff..ad2a914 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -347,7 +347,7 @@ fi - Merged some changes from fedora - Upped general version to 3.0 prerelease in trunk -* Wed Nov 04 2010 Ingvar Hagelund - 2.1.4-4 +* Thu Nov 04 2010 Ingvar Hagelund - 2.1.4-4 - Added a patch fixing a missing echo in the init script that masked failure output from the script - Added a patch from upstream, fixing a problem with Content-Length @@ -428,7 +428,7 @@ fi * Sun Jul 26 2009 Fedora Release Engineering - 2.0.4-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild -* Thu May 04 2009 Ingvar Hagelund - 2.0.4-2 +* Thu Jun 04 2009 Ingvar Hagelund - 2.0.4-2 - Added a s390 specific patch to libjemalloc. * Fri Mar 27 2009 Ingvar Hagelund - 2.0.4-1 @@ -529,11 +529,11 @@ fi - Bumped the version number to 1.1.2. - Addeed build dependency on libxslt -* Wed Sep 08 2007 Ingvar Hagelund - 1.1.1-3 +* Fri Sep 07 2007 Ingvar Hagelund - 1.1.1-3 - Added a patch, changeset 1913 from svn trunk. This makes varnish more stable under specific loads. -* Tue Sep 06 2007 Ingvar Hagelund - 1.1.1-2 +* Thu Sep 06 2007 Ingvar Hagelund - 1.1.1-2 - Removed autogen call (only diff from relase tarball) * Mon Aug 20 2007 Ingvar Hagelund - 1.1.1-1 From nils.goroll at uplex.de Tue Aug 5 11:09:30 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 05 Aug 2014 13:09:30 +0200 Subject: [4.0] f642ddd Fix errnous dates in the old specfile entries that give warnings on fedora. Message-ID: commit f642ddde54a8ee0a2d8c15fb44b12920ad17a708 Author: Nils Goroll Date: Tue Aug 5 13:06:59 2014 +0200 Fix errnous dates in the old specfile entries that give warnings on fedora. Patch by ingvar at redpill-linpro.com https://www.varnish-cache.org/patchwork/patch/145/ diff --git a/redhat/varnish.spec b/redhat/varnish.spec index b541d91..7e7e87f 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -342,7 +342,7 @@ fi - Merged some changes from fedora - Upped general version to 3.0 prerelease in trunk -* Wed Nov 04 2010 Ingvar Hagelund - 2.1.4-4 +* Thu Nov 04 2010 Ingvar Hagelund - 2.1.4-4 - Added a patch fixing a missing echo in the init script that masked failure output from the script - Added a patch from upstream, fixing a problem with Content-Length @@ -423,7 +423,7 @@ fi * Sun Jul 26 2009 Fedora Release Engineering - 2.0.4-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild -* Thu May 04 2009 Ingvar Hagelund - 2.0.4-2 +* Thu Jun 04 2009 Ingvar Hagelund - 2.0.4-2 - Added a s390 specific patch to libjemalloc. * Fri Mar 27 2009 Ingvar Hagelund - 2.0.4-1 @@ -524,11 +524,11 @@ fi - Bumped the version number to 1.1.2. - Addeed build dependency on libxslt -* Wed Sep 08 2007 Ingvar Hagelund - 1.1.1-3 +* Fri Sep 07 2007 Ingvar Hagelund - 1.1.1-3 - Added a patch, changeset 1913 from svn trunk. This makes varnish more stable under specific loads. -* Tue Sep 06 2007 Ingvar Hagelund - 1.1.1-2 +* Thu Sep 06 2007 Ingvar Hagelund - 1.1.1-2 - Removed autogen call (only diff from relase tarball) * Mon Aug 20 2007 Ingvar Hagelund - 1.1.1-1 From phk at FreeBSD.org Tue Aug 5 11:40:29 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 05 Aug 2014 13:40:29 +0200 Subject: [master] 93d2928 Use req->objcore rather than req->obj Message-ID: commit 93d292804ed8644d15cbb9165a83a571e578a3d4 Author: Poul-Henning Kamp Date: Tue Aug 5 11:40:14 2014 +0000 Use req->objcore rather than req->obj diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index ab5590a..3f50a4b 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -481,10 +481,10 @@ VRT_r_##which##_##fld(const struct vrt_ctx *ctx) \ return(0.0); \ } -VRT_DO_EXP_R(obj, ctx->req->obj->objcore->exp, ttl, - (ctx->req->t_req - ctx->req->obj->objcore->exp.t_origin)) -VRT_DO_EXP_R(obj, ctx->req->obj->objcore->exp, grace, 0) -VRT_DO_EXP_R(obj, ctx->req->obj->objcore->exp, keep, 0) +VRT_DO_EXP_R(obj, ctx->req->objcore->exp, ttl, + (ctx->req->t_req - ctx->req->objcore->exp.t_origin)) +VRT_DO_EXP_R(obj, ctx->req->objcore->exp, grace, 0) +VRT_DO_EXP_R(obj, ctx->req->objcore->exp, keep, 0) VRT_DO_EXP_L(beresp, ctx->bo->fetch_objcore->exp, ttl) VRT_DO_EXP_R(beresp, ctx->bo->fetch_objcore->exp, ttl, 0) @@ -591,10 +591,9 @@ VRT_r_obj_hits(const struct vrt_ctx *ctx) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req->obj, OBJECT_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req->obj->objcore, OBJCORE_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req->obj->objcore->objhead, OBJHEAD_MAGIC); - return (ctx->req->obj->objcore->objhead->hits); + CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->objcore->objhead, OBJHEAD_MAGIC); + return (ctx->req->objcore->objhead->hits); } unsigned @@ -603,8 +602,8 @@ VRT_r_obj_uncacheable(const struct vrt_ctx *ctx) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req->obj, OBJECT_MAGIC); - return (ctx->req->obj->objcore->flags & OC_F_PASS ? 1 : 0); + CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); + return (ctx->req->objcore->flags & OC_F_PASS ? 1 : 0); } /*--------------------------------------------------------------------*/ From phk at FreeBSD.org Tue Aug 5 12:00:12 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 05 Aug 2014 14:00:12 +0200 Subject: [master] 01ccb32 Eliminate a couple of trivial uses of req->obj Message-ID: commit 01ccb3200d4f9e97b3508c7d5036b247505ca3fa Author: Poul-Henning Kamp Date: Tue Aug 5 11:59:56 2014 +0000 Eliminate a couple of trivial uses of req->obj diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 3266ade..ba145ea 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -264,7 +264,7 @@ ESI_Deliver(struct req *req) int i; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - p = ObjGetattr(req->obj->objcore, &req->wrk->stats, OA_ESIDATA, &l); + p = ObjGetattr(req->objcore, &req->wrk->stats, OA_ESIDATA, &l); AN(p); assert(l > 0); e = p + l; diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 73aea69..2817d09 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -235,12 +235,12 @@ V1D_Deliver(struct req *req, struct busyobj *bo) ssize_t l; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(req->obj->objcore, OBJCORE_MAGIC); req->res_mode = 0; - if (!req->disable_esi && req->obj->esidata != NULL) { + if (!req->disable_esi && ObjGetattr(req->objcore, &req->wrk->stats, + OA_ESIDATA, NULL) != NULL) { /* In ESI mode, we can't know the aggregate length */ req->res_mode &= ~RES_LEN; req->res_mode |= RES_ESI; From phk at FreeBSD.org Tue Aug 5 12:15:32 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 05 Aug 2014 14:15:32 +0200 Subject: [master] d717b1b More trivial changes to use req->objcore instead of req->obj Message-ID: commit d717b1bc803d9088c872213f9b3f801fb86b0f8e Author: Poul-Henning Kamp Date: Tue Aug 5 12:14:58 2014 +0000 More trivial changes to use req->objcore instead of req->obj diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 2817d09..83eb73d 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -235,7 +235,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo) ssize_t l; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->obj->objcore, OBJCORE_MAGIC); + CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); req->res_mode = 0; @@ -251,7 +251,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo) } else if (bo == NULL) { /* XXX: Not happy with this convoluted test */ req->res_mode |= RES_LEN; - if (!(req->obj->objcore->flags & OC_F_PASS) || + if (!(req->objcore->flags & OC_F_PASS) || req->obj->len != 0) { http_Unset(req->resp, H_Content_Length); http_PrintfHeader(req->resp, @@ -336,7 +336,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo) ESI_Deliver(req); } else if (req->res_mode & RES_ESI_CHILD && req->gzip_resp) { l = -1; - while (req->obj->objcore->busyobj) { + while (req->objcore->busyobj) { assert(bo != NULL); l = VBO_waitlen(bo, l); } diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 111e8c5..20225b5 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -397,8 +397,8 @@ pan_req(const struct req *req) pan_vcl(req->vcl); if (VALID_OBJ(req->obj, OBJECT_MAGIC)) { - if (req->obj->objcore->busyobj != NULL) - pan_busyobj(req->obj->objcore->busyobj); + if (req->objcore->busyobj != NULL) + pan_busyobj(req->objcore->busyobj); pan_object("REQ", req->obj); } diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index bc29e89..ed30dd0 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -95,14 +95,14 @@ cnt_deliver(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(req->obj->objcore, OBJCORE_MAGIC); assert(req->obj->objcore == req->objcore); - CHECK_OBJ_NOTNULL(req->obj->objcore->objhead, OBJHEAD_MAGIC); + CHECK_OBJ_NOTNULL(req->objcore->objhead, OBJHEAD_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); assert(WRW_IsReleased(wrk)); - assert(req->obj->objcore->refcnt > 0); + assert(req->objcore->refcnt > 0); - if (req->obj->objcore->exp_flags & OC_EF_EXP) - EXP_Touch(req->obj->objcore, req->t_prev); + if (req->objcore->exp_flags & OC_EF_EXP) + EXP_Touch(req->objcore, req->t_prev); HTTP_Setup(req->resp, req->ws, req->vsl, SLT_RespMethod); http_FilterResp(req->obj->http, req->resp, 0); @@ -111,7 +111,7 @@ cnt_deliver(struct worker *wrk, struct req *req) if (req->wrk->stats.cache_hit) http_PrintfHeader(req->resp, "X-Varnish: %u %u", VXID(req->vsl->wid), - VXID(ObjGetXID(req->obj->objcore, &wrk->stats))); + VXID(ObjGetXID(req->objcore, &wrk->stats))); else http_PrintfHeader(req->resp, "X-Varnish: %u", VXID(req->vsl->wid)); @@ -124,7 +124,7 @@ cnt_deliver(struct worker *wrk, struct req *req) age. Truncate to zero in that case). */ http_PrintfHeader(req->resp, "Age: %.0f", - fmax(0., req->t_prev - req->obj->objcore->exp.t_origin)); + fmax(0., req->t_prev - req->objcore->exp.t_origin)); http_SetHeader(req->resp, "Via: 1.1 varnish-v4"); @@ -140,7 +140,7 @@ cnt_deliver(struct worker *wrk, struct req *req) wrk->handling = VCL_RET_DELIVER; if (wrk->handling != VCL_RET_DELIVER) { - assert(req->obj->objcore == req->objcore); + assert(req->objcore == req->objcore); (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); req->obj = NULL; http_Teardown(req->resp); @@ -161,7 +161,7 @@ cnt_deliver(struct worker *wrk, struct req *req) assert(wrk->handling == VCL_RET_DELIVER); - if (!(req->obj->objcore->flags & OC_F_PASS) + if (!(req->objcore->flags & OC_F_PASS) && req->esi_level == 0 && http_GetStatus(req->obj->http) == 200 && req->http->conds && RFC2616_Do_Cond(req)) { @@ -170,7 +170,7 @@ cnt_deliver(struct worker *wrk, struct req *req) } /* Grab a ref to the bo if there is one, and hand it down */ - bo = HSH_RefBusy(req->obj->objcore); + bo = HSH_RefBusy(req->objcore); V1D_Deliver(req, bo); if (bo != NULL) VBO_DerefBusyObj(req->wrk, &bo); @@ -180,19 +180,19 @@ cnt_deliver(struct worker *wrk, struct req *req) if (http_HdrIs(req->resp, H_Connection, "close")) req->doclose = SC_RESP_CLOSE; - if (req->obj->objcore->flags & OC_F_PASS) { + if (req->objcore->flags & OC_F_PASS) { /* * No point in saving the body if it is hit-for-pass, * but we can't yank it until the fetching thread has * finished/abandoned also. */ - while (req->obj->objcore->busyobj != NULL) + while (req->objcore->busyobj != NULL) (void)usleep(100000); STV_Freestore(req->obj); } assert(WRW_IsReleased(wrk)); -VSLb(req->vsl, SLT_Debug, "XXX REF %d", req->obj->objcore->refcnt); +VSLb(req->vsl, SLT_Debug, "XXX REF %d", req->objcore->refcnt); assert(req->obj->objcore == req->objcore); (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); req->obj = NULL; @@ -409,7 +409,7 @@ cnt_lookup(struct worker *wrk, struct req *req) /* Found a hit-for-pass */ VSLb(req->vsl, SLT_Debug, "XXXX HIT-FOR-PASS"); VSLb(req->vsl, SLT_HitPass, "%u", - VXID(ObjGetXID(req->obj->objcore, &wrk->stats))); + VXID(ObjGetXID(req->objcore, &wrk->stats))); AZ(boc); assert(req->obj->objcore == req->objcore); (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); @@ -423,7 +423,7 @@ cnt_lookup(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); VSLb(req->vsl, SLT_Hit, "%u", - VXID(ObjGetXID(req->obj->objcore, &wrk->stats))); + VXID(ObjGetXID(req->objcore, &wrk->stats))); VCL_hit_method(req->vcl, wrk, req, NULL, req->http->ws); diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 1c26641..ab5edd7 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -355,7 +355,7 @@ RFC2616_Do_Cond(const struct req *req) ims = VTIM_parse(p); if (ims > req->t_req) /* [RFC2616 14.25] */ return (0); - lm = ObjGetLastModified(req->obj->objcore, &req->wrk->stats); + lm = ObjGetLastModified(req->objcore, &req->wrk->stats); if (lm > ims) return (0); do_cond = 1; diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index edfa2a5..46f3e02 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -500,7 +500,7 @@ VRT_purge(const struct vrt_ctx *ctx, double ttl, double grace, double keep) CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); CHECK_OBJ_NOTNULL(ctx->req->wrk, WORKER_MAGIC); if (ctx->method == VCL_MET_HIT) - HSH_Purge(ctx->req->wrk, ctx->req->obj->objcore->objhead, + HSH_Purge(ctx->req->wrk, ctx->req->objcore->objhead, ttl, grace, keep); else if (ctx->method == VCL_MET_MISS) HSH_Purge(ctx->req->wrk, ctx->req->objcore->objhead, From phk at FreeBSD.org Tue Aug 5 12:38:50 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 05 Aug 2014 14:38:50 +0200 Subject: [master] 9827226 More req->obj low hanging fruit Message-ID: commit 982722651d0dc6a23cd10c219110341bac1b0b56 Author: Poul-Henning Kamp Date: Tue Aug 5 12:38:33 2014 +0000 More req->obj low hanging fruit diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index ba145ea..12cb10f 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -262,9 +262,13 @@ ESI_Deliver(struct req *req) size_t dl; const void *dp; int i; + struct object *obj; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); p = ObjGetattr(req->objcore, &req->wrk->stats, OA_ESIDATA, &l); + obj = ObjGetObj(req->objcore, &req->wrk->stats); + CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); AN(p); assert(l > 0); e = p + l; @@ -304,7 +308,7 @@ ESI_Deliver(struct req *req) AZ(dl); } - st = VTAILQ_FIRST(&req->obj->body->list); + st = VTAILQ_FIRST(&obj->body->list); off = 0; while (p < e) { @@ -455,14 +459,15 @@ ESI_Deliver(struct req *req) */ static uint8_t -ved_deliver_byterange(struct req *req, ssize_t low, ssize_t high) +ved_deliver_byterange(struct req *req, const struct object *obj, ssize_t low, + ssize_t high) { struct storage *st; ssize_t l, lx; u_char *p; lx = 0; - VTAILQ_FOREACH(st, &req->obj->body->list, list) { + VTAILQ_FOREACH(st, &obj->body->list, list) { p = st->ptr; l = st->len; if (lx + l < low) { @@ -505,8 +510,13 @@ ESI_DeliverChild(struct req *req) uint8_t tailbuf[8]; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (!req->obj->gziped) { - VTAILQ_FOREACH(st, &req->obj->body->list, list) + CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); + + obj = ObjGetObj(req->objcore, &req->wrk->stats); + CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); + + if (!obj->gziped) { + VTAILQ_FOREACH(st, &obj->body->list, list) ved_pretend_gzip(req, st->ptr, st->len); return; } @@ -518,8 +528,6 @@ ESI_DeliverChild(struct req *req) dbits = (void*)WS_Alloc(req->ws, 8); AN(dbits); - obj = req->obj; - CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); p = ObjGetattr(obj->objcore, &req->wrk->stats, OA_GZIPBITS, &l); AN(p); assert(l == 24); @@ -539,10 +547,10 @@ ESI_DeliverChild(struct req *req) * XXX: optimize for the case where the 'last' * XXX: bit is in a empty copy block */ - *dbits = ved_deliver_byterange(req, start/8, last/8); + *dbits = ved_deliver_byterange(req, obj, start/8, last/8); *dbits &= ~(1U << (last & 7)); req->resp_bodybytes += WRW_Write(req->wrk, dbits, 1); - cc = ved_deliver_byterange(req, 1 + last/8, stop/8); + cc = ved_deliver_byterange(req, obj, 1 + last/8, stop/8); switch((int)(stop & 7)) { case 0: /* xxxxxxxx */ /* I think we have an off by one here, but that's OK */ @@ -588,7 +596,7 @@ ESI_DeliverChild(struct req *req) req->resp_bodybytes += WRW_Write(req->wrk, dbits + 1, lpad); /* We need the entire tail, but it may not be in one storage segment */ - st = VTAILQ_LAST(&req->obj->body->list, storagehead); + st = VTAILQ_LAST(&obj->body->list, storagehead); for (i = sizeof tailbuf; i > 0; i -= j) { j = st->len; if (j > i) From nils.goroll at uplex.de Tue Aug 5 12:53:26 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 05 Aug 2014 14:53:26 +0200 Subject: [3.0] 779ab3a always include config.h first Message-ID: commit 779ab3a41fbd19f9f916b972c0215d05d6d3e335 Author: Nils Goroll Date: Tue Aug 5 14:53:00 2014 +0200 always include config.h first Solaris (and others?) need defines from it (GNU_SOURCE in particular) diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 544e2dc..f31d1ad 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -26,6 +26,7 @@ * SUCH DAMAGE. */ +#include "config.h" #include #include #include diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index 6f06c2c..5b1b1a1 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -27,6 +27,7 @@ * */ +#include "config.h" #include #include #include diff --git a/lib/libvmod_std/vmod_std_fileread.c b/lib/libvmod_std/vmod_std_fileread.c index e1be09a..49d4f4c 100644 --- a/lib/libvmod_std/vmod_std_fileread.c +++ b/lib/libvmod_std/vmod_std_fileread.c @@ -37,6 +37,7 @@ * XXX: underlying file has been updated. */ +#include "config.h" #include #include "vrt.h" #include "../../bin/varnishd/cache.h" From phk at FreeBSD.org Tue Aug 5 13:51:02 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 05 Aug 2014 15:51:02 +0200 Subject: [master] c0f7ed6 More req->obj to req->objcore movement Message-ID: commit c0f7ed645f5be3be0b41710c6f978ce6a4f31538 Author: Poul-Henning Kamp Date: Tue Aug 5 13:50:44 2014 +0000 More req->obj to req->objcore movement diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index af290cd..6c5251b 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -649,6 +649,7 @@ struct req { struct ws ws[1]; struct object *obj; struct objcore *objcore; + struct objcore *ims_oc; /* Lookup stuff */ struct SHA256Context *sha256ctx; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index ed30dd0..596a68d 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -91,14 +91,14 @@ cnt_deliver(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); - CHECK_OBJ_NOTNULL(req->obj->objcore, OBJCORE_MAGIC); - assert(req->obj->objcore == req->objcore); CHECK_OBJ_NOTNULL(req->objcore->objhead, OBJHEAD_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); assert(WRW_IsReleased(wrk)); + req->obj = ObjGetObj(req->objcore, &wrk->stats); + CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); + assert(req->objcore->refcnt > 0); if (req->objcore->exp_flags & OC_EF_EXP) @@ -308,8 +308,6 @@ cnt_fetch(struct worker *wrk, struct req *req) return (REQ_FSM_MORE); } - req->obj = ObjGetObj(req->objcore, &wrk->stats); - req->err_code = http_GetStatus(req->obj->http); req->req_step = R_STP_DELIVER; return (REQ_FSM_MORE); } @@ -346,8 +344,6 @@ static enum req_fsm_nxt cnt_lookup(struct worker *wrk, struct req *req) { struct objcore *oc, *boc; - struct object *o; - struct objhead *oh; enum lookup_e lr; int had_objhead = 0; @@ -390,6 +386,7 @@ cnt_lookup(struct worker *wrk, struct req *req) /* Found nothing */ VSLb(req->vsl, SLT_Debug, "XXXX MISS"); AZ(oc); + AZ(req->obj); AN(boc); AN(boc->flags & OC_F_BUSY); req->objcore = boc; @@ -401,27 +398,19 @@ cnt_lookup(struct worker *wrk, struct req *req) AZ(oc->flags & OC_F_BUSY); req->objcore = oc; - o = ObjGetObj(oc, &wrk->stats); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - req->obj = o; - if (oc->flags & OC_F_PASS) { /* Found a hit-for-pass */ VSLb(req->vsl, SLT_Debug, "XXXX HIT-FOR-PASS"); VSLb(req->vsl, SLT_HitPass, "%u", VXID(ObjGetXID(req->objcore, &wrk->stats))); AZ(boc); - assert(req->obj->objcore == req->objcore); + AZ(req->obj); (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); - req->obj = NULL; wrk->stats.cache_hitpass++; req->req_step = R_STP_PASS; return (REQ_FSM_MORE); } - oh = oc->objhead; - CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); - VSLb(req->vsl, SLT_Hit, "%u", VXID(ObjGetXID(req->objcore, &wrk->stats))); @@ -441,13 +430,13 @@ cnt_lookup(struct worker *wrk, struct req *req) req->req_step = R_STP_DELIVER; return (REQ_FSM_MORE); case VCL_RET_FETCH: + AZ(req->obj); if (boc != NULL) { req->objcore = boc; + req->ims_oc = oc; req->req_step = R_STP_MISS; } else { - assert(req->obj->objcore == req->objcore); (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); - req->obj = NULL; /* * We don't have a busy object, so treat this * like a pass @@ -473,9 +462,8 @@ cnt_lookup(struct worker *wrk, struct req *req) } /* Drop our object, we won't need it */ - assert(req->obj->objcore == req->objcore); + AZ(req->obj); (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); - req->obj = NULL; if (boc != NULL) { (void)HSH_DerefObjCore(&wrk->stats, &boc); @@ -502,25 +490,20 @@ DOT static enum req_fsm_nxt cnt_miss(struct worker *wrk, struct req *req) { - struct object *o; 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); - o = req->obj; - req->obj = NULL; - VCL_miss_method(req->vcl, wrk, req, NULL, req->http->ws); switch (wrk->handling) { case VCL_RET_FETCH: wrk->stats.cache_miss++; - VBF_Fetch(wrk, req, req->objcore, - o == NULL ? NULL : o->objcore, VBF_NORMAL); + VBF_Fetch(wrk, req, req->objcore, req->ims_oc, VBF_NORMAL); req->req_step = R_STP_FETCH; - if (o != NULL) - (void)HSH_DerefObj(&wrk->stats, &o); + if (req->ims_oc != NULL) + (void)HSH_DerefObjCore(&wrk->stats, &req->ims_oc); return (REQ_FSM_MORE); case VCL_RET_SYNTH: req->req_step = R_STP_SYNTH; @@ -535,8 +518,8 @@ cnt_miss(struct worker *wrk, struct req *req) WRONG("Illegal return from vcl_miss{}"); } VRY_Clear(req); - if (o != NULL) - (void)HSH_DerefObj(&wrk->stats, &o); + if (req->ims_oc != NULL) + (void)HSH_DerefObjCore(&wrk->stats, &req->ims_oc); AZ(HSH_DerefObjCore(&wrk->stats, &req->objcore)); return (REQ_FSM_MORE); } diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 7e48a86..db1feb3 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -432,8 +432,9 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, ctx.http_req = req->http; ctx.http_resp = req->resp; ctx.req = req; - if (req->obj) - ctx.http_obj = req->obj->http; + if (method == VCL_MET_HIT) + ctx.http_obj = + ObjGetObj(req->objcore, &wrk->stats)->http; } if (bo != NULL) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); From phk at FreeBSD.org Wed Aug 6 08:49:23 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 06 Aug 2014 10:49:23 +0200 Subject: [master] dd7083a Make generic functions for OA's in double format. Message-ID: commit dd7083a2d192122d688c544506d0d1a23032d7d6 Author: Poul-Henning Kamp Date: Wed Aug 6 08:49:02 2014 +0000 Make generic functions for OA's in double format. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 6c5251b..30bee0e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1065,8 +1065,9 @@ void *ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, ssize_t len); int ObjCopyAttr(struct objcore *ocd, struct objcore *ocs, struct dstat *ds, enum obj_attr attr); -int ObjSetLastModified(struct objcore *oc, struct dstat *ds, double t); -double ObjGetLastModified(struct objcore *oc, struct dstat *ds); + +int ObjSetDouble(struct objcore *, struct dstat *, enum obj_attr, double); +int ObjGetDouble(struct objcore *, struct dstat *, enum obj_attr, double *); /* cache_panic.c */ void PAN_Init(void); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 70f467a..12faa3c 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -165,10 +165,10 @@ vbf_beresp2obj(struct busyobj *bo) http_CopyHome(hp2); if (http_GetHdr(hp, H_Last_Modified, &b)) - AZ(ObjSetLastModified(bo->fetch_objcore, bo->stats, + AZ(ObjSetDouble(bo->fetch_objcore, bo->stats, OA_LASTMODIFIED, VTIM_parse(b))); else - AZ(ObjSetLastModified(bo->fetch_objcore, bo->stats, + AZ(ObjSetDouble(bo->fetch_objcore, bo->stats, OA_LASTMODIFIED, floor(bo->fetch_objcore->exp.t_origin))); /* Disassociate the obj from the bo's workspace */ diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 495599a..f43893d 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -307,36 +307,43 @@ ObjGetXID(struct objcore *oc, struct dstat *ds) } /*-------------------------------------------------------------------- - * NB: Copying double <--> uint64_t for endian encoding is unverified + * There is no well-defined byteorder for IEEE-754 double and the + * correct solution (frexp(3) and manual encoding) is more work + * than our (weak) goal of being endian-agnostic requires at this point. + * We give it a shot by memcpy'ing doubles over a uint64_t and then + * BE encode that. */ int -ObjSetLastModified(struct objcore *oc, struct dstat *ds, double t) +ObjSetDouble(struct objcore *oc, struct dstat *ds, enum obj_attr a, double t) { void *vp; uint64_t u; assert(sizeof t == sizeof u); memcpy(&u, &t, sizeof u); - vp = ObjSetattr(oc, ds, OA_LASTMODIFIED, sizeof u); + vp = ObjSetattr(oc, ds, a, sizeof u); if (vp == NULL) return (-1); vbe64enc(vp, u); return (0); } -double -ObjGetLastModified(struct objcore *oc, struct dstat *ds) +int +ObjGetDouble(struct objcore *oc, struct dstat *ds, enum obj_attr a, double *d) { void *vp; uint64_t u; - double d; ssize_t l; - vp = ObjGetattr(oc, ds, OA_LASTMODIFIED, &l); - AN(vp); - assert(l == sizeof u); - u = vbe64dec(vp); - memcpy(&d, &u, sizeof d); - return (d); + assert(sizeof *d == sizeof u); + vp = ObjGetattr(oc, ds, a, &l); + if (vp == NULL) + return (-1); + if (d != NULL) { + assert(l == sizeof u); + u = vbe64dec(vp); + memcpy(d, &u, sizeof *d); + } + return (0); } diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index ab5edd7..6dc75ef 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -355,7 +355,8 @@ RFC2616_Do_Cond(const struct req *req) ims = VTIM_parse(p); if (ims > req->t_req) /* [RFC2616 14.25] */ return (0); - lm = ObjGetLastModified(req->objcore, &req->wrk->stats); + AZ(ObjGetDouble(req->objcore, &req->wrk->stats, + OA_LASTMODIFIED, &lm)); if (lm > ims) return (0); do_cond = 1; From phk at FreeBSD.org Wed Aug 6 09:10:38 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 06 Aug 2014 11:10:38 +0200 Subject: [master] 6ce5b1e Add generic uint{32, 64} OA_ accessor functions, use for VXID. Message-ID: commit 6ce5b1ef31a622c78283b9b6960cfe38ca90f899 Author: Poul-Henning Kamp Date: Wed Aug 6 09:10:11 2014 +0000 Add generic uint{32,64} OA_ accessor functions, use for VXID. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 30bee0e..856d5cd 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1068,6 +1068,10 @@ int ObjCopyAttr(struct objcore *ocd, struct objcore *ocs, struct dstat *ds, int ObjSetDouble(struct objcore *, struct dstat *, enum obj_attr, double); int ObjGetDouble(struct objcore *, struct dstat *, enum obj_attr, double *); +int ObjSetU32(struct objcore *, struct dstat *, enum obj_attr, uint32_t); +int ObjGetU32(struct objcore *, struct dstat *, enum obj_attr, uint32_t *); +int ObjSetU64(struct objcore *, struct dstat *, enum obj_attr, uint64_t); +int ObjGetU64(struct objcore *, struct dstat *, enum obj_attr, uint64_t *); /* cache_panic.c */ void PAN_Init(void); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 12faa3c..5b66145 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -102,7 +102,6 @@ vbf_beresp2obj(struct busyobj *bo) uint16_t nhttp; struct object *obj; struct http *hp, *hp2; - void *vp; l = 0; @@ -152,8 +151,7 @@ vbf_beresp2obj(struct busyobj *bo) VSB_delete(vary); } - vp = ObjSetattr(bo->fetch_objcore, bo->stats, OA_VXID, 4); - vbe32enc(vp, bo->vsl->wid); + AZ(ObjSetU32(bo->fetch_objcore, bo->stats, OA_VXID, bo->vsl->wid)); WS_Assert(bo->ws_o); /* Filter into object */ diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index f43893d..d5b7390 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -297,13 +297,10 @@ ObjCopyAttr(struct objcore *ocd, struct objcore *ocs, struct dstat *ds, unsigned ObjGetXID(struct objcore *oc, struct dstat *ds) { - ssize_t l; - void *p; + uint32_t u; - p = ObjGetattr(oc, ds, OA_VXID, &l); - AN(p); - assert(l == 4); - return (vbe32dec(p)); + AZ(ObjGetU32(oc, ds, OA_VXID, &u)); + return (u); } /*-------------------------------------------------------------------- @@ -347,3 +344,58 @@ ObjGetDouble(struct objcore *oc, struct dstat *ds, enum obj_attr a, double *d) } return (0); } + +/*-------------------------------------------------------------------- + */ + +int +ObjSetU64(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint64_t t) +{ + void *vp; + + vp = ObjSetattr(oc, ds, a, sizeof t); + if (vp == NULL) + return (-1); + vbe64enc(vp, t); + return (0); +} + +int +ObjGetU64(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint64_t *d) +{ + void *vp; + ssize_t l; + + vp = ObjGetattr(oc, ds, a, &l); + if (vp == NULL || l != sizeof *d) + return (-1); + if (d != NULL) + *d = vbe64dec(vp); + return (0); +} + +int +ObjSetU32(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint32_t t) +{ + void *vp; + + vp = ObjSetattr(oc, ds, a, sizeof t); + if (vp == NULL) + return (-1); + vbe32enc(vp, t); + return (0); +} + +int +ObjGetU32(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint32_t *d) +{ + void *vp; + ssize_t l; + + vp = ObjGetattr(oc, ds, a, &l); + if (vp == NULL || l != sizeof *d) + return (-1); + if (d != NULL) + *d = vbe32dec(vp); + return (0); +} From phk at FreeBSD.org Wed Aug 6 09:19:22 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 06 Aug 2014 11:19:22 +0200 Subject: [master] 4300c74 Strip the tag bits when setting obj->vxid rather than everytime we put it into a http-header. Message-ID: commit 4300c741125d9b45ba1660179a79907be3943d98 Author: Poul-Henning Kamp Date: Wed Aug 6 09:18:42 2014 +0000 Strip the tag bits when setting obj->vxid rather than everytime we put it into a http-header. diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 552b67a..fdd0443 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -968,7 +968,7 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req) } else { oc->ban = NULL; VSLb(vsl, SLT_ExpBan, "%u banned lookup", - VXID(ObjGetXID(oc, &wrk->stats))); + ObjGetXID(oc, &wrk->stats)); VSC_C_main->bans_obj_killed++; EXP_Rearm(oc, oc->exp.t_origin, 0, 0, 0); // XXX fake now return (1); @@ -1104,7 +1104,7 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt, } if (i) { VSLb(vsl, SLT_ExpBan, "%u banned by lurker", - VXID(ObjGetXID(oc, &wrk->stats))); + ObjGetXID(oc, &wrk->stats)); EXP_Rearm(oc, oc->exp.t_origin, 0, 0, 0); // XXX fake now VSC_C_main->bans_lurker_obj_killed++; } diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 6cea948..2afb254 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -340,7 +340,7 @@ EXP_NukeOne(struct busyobj *bo, struct lru *lru) exp_mail_it(oc); - VSLb(bo->vsl, SLT_ExpKill, "LRU x=%u", VXID(ObjGetXID(oc, bo->stats))); + VSLb(bo->vsl, SLT_ExpKill, "LRU x=%u", ObjGetXID(oc, bo->stats)); AN(bo->stats); AN(oc); (void)HSH_DerefObjCore(bo->stats, &oc); @@ -472,7 +472,7 @@ exp_expire(struct exp_priv *ep, double now) o = ObjGetObj(oc, &ep->wrk->stats); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); VSLb(&ep->vsl, SLT_ExpKill, "EXP_Expired x=%u t=%.0f", - VXID(ObjGetXID(oc, &ep->wrk->stats)), + ObjGetXID(oc, &ep->wrk->stats), EXP_Ttl(NULL, &oc->exp) - now); (void)HSH_DerefObjCore(&ep->wrk->stats, &oc); return (0); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 5b66145..4fab36b 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -151,7 +151,8 @@ vbf_beresp2obj(struct busyobj *bo) VSB_delete(vary); } - AZ(ObjSetU32(bo->fetch_objcore, bo->stats, OA_VXID, bo->vsl->wid)); + AZ(ObjSetU32(bo->fetch_objcore, bo->stats, OA_VXID, + VXID(bo->vsl->wid))); WS_Assert(bo->ws_o); /* Filter into object */ diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 596a68d..a07f12f 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -111,7 +111,7 @@ cnt_deliver(struct worker *wrk, struct req *req) if (req->wrk->stats.cache_hit) http_PrintfHeader(req->resp, "X-Varnish: %u %u", VXID(req->vsl->wid), - VXID(ObjGetXID(req->objcore, &wrk->stats))); + ObjGetXID(req->objcore, &wrk->stats)); else http_PrintfHeader(req->resp, "X-Varnish: %u", VXID(req->vsl->wid)); @@ -402,7 +402,7 @@ cnt_lookup(struct worker *wrk, struct req *req) /* Found a hit-for-pass */ VSLb(req->vsl, SLT_Debug, "XXXX HIT-FOR-PASS"); VSLb(req->vsl, SLT_HitPass, "%u", - VXID(ObjGetXID(req->objcore, &wrk->stats))); + ObjGetXID(req->objcore, &wrk->stats)); AZ(boc); AZ(req->obj); (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); @@ -412,7 +412,7 @@ cnt_lookup(struct worker *wrk, struct req *req) } VSLb(req->vsl, SLT_Hit, "%u", - VXID(ObjGetXID(req->objcore, &wrk->stats))); + ObjGetXID(req->objcore, &wrk->stats)); VCL_hit_method(req->vcl, wrk, req, NULL, req->http->ws); From fgsch at lodoss.net Wed Aug 6 17:29:51 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 06 Aug 2014 19:29:51 +0200 Subject: [4.0] 881825b Spelling Message-ID: commit 881825b2cf9ffcf70f08de1d495cb01a9390c2c3 Author: Federico G. Schwindt Date: Thu Jun 26 18:30:13 2014 +0100 Spelling diff --git a/doc/sphinx/tutorial/peculiarities.rst b/doc/sphinx/tutorial/peculiarities.rst index 45f2f25..085edfd 100644 --- a/doc/sphinx/tutorial/peculiarities.rst +++ b/doc/sphinx/tutorial/peculiarities.rst @@ -3,7 +3,7 @@ Peculiarities ------------- There are a couple of things that are different with Varnish Cache, as -opposed to other programs. One thing you've already seen - VCL. In this section we provide a very quick tour of other pecularities you need to know about to get the most out of Varnish. +opposed to other programs. One thing you've already seen - VCL. In this section we provide a very quick tour of other peculiarities you need to know about to get the most out of Varnish. Configuration ~~~~~~~~~~~~~ diff --git a/doc/sphinx/users-guide/command-line.rst b/doc/sphinx/users-guide/command-line.rst index aa8c5be..854fb32 100644 --- a/doc/sphinx/users-guide/command-line.rst +++ b/doc/sphinx/users-guide/command-line.rst @@ -36,7 +36,7 @@ Here are some examples:: -a '[fe80::1]:80' -a '0.0.0.0:8080,[::]:8081' -.. XXX:brief explanation of some of the more comples examples perhaps? benc +.. XXX:brief explanation of some of the more complex examples perhaps? benc If your webserver runs on the same machine, you will have to move it to another port number first. diff --git a/doc/sphinx/users-guide/compression.rst b/doc/sphinx/users-guide/compression.rst index cb95619..bff1ebb 100644 --- a/doc/sphinx/users-guide/compression.rst +++ b/doc/sphinx/users-guide/compression.rst @@ -9,7 +9,7 @@ encoding. *Before* 3.0, Varnish would never compress objects. In Varnish 4.0 compression defaults to "on", meaning that it tries to be smart and do the sensible thing. -.. XXX:Heavy refactoring to VArnish 4 above. benc +.. XXX:Heavy refactoring to Varnish 4 above. benc If you don't want Varnish tampering with the encoding you can disable compression all together by setting the parameter 'http_gzip_support' to @@ -40,7 +40,7 @@ You can make Varnish compress content before storing it in cache in Please make sure that you don't try to compress content that is uncompressable, like jpgs, gifs and mp3. You'll only waste CPU cycles. You can also uncompress objects before storing it in memory by -setting 'do_gunzip' to true but that will ususally not be the most sensible thing to do. +setting 'do_gunzip' to true but that will usually not be the most sensible thing to do. Generally, Varnish doesn't use much CPU so it might make more sense to have Varnish spend CPU cycles compressing content than doing it in your web- or application servers, which are more likely to be @@ -71,5 +71,5 @@ the page while delivering it. A random outburst ~~~~~~~~~~~~~~~~~ -Poul-Henning Kamp has written :ref:`phk_gzip` which talks abit more about how the +Poul-Henning Kamp has written :ref:`phk_gzip` which talks a bit more about how the implementation works. diff --git a/doc/sphinx/users-guide/devicedetection.rst b/doc/sphinx/users-guide/devicedetection.rst index 2a0cb21..9138816 100644 --- a/doc/sphinx/users-guide/devicedetection.rst +++ b/doc/sphinx/users-guide/devicedetection.rst @@ -68,7 +68,7 @@ VCL:: } # req.http.X-UA-Device is copied by Varnish into bereq.http.X-UA-Device - # so, this is a bit conterintuitive. The backend creates content based on + # so, this is a bit counterintuitive. The backend creates content based on # the normalized User-Agent, but we use Vary on X-UA-Device so Varnish will # use the same cached object for all U-As that map to the same X-UA-Device. # @@ -101,7 +101,7 @@ VCL:: Example 2: Normalize the User-Agent string '''''''''''''''''''''''''''''''''''''''''' -Another way of signaling the device type is to override or normalize the +Another way of signalling the device type is to override or normalize the 'User-Agent' header sent to the backend. For example:: diff --git a/doc/sphinx/users-guide/intro.rst b/doc/sphinx/users-guide/intro.rst index f9c5587..927292a 100644 --- a/doc/sphinx/users-guide/intro.rst +++ b/doc/sphinx/users-guide/intro.rst @@ -65,7 +65,7 @@ simple to do simple things with:: } The CLI interface allows you to compile and load new VCL programs -at any time, and you can switch betweem the loaded VCL programs +at any time, and you can switch between the loaded VCL programs instantly, without restarting the child process and without missing a single HTTP request. diff --git a/doc/sphinx/users-guide/operation-logging.rst b/doc/sphinx/users-guide/operation-logging.rst index 4bfdca0..4dfa40f 100644 --- a/doc/sphinx/users-guide/operation-logging.rst +++ b/doc/sphinx/users-guide/operation-logging.rst @@ -51,7 +51,7 @@ session. Lines with the same number are coming from the same session and are being handled by the same thread. The second column is the *tag* of the log message. All log entries are tagged with a tag indicating what sort of activity is being logged. Tags starting with -'Rx' indicate Varnish is recieving data and 'Tx' indicates sending data. +'Rx' indicate Varnish is receiving data and 'Tx' indicates sending data. The third column tell us whether this is is data coming or going to the client ('c') or to/from the backend ('b'). The forth column is the From fgsch at lodoss.net Wed Aug 6 17:29:51 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 06 Aug 2014 19:29:51 +0200 Subject: [4.0] 01e63b2 Sync with reality Message-ID: commit 01e63b259a0d4fc977042e0a80a11eb8ea9e595c Author: Federico G. Schwindt Date: Thu Jun 26 18:47:23 2014 +0100 Sync with reality diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 3f8a831..743689e 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -364,10 +364,6 @@ hash_data(input) new() Instanciate a new VCL object. Available in vcl_init. -purge() - Invalidate all variants of the current object using purge. Available in - vcl_miss and vcl_hit. - return() End execution of the current VCL subroutine, and continue to the next step in the request handling state machine. diff --git a/doc/sphinx/users-guide/purging.rst b/doc/sphinx/users-guide/purging.rst index 0c9b7c9..17b02ee 100644 --- a/doc/sphinx/users-guide/purging.rst +++ b/doc/sphinx/users-guide/purging.rst @@ -39,7 +39,6 @@ following VCL in place:: if (!client.ip ~ purge) { return(synth(405,"Not allowed.")); } - # jump to hit/miss return (purge); } } From fgsch at lodoss.net Wed Aug 6 17:29:51 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 06 Aug 2014 19:29:51 +0200 Subject: [4.0] f2d23a7 Sync with reality Message-ID: commit f2d23a783c986423339ba813035265219fd4a00d Author: Federico G. Schwindt Date: Sun Jun 29 11:23:03 2014 +0100 Sync with reality beresp.cacheable is gone. diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index cb6396e..5280eb4 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -202,8 +202,7 @@ The `vcl_backend_response` subroutine may terminate with calling deliver Possibly insert the object into the cache, then deliver it to the - Control will eventually pass to `vcl_deliver`. Caching is dependant - on 'beresp.cacheable'. + Control will eventually pass to `vcl_deliver`. abandon Abandon the backend request and generates an error. From fgsch at lodoss.net Wed Aug 6 17:29:51 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 06 Aug 2014 19:29:51 +0200 Subject: [4.0] 177fc4d Spelling Message-ID: commit 177fc4dee03265a5d591ccea4743fbf95111f563 Author: Federico G. Schwindt Date: Mon Jun 30 12:56:01 2014 +0100 Spelling diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 8f25d39..a88a12d 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -271,7 +271,7 @@ VSC_F(threads_created, uint64_t, 0, 'c', info, ) VSC_F(threads_destroyed, uint64_t, 0, 'c', info, - "Threads destoryed", + "Threads destroyed", "Total number of threads destroyed in all pools." ) From fgsch at lodoss.net Wed Aug 6 17:29:51 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 06 Aug 2014 19:29:51 +0200 Subject: [4.0] 455281a Workaround a problem in recent libedit versions Message-ID: commit 455281a9eff278f831de26644fd08c21528667a1 Author: Federico G. Schwindt Date: Mon Jun 30 13:08:42 2014 +0100 Workaround a problem in recent libedit versions Reinstall the readline handler when we are called in order to clear the input line. Tested in a variety of versions by scn and myself. Fixes #1531 diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 60f36ba..0c2ecc1 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -184,6 +184,7 @@ static void send_line(char *l) cli_write(_line_sock, l); cli_write(_line_sock, "\n"); add_history(l); + rl_callback_handler_install("varnish> ", send_line); } else { RL_EXIT(0); } From fgsch at lodoss.net Wed Aug 6 17:29:51 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 06 Aug 2014 19:29:51 +0200 Subject: [4.0] 9ea22d7 Fix incorrect representation when using reals Message-ID: commit 9ea22d7800839d172926ddd55aa04d0e2816e394 Author: Federico G. Schwindt Date: Mon Jun 30 13:18:11 2014 +0100 Fix incorrect representation when using reals Fixes #1532 diff --git a/bin/varnishtest/tests/r01532.vtc b/bin/varnishtest/tests/r01532.vtc new file mode 100644 index 0000000..c189f55 --- /dev/null +++ b/bin/varnishtest/tests/r01532.vtc @@ -0,0 +1,20 @@ +varnishtest "Incorrect representation when using reals - #1532" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import ${vmod_std}; + + sub vcl_deliver { + set resp.http.x-foo = std.real2time(1140618699.00); + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.x-foo == "Wed, 22 Feb 2006 14:31:39 GMT" +} -run diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 8e4e234..0d39073 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -749,7 +749,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) e1 = vcc_mk_expr(BYTES, "%.1f", d); ERRCHK(tl); } else if (fmt == REAL) { - e1 = vcc_mk_expr(REAL, "%g", vcc_DoubleVal(tl)); + e1 = vcc_mk_expr(REAL, "%f", vcc_DoubleVal(tl)); ERRCHK(tl); } else { e1 = vcc_mk_expr(INT, "%.*s", PF(tl->t)); From fgsch at lodoss.net Wed Aug 6 17:29:51 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 06 Aug 2014 19:29:51 +0200 Subject: [4.0] 212b652 Typo in BAN configuration Message-ID: commit 212b652eddbd3bd95d790444a239f6728e1f2c7d Author: Federico G. Schwindt Date: Fri Jul 4 17:02:05 2014 +0100 Typo in BAN configuration Submitted by: Clement Gautier via github diff --git a/doc/sphinx/users-guide/purging.rst b/doc/sphinx/users-guide/purging.rst index 17b02ee..70fb415 100644 --- a/doc/sphinx/users-guide/purging.rst +++ b/doc/sphinx/users-guide/purging.rst @@ -103,7 +103,7 @@ You can also add bans to Varnish via HTTP. Doing so requires a bit of VCL:: return(synth(403, "Not allowed.")); } ban("req.http.host == " + req.http.host + - "&& req.url == " + req.url); + " && req.url == " + req.url); # Throw a synthetic page so the # request won't go to the backend. From fgsch at lodoss.net Wed Aug 6 17:34:21 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 06 Aug 2014 19:34:21 +0200 Subject: [4.0] d0532eb Fix backends and vhosts example Message-ID: commit d0532eb3b76ddaa5640a80d7a8e00a45c1a73fdc Author: Federico G. Schwindt Date: Tue Jul 8 21:50:56 2014 +0100 Fix backends and vhosts example Submitted by: nublaii via github diff --git a/doc/sphinx/users-guide/vcl-backends.rst b/doc/sphinx/users-guide/vcl-backends.rst index ecb8b31..5d31e77 100644 --- a/doc/sphinx/users-guide/vcl-backends.rst +++ b/doc/sphinx/users-guide/vcl-backends.rst @@ -100,7 +100,7 @@ this example this is intentional but you might want it to be a bit more tight, maybe relying on the ``==`` operator in stead, like this::: sub vcl_recv { - if (req.http.host == "foo.com" or req.http.host == "www.foo.com") { + if (req.http.host == "foo.com" || req.http.host == "www.foo.com") { set req.backend_hint = foo; } } From phk at FreeBSD.org Thu Aug 7 07:23:18 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 07 Aug 2014 09:23:18 +0200 Subject: [master] c62d0b6 Don't keep looking at req->obj->http once we have req->resp populated. Message-ID: commit c62d0b6b324a3fbb5a098932b226e4a6fd70240e Author: Poul-Henning Kamp Date: Thu Aug 7 07:22:56 2014 +0000 Don't keep looking at req->obj->http once we have req->resp populated. diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 83eb73d..743816b 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -93,7 +93,7 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); - assert(http_GetStatus(req->obj->http) == 200); + assert(http_GetStatus(req->resp) == 200); /* We must snapshot the length if we're streaming from the backend */ if (bo != NULL) diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index a07f12f..8997f91 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -163,7 +163,7 @@ cnt_deliver(struct worker *wrk, struct req *req) if (!(req->objcore->flags & OC_F_PASS) && req->esi_level == 0 - && http_GetStatus(req->obj->http) == 200 + && http_GetStatus(req->resp) == 200 && req->http->conds && RFC2616_Do_Cond(req)) { http_PutResponse(req->resp, "HTTP/1.1", 304, NULL); req->wantbody = 0; diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 6dc75ef..154b633 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -363,7 +363,7 @@ RFC2616_Do_Cond(const struct req *req) } if (http_GetHdr(req->http, H_If_None_Match, &p) && - http_GetHdr(req->obj->http, H_ETag, &e)) { + http_GetHdr(req->resp, H_ETag, &e)) { if (strcmp(p,e) != 0) return (0); do_cond = 1; From phk at FreeBSD.org Thu Aug 7 07:32:10 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 07 Aug 2014 09:32:10 +0200 Subject: [master] 7820ecd Introduce the HTTP_Encode() and HTTP_Decode() functions which pack a http response into bytestring. Message-ID: commit 7820ecdeb4fd20506b80c7b5456151637df7dad6 Author: Poul-Henning Kamp Date: Thu Aug 7 07:31:48 2014 +0000 Introduce the HTTP_Encode() and HTTP_Decode() functions which pack a http response into bytestring. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 856d5cd..fe619fe 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -949,6 +949,8 @@ void http_PutResponse(struct http *to, const char *proto, uint16_t status, const char *response); void http_FilterReq(struct http *to, const struct http *fm, unsigned how); void http_FilterResp(const struct http *fm, struct http *to, unsigned how); +uint8_t *HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how); +int HTTP_Decode(struct http *to, uint8_t *fm); void http_ForceHeader(struct http *to, const char *hdr, const char *val); void http_PrintfHeader(struct http *to, const char *fmt, ...) __printflike(2, 3); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index f7d9477..6617381 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -36,6 +36,7 @@ #include "cache.h" +#include "vend.h" #include "vct.h" #define HTTPH(a, b, c) char b[] = "*" a ":"; @@ -624,6 +625,93 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd) return (l); } +/*-------------------------------------------------------------------- + * Encode http struct as byte string. + */ + +uint8_t * +HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how) +{ + unsigned u, w; + uint16_t n; + uint8_t *p, *e; + + u = WS_Reserve(ws, 0); + p = (uint8_t*)ws->f; + e = (uint8_t*)ws->f + u; + if (p + 5 > e) { + WS_Release(ws, 0); + return (NULL); + } + assert(fm->nhd < fm->shd); + n = HTTP_HDR_FIRST - 3; + vbe16enc(p + 2, fm->status); + p += 4; + CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); + for (u = 0; u < fm->nhd; u++) { + if (u == HTTP_HDR_METHOD || u == HTTP_HDR_URL) + continue; + AN(fm->hd[u].b); + AN(fm->hd[u].e); + if (fm->hdf[u] & HDF_FILTER) + continue; +#define HTTPH(a, b, c) \ + if (((c) & how) && http_IsHdr(&fm->hd[u], (b))) \ + continue; +#include "tbl/http_headers.h" +#undef HTTPH + w = Tlen(fm->hd[u]) + 1L; + if (p + w + 1 > e) { + WS_Release(ws, 0); + return (NULL); + } + memcpy(p, fm->hd[u].b, w); + p += w; + n++; + } + *p++ = '\0'; + assert(p <= e); + e = (uint8_t*)ws->f; + vbe16enc(e, n + 1); + WS_ReleaseP(ws, (void*)p); + return (e); +} + +/*-------------------------------------------------------------------- + * Decode byte string into http struct + * + * XXX: cannot make fm const because to->hd isn't. + */ + +int +HTTP_Decode(struct http *to, uint8_t *fm) +{ + + CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); + AN(fm); + if (vbe16dec(fm) > to->shd) + return(-1); + to->status = vbe16dec(fm + 2); + fm += 4; + for (to->nhd = 0; to->nhd < to->shd; to->nhd++) { + if (to->nhd == HTTP_HDR_METHOD || to->nhd == HTTP_HDR_URL) { + to->hd[to->nhd].b = NULL; + to->hd[to->nhd].e = NULL; + continue; + } + if (*fm == '\0') + return (0); + to->hd[to->nhd].b = (void*)fm; + fm = strchr((void*)fm, '\0'); + to->hd[to->nhd].e = (void*)fm; + fm++; + if (to->vsl != NULL) + http_VSLH(to, to->nhd); + } + return (-1); +} + + /*--------------------------------------------------------------------*/ static void From phk at FreeBSD.org Thu Aug 7 07:50:23 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 07 Aug 2014 09:50:23 +0200 Subject: [master] 8374871 Pack obj->http into a oa_http bytestring and populate the obj->http structure from that while we still need it. Message-ID: commit 83748716c2a7f6dea841f3e546809c80c75da78b Author: Poul-Henning Kamp Date: Thu Aug 7 07:49:43 2014 +0000 Pack obj->http into a oa_http bytestring and populate the obj->http structure from that while we still need it. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index fe619fe..78d84a6 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -561,6 +561,8 @@ struct object { uint8_t *vary; + uint8_t *oa_http; + unsigned gziped:1; unsigned changed_gzip:1; @@ -948,7 +950,6 @@ void HTTP_Init(void); void http_PutResponse(struct http *to, const char *proto, uint16_t status, const char *response); void http_FilterReq(struct http *to, const struct http *fm, unsigned how); -void http_FilterResp(const struct http *fm, struct http *to, unsigned how); uint8_t *HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how); int HTTP_Decode(struct http *to, uint8_t *fm); void http_ForceHeader(struct http *to, const char *hdr, const char *val); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 4fab36b..9a896fd 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -101,7 +101,6 @@ vbf_beresp2obj(struct busyobj *bo) int varyl = 0; uint16_t nhttp; struct object *obj; - struct http *hp, *hp2; l = 0; @@ -156,23 +155,19 @@ vbf_beresp2obj(struct busyobj *bo) WS_Assert(bo->ws_o); /* Filter into object */ - hp = bo->beresp; - hp2 = obj->http; + obj->http->logtag = SLT_ObjMethod; + obj->oa_http = HTTP_Encode(bo->beresp, bo->ws_o, + bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS); + AN(obj->oa_http); + AZ(HTTP_Decode(obj->http, obj->oa_http)); - hp2->logtag = SLT_ObjMethod; - http_FilterResp(hp, hp2, bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS); - http_CopyHome(hp2); - - if (http_GetHdr(hp, H_Last_Modified, &b)) + if (http_GetHdr(bo->beresp, H_Last_Modified, &b)) AZ(ObjSetDouble(bo->fetch_objcore, bo->stats, OA_LASTMODIFIED, VTIM_parse(b))); else AZ(ObjSetDouble(bo->fetch_objcore, bo->stats, OA_LASTMODIFIED, floor(bo->fetch_objcore->exp.t_origin))); - /* Disassociate the obj from the bo's workspace */ - hp2->ws = NULL; - return (0); } diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 6617381..f2e310f 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -136,7 +136,7 @@ HTTP_estimate(unsigned nhttp) { /* XXX: We trust the structs to size-aligned as necessary */ - return (sizeof (struct http) + (sizeof (txt) + 1) * nhttp); + return (PRNDUP(sizeof (struct http) + sizeof(txt) * nhttp + nhttp)); } struct http * @@ -605,12 +605,14 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd) { unsigned u, l; - l = 0; - *nhd = HTTP_HDR_FIRST; + l = 4; + *nhd = 1 + HTTP_HDR_FIRST - 3; CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); for (u = 0; u < fm->nhd; u++) { - if (fm->hd[u].b == NULL) + if (u == HTTP_HDR_METHOD || u == HTTP_HDR_URL) continue; + AN(fm->hd[u].b); + AN(fm->hd[u].e); if (fm->hdf[u] & HDF_FILTER) continue; #define HTTPH(a, b, c) \ @@ -618,11 +620,10 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd) continue; #include "tbl/http_headers.h" #undef HTTPH - l += PRNDUP(Tlen(fm->hd[u]) + 1L); + l += Tlen(fm->hd[u]) + 1L; (*nhd)++; - // fm->hdf[u] |= HDF_COPY; } - return (l); + return (PRNDUP(l + 1L)); } /*-------------------------------------------------------------------- @@ -673,6 +674,7 @@ HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how) assert(p <= e); e = (uint8_t*)ws->f; vbe16enc(e, n + 1); + VSLb(fm->vsl, SLT_Debug, "HTTPENC %zd", p - (uint8_t*)ws->f); WS_ReleaseP(ws, (void*)p); return (e); } @@ -711,7 +713,6 @@ HTTP_Decode(struct http *to, uint8_t *fm) return (-1); } - /*--------------------------------------------------------------------*/ static void @@ -769,21 +770,6 @@ http_FilterReq(struct http *to, const struct http *fm, unsigned how) http_filterfields(to, fm, how); } -/*--------------------------------------------------------------------*/ - -void -http_FilterResp(const struct http *fm, struct http *to, unsigned how) -{ - - CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); - CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); - to->status = fm->status; - http_linkh(to, fm, HTTP_HDR_PROTO); - http_linkh(to, fm, HTTP_HDR_STATUS); - http_linkh(to, fm, HTTP_HDR_REASON); - http_filterfields(to, fm, how); -} - /*-------------------------------------------------------------------- * Merge two HTTP headers the "wrong" way. Used by backend IMS to * merge in the headers of the validated object with the headers of diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 8997f91..3be502c 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -105,7 +105,7 @@ cnt_deliver(struct worker *wrk, struct req *req) EXP_Touch(req->objcore, req->t_prev); HTTP_Setup(req->resp, req->ws, req->vsl, SLT_RespMethod); - http_FilterResp(req->obj->http, req->resp, 0); + AZ(HTTP_Decode(req->resp, req->obj->oa_http)); http_ForceField(req->resp, HTTP_HDR_PROTO, "HTTP/1.1"); if (req->wrk->stats.cache_hit) From phk at FreeBSD.org Thu Aug 7 07:52:42 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 07 Aug 2014 09:52:42 +0200 Subject: [master] a25a2b6 Fix for GCC warning Message-ID: commit a25a2b67a83ba4ba898d480a9335ed918b606214 Author: Poul-Henning Kamp Date: Thu Aug 7 07:52:18 2014 +0000 Fix for GCC warning diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index f2e310f..54e14ab 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -704,7 +704,7 @@ HTTP_Decode(struct http *to, uint8_t *fm) if (*fm == '\0') return (0); to->hd[to->nhd].b = (void*)fm; - fm = strchr((void*)fm, '\0'); + fm = (void*)strchr((void*)fm, '\0'); to->hd[to->nhd].e = (void*)fm; fm++; if (to->vsl != NULL) From phk at FreeBSD.org Thu Aug 7 10:14:46 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 07 Aug 2014 12:14:46 +0200 Subject: [master] 4d5a73b Don't frob http->status directly to test value, we need to take account for the extra two digits made available for VCL. Message-ID: commit 4d5a73ba3e75705657181706d216d37a7cdcbbfb Author: Poul-Henning Kamp Date: Thu Aug 7 10:14:15 2014 +0000 Don't frob http->status directly to test value, we need to take account for the extra two digits made available for VCL. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 78d84a6..810fe4e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -967,6 +967,7 @@ int http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr); double http_GetHdrQ(const struct http *hp, const char *hdr, const char *field); uint16_t http_GetStatus(const struct http *hp); +int http_IsStatus(const struct http *hp, int); void http_SetStatus(struct http *to, uint16_t status); const char *http_GetReq(const struct http *hp); int http_HdrIs(const struct http *hp, const char *hdr, const char *val); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 9a896fd..1c67e9a 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -203,7 +203,7 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) http_CopyHome(bo->bereq0); } - if (bo->ims_obj != NULL && bo->ims_obj->http->status == 200) { + if (bo->ims_obj != NULL && http_IsStatus(bo->ims_obj->http, 200)) { if (http_GetHdr(bo->ims_obj->http, H_Last_Modified, &p)) { http_PrintfHeader(bo->bereq0, "If-Modified-Since: %s", p); @@ -351,10 +351,10 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) AZ(bo->do_esi); - if (bo->ims_obj != NULL && bo->beresp->status == 304) { + if (bo->ims_obj != NULL && http_IsStatus(bo->beresp, 304)) { http_Merge(bo->ims_obj->http, bo->beresp, bo->ims_obj->changed_gzip); - assert(bo->beresp->status == 200); + assert(http_IsStatus(bo->beresp, 200)); do_ims = 1; } else do_ims = 0; diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 54e14ab..79e2bd2 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -532,6 +532,15 @@ http_GetStatus(const struct http *hp) return (hp->status); } +int +http_IsStatus(const struct http *hp, int val) +{ + + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); + assert(val >= 100 && val <= 999); + return (val == (hp->status % 1000)); +} + /*-------------------------------------------------------------------- * Setting the status will also set the Reason appropriately */ diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 743816b..f93d492 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -93,7 +93,7 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); - assert(http_GetStatus(req->resp) == 200); + assert(http_IsStatus(req->resp, 200)); /* We must snapshot the length if we're streaming from the backend */ if (bo != NULL) @@ -244,7 +244,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo) /* In ESI mode, we can't know the aggregate length */ req->res_mode &= ~RES_LEN; req->res_mode |= RES_ESI; - } else if (req->resp->status == 304) { + } else if (http_IsStatus(req->resp, 304)) { req->res_mode &= ~RES_LEN; http_Unset(req->resp, H_Content_Length); req->wantbody = 0; @@ -308,7 +308,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo) req->wantbody && !(req->res_mode & (RES_ESI|RES_ESI_CHILD)) && cache_param->http_range_support && - http_GetStatus(req->resp) == 200) { + http_IsStatus(req->resp, 200)) { http_SetHeader(req->resp, "Accept-Ranges: bytes"); if (http_GetHdr(req->http, H_Range, &r)) v1d_dorange(req, bo, r); @@ -373,7 +373,7 @@ V1D_Deliver_Synth(struct req *req) AN(req->synth_body); req->res_mode = 0; - if (req->resp->status == 304) { + if (http_IsStatus(req->resp, 304)) { req->res_mode &= ~RES_LEN; http_Unset(req->resp, H_Content_Length); req->wantbody = 0; @@ -422,7 +422,7 @@ V1D_Deliver_Synth(struct req *req) req->wantbody && !(req->res_mode & RES_ESI_CHILD) && cache_param->http_range_support && - http_GetStatus(req->resp) == 200) { + http_IsStatus(req->resp, 200)) { http_SetHeader(req->resp, "Accept-Ranges: bytes"); if (http_GetHdr(req->http, H_Range, &r)) v1d_dorange(req, NULL, r); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 3be502c..3405a1a 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -163,7 +163,7 @@ cnt_deliver(struct worker *wrk, struct req *req) if (!(req->objcore->flags & OC_F_PASS) && req->esi_level == 0 - && http_GetStatus(req->resp) == 200 + && http_IsStatus(req->resp, 200) && req->http->conds && RFC2616_Do_Cond(req)) { http_PutResponse(req->resp, "HTTP/1.1", 304, NULL); req->wantbody = 0; diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 154b633..cddab7c 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -207,16 +207,17 @@ RFC2616_Body(struct busyobj *bo, struct dstat *stats) return (BS_NONE); } - if (hp->status <= 199) { + if (http_GetStatus(hp) <= 199) { /* * 1xx responses never have a body. * [RFC2616 4.3 p33] + * ... but we should never see them. */ stats->fetch_1xx++; - return (BS_NONE); + return (BS_ERROR); } - if (hp->status == 204) { + if (http_IsStatus(hp, 204)) { /* * 204 is "No Content", obviously don't expect a body. * [RFC2616 10.2.5 p60] @@ -225,7 +226,7 @@ RFC2616_Body(struct busyobj *bo, struct dstat *stats) return (BS_NONE); } - if (hp->status == 304) { + if (http_IsStatus(hp, 304)) { /* * 304 is "Not Modified" it has no body. * [RFC2616 10.3.5 p63] From phk at FreeBSD.org Mon Aug 11 07:31:53 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Aug 2014 09:31:53 +0200 Subject: [master] be938d3 Wrap obj->len in an accessor function Message-ID: commit be938d34eea6dfb9ef8c63b41838236b1cf72367 Author: Poul-Henning Kamp Date: Mon Aug 11 07:31:36 2014 +0000 Wrap obj->len in an accessor function diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 810fe4e..1038e85 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1059,6 +1059,7 @@ enum objiter_status ObjIter(struct objiter *, void **, ssize_t *); void ObjIterEnd(struct objiter **); void ObjTrimStore(struct objcore *, struct dstat *); unsigned ObjGetXID(struct objcore *, struct dstat *); +uint64_t ObjGetLen(struct objcore *oc, struct dstat *ds); struct object *ObjGetObj(struct objcore *, struct dstat *); void ObjUpdateMeta(struct objcore *); void ObjFreeObj(struct objcore *, struct dstat *); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 12cb10f..185378e 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -505,6 +505,7 @@ ESI_DeliverChild(struct req *req) u_char cc; uint32_t icrc; uint32_t ilen; + uint64_t olen; uint8_t *dbits; int i, j; uint8_t tailbuf[8]; @@ -534,9 +535,10 @@ ESI_DeliverChild(struct req *req) start = vbe64dec(p); last = vbe64dec(p + 8); stop = vbe64dec(p + 16); - assert(start > 0 && start < obj->len * 8); - assert(last > 0 && last < obj->len * 8); - assert(stop > 0 && stop < obj->len * 8); + olen = ObjGetLen(obj->objcore, &req->wrk->stats); + assert(start > 0 && start < olen * 8); + assert(last > 0 && last < olen * 8); + assert(stop > 0 && stop < olen * 8); assert(last >= start); assert(last < stop); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 1c67e9a..d8ebfc6 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -559,6 +559,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) struct objiter *oi; void *sp; ssize_t sl, al, tl; + uint64_t ol; struct storage *st; enum objiter_status ois; char *p; @@ -606,13 +607,13 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) st = NULL; al = 0; + ol = ObjGetLen(bo->ims_oc, bo->stats); oi = ObjIterBegin(wrk, bo->ims_obj); do { ois = ObjIter(oi, &sp, &sl); while (sl > 0) { if (st == NULL) - st = VFP_GetStorage(bo->vfc, - bo->ims_obj->len - al); + st = VFP_GetStorage(bo->vfc, ol - al); if (st == NULL) break; tl = sl; @@ -634,8 +635,8 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) if (!bo->do_stream) HSH_Unbusy(&wrk->stats, obj->objcore); - assert(al == bo->ims_obj->len); - assert(obj->len == al); + assert(al == ol); + assert(ObjGetLen(bo->fetch_objcore, bo->stats) == al); EXP_Rearm(bo->ims_oc, bo->ims_oc->exp.t_origin, 0, 0, 0); /* Recycle the backend connection before setting BOS_FINISHED to @@ -802,8 +803,6 @@ vbf_fetch_thread(struct worker *wrk, void *priv) } assert(WRW_IsReleased(wrk)); - bo->stats = NULL; - if (bo->vbc != NULL) { if (bo->doclose != SC_NULL) VDI_CloseFd(&bo->vbc, &bo->acct); @@ -818,22 +817,8 @@ vbf_fetch_thread(struct worker *wrk, void *priv) if (bo->state == BOS_FINISHED) { AZ(bo->fetch_objcore->flags & OC_F_FAILED); HSH_Complete(bo->fetch_objcore); - VSLb(bo->vsl, SLT_Length, "%zd", bo->fetch_obj->len); - { - /* Sanity check fetch methods accounting */ - ssize_t uu; - struct storage *st; - - uu = 0; - VTAILQ_FOREACH(st, &bo->fetch_obj->body->list, list) - uu += st->len; - if (bo->do_stream) - /* Streaming might have started freeing stuff */ - assert(uu <= bo->fetch_obj->len); - - else - assert(uu == bo->fetch_obj->len); - } + VSLb(bo->vsl, SLT_Length, "%zd", + ObjGetLen(bo->fetch_objcore, bo->stats)); } AZ(bo->fetch_objcore->busyobj); @@ -842,6 +827,8 @@ vbf_fetch_thread(struct worker *wrk, void *priv) bo->ims_obj = NULL; } + bo->stats = NULL; + VBO_DerefBusyObj(wrk, &bo); THR_SetBusyobj(NULL); } diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index f93d492..2a2b1bc 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -99,7 +99,7 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r) if (bo != NULL) len = VBO_waitlen(bo, -1); else - len = req->obj->len; + len = ObjGetLen(req->objcore, &req->wrk->stats); if (strncmp(r, "bytes=", 6)) return; @@ -252,10 +252,11 @@ V1D_Deliver(struct req *req, struct busyobj *bo) /* XXX: Not happy with this convoluted test */ req->res_mode |= RES_LEN; if (!(req->objcore->flags & OC_F_PASS) || - req->obj->len != 0) { + ObjGetLen(req->objcore, &req->wrk->stats) != 0) { http_Unset(req->resp, H_Content_Length); http_PrintfHeader(req->resp, - "Content-Length: %zd", req->obj->len); + "Content-Length: %ju", (uintmax_t)ObjGetLen( + req->objcore, &req->wrk->stats)); } } diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index d5b7390..f8da916 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -303,6 +303,16 @@ ObjGetXID(struct objcore *oc, struct dstat *ds) return (u); } +uint64_t +ObjGetLen(struct objcore *oc, struct dstat *ds) +{ + struct object *o; + + o = ObjGetObj(oc, ds); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + return (o->len); +} + /*-------------------------------------------------------------------- * There is no well-defined byteorder for IEEE-754 double and the * correct solution (frexp(3) and manual encoding) is more work From phk at FreeBSD.org Mon Aug 11 08:48:16 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Aug 2014 10:48:16 +0200 Subject: [master] 95e9092 Incrementally chip away at struct object Message-ID: commit 95e9092eff6f4d9e306ddb6d2955554b1828cf9e Author: Poul-Henning Kamp Date: Mon Aug 11 08:48:01 2014 +0000 Incrementally chip away at struct object diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index d8ebfc6..d22d1db 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -159,7 +159,8 @@ vbf_beresp2obj(struct busyobj *bo) obj->oa_http = HTTP_Encode(bo->beresp, bo->ws_o, bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS); AN(obj->oa_http); - AZ(HTTP_Decode(obj->http, obj->oa_http)); + AZ(HTTP_Decode(obj->http, + ObjGetattr(bo->fetch_objcore, bo->stats, OA_HEADERS, NULL))); if (http_GetHdr(bo->beresp, H_Last_Modified, &b)) AZ(ObjSetDouble(bo->fetch_objcore, bo->stats, OA_LASTMODIFIED, diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 2a2b1bc..e3b392a 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -92,7 +92,7 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r) ssize_t len, low, high, has_low; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); assert(http_IsStatus(req->resp, 200)); /* We must snapshot the length if we're streaming from the backend */ diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index f8da916..f249d7b 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -236,6 +236,9 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, case OA_GZIPBITS: *len = sizeof o->oa_gzipbits; return (o->oa_gzipbits); + case OA_HEADERS: + *len = 0; // XXX: hack + return (o->oa_http); case OA_LASTMODIFIED: *len = sizeof o->oa_lastmodified; return (o->oa_lastmodified); @@ -256,6 +259,7 @@ ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, ssize_t len) { struct object *o; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(ds); o = ObjGetObj(oc, ds); diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 751c0a3..3ab1b9c 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -187,7 +187,6 @@ stv_alloc_obj(const struct vfp_ctx *vc, size_t size) struct storage *st = NULL; struct stevedore *stv; unsigned fail; - struct object *obj; /* * Always use the stevedore which allocated the object in order to @@ -196,9 +195,7 @@ stv_alloc_obj(const struct vfp_ctx *vc, size_t size) CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); AN(vc->bo->stats); - obj = vc->bo->fetch_obj; - CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - stv = obj->body->stevedore; + stv = vc->body->stevedore; CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); if (size > cache_param->fetch_maxchunksize) From phk at FreeBSD.org Mon Aug 11 09:37:20 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Aug 2014 11:37:20 +0200 Subject: [master] 8fc1898 Make the length a property of the body. Message-ID: commit 8fc18981fa02f2e3eaf74fedcd2112d80e5bb723 Author: Poul-Henning Kamp Date: Mon Aug 11 09:35:29 2014 +0000 Make the length a property of the body. Use vfp_ctx as argument for ObjSetattr() Make OA_ESIDATA the first "real" attribute where allocation is done by the ObjSetattr() function. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 1038e85..9a0d53d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -544,6 +544,7 @@ VTAILQ_HEAD(storagehead, storage); struct body { struct stevedore *stevedore; struct storagehead list; + ssize_t len; }; enum obj_attr { @@ -569,7 +570,6 @@ struct object { /* Bit positions in the gzip stream */ char oa_gzipbits[24]; - ssize_t len; /* VCL only variables */ char oa_lastmodified[8]; @@ -932,7 +932,7 @@ int VGZ_ObufFull(const struct vgz *vg); enum vgzret_e VGZ_Gzip(struct vgz *, const void **, size_t *len, enum vgz_flag); enum vgzret_e VGZ_Gunzip(struct vgz *, const void **, size_t *len); enum vgzret_e VGZ_Destroy(struct vgz **); -void VGZ_UpdateObj(struct dstat *ds, const struct vgz*, struct objcore *); +void VGZ_UpdateObj(const struct vfp_ctx *, const struct vgz*); vdp_bytes VDP_gunzip; int VGZ_WrwInit(struct vgz *vg); @@ -1066,16 +1066,15 @@ void ObjFreeObj(struct objcore *, struct dstat *); struct lru *ObjGetLRU(const struct objcore *); void *ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, ssize_t *len); -void *ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, - ssize_t len); -int ObjCopyAttr(struct objcore *ocd, struct objcore *ocs, struct dstat *ds, - enum obj_attr attr); +void *ObjSetattr(const struct vfp_ctx *, enum obj_attr attr, ssize_t len); +int ObjCopyAttr(const struct vfp_ctx *, struct objcore *, enum obj_attr attr); + +int ObjSetDouble(const struct vfp_ctx*, enum obj_attr, double); +int ObjSetU32(const struct vfp_ctx *, enum obj_attr, uint32_t); +int ObjSetU64(const struct vfp_ctx *, enum obj_attr, uint64_t); -int ObjSetDouble(struct objcore *, struct dstat *, enum obj_attr, double); int ObjGetDouble(struct objcore *, struct dstat *, enum obj_attr, double *); -int ObjSetU32(struct objcore *, struct dstat *, enum obj_attr, uint32_t); int ObjGetU32(struct objcore *, struct dstat *, enum obj_attr, uint32_t *); -int ObjSetU64(struct objcore *, struct dstat *, enum obj_attr, uint64_t); int ObjGetU64(struct objcore *, struct dstat *, enum obj_attr, uint64_t *); /* cache_panic.c */ diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 17874f1..abbf03f 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -168,7 +168,6 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) *pbo = NULL; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_ORNULL(bo->fetch_objcore, OBJCORE_MAGIC); - CHECK_OBJ_ORNULL(bo->fetch_obj, OBJECT_MAGIC); if (bo->fetch_objcore != NULL) { oc = bo->fetch_objcore; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); @@ -222,15 +221,15 @@ VBO_extend(struct busyobj *bo, ssize_t l) struct storage *st; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->fetch_obj, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(bo->vfc, VFP_CTX_MAGIC); if (l == 0) return; assert(l > 0); Lck_Lock(&bo->mtx); - st = VTAILQ_LAST(&bo->fetch_obj->body->list, storagehead); + st = VTAILQ_LAST(&bo->vfc->body->list, storagehead); CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); st->len += l; - bo->fetch_obj->len += l; + bo->vfc->body->len += l; AZ(pthread_cond_broadcast(&bo->cond)); Lck_Unlock(&bo->mtx); } @@ -239,13 +238,13 @@ ssize_t VBO_waitlen(struct busyobj *bo, ssize_t l) { Lck_Lock(&bo->mtx); - assert(l <= bo->fetch_obj->len || bo->state == BOS_FAILED); while (1) { - if (bo->fetch_obj->len > l || bo->state >= BOS_FINISHED) + assert(l <= bo->vfc->body->len || bo->state == BOS_FAILED); + if (bo->vfc->body->len > l || bo->state >= BOS_FINISHED) break; (void)Lck_CondWait(&bo->cond, &bo->mtx, 0); } - l = bo->fetch_obj->len; + l = bo->vfc->body->len; Lck_Unlock(&bo->mtx); return (l); } diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 8014ca9..1608eff 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -106,6 +106,7 @@ vfp_esi_end(struct vfp_ctx *vc, struct vef_priv *vef, { struct vsb *vsb; ssize_t l; + void *p; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); @@ -117,22 +118,19 @@ vfp_esi_end(struct vfp_ctx *vc, struct vef_priv *vef, if (retval == VFP_END) { l = VSB_len(vsb); assert(l > 0); - /* XXX: This is a huge waste of storage... */ - vc->bo->fetch_obj->esidata = STV_alloc(vc, l); - if (vc->bo->fetch_obj->esidata != NULL) { - memcpy(vc->bo->fetch_obj->esidata->ptr, - VSB_data(vsb), l); - vc->bo->fetch_obj->esidata->len = l; - } else { + p = ObjSetattr(vc, OA_ESIDATA, l); + if (p == NULL) { retval = VFP_Error(vc, "Could not allocate storage for esidata"); + } else { + memcpy(p, VSB_data(vsb), l); } } VSB_delete(vsb); } if (vef->vgz != NULL) { - VGZ_UpdateObj(vc->bo->stats, vef->vgz, vc->bo->fetch_objcore); + VGZ_UpdateObj(vc, vef->vgz); if (VGZ_Destroy(&vef->vgz) != VGZ_END) retval = VFP_Error(vc, "ESI+Gzip Failed at the very end"); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index d22d1db..9635293 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -150,8 +150,7 @@ vbf_beresp2obj(struct busyobj *bo) VSB_delete(vary); } - AZ(ObjSetU32(bo->fetch_objcore, bo->stats, OA_VXID, - VXID(bo->vsl->wid))); + AZ(ObjSetU32(bo->vfc, OA_VXID, VXID(bo->vsl->wid))); WS_Assert(bo->ws_o); /* Filter into object */ @@ -163,10 +162,9 @@ vbf_beresp2obj(struct busyobj *bo) ObjGetattr(bo->fetch_objcore, bo->stats, OA_HEADERS, NULL))); if (http_GetHdr(bo->beresp, H_Last_Modified, &b)) - AZ(ObjSetDouble(bo->fetch_objcore, bo->stats, OA_LASTMODIFIED, - VTIM_parse(b))); + AZ(ObjSetDouble(bo->vfc, OA_LASTMODIFIED, VTIM_parse(b))); else - AZ(ObjSetDouble(bo->fetch_objcore, bo->stats, OA_LASTMODIFIED, + AZ(ObjSetDouble(bo->vfc, OA_LASTMODIFIED, floor(bo->fetch_objcore->exp.t_origin))); return (0); @@ -519,7 +517,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->vfc->failed && !bo->do_stream) { assert(bo->state < BOS_STREAM); - if (bo->fetch_obj != NULL) { + if (bo->fetch_objcore != NULL) { ObjFreeObj(bo->fetch_objcore, bo->stats); bo->fetch_obj = NULL; } @@ -583,21 +581,12 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) obj = bo->fetch_obj; bo->vfc->body = obj->body; - if (bo->ims_obj->esidata != NULL) { - sl = bo->ims_obj->esidata->len; - obj->esidata = STV_alloc(bo->vfc, sl); - if (obj->esidata == NULL || obj->esidata->space < sl) { - VSLb(bo->vsl, SLT_Error, - "No space for %zd bytes of ESI data", sl); - return (F_STP_FAIL); - } - memcpy(obj->esidata->ptr, bo->ims_obj->esidata->ptr, sl); - obj->esidata->len = sl; - } + if (ObjGetattr(bo->ims_oc, bo->stats, OA_ESIDATA, NULL) != NULL) + AZ(ObjCopyAttr(bo->vfc, bo->ims_oc, OA_ESIDATA)); obj->gziped = bo->ims_obj->gziped; - AZ(ObjCopyAttr(bo->fetch_objcore, bo->ims_oc, bo->stats, OA_GZIPBITS)); + AZ(ObjCopyAttr(bo->vfc, bo->ims_oc, OA_GZIPBITS)); AZ(WS_Overflowed(bo->ws_o)); if (bo->do_stream) { @@ -749,7 +738,7 @@ vbf_stp_fail(struct worker *wrk, struct busyobj *bo) HSH_Fail(bo->fetch_objcore); if (bo->fetch_objcore->exp_flags & OC_EF_EXP) { /* Already unbusied - expire it */ - AN(bo->fetch_obj); + AN(bo->fetch_objcore); EXP_Rearm(bo->fetch_objcore, bo->fetch_objcore->exp.t_origin, 0, 0, 0); } diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 14b26f2..fd83152 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -231,13 +231,13 @@ VFP_Fetch_Body(struct busyobj *bo) } CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - assert(st == VTAILQ_LAST(&bo->fetch_obj->body->list, + assert(st == VTAILQ_LAST(&bo->vfc->body->list, storagehead)); l = st->space - st->len; AZ(bo->vfc->failed); vfps = VFP_Suck(bo->vfc, st->ptr + st->len, &l); if (l > 0 && vfps != VFP_ERROR) { - AZ(VTAILQ_EMPTY(&bo->fetch_obj->body->list)); + AZ(VTAILQ_EMPTY(&bo->vfc->body->list)); VBO_extend(bo, l); } if (st->len == st->space) diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index e8112e8..8cafe6b 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -391,13 +391,12 @@ VGZ_WrwFlush(struct req *req, struct vgz *vg) /*--------------------------------------------------------------------*/ void -VGZ_UpdateObj(struct dstat *ds, const struct vgz *vg, struct objcore *oc) +VGZ_UpdateObj(const struct vfp_ctx *vc, const struct vgz *vg) { char *p; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - p = ObjSetattr(oc, ds, OA_GZIPBITS, 24); + p = ObjSetattr(vc, OA_GZIPBITS, 24); AN(p); vbe64enc(p, vg->vz.start_bit); vbe64enc(p + 8, vg->vz.last_bit); @@ -601,7 +600,7 @@ vfp_gzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, if (vr != VGZ_END) return (VFP_Error(vc, "Gzip failed")); - VGZ_UpdateObj(vc->bo->stats, vg, vc->bo->fetch_objcore); + VGZ_UpdateObj(vc, vg); return (VFP_END); } @@ -647,7 +646,7 @@ vfp_testgunzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, if (vp == VFP_END) { if (vr != VGZ_END) return (VFP_Error(vc, "tGunzip failed")); - VGZ_UpdateObj(vc->bo->stats, vg, vc->bo->fetch_objcore); + VGZ_UpdateObj(vc, vg); } return (vp); } diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index f249d7b..e18169a 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -173,7 +173,6 @@ ObjTrimStore(struct objcore *oc, struct dstat *ds) } } - struct object * ObjGetObj(struct objcore *oc, struct dstat *ds) { @@ -255,16 +254,23 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, } void * -ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, +ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, ssize_t len) { struct object *o; - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - AN(ds); - o = ObjGetObj(oc, ds); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo->fetch_objcore, OBJCORE_MAGIC); + o = ObjGetObj(vc->bo->fetch_objcore, vc->bo->stats); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); switch (attr) { + case OA_ESIDATA: + o->esidata = STV_alloc(vc, len); + if (o->esidata == NULL) + return (NULL); + o->esidata->len = len; + return (o->esidata->ptr); case OA_GZIPBITS: assert(len == sizeof o->oa_gzipbits); return (o->oa_gzipbits); @@ -281,17 +287,18 @@ ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, } int -ObjCopyAttr(struct objcore *ocd, struct objcore *ocs, struct dstat *ds, - enum obj_attr attr) +ObjCopyAttr(const struct vfp_ctx *vc, struct objcore *ocs, enum obj_attr attr) { void *vps, *vpd; ssize_t l; - vps = ObjGetattr(ocs, ds, attr, &l); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + + vps = ObjGetattr(ocs, vc->bo->stats, attr, &l); // XXX: later we want to have zero-length OA's too if (vps == NULL || l <= 0) return (-1); - vpd = ObjSetattr(ocd, ds, attr, l); + vpd = ObjSetattr(vc, attr, l); if (vpd == NULL) return (-1); memcpy(vpd, vps, l); @@ -314,7 +321,7 @@ ObjGetLen(struct objcore *oc, struct dstat *ds) o = ObjGetObj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - return (o->len); + return (o->body->len); } /*-------------------------------------------------------------------- @@ -326,14 +333,14 @@ ObjGetLen(struct objcore *oc, struct dstat *ds) */ int -ObjSetDouble(struct objcore *oc, struct dstat *ds, enum obj_attr a, double t) +ObjSetDouble(const struct vfp_ctx *vc, enum obj_attr a, double t) { void *vp; uint64_t u; assert(sizeof t == sizeof u); memcpy(&u, &t, sizeof u); - vp = ObjSetattr(oc, ds, a, sizeof u); + vp = ObjSetattr(vc, a, sizeof u); if (vp == NULL) return (-1); vbe64enc(vp, u); @@ -363,11 +370,11 @@ ObjGetDouble(struct objcore *oc, struct dstat *ds, enum obj_attr a, double *d) */ int -ObjSetU64(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint64_t t) +ObjSetU64(const struct vfp_ctx *vc, enum obj_attr a, uint64_t t) { void *vp; - vp = ObjSetattr(oc, ds, a, sizeof t); + vp = ObjSetattr(vc, a, sizeof t); if (vp == NULL) return (-1); vbe64enc(vp, t); @@ -389,11 +396,11 @@ ObjGetU64(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint64_t *d) } int -ObjSetU32(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint32_t t) +ObjSetU32(const struct vfp_ctx *vc, enum obj_attr a, uint32_t t) { void *vp; - vp = ObjSetattr(oc, ds, a, sizeof t); + vp = ObjSetattr(vc, a, sizeof t); if (vp == NULL) return (-1); vbe32enc(vp, t); diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 20225b5..03ef16c 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -218,7 +218,7 @@ pan_object(const char *typ, const struct object *o) VSB_printf(pan_vsp, " obj (%s) = %p {\n", typ, o); VSB_printf(pan_vsp, " vxid = %u,\n", VXID(vbe32dec(o->oa_vxid))); pan_http("obj", o->http, 4); - VSB_printf(pan_vsp, " len = %jd,\n", (intmax_t)o->len); + VSB_printf(pan_vsp, " len = %jd,\n", (intmax_t)o->body->len); VSB_printf(pan_vsp, " store = {\n"); VTAILQ_FOREACH(st, &o->body->list, list) pan_storage(st); diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index ba56ddc..103c0bc 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -431,7 +431,7 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc) break; l += st->len; } - if (l != o->len) + if (l != o->body->len) bad |= 0x100; if(bad) { From phk at FreeBSD.org Mon Aug 11 10:19:01 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Aug 2014 12:19:01 +0200 Subject: [master] ab53b55 Fix a printf format error Message-ID: commit ab53b55f7b861d55d102998c0bfb0096d234efb4 Author: Poul-Henning Kamp Date: Mon Aug 11 10:18:53 2014 +0000 Fix a printf format error diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 9635293..3abd6ef 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -808,7 +808,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv) AZ(bo->fetch_objcore->flags & OC_F_FAILED); HSH_Complete(bo->fetch_objcore); VSLb(bo->vsl, SLT_Length, "%zd", - ObjGetLen(bo->fetch_objcore, bo->stats)); + (uintmax_t)ObjGetLen(bo->fetch_objcore, bo->stats)); } AZ(bo->fetch_objcore->busyobj); From phk at FreeBSD.org Mon Aug 11 11:45:17 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Aug 2014 13:45:17 +0200 Subject: [master] 4ee1b91 Wrap the gzip/changed_gzip flags into a more general object flag mechanism. Message-ID: commit 4ee1b911bbf0b81542a4f013156810862d1d0d66 Author: Poul-Henning Kamp Date: Mon Aug 11 11:44:00 2014 +0000 Wrap the gzip/changed_gzip flags into a more general object flag mechanism. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 9a0d53d..12712b5 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -553,6 +553,12 @@ enum obj_attr { #undef OBJ_ATTR }; +enum obj_flags { +#define OBJ_FLAG(U, l, v) OF_##U = v, +#include "tbl/obj_attr.h" +#undef OBJ_FLAG +}; + struct object { unsigned magic; #define OBJECT_MAGIC 0x32851d42 @@ -564,13 +570,12 @@ struct object { uint8_t *oa_http; - unsigned gziped:1; - unsigned changed_gzip:1; + + uint8_t oa_flags[1]; /* Bit positions in the gzip stream */ char oa_gzipbits[24]; - /* VCL only variables */ char oa_lastmodified[8]; @@ -1077,6 +1082,9 @@ int ObjGetDouble(struct objcore *, struct dstat *, enum obj_attr, double *); int ObjGetU32(struct objcore *, struct dstat *, enum obj_attr, uint32_t *); int ObjGetU64(struct objcore *, struct dstat *, enum obj_attr, uint64_t *); +int ObjCheckFlag(struct objcore *oc, struct dstat *ds, enum obj_flags of); +void ObjSetFlag(const struct vfp_ctx *vc, enum obj_flags of, int val); + /* cache_panic.c */ void PAN_Init(void); const char *body_status_2str(enum body_status e); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 185378e..71313e3 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -516,7 +516,7 @@ ESI_DeliverChild(struct req *req) obj = ObjGetObj(req->objcore, &req->wrk->stats); CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - if (!obj->gziped) { + if (!ObjCheckFlag(req->objcore, &req->wrk->stats, OF_GZIPED)) { VTAILQ_FOREACH(st, &obj->body->list, list) ved_pretend_gzip(req, st->ptr, st->len); return; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 3abd6ef..b657c03 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -352,7 +352,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (bo->ims_obj != NULL && http_IsStatus(bo->beresp, 304)) { http_Merge(bo->ims_obj->http, bo->beresp, - bo->ims_obj->changed_gzip); + ObjCheckFlag(bo->ims_oc, bo->stats, OF_CHGGZIP)); assert(http_IsStatus(bo->beresp, 200)); do_ims = 1; } else @@ -482,10 +482,10 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) bo->vfc->body = obj->body; if (bo->do_gzip || (bo->is_gzip && !bo->do_gunzip)) - obj->gziped = 1; + ObjSetFlag(bo->vfc, OF_GZIPED, 1); if (bo->do_gzip || bo->do_gunzip) - obj->changed_gzip = 1; + ObjSetFlag(bo->vfc, OF_CHGGZIP, 1); if (bo->htc.body_status != BS_NONE) V1F_Setup_Fetch(bo); @@ -566,7 +566,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - if (bo->ims_obj->changed_gzip) { + if (ObjCheckFlag(bo->ims_oc, bo->stats, OF_CHGGZIP)) { /* * If we modified the gzip status of the IMS object, that * must control the C-E header, if any. @@ -584,8 +584,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) if (ObjGetattr(bo->ims_oc, bo->stats, OA_ESIDATA, NULL) != NULL) AZ(ObjCopyAttr(bo->vfc, bo->ims_oc, OA_ESIDATA)); - obj->gziped = bo->ims_obj->gziped; - + AZ(ObjCopyAttr(bo->vfc, bo->ims_oc, OA_FLAGS)); AZ(ObjCopyAttr(bo->vfc, bo->ims_oc, OA_GZIPBITS)); AZ(WS_Overflowed(bo->ws_o)); diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index e3b392a..f27f1bd 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -266,7 +266,8 @@ V1D_Deliver(struct req *req, struct busyobj *bo) req->res_mode |= RES_ESI_CHILD; } - if (cache_param->http_gzip_support && req->obj->gziped && + if (cache_param->http_gzip_support && + ObjCheckFlag(req->objcore, &req->wrk->stats, OF_GZIPED) && !RFC2616_Req_Gzip(req->http)) { /* * We don't know what it uncompresses to @@ -344,7 +345,8 @@ V1D_Deliver(struct req *req, struct busyobj *bo) ESI_DeliverChild(req); } else if (req->res_mode & RES_GUNZIP || (req->res_mode & RES_ESI_CHILD && - !req->gzip_resp && req->obj->gziped)) { + !req->gzip_resp && + ObjCheckFlag(req->objcore, &req->wrk->stats, OF_GZIPED))) { VDP_push(req, VDP_gunzip); req->vgz = VGZ_NewUngzip(req->vsl, "U D -"); AZ(VGZ_WrwInit(req->vgz)); diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index e18169a..94dfb17 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -232,6 +232,9 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, return (NULL); *len = o->esidata->len; return (o->esidata->ptr); + case OA_FLAGS: + *len = sizeof o->oa_flags; + return (o->oa_flags); case OA_GZIPBITS: *len = sizeof o->oa_gzipbits; return (o->oa_gzipbits); @@ -271,6 +274,9 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, return (NULL); o->esidata->len = len; return (o->esidata->ptr); + case OA_FLAGS: + assert(len == sizeof o->oa_flags); + return (o->oa_flags); case OA_GZIPBITS: assert(len == sizeof o->oa_gzipbits); return (o->oa_gzipbits); @@ -420,3 +426,29 @@ ObjGetU32(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint32_t *d) *d = vbe32dec(vp); return (0); } + +/*-------------------------------------------------------------------- + */ + +int +ObjCheckFlag(struct objcore *oc, struct dstat *ds, enum obj_flags of) +{ + uint8_t *fp; + + fp = ObjGetattr(oc, ds, OA_FLAGS, NULL); + AN(fp); + return ((*fp) & of); +} + +void +ObjSetFlag(const struct vfp_ctx *vc, enum obj_flags of, int val) +{ + uint8_t *fp; + + fp = ObjSetattr(vc, OA_FLAGS, 1); + AN(fp); + if (val) + (*fp) |= of; + else + (*fp) &= ~of; +} diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 3405a1a..ecdbe15 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -128,7 +128,8 @@ cnt_deliver(struct worker *wrk, struct req *req) http_SetHeader(req->resp, "Via: 1.1 varnish-v4"); - if (cache_param->http_gzip_support && req->obj->gziped && + if (cache_param->http_gzip_support && + ObjCheckFlag(req->objcore, &req->wrk->stats, OF_GZIPED) && !RFC2616_Req_Gzip(req->http)) RFC2616_Weaken_Etag(req->resp); diff --git a/include/tbl/obj_attr.h b/include/tbl/obj_attr.h index 860fc5c..42e58e7 100644 --- a/include/tbl/obj_attr.h +++ b/include/tbl/obj_attr.h @@ -30,13 +30,21 @@ /*lint -save -e525 -e539 */ /* upper, lower */ +#ifdef OBJ_ATTR OBJ_ATTR(VXID, vxid) OBJ_ATTR(EXP, exp) OBJ_ATTR(VARY, vary) OBJ_ATTR(HEADERS, headers) -OBJ_ATTR(GZIPFLAGS, gzipflags) +OBJ_ATTR(FLAGS, flags) OBJ_ATTR(GZIPBITS, gzipbits) OBJ_ATTR(ESIDATA, esidata) OBJ_ATTR(LASTMODIFIED, lastmodified) +#endif + +#ifdef OBJ_FLAG +/* upper, lower, val */ +OBJ_FLAG(GZIPED, gziped, (1<<1)) +OBJ_FLAG(CHGGZIP, chggzip, (1<<2)) +#endif /*lint -restore */ From phk at FreeBSD.org Mon Aug 11 11:56:05 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Aug 2014 13:56:05 +0200 Subject: [master] 6699df5 Eliminate bo->fetch_obj Message-ID: commit 6699df5903e6938e67a21a67bb215b950b5cc3d4 Author: Poul-Henning Kamp Date: Mon Aug 11 11:55:52 2014 +0000 Eliminate bo->fetch_obj diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 12712b5..47e4fa7 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -498,7 +498,6 @@ struct busyobj { struct object *ims_obj; struct objcore *ims_oc; struct objcore *fetch_objcore; - struct object *fetch_obj; struct http_conn htc; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index b657c03..aa5f2e5 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -139,9 +139,6 @@ vbf_beresp2obj(struct busyobj *bo) CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - AZ(bo->fetch_obj); - bo->fetch_obj = obj; - if (vary != NULL) { obj->vary = (void *)WS_Copy(obj->http->ws, VSB_data(vary), varyl); @@ -167,6 +164,8 @@ vbf_beresp2obj(struct busyobj *bo) AZ(ObjSetDouble(bo->vfc, OA_LASTMODIFIED, floor(bo->fetch_objcore->exp.t_origin))); + bo->vfc->body = obj->body; + return (0); } @@ -398,7 +397,6 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) static enum fetch_step vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) { - struct object *obj; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -478,8 +476,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(WRW_IsReleased(wrk)); - obj = bo->fetch_obj; - bo->vfc->body = obj->body; if (bo->do_gzip || (bo->is_gzip && !bo->do_gunzip)) ObjSetFlag(bo->vfc, OF_GZIPED, 1); @@ -501,7 +497,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert (bo->state == BOS_REQ_DONE); if (bo->do_stream) { - HSH_Unbusy(&wrk->stats, obj->objcore); + HSH_Unbusy(&wrk->stats, bo->fetch_objcore); VBO_setstate(bo, BOS_STREAM); } @@ -517,10 +513,8 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->vfc->failed && !bo->do_stream) { assert(bo->state < BOS_STREAM); - if (bo->fetch_objcore != NULL) { + if (bo->fetch_objcore != NULL) ObjFreeObj(bo->fetch_objcore, bo->stats); - bo->fetch_obj = NULL; - } return (F_STP_ERROR); } @@ -531,7 +525,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(bo->state == BOS_STREAM); else { assert(bo->state == BOS_REQ_DONE); - HSH_Unbusy(&wrk->stats, obj->objcore); + HSH_Unbusy(&wrk->stats, bo->fetch_objcore); } /* Recycle the backend connection before setting BOS_FINISHED to @@ -554,7 +548,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) static enum fetch_step vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) { - struct object *obj; struct objiter *oi; void *sp; ssize_t sl, al, tl; @@ -578,8 +571,6 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) } AZ(vbf_beresp2obj(bo)); - obj = bo->fetch_obj; - bo->vfc->body = obj->body; if (ObjGetattr(bo->ims_oc, bo->stats, OA_ESIDATA, NULL) != NULL) AZ(ObjCopyAttr(bo->vfc, bo->ims_oc, OA_ESIDATA)); @@ -589,7 +580,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) AZ(WS_Overflowed(bo->ws_o)); if (bo->do_stream) { - HSH_Unbusy(&wrk->stats, obj->objcore); + HSH_Unbusy(&wrk->stats, bo->fetch_objcore); VBO_setstate(bo, BOS_STREAM); } @@ -622,7 +613,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) return (F_STP_FAIL); if (!bo->do_stream) - HSH_Unbusy(&wrk->stats, obj->objcore); + HSH_Unbusy(&wrk->stats, bo->fetch_objcore); assert(al == ol); assert(ObjGetLen(bo->fetch_objcore, bo->stats) == al); @@ -700,7 +691,6 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) if (vbf_beresp2obj(bo)) return (F_STP_FAIL); - bo->vfc->body = bo->fetch_obj->body; l = VSB_len(bo->synth_body); if (l > 0) { diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 03ef16c..e130925 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -341,8 +341,6 @@ pan_busyobj(const struct busyobj *bo) pan_ws(bo->ws_o, 4); if (bo->fetch_objcore) pan_objcore("FETCH", bo->fetch_objcore); - if (bo->fetch_obj) - pan_object("FETCH", bo->fetch_obj); if (bo->ims_obj) pan_object("IMS", bo->ims_obj); VSB_printf(pan_vsp, " }\n"); From arianna.aondio at varnish-software.com Mon Aug 11 12:24:09 2014 From: arianna.aondio at varnish-software.com (arianna) Date: Mon, 11 Aug 2014 14:24:09 +0200 Subject: [master] c6f20e4 Varnishstat hitrate implementation Message-ID: commit c6f20e4701cfc7484a8bc064e7c6f41de243865d Author: arianna Date: Fri Aug 8 12:56:55 2014 +0200 Varnishstat hitrate implementation diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index fd80580..8ce35f1 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -91,6 +91,15 @@ struct pt { struct ma ma_10, ma_100, ma_1000; }; +struct hitrate { + double lt; + uint64_t lhit, lmiss; + struct ma hr_10; + struct ma hr_100; + struct ma hr_1000; +}; +static struct hitrate hitrate; + static VTAILQ_HEAD(, pt) ptlist = VTAILQ_HEAD_INITIALIZER(ptlist); static int n_ptlist = 0; static int n_ptarray = 0; @@ -119,6 +128,19 @@ static double t_sample = 0.; static double interval = 1.; static void +init_hitrate(void) +{ + memset(&hitrate, 0, sizeof (struct hitrate)); + if (VSC_C_main != NULL) { + hitrate.lhit = VSC_C_main->cache_hit; + hitrate.lmiss = VSC_C_main->cache_miss; + } + hitrate.hr_10.nmax = 10; + hitrate.hr_100.nmax = 100; + hitrate.hr_1000.nmax = 1000; +} + +static void update_ma(struct ma *ma, double val) { AN(ma); @@ -348,10 +370,6 @@ sample_points(void) { struct pt *pt; - t_sample = VTIM_mono(); - sample = 0; - redraw = 1; - VTAILQ_FOREACH(pt, &ptlist, list) { AN(pt->vpt); AN(pt->ptr); @@ -390,6 +408,46 @@ sample_points(void) } static void +sample_hitrate(void) +{ + double tv,dt; + double hr, mr, ratio; + uint64_t hit, miss; + + if (VSC_C_mgt == NULL) + return; + + tv = VTIM_mono(); + dt = tv - hitrate.lt; + hitrate.lt= tv; + + hit = VSC_C_main->cache_hit; + miss = VSC_C_main->cache_miss; + hr = (hit - hitrate.lhit) / dt; + mr = (miss - hitrate.lmiss) / dt; + hitrate.lhit = hit; + hitrate.lmiss = miss; + + if (hr + mr != 0) + ratio = hr / (hr + mr); + else + ratio = 0; + update_ma(&hitrate.hr_10, ratio); + update_ma(&hitrate.hr_100, ratio); + update_ma(&hitrate.hr_1000, ratio); +} + +static void +sample_data(void) +{ + t_sample = VTIM_mono(); + sample = 0; + redraw = 1; + sample_points(); + sample_hitrate(); +} + +static void make_windows(void) { int Y, X; @@ -489,8 +547,18 @@ draw_status(void) AN(w_status); werase(w_status); - if (VSC_C_mgt != NULL) + + if (VSC_C_mgt != NULL) { up_mgt = VSC_C_mgt->uptime; + if( COLS > 70) { + mvwprintw(w_status, 0, (getmaxx (w_status) - 37), + "Hitrate n: %8u %8u %8u", hitrate.hr_10.n, hitrate.hr_100.n, + hitrate.hr_1000.n); + mvwprintw(w_status, 1, (getmaxx (w_status) - 37), + " avg(n): %8.4f %8.4f %8.4f", hitrate.hr_10.acc, + hitrate.hr_100.acc, hitrate.hr_1000.acc); + } + } if (VSC_C_main != NULL) up_chld = VSC_C_main->uptime; @@ -866,8 +934,10 @@ do_curses(struct VSM_data *vd, int delay) VSC_C_mgt = VSC_Mgt(vd, &f_mgt); VSC_C_main = VSC_Main(vd, &f_main); + init_hitrate(); while (keep_running) { if (VSM_Abandoned(vd)) { + init_hitrate(); delete_pt_list(); VSM_Close(vd); VSM_Open(vd); @@ -881,7 +951,7 @@ do_curses(struct VSM_data *vd, int delay) if (now - t_sample > interval) sample = 1; if (sample) - sample_points(); + sample_data(); if (rebuild) build_pt_array(); if (redraw) From phk at FreeBSD.org Mon Aug 11 12:43:23 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Aug 2014 14:43:23 +0200 Subject: [master] 85956ba Another stab at getting this printf right Message-ID: commit 85956bae06a516394dec3dc47ca0c0e13b06c4aa Author: Poul-Henning Kamp Date: Mon Aug 11 12:43:01 2014 +0000 Another stab at getting this printf right diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index aa5f2e5..b69b0c0 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -796,7 +796,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv) if (bo->state == BOS_FINISHED) { AZ(bo->fetch_objcore->flags & OC_F_FAILED); HSH_Complete(bo->fetch_objcore); - VSLb(bo->vsl, SLT_Length, "%zd", + VSLb(bo->vsl, SLT_Length, "%ju", (uintmax_t)ObjGetLen(bo->fetch_objcore, bo->stats)); } AZ(bo->fetch_objcore->busyobj); From phk at FreeBSD.org Mon Aug 11 13:58:40 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Aug 2014 15:58:40 +0200 Subject: [master] 4489553 Remove debugging Message-ID: commit 44895531873eedb589fd42f6c34c54612464217e Author: Poul-Henning Kamp Date: Mon Aug 11 13:58:31 2014 +0000 Remove debugging diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 79e2bd2..6dc5251 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -683,7 +683,6 @@ HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how) assert(p <= e); e = (uint8_t*)ws->f; vbe16enc(e, n + 1); - VSLb(fm->vsl, SLT_Debug, "HTTPENC %zd", p - (uint8_t*)ws->f); WS_ReleaseP(ws, (void*)p); return (e); } From fgsch at lodoss.net Mon Aug 11 15:38:35 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 11 Aug 2014 17:38:35 +0200 Subject: [master] 716810b Fix compilation if SO_{SND, RCV}TIMEO_WORKS is not defined Message-ID: commit 716810bb51a8517c304ec34543b3426ad247bcbb Author: Federico G. Schwindt Date: Mon Aug 11 16:14:12 2014 +0100 Fix compilation if SO_{SND,RCV}TIMEO_WORKS is not defined Fixes #1567 diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index bad4ed9..af86b2b 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -126,13 +126,13 @@ vca_tcp_opt_init(void) { int n; int one = 1; - // int zero = 0; struct tcp_opt *to; struct timeval tv; int chg = 0; -#ifdef HAVE_TCP_KEEP int x; -#endif + + (void)tv; + (void)x; for (n = 0; n < n_tcp_opts; n++) { to = &tcp_opts[n]; From phk at FreeBSD.org Tue Aug 12 08:15:04 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Aug 2014 10:15:04 +0200 Subject: [master] ea518c6 Add a OF_IMSCAND flag at set it when we create the object, and replace the duplicated test for :status, Last-Modified and ETag. Message-ID: commit ea518c6930b80e24b4773e2e6039240928ff4c48 Author: Poul-Henning Kamp Date: Tue Aug 12 08:13:44 2014 +0000 Add a OF_IMSCAND flag at set it when we create the object, and replace the duplicated test for :status, Last-Modified and ETag. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index b69b0c0..9dfdbc8 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -397,6 +397,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) static enum fetch_step vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) { + char *p; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -483,6 +484,11 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->do_gzip || bo->do_gunzip) ObjSetFlag(bo->vfc, OF_CHGGZIP, 1); + if (http_IsStatus(bo->beresp, 200) && ( + http_GetHdr(bo->beresp, H_Last_Modified, &p) || + http_GetHdr(bo->beresp, H_ETag, &p))) + ObjSetFlag(bo->vfc, OF_IMSCAND, 1); + if (bo->htc.body_status != BS_NONE) V1F_Setup_Fetch(bo); @@ -865,8 +871,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, oldobj = ObjGetObj(oldoc, &wrk->stats); CHECK_OBJ_NOTNULL(oldobj, OBJECT_MAGIC); - if (http_GetHdr(oldobj->http, H_Last_Modified, NULL) || - http_GetHdr(oldobj->http, H_ETag, NULL)) { + if (ObjCheckFlag(oldoc, &req->wrk->stats, OF_IMSCAND)) { assert(oldoc->refcnt > 0); HSH_Ref(oldoc); bo->ims_obj = oldobj; diff --git a/include/tbl/obj_attr.h b/include/tbl/obj_attr.h index 42e58e7..b121793 100644 --- a/include/tbl/obj_attr.h +++ b/include/tbl/obj_attr.h @@ -45,6 +45,7 @@ OBJ_ATTR(LASTMODIFIED, lastmodified) /* upper, lower, val */ OBJ_FLAG(GZIPED, gziped, (1<<1)) OBJ_FLAG(CHGGZIP, chggzip, (1<<2)) +OBJ_FLAG(IMSCAND, imscand, (1<<3)) #endif /*lint -restore */ From phk at FreeBSD.org Tue Aug 12 08:29:33 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Aug 2014 10:29:33 +0200 Subject: [master] 7a385e9 Strictly speaking Message-ID: commit 7a385e94959f8210a504746be10adf055aa6c4b2 Author: Poul-Henning Kamp Date: Tue Aug 12 08:27:54 2014 +0000 Strictly speaking int foo() { int bar; (void)bar; [...] } Isn't valid C because bar has an undefined value when you cast its value away. Yes, many thanks to ISO-C for that gem. Memset the variables to zero instead. diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index af86b2b..7afcef6 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -131,8 +131,8 @@ vca_tcp_opt_init(void) int chg = 0; int x; - (void)tv; - (void)x; + memset(&tv, 0, sizeof tv); + memset(&x, 0, sizeof x); for (n = 0; n < n_tcp_opts; n++) { to = &tcp_opts[n]; From phk at FreeBSD.org Tue Aug 12 08:29:33 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Aug 2014 10:29:33 +0200 Subject: [master] 420cc26 Minor polish around IMS tests. Message-ID: commit 420cc26bd6bd503d6f6ffcd1c1fccf49c0256089 Author: Poul-Henning Kamp Date: Tue Aug 12 08:29:15 2014 +0000 Minor polish around IMS tests. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 9dfdbc8..8b605ce 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -201,7 +201,7 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) http_CopyHome(bo->bereq0); } - if (bo->ims_obj != NULL && http_IsStatus(bo->ims_obj->http, 200)) { + if (bo->ims_oc != NULL) { if (http_GetHdr(bo->ims_obj->http, H_Last_Modified, &p)) { http_PrintfHeader(bo->bereq0, "If-Modified-Since: %s", p); @@ -349,7 +349,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) AZ(bo->do_esi); - if (bo->ims_obj != NULL && http_IsStatus(bo->beresp, 304)) { + if (bo->ims_oc != NULL && http_IsStatus(bo->beresp, 304)) { http_Merge(bo->ims_obj->http, bo->beresp, ObjCheckFlag(bo->ims_oc, bo->stats, OF_CHGGZIP)); assert(http_IsStatus(bo->beresp, 200)); @@ -867,16 +867,15 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, AZ(bo->ims_obj); AZ(bo->ims_oc); - if (oldoc != NULL) { + if (oldoc != NULL && + ObjCheckFlag(oldoc, &req->wrk->stats, OF_IMSCAND)) { + assert(oldoc->refcnt > 0); + HSH_Ref(oldoc); + bo->ims_oc = oldoc; + oldobj = ObjGetObj(oldoc, &wrk->stats); CHECK_OBJ_NOTNULL(oldobj, OBJECT_MAGIC); - - if (ObjCheckFlag(oldoc, &req->wrk->stats, OF_IMSCAND)) { - assert(oldoc->refcnt > 0); - HSH_Ref(oldoc); - bo->ims_obj = oldobj; - bo->ims_oc = oldoc; - } + bo->ims_obj = oldobj; } AZ(bo->req); From phk at FreeBSD.org Tue Aug 12 09:22:54 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Aug 2014 11:22:54 +0200 Subject: [master] 6a06d64 Get IMS and gzip/gunzip more correct: Message-ID: commit 6a06d64d4d83215812e9f030877364ac6c1a9e9d Author: Poul-Henning Kamp Date: Tue Aug 12 09:22:00 2014 +0000 Get IMS and gzip/gunzip more correct: If we gzip/gzunzipped the object, the C-E header we produced controls and if the 304 contains an ETag, it must be weakened. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 47e4fa7..0f9605b 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -982,7 +982,7 @@ void http_MarkHeader(const struct http *, const char *hdr, unsigned hdrlen, uint8_t flag); void http_CollectHdr(struct http *hp, const char *hdr); void http_VSL_log(const struct http *hp); -void http_Merge(const struct http *fm, struct http *to, int not_ce); +void http_Merge(const struct http *fm, struct http *to); /* cache_http1_proto.c */ diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 8b605ce..8c1d2a5 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -350,8 +350,16 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) AZ(bo->do_esi); if (bo->ims_oc != NULL && http_IsStatus(bo->beresp, 304)) { - http_Merge(bo->ims_obj->http, bo->beresp, - ObjCheckFlag(bo->ims_oc, bo->stats, OF_CHGGZIP)); + if (ObjCheckFlag(bo->ims_oc, bo->stats, OF_CHGGZIP)) { + /* + * If we changed the gzip status of the object + * the stored Content_Encoding controls and we + * must weaken any new ETag we get. + */ + http_Unset(bo->beresp, H_Content_Encoding); + RFC2616_Weaken_Etag(bo->beresp); + } + http_Merge(bo->ims_obj->http, bo->beresp); assert(http_IsStatus(bo->beresp, 200)); do_ims = 1; } else diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 6dc5251..b788f89 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -785,7 +785,7 @@ http_FilterReq(struct http *to, const struct http *fm, unsigned how) */ void -http_Merge(const struct http *fm, struct http *to, int not_ce) +http_Merge(const struct http *fm, struct http *to) { unsigned u, v; const char *p; @@ -797,12 +797,6 @@ http_Merge(const struct http *fm, struct http *to, int not_ce) for (u = HTTP_HDR_FIRST; u < fm->nhd; u++) fm->hdf[u] |= HDF_MARKER; - if (not_ce) { - u = http_findhdr(fm, - H_Content_Encoding[0] - 1, H_Content_Encoding + 1); - if (u > 0) - fm->hdf[u] &= ~HDF_MARKER; - } for (v = HTTP_HDR_FIRST; v < to->nhd; v++) { p = strchr(to->hd[v].b, ':'); AN(p); diff --git a/bin/varnishtest/tests/g00006.vtc b/bin/varnishtest/tests/g00006.vtc index 740d4bd..cbae574 100644 --- a/bin/varnishtest/tests/g00006.vtc +++ b/bin/varnishtest/tests/g00006.vtc @@ -3,21 +3,29 @@ varnishtest "IMS'ing g[un]zip'ed objects" server s1 { rxreq expect req.url == /1 - txresp -hdr "Last-Modified: Wed, 11 Sep 2013 13:36:55 GMT" -bodylen 20 + txresp -hdr "Last-Modified: Wed, 11 Sep 2013 13:36:55 GMT" \ + -hdr "ETag: foozle" \ + -bodylen 20 rxreq expect req.url == /1 expect req.http.if-modified-since == "Wed, 11 Sep 2013 13:36:55 GMT" - txresp -status 304 -nolen + txresp -status 304 \ + -hdr "ETag: fizle" \ + -nolen rxreq expect req.url == /2 - txresp -hdr "Last-Modified: Wed, 11 Sep 2013 13:36:55 GMT" -gzipbody "012345678901234567" + txresp -hdr "Last-Modified: Wed, 11 Sep 2013 13:36:55 GMT" \ + -hdr "ETag: foobar" \ + -gzipbody "012345678901234567" rxreq expect req.url == /2 expect req.http.if-modified-since == "Wed, 11 Sep 2013 13:36:55 GMT" - txresp -status 304 -hdr "Content-Encoding: gzip,rot13" -nolen + txresp -status 304 -hdr "Content-Encoding: gzip,rot13" \ + -hdr "ETag: snafu" \ + -nolen } -start @@ -40,6 +48,7 @@ client c1 { rxresp expect resp.http.content-encoding == "gzip" expect resp.http.foobar == "" + expect resp.http.etag == "W/foozle" gunzip expect resp.bodylen == 20 @@ -48,7 +57,8 @@ client c1 { txreq -url /1 -hdr "Accept-Encoding: gzip" rxresp expect resp.http.content-encoding == "gzip" - expect resp.http.foobar == "" + expect resp.http.foobar == "gzip" + expect resp.http.etag == "W/fizle" gunzip expect resp.bodylen == 20 @@ -59,6 +69,7 @@ client c1 { expect resp.http.content-encoding == "" expect resp.http.foobar == "gzip" expect resp.bodylen == 18 + expect resp.http.etag == "W/foobar" delay 1 @@ -66,7 +77,8 @@ client c1 { rxresp expect resp.http.content-encoding == "" # Here we see the C-E of the IMS OBJ - expect resp.http.foobar == "gzip,rot13" + expect resp.http.foobar == "" + expect resp.http.etag == "W/snafu" expect resp.bodylen == 18 } -run From phk at FreeBSD.org Tue Aug 12 20:37:21 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Aug 2014 22:37:21 +0200 Subject: [master] d9a6da6 Get OA_HEADERS using the accessor function Message-ID: commit d9a6da6d104b2544d904c48c4b98e2bf139bda50 Author: Poul-Henning Kamp Date: Tue Aug 12 20:37:07 2014 +0000 Get OA_HEADERS using the accessor function diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index ecdbe15..c01d7b7 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -105,7 +105,8 @@ cnt_deliver(struct worker *wrk, struct req *req) EXP_Touch(req->objcore, req->t_prev); HTTP_Setup(req->resp, req->ws, req->vsl, SLT_RespMethod); - AZ(HTTP_Decode(req->resp, req->obj->oa_http)); + AZ(HTTP_Decode(req->resp, + ObjGetattr(req->objcore, &req->wrk->stats, OA_HEADERS, NULL))); http_ForceField(req->resp, HTTP_HDR_PROTO, "HTTP/1.1"); if (req->wrk->stats.cache_hit) From phk at FreeBSD.org Tue Aug 12 21:20:11 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Aug 2014 23:20:11 +0200 Subject: [master] 9b35b6f Introduce a function to extract a header from OA_HEADER Message-ID: commit 9b35b6f7fca377feb4bd3ff46d99382d8a2437bc Author: Poul-Henning Kamp Date: Tue Aug 12 21:19:44 2014 +0000 Introduce a function to extract a header from OA_HEADER diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 0f9605b..54af650 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -983,6 +983,8 @@ void http_MarkHeader(const struct http *, const char *hdr, unsigned hdrlen, void http_CollectHdr(struct http *hp, const char *hdr); void http_VSL_log(const struct http *hp); void http_Merge(const struct http *fm, struct http *to); +const char *HTTP_GetHdrPack(struct objcore *, struct dstat *, + const char *hdr); /* cache_http1_proto.c */ diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 8c1d2a5..895de56 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -176,7 +176,7 @@ vbf_beresp2obj(struct busyobj *bo) static enum fetch_step vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) { - char *p; + const char *q; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -202,14 +202,14 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) } if (bo->ims_oc != NULL) { - if (http_GetHdr(bo->ims_obj->http, H_Last_Modified, &p)) { + q = HTTP_GetHdrPack(bo->ims_oc, bo->stats, H_Last_Modified); + if (q != NULL) http_PrintfHeader(bo->bereq0, - "If-Modified-Since: %s", p); - } - if (http_GetHdr(bo->ims_obj->http, H_ETag, &p)) { + "If-Modified-Since: %s", q); + q = HTTP_GetHdrPack(bo->ims_oc, bo->stats, H_ETag); + if (q != NULL) http_PrintfHeader(bo->bereq0, - "If-None-Match: %s", p); - } + "If-None-Match: %s", q); } HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod); @@ -568,22 +568,10 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) uint64_t ol; struct storage *st; enum objiter_status ois; - char *p; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - if (ObjCheckFlag(bo->ims_oc, bo->stats, OF_CHGGZIP)) { - /* - * If we modified the gzip status of the IMS object, that - * must control the C-E header, if any. - */ - http_Unset(bo->beresp, H_Content_Encoding); - if (http_GetHdr(bo->ims_obj->http, H_Content_Encoding, &p)) - http_PrintfHeader(bo->beresp, - "Content-Encoding: %s", p); - } - AZ(vbf_beresp2obj(bo)); if (ObjGetattr(bo->ims_oc, bo->stats, OA_ESIDATA, NULL) != NULL) diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index b788f89..db4123b 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -723,6 +723,54 @@ HTTP_Decode(struct http *to, uint8_t *fm) /*--------------------------------------------------------------------*/ +const char * +HTTP_GetHdrPack(struct objcore *oc, struct dstat *ds, const char *hdr) +{ + char *ptr; + unsigned l; + + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + AN(ds); + AN(hdr); + + l = hdr[0]; + assert(l == strlen(hdr + 1)); + assert(hdr[l] == ':'); + hdr++; + ptr = ObjGetattr(oc, ds, OA_HEADERS, NULL); + AN(ptr); + + /* Skip nhd and status */ + ptr += 4; + VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr); + + /* Skip PROTO, STATUS and REASON */ + ptr = strchr(ptr, '\0') + 1; + VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr); + ptr = strchr(ptr, '\0') + 1; + VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr); + ptr = strchr(ptr, '\0') + 1; + VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr); + + while (*ptr != '\0') { + VSL(SLT_Debug, 0, "%d <%s> %u <%s>", __LINE__, ptr, l, hdr); + if (!strncasecmp(ptr, hdr, l)) { + ptr += l; + assert (vct_issp(*ptr)); + ptr++; + assert (!vct_issp(*ptr)); + return (ptr); + } + ptr = strchr(ptr, '\0') + 1; + VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr); + } + return (NULL); +} + + + +/*--------------------------------------------------------------------*/ + static void http_filterfields(struct http *to, const struct http *fm, unsigned how) { diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index c01d7b7..c69c0ed 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -105,7 +105,7 @@ cnt_deliver(struct worker *wrk, struct req *req) EXP_Touch(req->objcore, req->t_prev); HTTP_Setup(req->resp, req->ws, req->vsl, SLT_RespMethod); - AZ(HTTP_Decode(req->resp, + AZ(HTTP_Decode(req->resp, ObjGetattr(req->objcore, &req->wrk->stats, OA_HEADERS, NULL))); http_ForceField(req->resp, HTTP_HDR_PROTO, "HTTP/1.1"); From phk at FreeBSD.org Tue Aug 12 21:44:13 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Aug 2014 23:44:13 +0200 Subject: [master] b582416 Rewrite http_Merge() to pull from OA_HEADERS Message-ID: commit b58241634cd84c8314e5face68bd9bb0da091be7 Author: Poul-Henning Kamp Date: Tue Aug 12 21:43:55 2014 +0000 Rewrite http_Merge() to pull from OA_HEADERS diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 54af650..0b6ebd3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -185,7 +185,6 @@ struct http { txt *hd; unsigned char *hdf; #define HDF_FILTER (1 << 0) /* Filtered by Connection */ -#define HDF_MARKER (1 << 1) /* Marker bit */ /* NB: ->nhd and below zeroed/initialized by http_Teardown */ uint16_t nhd; /* Next free hd */ @@ -982,7 +981,7 @@ void http_MarkHeader(const struct http *, const char *hdr, unsigned hdrlen, uint8_t flag); void http_CollectHdr(struct http *hp, const char *hdr); void http_VSL_log(const struct http *hp); -void http_Merge(const struct http *fm, struct http *to); +void HTTP_Merge(struct objcore *, struct dstat *, struct http *to); const char *HTTP_GetHdrPack(struct objcore *, struct dstat *, const char *hdr); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 895de56..03b4772 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -359,7 +359,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) http_Unset(bo->beresp, H_Content_Encoding); RFC2616_Weaken_Etag(bo->beresp); } - http_Merge(bo->ims_obj->http, bo->beresp); + HTTP_Merge(bo->ims_oc, bo->stats, bo->beresp); assert(http_IsStatus(bo->beresp, 200)); do_ims = 1; } else diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index db4123b..f6a7f39 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -726,7 +726,7 @@ HTTP_Decode(struct http *to, uint8_t *fm) const char * HTTP_GetHdrPack(struct objcore *oc, struct dstat *ds, const char *hdr) { - char *ptr; + const char *ptr; unsigned l; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); @@ -746,14 +746,10 @@ HTTP_GetHdrPack(struct objcore *oc, struct dstat *ds, const char *hdr) /* Skip PROTO, STATUS and REASON */ ptr = strchr(ptr, '\0') + 1; - VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr); ptr = strchr(ptr, '\0') + 1; - VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr); ptr = strchr(ptr, '\0') + 1; - VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr); while (*ptr != '\0') { - VSL(SLT_Debug, 0, "%d <%s> %u <%s>", __LINE__, ptr, l, hdr); if (!strncasecmp(ptr, hdr, l)) { ptr += l; assert (vct_issp(*ptr)); @@ -762,12 +758,46 @@ HTTP_GetHdrPack(struct objcore *oc, struct dstat *ds, const char *hdr) return (ptr); } ptr = strchr(ptr, '\0') + 1; - VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr); } return (NULL); } +/*-------------------------------------------------------------------- + * Merge any headers in the oc->OA_HEADER into the struct http if they + * are not there already. + */ +void +HTTP_Merge(struct objcore *oc, struct dstat *ds, struct http *to) +{ + const char *ptr; + unsigned u; + const char *p; + + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); + AN(ds); + + ptr = ObjGetattr(oc, ds, OA_HEADERS, NULL); + AN(ptr); + + to->status = vbe16dec(ptr + 2); + ptr += 4; + + for (u = 0; u < HTTP_HDR_FIRST; u++) { + if (u == HTTP_HDR_METHOD || u == HTTP_HDR_URL) + continue; + http_SetH(to, u, ptr); + ptr = strchr(ptr, '\0') + 1; + } + while (*ptr != '\0') { + p = strchr(ptr, ':'); + AN(p); + if (!http_findhdr(to, p - ptr, ptr)) + http_SetHeader(to, ptr); + ptr = strchr(ptr, '\0') + 1; + } +} /*--------------------------------------------------------------------*/ @@ -827,37 +857,6 @@ http_FilterReq(struct http *to, const struct http *fm, unsigned how) } /*-------------------------------------------------------------------- - * Merge two HTTP headers the "wrong" way. Used by backend IMS to - * merge in the headers of the validated object with the headers of - * the 304 response. - */ - -void -http_Merge(const struct http *fm, struct http *to) -{ - unsigned u, v; - const char *p; - - to->status = fm->status; - http_linkh(to, fm, HTTP_HDR_PROTO); - http_linkh(to, fm, HTTP_HDR_STATUS); - http_linkh(to, fm, HTTP_HDR_REASON); - - for (u = HTTP_HDR_FIRST; u < fm->nhd; u++) - fm->hdf[u] |= HDF_MARKER; - for (v = HTTP_HDR_FIRST; v < to->nhd; v++) { - p = strchr(to->hd[v].b, ':'); - AN(p); - u = http_findhdr(fm, p - to->hd[v].b, to->hd[v].b); - if (u) - fm->hdf[u] &= ~HDF_MARKER; - } - for (u = HTTP_HDR_FIRST; u < fm->nhd; u++) - if (fm->hdf[u] & HDF_MARKER) - http_SetHeader(to, fm->hd[u].b); -} - -/*-------------------------------------------------------------------- * This function copies any header fields which reference foreign * storage into our own WS. */ From nils.goroll at uplex.de Wed Aug 13 08:40:32 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 13 Aug 2014 10:40:32 +0200 Subject: [master] 4c9b521 Quote etags used in tests. Message-ID: commit 4c9b521badf0f8d5f856bf654fde7215d43336fc Author: Nils Goroll Date: Tue Aug 12 13:04:03 2014 +0200 Quote etags used in tests. Though unquoted Etags are commonly seen in the wild, according to rfc2616 the entity-tag itself should be quoted. diff --git a/bin/varnishtest/tests/c00008.vtc b/bin/varnishtest/tests/c00008.vtc index 64762f6..09535c9 100644 --- a/bin/varnishtest/tests/c00008.vtc +++ b/bin/varnishtest/tests/c00008.vtc @@ -4,7 +4,7 @@ server s1 { rxreq expect req.url == "/foo" txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ - -hdr "ETag: foo" \ + -hdr {ETag: "foo"} \ -body "11111\n" } -start @@ -14,26 +14,26 @@ client c1 { txreq -url "/foo" rxresp expect resp.status == 200 - expect resp.http.etag == "foo" + expect resp.http.etag == {"foo"} expect resp.bodylen == 6 txreq -url "/foo" \ -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:00 GMT" rxresp expect resp.status == 200 - expect resp.http.etag == "foo" + expect resp.http.etag == {"foo"} txreq -url "/foo" \ -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" rxresp -no_obj expect resp.status == 304 - expect resp.http.etag == "foo" + expect resp.http.etag == {"foo"} txreq -url "/foo" \ -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:02 GMT" rxresp -no_obj expect resp.status == 304 - expect resp.http.etag == "foo" + expect resp.http.etag == {"foo"} } client c1 -run diff --git a/bin/varnishtest/tests/c00025.vtc b/bin/varnishtest/tests/c00025.vtc index d1a55f3..ea0866a 100644 --- a/bin/varnishtest/tests/c00025.vtc +++ b/bin/varnishtest/tests/c00025.vtc @@ -3,7 +3,7 @@ varnishtest "Test If-None-Match" server s1 { rxreq expect req.url == "/foo" - txresp -hdr "ETag: 123456789" \ + txresp -hdr {ETag: "123456789"} \ -body "11111\n" } -start @@ -16,12 +16,12 @@ client c1 { expect resp.bodylen == 6 txreq -url "/foo" \ - -hdr "If-None-Match: 12345678" + -hdr {If-None-Match: "12345678"} rxresp expect resp.status == 200 txreq -url "/foo" \ - -hdr "If-None-Match: 123456789" + -hdr {If-None-Match: "123456789"} rxresp -no_obj expect resp.status == 304 } diff --git a/bin/varnishtest/tests/c00026.vtc b/bin/varnishtest/tests/c00026.vtc index 7d5c32c..7840b48 100644 --- a/bin/varnishtest/tests/c00026.vtc +++ b/bin/varnishtest/tests/c00026.vtc @@ -3,7 +3,7 @@ varnishtest "Test Combination of If-None-Match and If-Modified-Since" server s1 { rxreq expect req.url == "/foo" - txresp -hdr "ETag: 123456789" \ + txresp -hdr {ETag: "123456789"} \ -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ -body "11111\n" } -start @@ -17,7 +17,7 @@ client c1 { expect resp.bodylen == 6 txreq -url "/foo" \ - -hdr "If-None-Match: 123456789" + -hdr {If-None-Match: "123456789"} rxresp -no_obj expect resp.status == 304 @@ -28,19 +28,19 @@ client c1 { txreq -url "/foo" \ -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:00 GMT" \ - -hdr "If-None-Match: 123456789" + -hdr {If-None-Match: "123456789"} rxresp expect resp.status == 200 txreq -url "/foo" \ -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" \ - -hdr "If-None-Match: 12345678" + -hdr {If-None-Match: "12345678"} rxresp expect resp.status == 200 txreq -url "/foo" \ -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" \ - -hdr "If-None-Match: 123456789" + -hdr {If-None-Match: "123456789"} rxresp -no_obj expect resp.status == 304 diff --git a/bin/varnishtest/tests/g00006.vtc b/bin/varnishtest/tests/g00006.vtc index cbae574..2400401 100644 --- a/bin/varnishtest/tests/g00006.vtc +++ b/bin/varnishtest/tests/g00006.vtc @@ -4,27 +4,27 @@ server s1 { rxreq expect req.url == /1 txresp -hdr "Last-Modified: Wed, 11 Sep 2013 13:36:55 GMT" \ - -hdr "ETag: foozle" \ + -hdr {ETag: "foozle"} \ -bodylen 20 rxreq expect req.url == /1 expect req.http.if-modified-since == "Wed, 11 Sep 2013 13:36:55 GMT" txresp -status 304 \ - -hdr "ETag: fizle" \ + -hdr {ETag: "fizle"} \ -nolen rxreq expect req.url == /2 txresp -hdr "Last-Modified: Wed, 11 Sep 2013 13:36:55 GMT" \ - -hdr "ETag: foobar" \ + -hdr {ETag: "foobar"} \ -gzipbody "012345678901234567" rxreq expect req.url == /2 expect req.http.if-modified-since == "Wed, 11 Sep 2013 13:36:55 GMT" txresp -status 304 -hdr "Content-Encoding: gzip,rot13" \ - -hdr "ETag: snafu" \ + -hdr {ETag: "snafu"} \ -nolen } -start @@ -48,7 +48,7 @@ client c1 { rxresp expect resp.http.content-encoding == "gzip" expect resp.http.foobar == "" - expect resp.http.etag == "W/foozle" + expect resp.http.etag == {W/"foozle"} gunzip expect resp.bodylen == 20 @@ -58,7 +58,7 @@ client c1 { rxresp expect resp.http.content-encoding == "gzip" expect resp.http.foobar == "gzip" - expect resp.http.etag == "W/fizle" + expect resp.http.etag == {W/"fizle"} gunzip expect resp.bodylen == 20 @@ -69,7 +69,7 @@ client c1 { expect resp.http.content-encoding == "" expect resp.http.foobar == "gzip" expect resp.bodylen == 18 - expect resp.http.etag == "W/foobar" + expect resp.http.etag == {W/"foobar"} delay 1 @@ -78,7 +78,7 @@ client c1 { expect resp.http.content-encoding == "" # Here we see the C-E of the IMS OBJ expect resp.http.foobar == "" - expect resp.http.etag == "W/snafu" + expect resp.http.etag == {W/"snafu"} expect resp.bodylen == 18 } -run diff --git a/bin/varnishtest/tests/r00907.vtc b/bin/varnishtest/tests/r00907.vtc index 8bb1139..4bd767f 100644 --- a/bin/varnishtest/tests/r00907.vtc +++ b/bin/varnishtest/tests/r00907.vtc @@ -3,7 +3,7 @@ varnishtest "Ticket #907 200/304 handling with Etags + Last-Modified" server s1 { rxreq txresp \ - -hdr "ETag: saengei1Ohshicich4iteesu" \ + -hdr {ETag: "saengei1Ohshicich4iteesu"} \ -hdr "Last-Modified: Tue, 20 Sep 2011 18:55:00 GMT" } -start @@ -14,16 +14,16 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq -hdr "If-None-Match: saengei1Ohshicich4iteesu" + txreq -hdr {If-None-Match: "saengei1Ohshicich4iteesu"} rxresp -no_obj expect resp.status == 304 - txreq -hdr "If-None-Match: saengei1Ohshicich4iteesu" \ + txreq -hdr {If-None-Match: "saengei1Ohshicich4iteesu"} \ -hdr "If-Modified-Since: Tue, 20 Sep 2011 18:54:59 GMT" rxresp -no_obj expect resp.status == 200 - txreq -hdr "If-None-Match: saengei1Ohshicich4iteesu" \ + txreq -hdr {If-None-Match: "saengei1Ohshicich4iteesu"} \ -hdr "If-Modified-Since: Tue, 20 Sep 2011 18:55:00 GMT" rxresp -no_obj expect resp.status == 304 diff --git a/bin/varnishtest/tests/r00972.vtc b/bin/varnishtest/tests/r00972.vtc index d5e0f0e..0b173f2 100644 --- a/bin/varnishtest/tests/r00972.vtc +++ b/bin/varnishtest/tests/r00972.vtc @@ -2,7 +2,7 @@ varnishtest "Test conditional delivery and do_stream" server s1 { rxreq - txresp -hdr "ETag: foo" -body "11111\n" + txresp -hdr {ETag: "foo"} -body "11111\n" } -start varnish v1 -vcl+backend { @@ -12,9 +12,9 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq -hdr "If-None-Match: foo" + txreq -hdr {If-None-Match: "foo"} rxresp -no_obj expect resp.status == 304 - expect resp.http.etag == "foo" + expect resp.http.etag == {"foo"} } -run diff --git a/bin/varnishtest/tests/r01206.vtc b/bin/varnishtest/tests/r01206.vtc index 78e00b4..1ceb85f 100644 --- a/bin/varnishtest/tests/r01206.vtc +++ b/bin/varnishtest/tests/r01206.vtc @@ -5,7 +5,7 @@ server s1 { txresp -bodylen 6 rxreq - txresp -hdr "ETag: 123456789" \ + txresp -hdr {ETag: "123456789"} \ -bodylen 7 rxreq @@ -25,7 +25,7 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 6 - txreq -hdr "If-None-Match: 123456789" + txreq -hdr {If-None-Match: "123456789"} rxresp expect resp.status == 200 expect resp.bodylen == 7 diff --git a/bin/varnishtest/tests/r01404.vtc b/bin/varnishtest/tests/r01404.vtc index 1411a00..1c04139 100644 --- a/bin/varnishtest/tests/r01404.vtc +++ b/bin/varnishtest/tests/r01404.vtc @@ -2,7 +2,7 @@ varnishtest "Test that 304 does not send Content-Length" server s1 { rxreq - txresp -hdr "ETag: foo" -body "11111\n" + txresp -hdr {ETag: "foo"} -body "11111\n" } -start varnish v1 -vcl+backend { @@ -12,7 +12,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq -hdr "If-None-Match: foo" + txreq -hdr {If-None-Match: "foo"} rxresp -no_obj expect resp.status == 304 expect resp.http.Content-Length == diff --git a/bin/varnishtest/tests/r01485.vtc b/bin/varnishtest/tests/r01485.vtc index caf267a..abfe839 100644 --- a/bin/varnishtest/tests/r01485.vtc +++ b/bin/varnishtest/tests/r01485.vtc @@ -2,10 +2,10 @@ varnishtest "#1485: Wrong response reason phrase" server s1 { rxreq - txresp -hdr "Etag: foo" + txresp -hdr {Etag: "foo"} rxreq - expect req.http.If-None-Match == "foo" + expect req.http.If-None-Match == {"foo"} txresp -status 304 -msg "Not Modified" } -start diff --git a/bin/varnishtest/tests/r01499.vtc b/bin/varnishtest/tests/r01499.vtc index 7b438b2..fb9ec15 100644 --- a/bin/varnishtest/tests/r01499.vtc +++ b/bin/varnishtest/tests/r01499.vtc @@ -2,9 +2,9 @@ varnishtest "#1499 - objcore ref leak on IMS update" server s1 { rxreq - txresp -hdr "Etag: foo" + txresp -hdr {Etag: "foo"} rxreq - expect req.http.if-none-match == "foo" + expect req.http.if-none-match == {"foo"} txresp -hdr "X-Resp: 2" } -start diff --git a/bin/varnishtest/tests/v00024.vtc b/bin/varnishtest/tests/v00024.vtc index e502eee..71b13f8 100644 --- a/bin/varnishtest/tests/v00024.vtc +++ b/bin/varnishtest/tests/v00024.vtc @@ -19,7 +19,7 @@ client c1 { rxresp expect resp.status == 200 expect resp.bodylen == 1 - txreq -url "/foo" -hdr "etag: foo" -hdr "if-none-match: foo" + txreq -url "/foo" -hdr {etag: "foo"} -hdr {if-none-match: "foo"} rxresp expect resp.status == 400 } -run From phk at FreeBSD.org Wed Aug 13 12:56:03 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Aug 2014 14:56:03 +0200 Subject: [master] 6718050 Pass a dstat arg to oc->updatemeta() Message-ID: commit 67180503c2d9297da7f5618f94bbb47f0bc323f8 Author: Poul-Henning Kamp Date: Wed Aug 13 12:55:46 2014 +0000 Pass a dstat arg to oc->updatemeta() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 0b6ebd3..9ff55f6 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -373,7 +373,7 @@ struct storage { */ typedef struct object *getobj_f(struct dstat *ds, struct objcore *oc); -typedef void updatemeta_f(struct objcore *oc); +typedef void updatemeta_f(struct objcore *oc, struct dstat *); typedef void freeobj_f(struct dstat *ds, struct objcore *oc); typedef struct lru *getlru_f(const struct objcore *oc); @@ -1066,7 +1066,7 @@ void ObjTrimStore(struct objcore *, struct dstat *); unsigned ObjGetXID(struct objcore *, struct dstat *); uint64_t ObjGetLen(struct objcore *oc, struct dstat *ds); struct object *ObjGetObj(struct objcore *, struct dstat *); -void ObjUpdateMeta(struct objcore *); +void ObjUpdateMeta(struct objcore *, struct dstat *); void ObjFreeObj(struct objcore *, struct dstat *); struct lru *ObjGetLRU(const struct objcore *); void *ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index fdd0443..73992bc 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -963,7 +963,7 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req) if (b == oc->ban) { /* not banned */ oc->ban = b0; - ObjUpdateMeta(oc); + ObjUpdateMeta(oc, &wrk->stats); return (0); } else { oc->ban = NULL; diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 2afb254..ca82aaa 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -397,7 +397,7 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, double now) o = ObjGetObj(oc, &ep->wrk->stats); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); oc->timer_when = EXP_When(&oc->exp); - ObjUpdateMeta(oc); + ObjUpdateMeta(oc, &ep->wrk->stats); } VSLb(&ep->vsl, SLT_ExpKill, "EXP_When p=%p e=%.9f f=0x%x", oc, diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 94dfb17..6d4f593 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -184,12 +184,12 @@ ObjGetObj(struct objcore *oc, struct dstat *ds) } void -ObjUpdateMeta(struct objcore *oc) +ObjUpdateMeta(struct objcore *oc, struct dstat *ds) { const struct objcore_methods *m = obj_getmethods(oc); if (m->updatemeta != NULL) - m->updatemeta(oc); + m->updatemeta(oc, ds); } void diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 103c0bc..472453f 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -450,14 +450,14 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc) } static void -smp_oc_updatemeta(struct objcore *oc) +smp_oc_updatemeta(struct objcore *oc, struct dstat *ds) { struct object *o; struct smp_seg *sg; struct smp_object *so; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - o = smp_oc_getobj(NULL, oc); + o = smp_oc_getobj(ds, oc); AN(o); CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC); From phk at FreeBSD.org Wed Aug 13 13:03:19 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Aug 2014 15:03:19 +0200 Subject: [master] 37e6f87 Complete obj->objcore change for bans Message-ID: commit 37e6f8710da9111720ae52569c3d5d17320f589f Author: Poul-Henning Kamp Date: Wed Aug 13 13:02:53 2014 +0000 Complete obj->objcore change for bans diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 73992bc..a0c5c75 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -827,13 +827,13 @@ BAN_Compile(void) */ static int -ban_evaluate(const uint8_t *bs, const struct http *objhttp, +ban_evaluate(const uint8_t *bs, struct objcore *oc, struct dstat *ds, const struct http *reqhttp, unsigned *tests) { struct ban_test bt; const uint8_t *be; - char *arg1; - char buf[10]; + char *p; + const char *arg1; be = bs + ban_len(bs); bs += 13; @@ -848,14 +848,14 @@ ban_evaluate(const uint8_t *bs, const struct http *objhttp, break; case BANS_ARG_REQHTTP: AN(reqhttp); - (void)http_GetHdr(reqhttp, bt.arg1_spec, &arg1); + (void)http_GetHdr(reqhttp, bt.arg1_spec, &p); + arg1 = p; break; case BANS_ARG_OBJHTTP: - (void)http_GetHdr(objhttp, bt.arg1_spec, &arg1); + arg1 = HTTP_GetHdrPack(oc, ds, bt.arg1_spec); break; case BANS_ARG_OBJSTATUS: - arg1 = buf; - sprintf(buf, "%d", objhttp->status); + arg1 = HTTP_GetHdrPack(oc, ds, ":status"); break; default: WRONG("Wrong BAN_ARG code"); @@ -904,7 +904,6 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req) { struct ban *b; struct vsl_log *vsl; - struct object *o; struct ban * volatile b0; unsigned tests; @@ -930,10 +929,6 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req) if (b0 == oc->ban) return (0); - /* Now we need the object */ - o = ObjGetObj(oc, &wrk->stats); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - /* * This loop is safe without locks, because we know we hold * a refcount on a ban somewhere in the list and we do not @@ -944,7 +939,7 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req) CHECK_OBJ_NOTNULL(b, BAN_MAGIC); if (b->flags & BANS_FLAG_COMPLETED) continue; - if (ban_evaluate(b->spec, o->http, req->http, &tests)) + if (ban_evaluate(b->spec, oc, &wrk->stats, req->http, &tests)) break; } @@ -1096,7 +1091,7 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt, continue; } tests = 0; - i = ban_evaluate(bl->spec, o->http, NULL, &tests); + i = ban_evaluate(bl->spec, oc, &wrk->stats, NULL, &tests); VSC_C_main->bans_lurker_tested++; VSC_C_main->bans_lurker_tests_tested += tests; if (i) diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index f6a7f39..83f4aa2 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -733,10 +733,6 @@ HTTP_GetHdrPack(struct objcore *oc, struct dstat *ds, const char *hdr) AN(ds); AN(hdr); - l = hdr[0]; - assert(l == strlen(hdr + 1)); - assert(hdr[l] == ':'); - hdr++; ptr = ObjGetattr(oc, ds, OA_HEADERS, NULL); AN(ptr); @@ -746,9 +742,16 @@ HTTP_GetHdrPack(struct objcore *oc, struct dstat *ds, const char *hdr) /* Skip PROTO, STATUS and REASON */ ptr = strchr(ptr, '\0') + 1; + if (!strcmp(hdr, ":status")) + return (ptr); ptr = strchr(ptr, '\0') + 1; ptr = strchr(ptr, '\0') + 1; + l = hdr[0]; + assert(l == strlen(hdr + 1)); + assert(hdr[l] == ':'); + hdr++; + while (*ptr != '\0') { if (!strncasecmp(ptr, hdr, l)) { ptr += l; From phk at FreeBSD.org Wed Aug 13 17:16:45 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Aug 2014 19:16:45 +0200 Subject: [master] 63728f8 Update the XHTML in the default guru page. Message-ID: commit 63728f8839d47b308fd269cfc5bac2d2ff8a7f16 Author: Poul-Henning Kamp Date: Wed Aug 13 17:15:58 2014 +0000 Update the XHTML in the default guru page. Submitted by: mattrobenolt Approved by: mithradir diff --git a/bin/varnishd/builtin.vcl b/bin/varnishd/builtin.vcl index cfb2238..6ead64e 100644 --- a/bin/varnishd/builtin.vcl +++ b/bin/varnishd/builtin.vcl @@ -126,10 +126,7 @@ sub vcl_deliver { sub vcl_synth { set resp.http.Content-Type = "text/html; charset=utf-8"; set resp.http.Retry-After = "5"; - synthetic( {" - - + synthetic( {" "} + resp.status + " " + resp.reason + {" @@ -173,10 +170,7 @@ sub vcl_backend_response { sub vcl_backend_error { set beresp.http.Content-Type = "text/html; charset=utf-8"; set beresp.http.Retry-After = "5"; - synthetic( {" - - + synthetic( {" "} + beresp.status + " " + beresp.reason + {" From phk at FreeBSD.org Mon Aug 18 06:38:34 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 18 Aug 2014 08:38:34 +0200 Subject: [master] 43b39e5 Minor cleanups Message-ID: commit 43b39e5ff77b9ed01eb77bdc418fc422bf1beb89 Author: Poul-Henning Kamp Date: Mon Aug 18 06:38:22 2014 +0000 Minor cleanups diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 9ff55f6..0e6a240 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -899,7 +899,6 @@ void EXP_Rearm(struct objcore *, double now, double ttl, double grace, double keep); void EXP_Touch(struct objcore *oc, double now); int EXP_NukeOne(struct busyobj *, struct lru *lru); -void EXP_NukeLRU(struct worker *wrk, struct vsl_log *vsl, struct lru *lru); /* cache_fetch.c */ enum vbf_fetch_mode_e { @@ -1088,7 +1087,6 @@ void ObjSetFlag(const struct vfp_ctx *vc, enum obj_flags of, int val); /* cache_panic.c */ void PAN_Init(void); const char *body_status_2str(enum body_status e); -const char *reqbody_status_2str(enum req_body_state_e e); const char *sess_close_2str(enum sess_close sc, int want_desc); /* cache_pipe.c */ diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index e130925..74dcab9 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -76,7 +76,7 @@ body_status_2str(enum body_status e) /*--------------------------------------------------------------------*/ -const char * +static const char * reqbody_status_2str(enum req_body_state_e e) { switch (e) { From phk at FreeBSD.org Mon Aug 18 06:54:17 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 18 Aug 2014 08:54:17 +0200 Subject: [master] 7804592 Make the object iterator work on objcore and get rid of ims_obj. Message-ID: commit 780459204d77e421ec859a5d3b8771de68acd75e Author: Poul-Henning Kamp Date: Mon Aug 18 06:53:53 2014 +0000 Make the object iterator work on objcore and get rid of ims_obj. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 0e6a240..f71f507 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -494,7 +494,6 @@ struct busyobj { struct http *bereq0; struct http *bereq; struct http *beresp; - struct object *ims_obj; struct objcore *ims_oc; struct objcore *fetch_objcore; @@ -1058,7 +1057,7 @@ enum objiter_status { OIS_STREAM, OIS_ERROR, }; -struct objiter *ObjIterBegin(struct worker *, struct object *); +struct objiter *ObjIterBegin(struct worker *, struct objcore *); enum objiter_status ObjIter(struct objiter *, void **, ssize_t *); void ObjIterEnd(struct objiter **); void ObjTrimStore(struct objcore *, struct dstat *); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 03b4772..19c9bf6 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -590,7 +590,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) al = 0; ol = ObjGetLen(bo->ims_oc, bo->stats); - oi = ObjIterBegin(wrk, bo->ims_obj); + oi = ObjIterBegin(wrk, bo->ims_oc); do { ois = ObjIter(oi, &sp, &sl); while (sl > 0) { @@ -803,10 +803,8 @@ vbf_fetch_thread(struct worker *wrk, void *priv) } AZ(bo->fetch_objcore->busyobj); - if (bo->ims_oc != NULL) { + if (bo->ims_oc != NULL) (void)HSH_DerefObjCore(&wrk->stats, &bo->ims_oc); - bo->ims_obj = NULL; - } bo->stats = NULL; @@ -823,7 +821,6 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, { struct busyobj *bo; const char *how; - struct object *oldobj = NULL; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -861,17 +858,12 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, HSH_Ref(oc); bo->fetch_objcore = oc; - AZ(bo->ims_obj); AZ(bo->ims_oc); if (oldoc != NULL && ObjCheckFlag(oldoc, &req->wrk->stats, OF_IMSCAND)) { assert(oldoc->refcnt > 0); HSH_Ref(oldoc); bo->ims_oc = oldoc; - - oldobj = ObjGetObj(oldoc, &wrk->stats); - CHECK_OBJ_NOTNULL(oldobj, OBJECT_MAGIC); - bo->ims_obj = oldobj; } AZ(bo->req); diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index f27f1bd..194193a 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -174,7 +174,7 @@ v1d_WriteDirObj(struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - oi = ObjIterBegin(req->wrk, req->obj); + oi = ObjIterBegin(req->wrk, req->objcore); XXXAN(oi); do { diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 6d4f593..8e6474b 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -46,10 +46,13 @@ struct objiter { }; struct objiter * -ObjIterBegin(struct worker *wrk, struct object *obj) +ObjIterBegin(struct worker *wrk, struct objcore *oc) { struct objiter *oi; + struct object *obj; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + obj = ObjGetObj(oc, &wrk->stats); CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); ALLOC_OBJ(oi, OBJITER_MAGIC); if (oi == NULL) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 74dcab9..43919d7 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -341,8 +341,8 @@ pan_busyobj(const struct busyobj *bo) pan_ws(bo->ws_o, 4); if (bo->fetch_objcore) pan_objcore("FETCH", bo->fetch_objcore); - if (bo->ims_obj) - pan_object("IMS", bo->ims_obj); + if (bo->ims_oc) + pan_objcore("IMS", bo->ims_oc); VSB_printf(pan_vsp, " }\n"); } From phk at FreeBSD.org Mon Aug 18 07:43:06 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 18 Aug 2014 09:43:06 +0200 Subject: [master] ecd7f92 Move STV_Freestore() to ObjSlim() Message-ID: commit ecd7f92afeeb0c876a3dead4272f6340812d9c33 Author: Poul-Henning Kamp Date: Mon Aug 18 07:42:39 2014 +0000 Move STV_Freestore() to ObjSlim() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f71f507..6bcecd6 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1066,6 +1066,7 @@ uint64_t ObjGetLen(struct objcore *oc, struct dstat *ds); struct object *ObjGetObj(struct objcore *, struct dstat *); void ObjUpdateMeta(struct objcore *, struct dstat *); void ObjFreeObj(struct objcore *, struct dstat *); +void ObjSlim(struct objcore *oc, struct dstat *ds); struct lru *ObjGetLRU(const struct objcore *); void *ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, ssize_t *len); @@ -1248,7 +1249,6 @@ void STV_trim(struct storage *st, size_t size, int move_ok); void STV_free(struct storage *st); void STV_open(void); void STV_close(void); -void STV_Freestore(struct object *o); int STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len); void STV_BanExport(const uint8_t *bans, unsigned len); struct storage *STV_alloc_transient(size_t size); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index ca82aaa..36f171b 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -290,7 +290,6 @@ EXP_NukeOne(struct busyobj *bo, struct lru *lru) { struct objcore *oc, *oc2; struct objhead *oh; - struct object *o; /* Find the first currently unused object on the LRU. */ Lck_Lock(&lru->mtx); @@ -334,9 +333,7 @@ EXP_NukeOne(struct busyobj *bo, struct lru *lru) } /* XXX: We could grab and return one storage segment to our caller */ - o = ObjGetObj(oc, bo->stats); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - STV_Freestore(o); + ObjSlim(oc, bo->stats); exp_mail_it(oc); diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 8e6474b..c66a343 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -176,6 +176,32 @@ ObjTrimStore(struct objcore *oc, struct dstat *ds) } } +/*-------------------------------------------------------------------- + * Early disposal of storage from soon to be killed object. + */ + +void +ObjSlim(struct objcore *oc, struct dstat *ds) +{ + struct object *o; + struct storage *st, *stn; + + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + AN(ds); + o = ObjGetObj(oc, ds); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + + if (o->esidata != NULL) { + STV_free(o->esidata); + o->esidata = NULL; + } + VTAILQ_FOREACH_SAFE(st, &o->body->list, list, stn) { + CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); + VTAILQ_REMOVE(&o->body->list, st, list); + STV_free(st); + } +} + struct object * ObjGetObj(struct objcore *oc, struct dstat *ds) { diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index c69c0ed..0f27c48 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -175,7 +175,7 @@ cnt_deliver(struct worker *wrk, struct req *req) bo = HSH_RefBusy(req->objcore); V1D_Deliver(req, bo); if (bo != NULL) - VBO_DerefBusyObj(req->wrk, &bo); + VBO_DerefBusyObj(wrk, &bo); VSLb_ts_req(req, "Resp", W_TIM_real(wrk)); @@ -190,7 +190,7 @@ cnt_deliver(struct worker *wrk, struct req *req) */ while (req->objcore->busyobj != NULL) (void)usleep(100000); - STV_Freestore(req->obj); + ObjSlim(req->objcore, &wrk->stats); } assert(WRW_IsReleased(wrk)); diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 3ab1b9c..adbe556 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -65,13 +65,14 @@ default_oc_freeobj(struct dstat *ds, struct objcore *oc) { struct object *o; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(ds); + ObjSlim(oc, ds); CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC); oc->priv = NULL; oc->stevedore = NULL; o->magic = 0; - STV_Freestore(o); STV_free(o->objstore); ds->n_object--; @@ -379,24 +380,6 @@ STV_NewObject(struct busyobj *bo, const char *hint, /*-------------------------------------------------------------------*/ -void -STV_Freestore(struct object *o) -{ - struct storage *st, *stn; - - if (o->esidata != NULL) { - STV_free(o->esidata); - o->esidata = NULL; - } - VTAILQ_FOREACH_SAFE(st, &o->body->list, list, stn) { - CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - VTAILQ_REMOVE(&o->body->list, st, list); - STV_free(st); - } -} - -/*-------------------------------------------------------------------*/ - struct storage * STV_alloc(const struct vfp_ctx *vc, size_t size) { From phk at FreeBSD.org Mon Aug 18 07:54:39 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 18 Aug 2014 09:54:39 +0200 Subject: [master] bdc6f73 Eliminate req->obj. Message-ID: commit bdc6f7343e1267f69792a08b8f1031fbe54636c6 Author: Poul-Henning Kamp Date: Mon Aug 18 07:54:13 2014 +0000 Eliminate req->obj. Until reimplemented we have slightly less info in panics about objects. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 6bcecd6..8d718fa 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -651,7 +651,6 @@ struct req { struct http *resp; struct ws ws[1]; - struct object *obj; struct objcore *objcore; struct objcore *ims_oc; /* Lookup stuff */ diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 194193a..202ae12 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -372,7 +372,6 @@ V1D_Deliver_Synth(struct req *req) char *r; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - AZ(req->obj); AN(req->synth_body); req->res_mode = 0; diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index 4290c47..b0c5299 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -101,7 +101,6 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req) assert(req->sp == sp); AZ(req->vcl); - AZ(req->obj); AZ(req->esi_level); AZ(isnan(sp->t_idle)); assert(isnan(req->t_first)); @@ -190,7 +189,6 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_ORNULL(req->vcl, VCL_CONF_MAGIC); - AZ(req->obj); req->director_hint = NULL; req->restarts = 0; diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 43919d7..4a1c880 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -154,6 +154,7 @@ pan_vbc(const struct vbc *vbc) /*--------------------------------------------------------------------*/ +#if 0 static void pan_storage(const struct storage *st) { @@ -186,6 +187,7 @@ pan_storage(const struct storage *st) #undef show #undef MAX_BYTES } +#endif /*--------------------------------------------------------------------*/ @@ -210,6 +212,7 @@ pan_http(const char *id, const struct http *h, int indent) /*--------------------------------------------------------------------*/ +#if 0 static void pan_object(const char *typ, const struct object *o) { @@ -225,6 +228,7 @@ pan_object(const char *typ, const struct object *o) VSB_printf(pan_vsp, " },\n"); VSB_printf(pan_vsp, " },\n"); } +#endif /*--------------------------------------------------------------------*/ @@ -394,10 +398,10 @@ pan_req(const struct req *req) if (VALID_OBJ(req->vcl, VCL_CONF_MAGIC)) pan_vcl(req->vcl); - if (VALID_OBJ(req->obj, OBJECT_MAGIC)) { + if (req->objcore != NULL) { + pan_objcore("REQ", req->objcore); if (req->objcore->busyobj != NULL) pan_busyobj(req->objcore->busyobj); - pan_object("REQ", req->obj); } VSB_printf(pan_vsp, "},\n"); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 0f27c48..7ab29ac 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -96,9 +96,6 @@ cnt_deliver(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); assert(WRW_IsReleased(wrk)); - req->obj = ObjGetObj(req->objcore, &wrk->stats); - CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC); - assert(req->objcore->refcnt > 0); if (req->objcore->exp_flags & OC_EF_EXP) @@ -144,7 +141,6 @@ cnt_deliver(struct worker *wrk, struct req *req) if (wrk->handling != VCL_RET_DELIVER) { assert(req->objcore == req->objcore); (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); - req->obj = NULL; http_Teardown(req->resp); switch (wrk->handling) { @@ -194,10 +190,7 @@ cnt_deliver(struct worker *wrk, struct req *req) } assert(WRW_IsReleased(wrk)); -VSLb(req->vsl, SLT_Debug, "XXX REF %d", req->objcore->refcnt); - assert(req->obj->objcore == req->objcore); (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); - req->obj = NULL; http_Teardown(req->resp); return (REQ_FSM_DONE); } @@ -297,7 +290,6 @@ cnt_fetch(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); - AZ(req->obj); wrk->stats.s_fetch++; (void)HTTP1_DiscardReqBody(req); @@ -388,7 +380,6 @@ cnt_lookup(struct worker *wrk, struct req *req) /* Found nothing */ VSLb(req->vsl, SLT_Debug, "XXXX MISS"); AZ(oc); - AZ(req->obj); AN(boc); AN(boc->flags & OC_F_BUSY); req->objcore = boc; @@ -406,7 +397,6 @@ cnt_lookup(struct worker *wrk, struct req *req) VSLb(req->vsl, SLT_HitPass, "%u", ObjGetXID(req->objcore, &wrk->stats)); AZ(boc); - AZ(req->obj); (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); wrk->stats.cache_hitpass++; req->req_step = R_STP_PASS; @@ -432,7 +422,6 @@ cnt_lookup(struct worker *wrk, struct req *req) req->req_step = R_STP_DELIVER; return (REQ_FSM_MORE); case VCL_RET_FETCH: - AZ(req->obj); if (boc != NULL) { req->objcore = boc; req->ims_oc = oc; @@ -464,7 +453,6 @@ cnt_lookup(struct worker *wrk, struct req *req) } /* Drop our object, we won't need it */ - AZ(req->obj); (void)HSH_DerefObjCore(&wrk->stats, &req->objcore); if (boc != NULL) { @@ -551,7 +539,6 @@ cnt_pass(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->objcore); - AZ(req->obj); VCL_pass_method(req->vcl, wrk, req, NULL, req->http->ws); switch (wrk->handling) { @@ -696,7 +683,6 @@ cnt_recv(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->objcore); - AZ(req->obj); AZ(isnan(req->t_first)); AZ(isnan(req->t_prev)); @@ -860,8 +846,8 @@ cnt_diag(struct req *req, const char *state) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - VSLb(req->vsl, SLT_Debug, "vxid %u STP_%s sp %p obj %p vcl %p", - req->vsl->wid, state, req->sp, req->obj, req->vcl); + VSLb(req->vsl, SLT_Debug, "vxid %u STP_%s sp %p vcl %p", + req->vsl->wid, state, req->sp, req->vcl); VSL_Flush(req->vsl, 0); } From phk at FreeBSD.org Mon Aug 18 08:02:52 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 18 Aug 2014 10:02:52 +0200 Subject: [master] 90b8267 Retire various struct object related infrastructure. Message-ID: commit 90b8267328495bb7dc431671267be6f2eca8a787 Author: Poul-Henning Kamp Date: Mon Aug 18 08:02:33 2014 +0000 Retire various struct object related infrastructure. diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index a0c5c75..6fe3bba 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -1058,7 +1058,6 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt, { struct ban *bl, *bln; struct objcore *oc; - struct object *o; unsigned tests; int i; @@ -1081,8 +1080,6 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt, oc = ban_lurker_getfirst(vsl, bt); if (oc == NULL) return; - o = ObjGetObj(oc, &wrk->stats); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); i = 0; VTAILQ_FOREACH_REVERSE_SAFE(bl, obans, banhead_s, l_list, bln) { if (bl->flags & BANS_FLAG_COMPLETED) { diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c index 99b781c..77a041c 100644 --- a/bin/varnishd/cache/cache_cli.c +++ b/bin/varnishd/cache/cache_cli.c @@ -178,29 +178,6 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv) OFOF(struct storage, len); OFOF(struct storage, space); #endif -#if 0 - OFOF(struct object, magic); - OFOF(struct object, xid); - OFOF(struct object, objstore); - OFOF(struct object, objcore); - OFOF(struct object, ws_o); - OFOF(struct object, vary); - OFOF(struct object, hits); - OFOF(struct object, response); - OFOF(struct object, gziped); - OFOF(struct object, gzip_start); - OFOF(struct object, gzip_last); - OFOF(struct object, gzip_stop); - OFOF(struct object, len); - OFOF(struct object, age); - OFOF(struct object, entered); - OFOF(struct object, exp); - OFOF(struct object, last_modified); - OFOF(struct object, last_lru); - OFOF(struct object, http); - OFOF(struct object, store); - OFOF(struct object, esidata); -#endif #undef OFOF #endif } diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 36f171b..5c59185 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -353,7 +353,6 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, double now) { unsigned flags; struct lru *lru; - struct object *o; CHECK_OBJ_NOTNULL(ep, EXP_PRIV_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); @@ -391,8 +390,6 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, double now) } if (flags & OC_EF_MOVE) { - o = ObjGetObj(oc, &ep->wrk->stats); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); oc->timer_when = EXP_When(&oc->exp); ObjUpdateMeta(oc, &ep->wrk->stats); } @@ -428,7 +425,6 @@ exp_expire(struct exp_priv *ep, double now) { struct lru *lru; struct objcore *oc; - struct object *o; CHECK_OBJ_NOTNULL(ep, EXP_PRIV_MAGIC); @@ -466,8 +462,6 @@ exp_expire(struct exp_priv *ep, double now) assert(oc->timer_idx == BINHEAP_NOIDX); CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC); - o = ObjGetObj(oc, &ep->wrk->stats); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); VSLb(&ep->vsl, SLT_ExpKill, "EXP_Expired x=%u t=%.0f", ObjGetXID(oc, &ep->wrk->stats), EXP_Ttl(NULL, &oc->exp) - now); diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 712243b..4e3fc67 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -609,22 +609,6 @@ double keep) Pool_PurgeStat(nobj); } - -/*--------------------------------------------------------------------- - * Kill a busy object we don't need and can't use. - */ - -void -HSH_Drop(struct worker *wrk, struct object **oo) -{ - - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - AN(oo); - CHECK_OBJ_NOTNULL(*oo, OBJECT_MAGIC); - (*oo)->objcore->exp.ttl = -1.; - AZ(HSH_DerefObj(&wrk->stats, oo)); -} - /*--------------------------------------------------------------------- * Fail an objcore */ @@ -747,35 +731,12 @@ HSH_RefBusy(const struct objcore *oc) } /*-------------------------------------------------------------------- - * Dereference objcore and or object - * - * Can deal with: - * bare objcore (incomplete fetch) - * bare object (pass) - * object with objcore - * XXX later: objcore with object (?) - * - * But you can only supply one of the two arguments at a time. + * Dereference objcore * * Returns zero if target was destroyed. */ int -HSH_DerefObj(struct dstat *ds, struct object **oo) -{ - struct object *o; - struct objcore *oc; - - AN(oo); - o = *oo; - *oo = NULL; - - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - oc = o->objcore; - return (HSH_DerefObjCore(ds, &oc)); -} - -int HSH_DerefObjCore(struct dstat *ds, struct objcore **ocp) { struct objcore *oc; diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 3c6f815..0b1fca0 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -66,7 +66,6 @@ void HSH_Cleanup(struct worker *w); enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **, int wait_for_busy, int always_insert); 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 req *, const char *str); void HSH_Insert(struct worker *, const void *hash, struct objcore *); @@ -117,7 +116,6 @@ void HSH_Complete(struct objcore *oc); void HSH_DeleteObjHead(struct dstat *, struct objhead *oh); int HSH_DerefObjHead(struct dstat *, struct objhead **poh); int HSH_DerefObjCore(struct dstat *, struct objcore **ocp); -int HSH_DerefObj(struct dstat *, struct object **o); #endif /* VARNISH_CACHE_CHILD */ extern const struct hash_slinger hsl_slinger; From phk at FreeBSD.org Mon Aug 18 10:17:32 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 18 Aug 2014 12:17:32 +0200 Subject: [master] 1ca4bfc Rewrite the esi_include delivery to use ObjIter() Message-ID: commit 1ca4bfc7b37ead6a9f0a95ee3f93bbb350cdf852 Author: Poul-Henning Kamp Date: Mon Aug 18 10:17:13 2014 +0000 Rewrite the esi_include delivery to use ObjIter() diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 71313e3..d74f27a 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -458,67 +458,34 @@ ESI_Deliver(struct req *req) * Include an object in a gzip'ed ESI object delivery */ -static uint8_t -ved_deliver_byterange(struct req *req, const struct object *obj, ssize_t low, - ssize_t high) -{ - struct storage *st; - ssize_t l, lx; - u_char *p; - - lx = 0; - VTAILQ_FOREACH(st, &obj->body->list, list) { - p = st->ptr; - l = st->len; - if (lx + l < low) { - lx += l; - continue; - } - if (lx == high) - return (p[0]); - assert(lx < high); - if (lx < low) { - p += (low - lx); - l -= (low - lx); - lx = low; - } - if (lx + l >= high) - l = high - lx; - assert(lx >= low && lx + l <= high); - if (l != 0) - req->resp_bodybytes += WRW_Write(req->wrk, p, l); - if (p + l < st->ptr + st->len) - return(p[l]); - lx += l; - } - INCOMPL(); -} - void ESI_DeliverChild(struct req *req) { - struct storage *st; - struct object *obj; ssize_t start, last, stop, lpad; ssize_t l; char *p; - u_char cc; uint32_t icrc; uint32_t ilen; uint64_t olen; uint8_t *dbits; - int i, j; + uint8_t *pp; uint8_t tailbuf[8]; + enum objiter_status ois; + struct objiter *oi; + void *sp; + ssize_t sl, ll, dl; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); - obj = ObjGetObj(req->objcore, &req->wrk->stats); - CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - if (!ObjCheckFlag(req->objcore, &req->wrk->stats, OF_GZIPED)) { - VTAILQ_FOREACH(st, &obj->body->list, list) - ved_pretend_gzip(req, st->ptr, st->len); + oi = ObjIterBegin(req->wrk, req->objcore); + do { + ois = ObjIter(oi, &sp, &sl); + if (sl > 0) + ved_pretend_gzip(req, sp, sl); + } while (ois == OIS_DATA || ois == OIS_STREAM); + ObjIterEnd(&oi); return; } /* @@ -527,15 +494,13 @@ ESI_DeliverChild(struct req *req) * padding it, as necessary, to a byte boundary. */ - dbits = (void*)WS_Alloc(req->ws, 8); - AN(dbits); - p = ObjGetattr(obj->objcore, &req->wrk->stats, OA_GZIPBITS, &l); + p = ObjGetattr(req->objcore, &req->wrk->stats, OA_GZIPBITS, &l); AN(p); assert(l == 24); start = vbe64dec(p); last = vbe64dec(p + 8); stop = vbe64dec(p + 16); - olen = ObjGetLen(obj->objcore, &req->wrk->stats); + olen = ObjGetLen(req->objcore, &req->wrk->stats); assert(start > 0 && start < olen * 8); assert(last > 0 && last < olen * 8); assert(stop > 0 && stop < olen * 8); @@ -549,64 +514,140 @@ ESI_DeliverChild(struct req *req) * XXX: optimize for the case where the 'last' * XXX: bit is in a empty copy block */ - *dbits = ved_deliver_byterange(req, obj, start/8, last/8); - *dbits &= ~(1U << (last & 7)); - req->resp_bodybytes += WRW_Write(req->wrk, dbits, 1); - cc = ved_deliver_byterange(req, obj, 1 + last/8, stop/8); - switch((int)(stop & 7)) { - case 0: /* xxxxxxxx */ - /* I think we have an off by one here, but that's OK */ - lpad = 0; - break; - case 1: /* x000.... 00000000 00000000 11111111 11111111 */ - case 3: /* xxx000.. 00000000 00000000 11111111 11111111 */ - case 5: /* xxxxx000 00000000 00000000 11111111 11111111 */ - dbits[1] = cc | 0x00; - dbits[2] = 0x00; dbits[3] = 0x00; - dbits[4] = 0xff; dbits[5] = 0xff; - lpad = 5; - break; - case 2: /* xx010000 00000100 00000001 00000000 */ - dbits[1] = cc | 0x08; - dbits[2] = 0x20; - dbits[3] = 0x80; - dbits[4] = 0x00; - lpad = 4; - break; - case 4: /* xxxx0100 00000001 00000000 */ - dbits[1] = cc | 0x20; - dbits[2] = 0x80; - dbits[3] = 0x00; - lpad = 3; - break; - case 6: /* xxxxxx01 00000000 */ - dbits[1] = cc | 0x80; - dbits[2] = 0x00; - lpad = 2; - break; - case 7: /* xxxxxxx0 00...... 00000000 00000000 11111111 11111111 */ - dbits[1] = cc | 0x00; - dbits[2] = 0x00; - dbits[3] = 0x00; dbits[4] = 0x00; - dbits[5] = 0xff; dbits[6] = 0xff; - lpad = 6; - break; - default: - INCOMPL(); - } - if (lpad > 0) - req->resp_bodybytes += WRW_Write(req->wrk, dbits + 1, lpad); - - /* We need the entire tail, but it may not be in one storage segment */ - st = VTAILQ_LAST(&obj->body->list, storagehead); - for (i = sizeof tailbuf; i > 0; i -= j) { - j = st->len; - if (j > i) - j = i; - memcpy(tailbuf + i - j, st->ptr + st->len - j, j); - st = VTAILQ_PREV(st, storagehead, list); - assert(i == j || st != NULL); - } + + memset(tailbuf, 0xdd, sizeof tailbuf); + dbits = (void*)WS_Alloc(req->ws, 8); + AN(dbits); + ll = 0; + oi = ObjIterBegin(req->wrk, req->objcore); + do { + ois = ObjIter(oi, &sp, &sl); + pp = sp; + if (sl > 0) { + /* Skip over the GZIP header */ + dl = start / 8 - ll; + if (dl > 0) { + /* Before start, skip */ + if (dl > sl) + dl = sl; + ll += dl; + sl -= dl; + pp += dl; + } + } + if (sl > 0) { + /* The main body of the object */ + dl = last / 8 - ll; + if (dl > 0) { + if (dl > sl) + dl = sl; + req->resp_bodybytes += + WRW_Write(req->wrk, pp, dl); + ll += dl; + sl -= dl; + pp += dl; + } + } + if (sl > 0 && ll == last / 8) { + /* Remove the "LAST" bit */ + dbits[0] = *pp; + dbits[0] &= ~(1U << (last & 7)); + req->resp_bodybytes += WRW_Write(req->wrk, dbits, 1); + ll++; + sl--; + pp++; + } + if (sl > 0) { + /* Last block */ + dl = stop / 8 - ll; + if (dl > 0) { + if (dl > sl) + dl = sl; + req->resp_bodybytes += + WRW_Write(req->wrk, pp, dl); + ll += dl; + sl -= dl; + pp += dl; + } + } + if (sl > 0 && (stop & 7) && ll == stop / 8) { + /* Add alignment to byte boundary */ + dbits[1] = *pp; + ll++; + sl--; + pp++; + switch((int)(stop & 7)) { + case 1: /* + * x000.... + * 00000000 00000000 11111111 11111111 + */ + case 3: /* + * xxx000.. + * 00000000 00000000 11111111 11111111 + */ + case 5: /* + * xxxxx000 + * 00000000 00000000 11111111 11111111 + */ + dbits[2] = 0x00; dbits[3] = 0x00; + dbits[4] = 0xff; dbits[5] = 0xff; + lpad = 5; + break; + case 2: /* xx010000 00000100 00000001 00000000 */ + dbits[1] |= 0x08; + dbits[2] = 0x20; + dbits[3] = 0x80; + dbits[4] = 0x00; + lpad = 4; + break; + case 4: /* xxxx0100 00000001 00000000 */ + dbits[1] |= 0x20; + dbits[2] = 0x80; + dbits[3] = 0x00; + lpad = 3; + break; + case 6: /* xxxxxx01 00000000 */ + dbits[1] |= 0x80; + dbits[2] = 0x00; + lpad = 2; + break; + case 7: /* + * xxxxxxx0 + * 00...... + * 00000000 00000000 11111111 11111111 + */ + dbits[2] = 0x00; + dbits[3] = 0x00; dbits[4] = 0x00; + dbits[5] = 0xff; dbits[6] = 0xff; + lpad = 6; + break; + case 0: /* xxxxxxxx */ + default: + WRONG("compiler must be broken"); + } + req->resp_bodybytes += + WRW_Write(req->wrk, dbits + 1, lpad); + } + if (sl > 0) { + /* Recover GZIP tail */ + dl = olen - ll; + assert(dl >= 0); + if (dl > sl) + dl = sl; + if (dl > 0) { + assert(dl <= 8); + l = ll - (olen - 8); + assert(l >= 0); + assert(l <= 8); + assert(l + dl <= 8); + memcpy(tailbuf + l, pp, dl); + ll += dl; + sl -= dl; + pp += dl; + } + } + } while (ois == OIS_DATA || ois == OIS_STREAM); + ObjIterEnd(&oi); icrc = vle32dec(tailbuf); ilen = vle32dec(tailbuf + 4); From nils.goroll at uplex.de Mon Aug 18 10:32:42 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 18 Aug 2014 12:32:42 +0200 Subject: [master] b0d96f6 Skip NULL and empty arguments when hashing. Hash all other arguments. Message-ID: commit b0d96f6a6049904f702dcae3238d3e00af23ae62 Author: Nils Goroll Date: Mon Aug 18 12:32:19 2014 +0200 Skip NULL and empty arguments when hashing. Hash all other arguments. When multiple arguments were passed to vmod_hash_backend, only the first argument was re-used for the number of arguments passed. Fixes #1568 diff --git a/bin/varnishtest/tests/v00026.vtc b/bin/varnishtest/tests/v00026.vtc index e1b77b9..711861d 100644 --- a/bin/varnishtest/tests/v00026.vtc +++ b/bin/varnishtest/tests/v00026.vtc @@ -12,6 +12,10 @@ server s2 { txresp -hdr "Foo: 2" -body "2" rxreq txresp -hdr "Foo: 4" -body "4" + rxreq + txresp -hdr "Foo: 6" -body "6" + rxreq + txresp -hdr "Foo: 8" -body "8" } -start @@ -28,7 +32,15 @@ varnish v1 -vcl+backend { return(pass); } sub vcl_backend_fetch { - set bereq.backend = h1.backend(bereq.url); + if (bereq.url == "/nohdr") { + set bereq.backend = h1.backend(bereq.http.Void); + } else if (bereq.url == "/emptystring") { + set bereq.backend = h1.backend(""); + } else if (bereq.url == "/13") { + set bereq.backend = h1.backend(bereq.http.Void + "" + bereq.url); + } else { + set bereq.backend = h1.backend(bereq.url); + } } } -start @@ -51,5 +63,13 @@ client c1 { rxresp expect resp.http.foo == "4" + txreq -url /emptystring + rxresp + expect resp.http.foo == "6" + + txreq -url /nohdr + rxresp + expect resp.http.foo == "8" + } -run diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index 35c8ed7..afef7ed 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -110,7 +110,8 @@ vmod_hash_backend(const struct vrt_ctx *ctx, struct vmod_directors_hash *rr, va_start(ap, arg); p = arg; while (p != vrt_magic_string_end) { - SHA256_Update(&sha_ctx, arg, strlen(arg)); + if (p != NULL && *p != '\0') + SHA256_Update(&sha_ctx, p, strlen(p)); p = va_arg(ap, const char *); } va_end(ap); From phk at FreeBSD.org Mon Aug 18 10:52:14 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 18 Aug 2014 12:52:14 +0200 Subject: [master] 1a9e5b0 Change the main esi_deliver loop to also use ObjIter Message-ID: commit 1a9e5b07b4800cfcbbde32c70794524193c5ab15 Author: Poul-Henning Kamp Date: Mon Aug 18 10:51:54 2014 +0000 Change the main esi_deliver loop to also use ObjIter diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index d74f27a..b3551ca 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -251,9 +251,7 @@ static const uint8_t gzip_hdr[] = { void ESI_Deliver(struct req *req) { - struct storage *st; uint8_t *p, *e, *q, *r; - unsigned off; ssize_t l, l2, l_icrc = 0; uint32_t icrc = 0; uint8_t tailbuf[8 + 5]; @@ -262,13 +260,15 @@ ESI_Deliver(struct req *req) size_t dl; const void *dp; int i; - struct object *obj; + struct objiter *oi; + enum objiter_status ois; + void *sp; + uint8_t *pp; + ssize_t sl; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); p = ObjGetattr(req->objcore, &req->wrk->stats, OA_ESIDATA, &l); - obj = ObjGetObj(req->objcore, &req->wrk->stats); - CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); AN(p); assert(l > 0); e = p + l; @@ -308,8 +308,10 @@ ESI_Deliver(struct req *req) AZ(dl); } - st = VTAILQ_FIRST(&obj->body->list); - off = 0; + oi = ObjIterBegin(req->wrk, req->objcore); + ois = ObjIter(oi, &sp, &sl); + assert(ois != OIS_ERROR); + pp = sp; while (p < e) { switch (*p) { @@ -336,8 +338,9 @@ ESI_Deliver(struct req *req) */ while (l > 0) { l2 = l; - if (l2 > st->len - off) - l2 = st->len - off; + if (l2 > sl) + l2 = sl; + sl -= l2; l -= l2; if (req->gzip_resp && isgzip) { @@ -346,23 +349,20 @@ ESI_Deliver(struct req *req) * a gzip'ed ESI response. */ req->resp_bodybytes += - WRW_Write(req->wrk, - st->ptr + off, l2); + WRW_Write(req->wrk, pp, l2); } else if (req->gzip_resp) { /* * A gzip'ed ESI response, but the VEC * was not gzip'ed. */ - ved_pretend_gzip(req, - st->ptr + off, l2); + ved_pretend_gzip(req, pp, l2); } else if (isgzip) { /* * A gzip'ed VEC, but ungzip'ed ESI * response */ AN(vgz); - i = VGZ_WrwGunzip(req, vgz, - st->ptr + off, l2); + i = VGZ_WrwGunzip(req, vgz, pp, l2); if (WRW_Error(req->wrk)) { SES_Close(req->sp, SC_REM_CLOSE); @@ -375,13 +375,13 @@ ESI_Deliver(struct req *req) * Ungzip'ed VEC, ungzip'ed ESI response */ req->resp_bodybytes += - WRW_Write(req->wrk, - st->ptr + off, l2); + WRW_Write(req->wrk, pp, l2); } - off += l2; - if (off == st->len) { - st = VTAILQ_NEXT(st, list); - off = 0; + pp += l2; + if (sl == 0) { + ois = ObjIter(oi, &sp, &sl); + assert(ois != OIS_ERROR); + pp = sp; } } break; @@ -397,13 +397,15 @@ ESI_Deliver(struct req *req) */ while (l > 0) { l2 = l; - if (l2 > st->len - off) - l2 = st->len - off; + if (l2 > sl) + l2 = sl; + sl -= l2; l -= l2; - off += l2; - if (off == st->len) { - st = VTAILQ_NEXT(st, list); - off = 0; + pp += l2; + if (sl == 0) { + ois = ObjIter(oi, &sp, &sl); + assert(ois != OIS_ERROR); + pp = sp; } } break; @@ -452,6 +454,7 @@ ESI_Deliver(struct req *req) req->resp_bodybytes += WRW_Write(req->wrk, tailbuf, 13); } (void)WRW_Flush(req->wrk); + ObjIterEnd(&oi); } /*--------------------------------------------------------------------- From phk at FreeBSD.org Mon Aug 18 11:36:19 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 18 Aug 2014 13:36:19 +0200 Subject: [master] 31741b8 Set the OA_VARY through the API. Message-ID: commit 31741b8417daef395f0e899c63cf048730568cf8 Author: Poul-Henning Kamp Date: Mon Aug 18 11:35:50 2014 +0000 Set the OA_VARY through the API. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 8d718fa..42c40d3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -563,7 +563,7 @@ struct object { struct storage *objstore; struct objcore *objcore; - uint8_t *vary; + uint8_t *oa_vary; uint8_t *oa_http; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 19c9bf6..29db641 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -140,10 +140,9 @@ vbf_beresp2obj(struct busyobj *bo) CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); if (vary != NULL) { - obj->vary = (void *)WS_Copy(obj->http->ws, - VSB_data(vary), varyl); - AN(obj->vary); - (void)VRY_Validate(obj->vary); + b = ObjSetattr(bo->vfc, OA_VARY, varyl); + memcpy(b, VSB_data(vary), varyl); + (void)VRY_Validate(obj->oa_vary); VSB_delete(vary); } diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index c66a343..ca028bc 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -275,7 +275,7 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, return (o->oa_lastmodified); case OA_VARY: *len = 4; // XXX: hack - return (o->vary); + return (o->oa_vary); case OA_VXID: *len = sizeof o->oa_vxid; return (o->oa_vxid); @@ -312,6 +312,10 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, case OA_LASTMODIFIED: assert(len == sizeof o->oa_lastmodified); return (o->oa_lastmodified); + case OA_VARY: + o->oa_vary = (void*)WS_Alloc(o->http->ws, len); + AN(o->oa_vary); + return (o->oa_vary); case OA_VXID: assert(len == sizeof o->oa_vxid); return (o->oa_vxid); From fgsch at lodoss.net Mon Aug 18 18:36:08 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 18 Aug 2014 20:36:08 +0200 Subject: [master] d27a9b3 Wording Message-ID: commit d27a9b39386597bb75e9e383818d4a0fe125a2f9 Author: Federico G. Schwindt Date: Mon Aug 18 19:34:38 2014 +0100 Wording diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 29db641..b374308 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -352,7 +352,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (ObjCheckFlag(bo->ims_oc, bo->stats, OF_CHGGZIP)) { /* * If we changed the gzip status of the object - * the stored Content_Encoding controls and we + * the stored Content_Encoding controls we * must weaken any new ETag we get. */ http_Unset(bo->beresp, H_Content_Encoding); From fgsch at lodoss.net Mon Aug 18 18:36:08 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 18 Aug 2014 20:36:08 +0200 Subject: [master] f1271c6 Describe bereq.retries Message-ID: commit f1271c633ee32b6bf4da063c0c6f33dab54a4a0f Author: Federico G. Schwindt Date: Mon Aug 18 19:35:06 2014 +0100 Describe bereq.retries diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 3d56bc5..6e3c91f 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -319,6 +319,7 @@ sp_variables = [ 'INT', ( 'backend',), ( ), """ + A count of how many times this request has been retried. """ ), ('bereq.backend', From nils.goroll at uplex.de Mon Aug 18 19:27:48 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 18 Aug 2014 21:27:48 +0200 Subject: [master] 7c0e75f Rework autocrap configuration for libedit/libreadline Message-ID: commit 7c0e75f0abc29ead11f945318274cf4e5669eedb Author: Nils Goroll Date: Mon Aug 18 21:26:17 2014 +0200 Rework autocrap configuration for libedit/libreadline As before, libedit is preferred over libreadline. Fail configure if neither is found or if libedit includes are missing. Require readline history support (as varnishadm needs it). Previously, if only libreadline was found, all binaries were linked against it. Now only binaries getting linked with LIBEDIT_LIBS will get linked aginst readline if libedit is not found. If configure succeeds, a build should not fail any longer due to libedit/libreadline headers missing. Fixes #1555 diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 0c2ecc1..26019a5 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -34,15 +34,17 @@ #include -#ifdef HAVE_EDIT_READLINE_READLINE_H -# include +#ifdef HAVE_LIBEDIT +# include #elif HAVE_READLINE_READLINE_H # include # ifdef HAVE_READLINE_HISTORY_H # include +# else +# error missing history.h - this should have got caught in configure # endif #else -# include +# error missing readline.h - this should have got caught in configure #endif #include diff --git a/configure.ac b/configure.ac index ced8495..c8a36f5 100644 --- a/configure.ac +++ b/configure.ac @@ -140,11 +140,25 @@ AC_SUBST(PCRE_CFLAGS) AC_SUBST(PCRE_LIBS) PKG_CHECK_MODULES([LIBEDIT], [libedit], - [AC_DEFINE([HAVE_LIBEDIT], [1], [Define we have libedit])], - [AX_LIB_READLINE]) -if test "$ac_cv_have_readline" = no; then - AC_MSG_ERROR([libedit or readline not found]) -fi + # having the module does not imply having the header + [AC_CHECK_HEADERS([editline/readline.h], + [AC_DEFINE([HAVE_LIBEDIT], [1], [Define if we have libedit])], + [AC_MSG_ERROR([Found libedit, but header file is missing. Hint: Install dev package?])])], + [ + # AX_LIB_READLINE overwrites LIBS which leads to every binary getting + # linked against libreadline uselessly. So we re-use LIBEDIT_LIBS which + # we have for libedit to add the lib specifically where needed + save_LIBS="${LIBS}" + AX_LIB_READLINE + LIBS="${save_LIBS}" + if test "$ax_cv_lib_readline" = "no"; then + AC_MSG_ERROR([neither libedit nor another readline compatible library found]) + fi + if test "x$ax_cv_lib_readline_history" != "xyes"; then + AC_MSG_ERROR([need readline history support]) + fi + LIBEDIT_LIBS="$ax_cv_lib_readline" + ]) # Checks for header files. AC_HEADER_STDC From nils.goroll at uplex.de Mon Aug 18 19:30:25 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 18 Aug 2014 21:30:25 +0200 Subject: [master] c2f91fe wrong kind of white space Message-ID: commit c2f91fe873989695f133ce11ba97e09e5b059895 Author: Nils Goroll Date: Mon Aug 18 21:30:10 2014 +0200 wrong kind of white space diff --git a/bin/varnishtest/tests/v00026.vtc b/bin/varnishtest/tests/v00026.vtc index 711861d..2b52238 100644 --- a/bin/varnishtest/tests/v00026.vtc +++ b/bin/varnishtest/tests/v00026.vtc @@ -33,7 +33,7 @@ varnish v1 -vcl+backend { } sub vcl_backend_fetch { if (bereq.url == "/nohdr") { - set bereq.backend = h1.backend(bereq.http.Void); + set bereq.backend = h1.backend(bereq.http.Void); } else if (bereq.url == "/emptystring") { set bereq.backend = h1.backend(""); } else if (bereq.url == "/13") { From phk at FreeBSD.org Mon Aug 18 21:34:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 18 Aug 2014 23:34:25 +0200 Subject: [master] f36b476 Make vcl_hit{}'s access to obj.* happen through the packed string. Message-ID: commit f36b47641fad8f6b6bd0f9841e3e3ee16cf6fdeb Author: Poul-Henning Kamp Date: Mon Aug 18 21:33:50 2014 +0000 Make vcl_hit{}'s access to obj.* happen through the packed string. This bumps the vrt.h major version. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 42c40d3..44dea14 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -979,6 +979,7 @@ void http_MarkHeader(const struct http *, const char *hdr, unsigned hdrlen, void http_CollectHdr(struct http *hp, const char *hdr); void http_VSL_log(const struct http *hp); void HTTP_Merge(struct objcore *, struct dstat *, struct http *to); +uint16_t HTTP_GetStatusPack(struct objcore *oc, struct dstat *ds); const char *HTTP_GetHdrPack(struct objcore *, struct dstat *, const char *hdr); @@ -1062,7 +1063,6 @@ void ObjIterEnd(struct objiter **); void ObjTrimStore(struct objcore *, struct dstat *); unsigned ObjGetXID(struct objcore *, struct dstat *); uint64_t ObjGetLen(struct objcore *oc, struct dstat *ds); -struct object *ObjGetObj(struct objcore *, struct dstat *); void ObjUpdateMeta(struct objcore *, struct dstat *); void ObjFreeObj(struct objcore *, struct dstat *); void ObjSlim(struct objcore *oc, struct dstat *ds); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 83f4aa2..f79d173 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -723,6 +723,18 @@ HTTP_Decode(struct http *to, uint8_t *fm) /*--------------------------------------------------------------------*/ +uint16_t +HTTP_GetStatusPack(struct objcore *oc, struct dstat *ds) +{ + const char *ptr; + ptr = ObjGetattr(oc, ds, OA_HEADERS, NULL); + AN(ptr); + + return(vbe16dec(ptr + 2)); +} + +/*--------------------------------------------------------------------*/ + const char * HTTP_GetHdrPack(struct objcore *oc, struct dstat *ds, const char *hdr) { @@ -741,10 +753,14 @@ HTTP_GetHdrPack(struct objcore *oc, struct dstat *ds, const char *hdr) VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr); /* Skip PROTO, STATUS and REASON */ + if (!strcmp(hdr, ":proto")) + return (ptr); ptr = strchr(ptr, '\0') + 1; if (!strcmp(hdr, ":status")) return (ptr); ptr = strchr(ptr, '\0') + 1; + if (!strcmp(hdr, ":reason")) + return (ptr); ptr = strchr(ptr, '\0') + 1; l = hdr[0]; diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index ca028bc..158fedb 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -35,6 +35,30 @@ #include "storage/storage.h" #include "hash/hash_slinger.h" + +static const struct objcore_methods * +obj_getmethods(const struct objcore *oc) +{ + + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + CHECK_OBJ_NOTNULL(oc->stevedore, STEVEDORE_MAGIC); + AN(oc->stevedore->methods); + return (oc->stevedore->methods); +} + +static struct object * +obj_getobj(struct objcore *oc, struct dstat *ds) +{ + const struct objcore_methods *m = obj_getmethods(oc); + + AN(ds); + AN(m->getobj); + return (m->getobj(ds, oc)); +} + +/*-------------------------------------------------------------------- + */ + struct objiter { unsigned magic; #define OBJITER_MAGIC 0x745fb151 @@ -52,7 +76,7 @@ ObjIterBegin(struct worker *wrk, struct objcore *oc) struct object *obj; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - obj = ObjGetObj(oc, &wrk->stats); + obj = obj_getobj(oc, &wrk->stats); CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); ALLOC_OBJ(oi, OBJITER_MAGIC); if (oi == NULL) @@ -142,16 +166,6 @@ ObjIterEnd(struct objiter **oi) *oi = NULL; } -static const struct objcore_methods * -obj_getmethods(const struct objcore *oc) -{ - - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - CHECK_OBJ_NOTNULL(oc->stevedore, STEVEDORE_MAGIC); - AN(oc->stevedore->methods); - return (oc->stevedore->methods); -} - void ObjTrimStore(struct objcore *oc, struct dstat *ds) { @@ -163,7 +177,7 @@ ObjTrimStore(struct objcore *oc, struct dstat *ds) AN(ds); stv = oc->stevedore; CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); - o = ObjGetObj(oc, ds); + o = obj_getobj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); st = VTAILQ_LAST(&o->body->list, storagehead); if (st == NULL) @@ -188,7 +202,7 @@ ObjSlim(struct objcore *oc, struct dstat *ds) CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(ds); - o = ObjGetObj(oc, ds); + o = obj_getobj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); if (o->esidata != NULL) { @@ -202,16 +216,6 @@ ObjSlim(struct objcore *oc, struct dstat *ds) } } -struct object * -ObjGetObj(struct objcore *oc, struct dstat *ds) -{ - const struct objcore_methods *m = obj_getmethods(oc); - - AN(ds); - AN(m->getobj); - return (m->getobj(ds, oc)); -} - void ObjUpdateMeta(struct objcore *oc, struct dstat *ds) { @@ -253,7 +257,7 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, AN(ds); if (len == NULL) len = &dummy; - o = ObjGetObj(oc, ds); + o = obj_getobj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); switch (attr) { case OA_ESIDATA: @@ -294,7 +298,7 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vc->bo->fetch_objcore, OBJCORE_MAGIC); - o = ObjGetObj(vc->bo->fetch_objcore, vc->bo->stats); + o = obj_getobj(vc->bo->fetch_objcore, vc->bo->stats); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); switch (attr) { case OA_ESIDATA: @@ -358,7 +362,7 @@ ObjGetLen(struct objcore *oc, struct dstat *ds) { struct object *o; - o = ObjGetObj(oc, ds); + o = obj_getobj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); return (o->body->len); } diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index db1feb3..345696e 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -432,9 +432,6 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, ctx.http_req = req->http; ctx.http_resp = req->resp; ctx.req = req; - if (method == VCL_MET_HIT) - ctx.http_obj = - ObjGetObj(req->objcore, &wrk->stats)->http; } if (bo != NULL) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 46f3e02..f2c2065 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -109,9 +109,6 @@ vrt_selecthttp(const struct vrt_ctx *ctx, enum gethdr_e where) case HDR_RESP: hp = ctx->http_resp; break; - case HDR_OBJ: - hp = ctx->http_obj; - break; default: WRONG("vrt_selecthttp 'where' invalid"); } @@ -120,13 +117,19 @@ vrt_selecthttp(const struct vrt_ctx *ctx, enum gethdr_e where) /*--------------------------------------------------------------------*/ -char * +const char * VRT_GetHdr(const struct vrt_ctx *ctx, const struct gethdr_s *hs) { char *p; struct http *hp; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (hs->where == HDR_OBJ) { + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); + return(HTTP_GetHdrPack(ctx->req->objcore, + &ctx->req->wrk->stats, hs->what)); + } hp = vrt_selecthttp(ctx, hs->where); CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); if (!http_GetHdr(hp, hs->what, &p)) diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 3f50a4b..0d639a7 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -124,10 +124,6 @@ VRT_HDR_LR(req, method, HTTP_HDR_METHOD) VRT_HDR_LR(req, url, HTTP_HDR_URL) VRT_HDR_LR(req, proto, HTTP_HDR_PROTO) -VRT_HDR_R(obj, proto, HTTP_HDR_PROTO) -VRT_HDR_R(obj, reason, HTTP_HDR_REASON) -VRT_STATUS_R(obj) - VRT_HDR_LR(resp, proto, HTTP_HDR_PROTO) VRT_HDR_LR(resp, reason, HTTP_HDR_REASON) VRT_STATUS_L(resp) @@ -142,6 +138,42 @@ VRT_STATUS_L(beresp) VRT_STATUS_R(beresp) /*-------------------------------------------------------------------- + * Pulling things out of the packed object->http + */ + +long +VRT_r_obj_status(const struct vrt_ctx *ctx) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); + + return (HTTP_GetStatusPack(ctx->req->objcore, &ctx->req->wrk->stats)); +} + +const char * +VRT_r_obj_proto(const struct vrt_ctx *ctx) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); + + return (HTTP_GetHdrPack(ctx->req->objcore, + &ctx->req->wrk->stats, ":proto")); +} + +const char * +VRT_r_obj_reason(const struct vrt_ctx *ctx) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); + + return (HTTP_GetHdrPack(ctx->req->objcore, + &ctx->req->wrk->stats, ":reason")); +} + +/*-------------------------------------------------------------------- * bool-fields (.do_*) */ diff --git a/include/vrt.h b/include/vrt.h index ead55d3..cb47db9 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -39,9 +39,9 @@ * binary/load-time compatible, increment MAJOR version */ -#define VRT_MAJOR_VERSION 1U +#define VRT_MAJOR_VERSION 2U -#define VRT_MINOR_VERSION 2U +#define VRT_MINOR_VERSION 0U /***********************************************************************/ @@ -95,7 +95,6 @@ struct vrt_ctx { struct req *req; struct http *http_req; - struct http *http_obj; struct http *http_resp; struct busyobj *bo; @@ -238,7 +237,7 @@ int VRT_rewrite(const char *, const char *); void VRT_error(const struct vrt_ctx *, unsigned, const char *); int VRT_switch_config(const char *); -char *VRT_GetHdr(const struct vrt_ctx *, const struct gethdr_s *); +const char *VRT_GetHdr(const struct vrt_ctx *, const struct gethdr_s *); void VRT_SetHdr(const struct vrt_ctx *, const struct gethdr_s *, const char *, ...); void VRT_handling(const struct vrt_ctx *, unsigned hand); From phk at FreeBSD.org Mon Aug 18 22:04:36 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 00:04:36 +0200 Subject: [master] 080fa4f Don't populate obj->http any more. Message-ID: commit 080fa4f97d81cd46a59eabe7cf3eabc10fff2d33 Author: Poul-Henning Kamp Date: Mon Aug 18 22:03:53 2014 +0000 Don't populate obj->http any more. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index b374308..5495af2 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -149,13 +149,13 @@ vbf_beresp2obj(struct busyobj *bo) AZ(ObjSetU32(bo->vfc, OA_VXID, VXID(bo->vsl->wid))); WS_Assert(bo->ws_o); + /* for HTTP_Encode() VSLH call */ + bo->beresp->logtag = SLT_ObjMethod; + /* Filter into object */ - obj->http->logtag = SLT_ObjMethod; obj->oa_http = HTTP_Encode(bo->beresp, bo->ws_o, bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS); AN(obj->oa_http); - AZ(HTTP_Decode(obj->http, - ObjGetattr(bo->fetch_objcore, bo->stats, OA_HEADERS, NULL))); if (http_GetHdr(bo->beresp, H_Last_Modified, &b)) AZ(ObjSetDouble(bo->vfc, OA_LASTMODIFIED, VTIM_parse(b))); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index f79d173..75b0617 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -670,6 +670,7 @@ HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how) continue; #include "tbl/http_headers.h" #undef HTTPH + http_VSLH(fm, u); w = Tlen(fm->hd[u]) + 1L; if (p + w + 1 > e) { WS_Release(ws, 0); From phk at FreeBSD.org Mon Aug 18 22:33:42 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 00:33:42 +0200 Subject: [master] 71f2b38 Remove obj->http. Message-ID: commit 71f2b383b443d2745e92fdb6b80374f858876fb4 Author: Poul-Henning Kamp Date: Mon Aug 18 22:33:00 2014 +0000 Remove obj->http. This shaves approx 100 bytes of stored objects, and is a major step to avoiding storing absolute pointers in persistent stevedores. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 44dea14..66a21d5 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -576,8 +576,6 @@ struct object { /* VCL only variables */ char oa_lastmodified[8]; - struct http *http; - struct body body[1]; struct storage *esidata; @@ -945,7 +943,7 @@ unsigned HTTP_estimate(unsigned nhttp); void HTTP_Copy(struct http *to, const struct http * const fm); struct http *HTTP_create(void *p, uint16_t nhttp); const char *http_Status2Reason(unsigned); -unsigned http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd); +unsigned http_EstimateWS(const struct http *fm, unsigned how); void HTTP_Init(void); void http_PutResponse(struct http *to, const char *proto, uint16_t status, const char *response); @@ -1241,8 +1239,7 @@ void RFC2616_Weaken_Etag(struct http *hp); /* stevedore.c */ -struct object *STV_NewObject(struct busyobj *, - const char *hint, unsigned len, uint16_t nhttp); +struct object *STV_NewObject(struct busyobj *, const char *hint, unsigned len); struct storage *STV_alloc(const struct vfp_ctx *, size_t size); void STV_trim(struct storage *st, size_t size, int move_ok); void STV_free(struct storage *st); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 5495af2..b3adfa1 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -47,7 +47,7 @@ */ static struct object * -vbf_allocobj(struct busyobj *bo, unsigned l, uint16_t nhttp) +vbf_allocobj(struct busyobj *bo, unsigned l) { struct object *obj; struct objcore *oc; @@ -67,7 +67,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l, uint16_t nhttp) bo->storage_hint = NULL; - obj = STV_NewObject(bo, storage_hint, l, nhttp); + obj = STV_NewObject(bo, storage_hint, l); if (obj != NULL) return (obj); @@ -84,7 +84,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l, uint16_t nhttp) oc->exp.ttl = cache_param->shortlived; oc->exp.grace = 0.0; oc->exp.keep = 0.0; - obj = STV_NewObject(bo, TRANSIENT_STORAGE, l, nhttp); + obj = STV_NewObject(bo, TRANSIENT_STORAGE, l); return (obj); } @@ -99,7 +99,6 @@ vbf_beresp2obj(struct busyobj *bo) char *b; struct vsb *vary = NULL; int varyl = 0; - uint16_t nhttp; struct object *obj; l = 0; @@ -127,12 +126,12 @@ vbf_beresp2obj(struct busyobj *bo) } l += http_EstimateWS(bo->beresp, - bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS, &nhttp); + bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS); if (bo->uncacheable) bo->fetch_objcore->flags |= OC_F_PASS; - obj = vbf_allocobj(bo, l, nhttp); + obj = vbf_allocobj(bo, l); if (obj == NULL) return (-1); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 75b0617..592d042 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -610,12 +610,11 @@ http_PutResponse(struct http *to, const char *proto, uint16_t status, */ unsigned -http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd) +http_EstimateWS(const struct http *fm, unsigned how) { unsigned u, l; l = 4; - *nhd = 1 + HTTP_HDR_FIRST - 3; CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); for (u = 0; u < fm->nhd; u++) { if (u == HTTP_HDR_METHOD || u == HTTP_HDR_URL) @@ -630,7 +629,6 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd) #include "tbl/http_headers.h" #undef HTTPH l += Tlen(fm->hd[u]) + 1L; - (*nhd)++; } return (PRNDUP(l + 1L)); } diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 158fedb..d7312e3 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -317,7 +317,7 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, assert(len == sizeof o->oa_lastmodified); return (o->oa_lastmodified); case OA_VARY: - o->oa_vary = (void*)WS_Alloc(o->http->ws, len); + o->oa_vary = (void*)WS_Alloc(vc->bo->ws_o, len); AN(o->oa_vary); return (o->oa_vary); case OA_VXID: diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index adbe556..d11f306 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -229,8 +229,6 @@ stv_alloc_obj(const struct vfp_ctx *vc, size_t size) struct stv_objsecrets { unsigned magic; #define STV_OBJ_SECRETES_MAGIC 0x78c87247 - uint16_t nhttp; - unsigned lhttp; unsigned wsl; }; @@ -256,24 +254,20 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo, assert(PAOK(ptr)); assert(PAOK(soc->wsl)); - assert(PAOK(soc->lhttp)); - assert(ltot >= sizeof *o + soc->lhttp + soc->wsl); + assert(ltot >= sizeof *o + soc->wsl); o = ptr; memset(o, 0, sizeof *o); o->magic = OBJECT_MAGIC; - l = PRNDDN(ltot - (sizeof *o + soc->lhttp)); + l = PRNDDN(ltot - sizeof *o); assert(l >= soc->wsl); - o->http = HTTP_create(o + 1, soc->nhttp); - WS_Init(bo->ws_o, "obj", (char *)(o + 1) + soc->lhttp, soc->wsl); + WS_Init(bo->ws_o, "obj", o + 1, l); WS_Assert(bo->ws_o); assert(bo->ws_o->e <= (char*)ptr + ltot); - HTTP_Setup(o->http, bo->ws_o, bo->vsl, SLT_ObjMethod); - o->http->magic = HTTP_MAGIC; VTAILQ_INIT(&o->body->list); o->objcore = bo->fetch_objcore; @@ -323,12 +317,11 @@ stv_default_allocobj(struct stevedore *stv, struct busyobj *bo, */ struct object * -STV_NewObject(struct busyobj *bo, const char *hint, - unsigned wsl, uint16_t nhttp) +STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl) { struct object *o; struct stevedore *stv, *stv0; - unsigned lhttp, ltot; + unsigned ltot; struct stv_objsecrets soc; int i; @@ -337,16 +330,11 @@ STV_NewObject(struct busyobj *bo, const char *hint, assert(wsl > 0); wsl = PRNDUP(wsl); - lhttp = HTTP_estimate(nhttp); - lhttp = PRNDUP(lhttp); - memset(&soc, 0, sizeof soc); soc.magic = STV_OBJ_SECRETES_MAGIC; - soc.nhttp = nhttp; - soc.lhttp = lhttp; soc.wsl = wsl; - ltot = sizeof *o + wsl + lhttp; + ltot = sizeof *o + wsl; stv = stv0 = stv_pick_stevedore(bo->vsl, &hint); AN(stv->allocobj); diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc index 587bf38..1519ff5 100644 --- a/bin/varnishtest/tests/c00044.vtc +++ b/bin/varnishtest/tests/c00044.vtc @@ -2,19 +2,19 @@ varnishtest "Object/LRU/Stevedores" server s1 { rxreq - txresp -bodylen 1048190 + txresp -bodylen 1048290 rxreq - txresp -bodylen 1048191 + txresp -bodylen 1048291 rxreq - txresp -bodylen 1048192 + txresp -bodylen 1048292 rxreq - txresp -bodylen 1047193 + txresp -bodylen 1047293 rxreq - txresp -bodylen 1047194 + txresp -bodylen 1047294 } -start varnish v1 \ @@ -35,7 +35,7 @@ client c1 { txreq -url /foo rxresp expect resp.status == 200 - expect resp.bodylen == 1048190 + expect resp.bodylen == 1048290 } -run varnish v1 -expect SMA.Transient.g_bytes == 0 @@ -50,7 +50,7 @@ client c1 { txreq -url /bar rxresp expect resp.status == 200 - expect resp.bodylen == 1048191 + expect resp.bodylen == 1048291 } -run varnish v1 -expect SMA.Transient.g_bytes == 0 @@ -65,7 +65,7 @@ client c1 { txreq -url /burp rxresp expect resp.status == 200 - expect resp.bodylen == 1048192 + expect resp.bodylen == 1048292 } -run varnish v1 -expect SMA.Transient.g_bytes == 0 @@ -80,7 +80,7 @@ client c1 { txreq -url /foo1 rxresp expect resp.status == 200 - expect resp.bodylen == 1047193 + expect resp.bodylen == 1047293 } -run varnish v1 -expect n_lru_nuked == 1 @@ -89,7 +89,7 @@ client c1 { txreq -url /foo rxresp expect resp.status == 200 - expect resp.bodylen == 1047194 + expect resp.bodylen == 1047294 } -run varnish v1 -expect n_lru_nuked == 2 diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc index 77425cb..57eef39 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 1048188 + txresp -bodylen 1048288 rxreq - txresp -bodylen 1047189 + txresp -bodylen 1047289 rxreq - txresp -bodylen 1047190 + txresp -bodylen 1047290 } -start varnish v1 \ @@ -27,7 +27,7 @@ client c1 { txreq -url /foo rxresp expect resp.status == 200 - expect resp.bodylen == 1048188 + expect resp.bodylen == 1048288 } -run varnish v1 -expect SMA.Transient.g_bytes == 0 @@ -42,7 +42,7 @@ client c1 { txreq -url /bar rxresp expect resp.status == 200 - expect resp.bodylen == 1047189 + expect resp.bodylen == 1047289 } -run varnish v1 -expect n_lru_nuked == 1 @@ -58,7 +58,7 @@ client c1 { txreq -url /foo rxresp expect resp.status == 200 - expect resp.bodylen == 1047190 + expect resp.bodylen == 1047290 } -run varnish v1 -expect n_lru_nuked == 2 diff --git a/bin/varnishtest/tests/r01140.vtc b/bin/varnishtest/tests/r01140.vtc index 11e2a72..da71446 100644 --- a/bin/varnishtest/tests/r01140.vtc +++ b/bin/varnishtest/tests/r01140.vtc @@ -4,7 +4,7 @@ server s1 { # This response should almost completely fill the storage rxreq expect req.url == /url1 - txresp -bodylen 1048208 + txresp -bodylen 1048308 # The next one should not fit in the storage, ending up in transient # with zero ttl (=shortlived) @@ -31,7 +31,7 @@ client c1 { txreq -url /url1 rxresp expect resp.status == 200 - expect resp.bodylen == 1048208 + expect resp.bodylen == 1048308 } -run delay .1 diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc index dc6336f..d613ab8 100644 --- a/bin/varnishtest/tests/r01284.vtc +++ b/bin/varnishtest/tests/r01284.vtc @@ -3,7 +3,7 @@ varnishtest "#1284 - Test resource cleanup after STV_NewObject fail in fetch" server s1 { rxreq expect req.url == "/obj1" - txresp -bodylen 1048190 + txresp -bodylen 1048290 rxreq expect req.url == "/obj2" txresp -hdr "Long: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -hdr "Long2: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" From phk at FreeBSD.org Mon Aug 18 22:48:34 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 00:48:34 +0200 Subject: [master] 305e69c Tweak size-sensitive test case for 32bit systems Message-ID: commit 305e69cc4beb84a8eded9bcf9d27e6cbff3113c5 Author: Poul-Henning Kamp Date: Mon Aug 18 22:48:18 2014 +0000 Tweak size-sensitive test case for 32bit systems diff --git a/bin/varnishtest/tests/r01140.vtc b/bin/varnishtest/tests/r01140.vtc index da71446..098a653 100644 --- a/bin/varnishtest/tests/r01140.vtc +++ b/bin/varnishtest/tests/r01140.vtc @@ -4,7 +4,7 @@ server s1 { # This response should almost completely fill the storage rxreq expect req.url == /url1 - txresp -bodylen 1048308 + txresp -bodylen 1048408 # The next one should not fit in the storage, ending up in transient # with zero ttl (=shortlived) @@ -31,7 +31,7 @@ client c1 { txreq -url /url1 rxresp expect resp.status == 200 - expect resp.bodylen == 1048308 + expect resp.bodylen == 1048408 } -run delay .1 From phk at FreeBSD.org Tue Aug 19 06:58:28 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 08:58:28 +0200 Subject: [master] d1d7333 Make it possible to pass a pointer to the new value to ObjSetattr() Message-ID: commit d1d73339f3fb1f5b44156911fda428eec8a10e86 Author: Poul-Henning Kamp Date: Tue Aug 19 06:58:04 2014 +0000 Make it possible to pass a pointer to the new value to ObjSetattr() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 66a21d5..cdfbcee 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1067,7 +1067,8 @@ void ObjSlim(struct objcore *oc, struct dstat *ds); struct lru *ObjGetLRU(const struct objcore *); void *ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, ssize_t *len); -void *ObjSetattr(const struct vfp_ctx *, enum obj_attr attr, ssize_t len); +void *ObjSetattr(const struct vfp_ctx *, enum obj_attr attr, ssize_t len, + const void *); int ObjCopyAttr(const struct vfp_ctx *, struct objcore *, enum obj_attr attr); int ObjSetDouble(const struct vfp_ctx*, enum obj_attr, double); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 1608eff..db6da83 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -118,12 +118,10 @@ vfp_esi_end(struct vfp_ctx *vc, struct vef_priv *vef, if (retval == VFP_END) { l = VSB_len(vsb); assert(l > 0); - p = ObjSetattr(vc, OA_ESIDATA, l); + p = ObjSetattr(vc, OA_ESIDATA, l, VSB_data(vsb)); if (p == NULL) { retval = VFP_Error(vc, "Could not allocate storage for esidata"); - } else { - memcpy(p, VSB_data(vsb), l); } } VSB_delete(vsb); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index b3adfa1..2c08ccd 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -139,8 +139,7 @@ vbf_beresp2obj(struct busyobj *bo) CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); if (vary != NULL) { - b = ObjSetattr(bo->vfc, OA_VARY, varyl); - memcpy(b, VSB_data(vary), varyl); + b = ObjSetattr(bo->vfc, OA_VARY, varyl, VSB_data(vary)); (void)VRY_Validate(obj->oa_vary); VSB_delete(vary); } diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 8cafe6b..96406ee 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -396,7 +396,7 @@ VGZ_UpdateObj(const struct vfp_ctx *vc, const struct vgz *vg) char *p; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - p = ObjSetattr(vc, OA_GZIPBITS, 24); + p = ObjSetattr(vc, OA_GZIPBITS, 24, NULL); AN(p); vbe64enc(p, vg->vz.start_bit); vbe64enc(p + 8, vg->vz.last_bit); diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index d7312e3..93cba08 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -290,10 +290,11 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, } void * -ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, - ssize_t len) +ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, ssize_t len, + const void *ptr) { struct object *o; + void *retval = NULL; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); @@ -306,27 +307,36 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, if (o->esidata == NULL) return (NULL); o->esidata->len = len; - return (o->esidata->ptr); + retval = o->esidata->ptr; + break; case OA_FLAGS: assert(len == sizeof o->oa_flags); - return (o->oa_flags); + retval = o->oa_flags; + break; case OA_GZIPBITS: assert(len == sizeof o->oa_gzipbits); - return (o->oa_gzipbits); + retval = o->oa_gzipbits; + break; case OA_LASTMODIFIED: assert(len == sizeof o->oa_lastmodified); - return (o->oa_lastmodified); + retval = o->oa_lastmodified; + break; case OA_VARY: o->oa_vary = (void*)WS_Alloc(vc->bo->ws_o, len); AN(o->oa_vary); - return (o->oa_vary); + retval = o->oa_vary; + break; case OA_VXID: assert(len == sizeof o->oa_vxid); - return (o->oa_vxid); + retval = o->oa_vxid; + break; default: + WRONG("Unsupported OBJ_ATTR"); break; } - WRONG("Unsupported OBJ_ATTR"); + if (ptr != NULL) + memcpy(retval, ptr, len); + return (retval); } int @@ -341,10 +351,9 @@ ObjCopyAttr(const struct vfp_ctx *vc, struct objcore *ocs, enum obj_attr attr) // XXX: later we want to have zero-length OA's too if (vps == NULL || l <= 0) return (-1); - vpd = ObjSetattr(vc, attr, l); + vpd = ObjSetattr(vc, attr, l, vps); if (vpd == NULL) return (-1); - memcpy(vpd, vps, l); return (0); } @@ -383,7 +392,7 @@ ObjSetDouble(const struct vfp_ctx *vc, enum obj_attr a, double t) assert(sizeof t == sizeof u); memcpy(&u, &t, sizeof u); - vp = ObjSetattr(vc, a, sizeof u); + vp = ObjSetattr(vc, a, sizeof u, NULL); if (vp == NULL) return (-1); vbe64enc(vp, u); @@ -417,7 +426,7 @@ ObjSetU64(const struct vfp_ctx *vc, enum obj_attr a, uint64_t t) { void *vp; - vp = ObjSetattr(vc, a, sizeof t); + vp = ObjSetattr(vc, a, sizeof t, NULL); if (vp == NULL) return (-1); vbe64enc(vp, t); @@ -443,7 +452,7 @@ ObjSetU32(const struct vfp_ctx *vc, enum obj_attr a, uint32_t t) { void *vp; - vp = ObjSetattr(vc, a, sizeof t); + vp = ObjSetattr(vc, a, sizeof t, NULL); if (vp == NULL) return (-1); vbe32enc(vp, t); @@ -482,7 +491,7 @@ ObjSetFlag(const struct vfp_ctx *vc, enum obj_flags of, int val) { uint8_t *fp; - fp = ObjSetattr(vc, OA_FLAGS, 1); + fp = ObjSetattr(vc, OA_FLAGS, 1, NULL); AN(fp); if (val) (*fp) |= of; From phk at FreeBSD.org Tue Aug 19 07:17:02 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 09:17:02 +0200 Subject: [master] 149e627 Put stats directly in vfp_ctx Message-ID: commit 149e6277af1bc5d43d69b3caad336882298c2f69 Author: Poul-Henning Kamp Date: Tue Aug 19 07:14:55 2014 +0000 Put stats directly in vfp_ctx diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index cdfbcee..854cf8b 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -455,6 +455,7 @@ struct vfp_ctx { unsigned magic; #define VFP_CTX_MAGIC 0x61d9d3e5 struct busyobj *bo; + struct dstat *stats; int failed; @@ -894,7 +895,7 @@ void EXP_Init(void); void EXP_Rearm(struct objcore *, double now, double ttl, double grace, double keep); void EXP_Touch(struct objcore *oc, double now); -int EXP_NukeOne(struct busyobj *, struct lru *lru); +int EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru); /* cache_fetch.c */ enum vbf_fetch_mode_e { diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 5c59185..1cc223b 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -286,17 +286,20 @@ EXP_Rearm(struct objcore *oc, double now, double ttl, double grace, double keep) */ int -EXP_NukeOne(struct busyobj *bo, struct lru *lru) +EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru) { struct objcore *oc, *oc2; struct objhead *oh; + AN(vsl); + AN(ds); + CHECK_OBJ_NOTNULL(lru, LRU_MAGIC); /* Find the first currently unused object on the LRU. */ Lck_Lock(&lru->mtx); VTAILQ_FOREACH_SAFE(oc, &lru->lru_head, lru_list, oc2) { CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - VSLb(bo->vsl, SLT_ExpKill, "LRU_Cand p=%p f=0x%x r=%d", + VSLb(vsl, SLT_ExpKill, "LRU_Cand p=%p f=0x%x r=%d", oc, oc->flags, oc->refcnt); AZ(oc->exp_flags & OC_EF_OFFLRU); @@ -328,19 +331,17 @@ EXP_NukeOne(struct busyobj *bo, struct lru *lru) Lck_Unlock(&lru->mtx); if (oc == NULL) { - VSLb(bo->vsl, SLT_ExpKill, "LRU_Fail"); + VSLb(vsl, SLT_ExpKill, "LRU_Fail"); return (-1); } /* XXX: We could grab and return one storage segment to our caller */ - ObjSlim(oc, bo->stats); + ObjSlim(oc, ds); exp_mail_it(oc); - VSLb(bo->vsl, SLT_ExpKill, "LRU x=%u", ObjGetXID(oc, bo->stats)); - AN(bo->stats); - AN(oc); - (void)HSH_DerefObjCore(bo->stats, &oc); + VSLb(vsl, SLT_ExpKill, "LRU x=%u", ObjGetXID(oc, ds)); + (void)HSH_DerefObjCore(ds, &oc); return (1); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 2c08ccd..f389304 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -364,6 +364,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) VFP_Setup(bo->vfc); bo->vfc->bo = bo; + bo->vfc->stats = bo->stats; bo->vfc->http = bo->beresp; bo->vfc->vsl = bo->vsl; @@ -684,6 +685,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) VFP_Setup(bo->vfc); bo->vfc->bo = bo; + bo->vfc->stats = bo->stats; bo->vfc->http = bo->beresp; bo->vfc->vsl = bo->vsl; diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index fd83152..43d89ef 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -86,7 +86,7 @@ VFP_GetStorage(struct vfp_ctx *vc, ssize_t sz) if (st != NULL && st->len < st->space) return (st); - AN(vc->bo->stats); + AN(vc->stats); l = fetchfrag; if (l == 0) l = sz; diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 93cba08..b9984d7 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -299,7 +299,7 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, ssize_t len, CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vc->bo->fetch_objcore, OBJCORE_MAGIC); - o = obj_getobj(vc->bo->fetch_objcore, vc->bo->stats); + o = obj_getobj(vc->bo->fetch_objcore, vc->stats); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); switch (attr) { case OA_ESIDATA: @@ -347,7 +347,7 @@ ObjCopyAttr(const struct vfp_ctx *vc, struct objcore *ocs, enum obj_attr attr) CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - vps = ObjGetattr(ocs, vc->bo->stats, attr, &l); + vps = ObjGetattr(ocs, vc->stats, attr, &l); // XXX: later we want to have zero-length OA's too if (vps == NULL || l <= 0) return (-1); diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index d11f306..39fddd9 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -195,7 +195,6 @@ stv_alloc_obj(const struct vfp_ctx *vc, size_t size) */ CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); - AN(vc->bo->stats); stv = vc->body->stevedore; CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); @@ -213,7 +212,7 @@ stv_alloc_obj(const struct vfp_ctx *vc, size_t size) /* no luck; try to free some space and keep trying */ if (fail < cache_param->nuke_limit && - EXP_NukeOne(vc->bo, stv->lru) == -1) + EXP_NukeOne(vc->vsl, vc->stats, stv->lru) == -1) break; } CHECK_OBJ_ORNULL(st, STORAGE_MAGIC); @@ -349,7 +348,7 @@ STV_NewObject(struct busyobj *bo, 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(bo, stv->lru) == -1) + if (EXP_NukeOne(bo->vsl, bo->stats, stv->lru) == -1) break; o = stv->allocobj(stv, bo, ltot, &soc); } From phk at FreeBSD.org Tue Aug 19 07:43:57 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 09:43:57 +0200 Subject: [master] 48ecc25 Move ESI parser from a struct busyobj to struct vfp_ctx Message-ID: commit 48ecc25ee97bad603351358f42953ecc3d1705d5 Author: Poul-Henning Kamp Date: Tue Aug 19 07:43:39 2014 +0000 Move ESI parser from a struct busyobj to struct vfp_ctx diff --git a/bin/varnishd/cache/cache_esi.h b/bin/varnishd/cache/cache_esi.h index 52c9d0b..100e034 100644 --- a/bin/varnishd/cache/cache_esi.h +++ b/bin/varnishd/cache/cache_esi.h @@ -39,10 +39,11 @@ #define VEC_S8 (0x60 + 8) #define VEC_INCL 'I' -typedef ssize_t vep_callback_t(struct busyobj *, void *priv, ssize_t l, +typedef ssize_t vep_callback_t(struct vfp_ctx *, void *priv, ssize_t l, enum vgz_flag flg); -struct vep_state *VEP_Init(struct busyobj *, vep_callback_t *cb, void *cb_priv); +struct vep_state *VEP_Init(struct vfp_ctx *vc, const struct http *req, + vep_callback_t *cb, void *cb_priv); void VEP_Parse(struct vep_state *, const struct busyobj *, const char *p, size_t l); struct vsb *VEP_Finish(struct vep_state *, const struct busyobj *); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index db6da83..77ed03d 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -56,7 +56,7 @@ struct vef_priv { }; static ssize_t -vfp_vep_callback(struct busyobj *bo, void *priv, ssize_t l, enum vgz_flag flg) +vfp_vep_callback(struct vfp_ctx *vc, void *priv, ssize_t l, enum vgz_flag flg) { struct vef_priv *vef; size_t dl; @@ -64,7 +64,8 @@ vfp_vep_callback(struct busyobj *bo, void *priv, ssize_t l, enum vgz_flag flg) struct storage *st; int i; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(vef, priv, VEF_MAGIC); assert(l >= 0); @@ -83,7 +84,7 @@ vfp_vep_callback(struct busyobj *bo, void *priv, ssize_t l, enum vgz_flag flg) VGZ_Ibuf(vef->vgz, vef->ibuf_o, l); do { - st = VFP_GetStorage(bo->vfc, 0); + st = VFP_GetStorage(vc, 0); if (st == NULL) { vef->error = ENOMEM; vef->tot += l; @@ -92,7 +93,7 @@ vfp_vep_callback(struct busyobj *bo, void *priv, ssize_t l, enum vgz_flag flg) VGZ_Obuf(vef->vgz, st->ptr + st->len, st->space - st->len); i = VGZ_Gzip(vef->vgz, &dp, &dl, flg); vef->tot += dl; - VBO_extend(bo, dl); + VBO_extend(vc->bo, dl); } while (i != VGZ_ERROR && (!VGZ_IbufEmpty(vef->vgz) || VGZ_ObufFull(vef->vgz))); assert(i == VGZ_ERROR || VGZ_IbufEmpty(vef->vgz)); @@ -151,7 +152,7 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) if (vef == NULL) return (VFP_ERROR); vef->vgz = VGZ_NewGzip(vc->vsl, "G F E"); - vef->vep = VEP_Init(vc->bo, vfp_vep_callback, vef); + vef->vep = VEP_Init(vc, vc->bo->bereq, vfp_vep_callback, vef); vef->ibuf_sz = cache_param->gzip_buffer; vef->ibuf = calloc(1L, vef->ibuf_sz); if (vef->ibuf == NULL) @@ -222,7 +223,7 @@ vfp_esi_init(struct vfp_ctx *vc, struct vfp_entry *vfe) ALLOC_OBJ(vef, VEF_MAGIC); if (vef == NULL) return (VFP_ERROR); - vef->vep = VEP_Init(vc->bo, NULL, NULL); + vef->vep = VEP_Init(vc, vc->bo->bereq, NULL, NULL); vfe->priv1 = vef; return (VFP_OK); } diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index e17ac52..d028c26 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -60,7 +60,8 @@ struct vep_state { #define VEP_MAGIC 0x55cb9b82 struct vsb *vsb; - struct busyobj *bo; + const char *url; + struct vfp_ctx *vc; int dogzip; vep_callback_t *cb; void *cb_priv; @@ -195,7 +196,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->vsl, SLT_ESI_xmlerror, "ERR at %jd %s", l, p); + VSLb(vep->vc->vsl, SLT_ESI_xmlerror, "ERR at %jd %s", l, p); } @@ -210,7 +211,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); - VSLb(vep->bo->vsl, SLT_ESI_xmlerror, "WARN at %jd %s", l, p); + VSLb(vep->vc->vsl, SLT_ESI_xmlerror, "WARN at %jd %s", l, p); } @@ -330,7 +331,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->bo, vep->cb_priv, 0, + lcb = vep->cb(vep->vc, vep->cb_priv, 0, mark == VERBATIM ? VGZ_RESET : VGZ_ALIGN); if (lcb - vep->o_last > 0) vep_emit_common(vep, lcb - vep->o_last, vep->last_mark); @@ -340,7 +341,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->bo, vep->cb_priv, vep->o_pending, + (void)vep->cb(vep->vc, vep->cb_priv, vep->o_pending, VGZ_NORMAL); if (vep->o_crc == 0) { vep->crc = vep->crcp; @@ -365,7 +366,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->bo, vep->cb_priv, l, VGZ_NORMAL); + (void)vep->cb(vep->vc, vep->cb_priv, l, VGZ_NORMAL); } static void @@ -442,9 +443,8 @@ vep_do_remove(struct vep_state *vep, enum dowhat what) static void __match_proto__() vep_do_include(struct vep_state *vep, enum dowhat what) { - char *p, *q, *h; + const char *p, *q, *h; ssize_t l; - txt url; Debug("DO_INCLUDE(%d)\n", what); if (what == DO_ATTR) { @@ -518,18 +518,17 @@ vep_do_include(struct vep_state *vep, enum dowhat what) } else { VSB_printf(vep->vsb, "%c", VEC_INCL); VSB_printf(vep->vsb, "%c", 0); - 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++) + for (q = vep->url; *q && *q != '?'; q++) if (*q == '/') h = q; if (h == NULL) h = q + 1; Debug("INCL:: [%.*s]/[%s]\n", - (int)(h - url.b), url.b, p); - VSB_printf(vep->vsb, "%.*s/", (int)(h - url.b), url.b); + (int)(h - vep->url), vep->url, p); + VSB_printf(vep->vsb, "%.*s/", (int)(h - vep->url), vep->url); } l -= (p - VSB_data(vep->include_src)); for (q = p; *q != '\0'; ) { @@ -637,14 +636,14 @@ VEP_Parse(struct vep_state *vep, const struct busyobj *bo, const char *p, p++; vep->state = VEP_STARTTAG; } else if (p < e && *p == '\xeb') { - VSLb(vep->bo->vsl, SLT_ESI_xmlerror, + VSLb(vep->vc->vsl, SLT_ESI_xmlerror, "No ESI processing, " "first char not '<' but BOM." " (See feature esi_remove_bom)" ); vep->state = VEP_NOTXML; } else if (p < e) { - VSLb(vep->bo->vsl, SLT_ESI_xmlerror, + VSLb(vep->vc->vsl, SLT_ESI_xmlerror, "No ESI processing, " "first char not '<'." " (See feature esi_disable_xml_check)" @@ -1025,11 +1024,11 @@ VEP_Parse(struct vep_state *vep, const struct busyobj *bo, const char *p, */ static ssize_t __match_proto__() -vep_default_cb(struct busyobj *bo, void *priv, ssize_t l, enum vgz_flag flg) +vep_default_cb(struct vfp_ctx *vc, void *priv, ssize_t l, enum vgz_flag flg) { ssize_t *s; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); AN(priv); s = priv; *s += l; @@ -1041,17 +1040,20 @@ vep_default_cb(struct busyobj *bo, void *priv, ssize_t l, enum vgz_flag flg) */ struct vep_state * -VEP_Init(struct busyobj *bo, vep_callback_t *cb, void *cb_priv) +VEP_Init(struct vfp_ctx *vc, const struct http *req, vep_callback_t *cb, + void *cb_priv) { struct vep_state *vep; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - vep = (void*)WS_Alloc(bo->ws, sizeof *vep); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(req, HTTP_MAGIC); + vep = (void*)WS_Alloc(vc->http->ws, sizeof *vep); AN(vep); memset(vep, 0, sizeof *vep); vep->magic = VEP_MAGIC; - vep->bo = bo; + vep->url = req->hd[HTTP_HDR_URL].b; + vep->vc = vc; vep->vsb = VSB_new_auto(); AN(vep->vsb); @@ -1084,15 +1086,14 @@ VEP_Finish(struct vep_state *vep, const struct busyobj *bo) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); 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->bo, vep->cb_priv, 0, VGZ_ALIGN); + lcb = vep->cb(vep->vc, vep->cb_priv, 0, VGZ_ALIGN); vep_emit_common(vep, lcb - vep->o_last, vep->last_mark); } - (void)vep->cb(vep->bo, vep->cb_priv, 0, VGZ_FINISH); + (void)vep->cb(vep->vc, vep->cb_priv, 0, VGZ_FINISH); AZ(VSB_finish(vep->vsb)); l = VSB_len(vep->vsb); From phk at FreeBSD.org Tue Aug 19 07:57:01 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 09:57:01 +0200 Subject: [master] 3635ea3 Eliminate unused arguments. Message-ID: commit 3635ea366c0791e9121d4ce8b39872800d2bc6e3 Author: Poul-Henning Kamp Date: Tue Aug 19 07:56:23 2014 +0000 Eliminate unused arguments. diff --git a/bin/varnishd/cache/cache_esi.h b/bin/varnishd/cache/cache_esi.h index 100e034..454e595 100644 --- a/bin/varnishd/cache/cache_esi.h +++ b/bin/varnishd/cache/cache_esi.h @@ -44,6 +44,5 @@ typedef ssize_t vep_callback_t(struct vfp_ctx *, void *priv, ssize_t l, struct vep_state *VEP_Init(struct vfp_ctx *vc, const struct http *req, vep_callback_t *cb, void *cb_priv); -void VEP_Parse(struct vep_state *, const struct busyobj *, const char *p, - size_t l); -struct vsb *VEP_Finish(struct vep_state *, const struct busyobj *); +void VEP_Parse(struct vep_state *, const char *p, size_t l); +struct vsb *VEP_Finish(struct vep_state *); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 77ed03d..d0f1bc6 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -113,7 +113,7 @@ vfp_esi_end(struct vfp_ctx *vc, struct vef_priv *vef, CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - vsb = VEP_Finish(vef->vep, vc->bo); + vsb = VEP_Finish(vef->vep); if (vsb != NULL) { if (retval == VFP_END) { @@ -193,7 +193,7 @@ vfp_esi_gzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, vp = VFP_Suck(vc, vef->ibuf_i, &l); if (l > 0) { - VEP_Parse(vef->vep, vc->bo, vef->ibuf_i, l); + VEP_Parse(vef->vep, vef->ibuf_i, l); vef->ibuf_i += l; assert(vef->ibuf_o >= vef->ibuf && vef->ibuf_o <= vef->ibuf_i); if (vef->error) { @@ -248,7 +248,7 @@ vfp_esi_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp) } vp = VFP_Suck(vc, p, lp); if (vp != VFP_ERROR && *lp > 0) - VEP_Parse(vef->vep, vc->bo, p, *lp); + VEP_Parse(vef->vep, p, *lp); if (vp == VFP_END) { vp = vfp_esi_end(vc, vef, vp); vfe->priv1 = NULL; diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index d028c26..1860b8f 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -566,14 +566,12 @@ vep_do_include(struct vep_state *vep, enum dowhat what) */ void -VEP_Parse(struct vep_state *vep, const struct busyobj *bo, const char *p, - size_t l) +VEP_Parse(struct vep_state *vep, const char *p, size_t l) { const char *e; struct vep_match *vm; int i; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vep, VEP_MAGIC); assert(l > 0); @@ -1080,11 +1078,10 @@ VEP_Init(struct vfp_ctx *vc, const struct http *req, vep_callback_t *cb, */ struct vsb * -VEP_Finish(struct vep_state *vep, const struct busyobj *bo) +VEP_Finish(struct vep_state *vep) { ssize_t l, lcb; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vep, VEP_MAGIC); if (vep->o_pending) From phk at FreeBSD.org Tue Aug 19 08:19:45 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 10:19:45 +0200 Subject: [master] f1fafd2 Add the objcore to the vfp_ctx Message-ID: commit f1fafd28239b93ca53350b7b5f3b8f3b89b7a5b5 Author: Poul-Henning Kamp Date: Tue Aug 19 08:10:42 2014 +0000 Add the objcore to the vfp_ctx diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 854cf8b..8fb679f 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -455,6 +455,7 @@ struct vfp_ctx { unsigned magic; #define VFP_CTX_MAGIC 0x61d9d3e5 struct busyobj *bo; + struct objcore *oc; struct dstat *stats; int failed; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index f389304..2ad6a48 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -364,6 +364,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) VFP_Setup(bo->vfc); bo->vfc->bo = bo; + bo->vfc->oc = bo->fetch_objcore; bo->vfc->stats = bo->stats; bo->vfc->http = bo->beresp; bo->vfc->vsl = bo->vsl; @@ -685,6 +686,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) VFP_Setup(bo->vfc); bo->vfc->bo = bo; + bo->vfc->oc = bo->fetch_objcore; bo->vfc->stats = bo->stats; bo->vfc->http = bo->beresp; bo->vfc->vsl = bo->vsl; diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index b9984d7..04fd764 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -297,9 +297,8 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, ssize_t len, void *retval = NULL; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo->fetch_objcore, OBJCORE_MAGIC); - o = obj_getobj(vc->bo->fetch_objcore, vc->stats); + CHECK_OBJ_NOTNULL(vc->oc, OBJCORE_MAGIC); + o = obj_getobj(vc->oc, vc->stats); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); switch (attr) { case OA_ESIDATA: From phk at FreeBSD.org Tue Aug 19 08:19:45 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 10:19:45 +0200 Subject: [master] 75f8f3a More reduction of vfp_ctx->bo usage Message-ID: commit 75f8f3a1c1487565854c5700b4d1416237cc7bec Author: Poul-Henning Kamp Date: Tue Aug 19 08:19:22 2014 +0000 More reduction of vfp_ctx->bo usage diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 8fb679f..4166f40 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -465,6 +465,7 @@ struct vfp_ctx { struct vsl_log *vsl; struct http *http; + struct http *esi_req; struct body *body; uint64_t bodybytes; }; diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index d0f1bc6..a0d10f8 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -110,7 +110,6 @@ vfp_esi_end(struct vfp_ctx *vc, struct vef_priv *vef, void *p; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); vsb = VEP_Finish(vef->vep); @@ -146,13 +145,13 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) struct vef_priv *vef; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc->esi_req, HTTP_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); ALLOC_OBJ(vef, VEF_MAGIC); if (vef == NULL) return (VFP_ERROR); vef->vgz = VGZ_NewGzip(vc->vsl, "G F E"); - vef->vep = VEP_Init(vc, vc->bo->bereq, vfp_vep_callback, vef); + vef->vep = VEP_Init(vc, vc->esi_req, vfp_vep_callback, vef); vef->ibuf_sz = cache_param->gzip_buffer; vef->ibuf = calloc(1L, vef->ibuf_sz); if (vef->ibuf == NULL) @@ -178,7 +177,6 @@ vfp_esi_gzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, struct vef_priv *vef; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(vef, vfe->priv1, VEF_MAGIC); AN(p); @@ -219,11 +217,11 @@ vfp_esi_init(struct vfp_ctx *vc, struct vfp_entry *vfe) struct vef_priv *vef; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc->esi_req, HTTP_MAGIC); ALLOC_OBJ(vef, VEF_MAGIC); if (vef == NULL) return (VFP_ERROR); - vef->vep = VEP_Init(vc, vc->bo->bereq, NULL, NULL); + vef->vep = VEP_Init(vc, vc->esi_req, NULL, NULL); vfe->priv1 = vef; return (VFP_OK); } @@ -236,7 +234,6 @@ vfp_esi_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp) struct vef_priv *vef; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(vef, vfe->priv1, VEF_MAGIC); AN(p); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 2ad6a48..faad2b1 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -367,6 +367,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) bo->vfc->oc = bo->fetch_objcore; bo->vfc->stats = bo->stats; bo->vfc->http = bo->beresp; + bo->vfc->esi_req = bo->bereq; bo->vfc->vsl = bo->vsl; VCL_backend_response_method(bo->vcl, wrk, NULL, bo, bo->beresp->ws); @@ -689,6 +690,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) bo->vfc->oc = bo->fetch_objcore; bo->vfc->stats = bo->stats; bo->vfc->http = bo->beresp; + bo->vfc->esi_req = bo->bereq; bo->vfc->vsl = bo->vsl; if (vbf_beresp2obj(bo)) diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 43d89ef..5c42c83 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -161,7 +161,6 @@ VFP_Suck(struct vfp_ctx *vc, void *p, ssize_t *lp) struct vfp_entry *vfe; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); AN(p); AN(lp); vfe = vc->vfp_nxt; @@ -262,7 +261,7 @@ VFP_Push(struct vfp_ctx *vc, const struct vfp *vfp, int top) struct vfp_entry *vfe; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - vfe = (void*)WS_Alloc(vc->bo->ws, sizeof *vfe); + vfe = (void*)WS_Alloc(vc->http->ws, sizeof *vfe); AN(vfe); vfe->magic = VFP_ENTRY_MAGIC; vfe->vfp = vfp; diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 96406ee..119be81 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -567,7 +567,6 @@ vfp_gzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, enum vfp_status vp = VFP_ERROR; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); AN(p); @@ -622,7 +621,6 @@ vfp_testgunzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, enum vfp_status vp; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); AN(p); diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 39fddd9..bbec41a 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -194,7 +194,6 @@ stv_alloc_obj(const struct vfp_ctx *vc, size_t size) * keep an object inside the same stevedore. */ CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); stv = vc->body->stevedore; CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); From phk at FreeBSD.org Tue Aug 19 09:05:27 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 11:05:27 +0200 Subject: [master] 689256a Isolate length manipulations of objects. Message-ID: commit 689256a2088ea301a16b5910590cfb79f116043a Author: Poul-Henning Kamp Date: Tue Aug 19 09:05:03 2014 +0000 Isolate length manipulations of objects. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 4166f40..2026cd8 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -803,7 +803,7 @@ struct busyobj *VBO_GetBusyObj(struct worker *, const struct req *); void VBO_DerefBusyObj(struct worker *wrk, struct busyobj **busyobj); void VBO_Free(struct busyobj **vbo); void VBO_extend(struct busyobj *, ssize_t); -ssize_t VBO_waitlen(struct busyobj *bo, ssize_t l); +ssize_t VBO_waitlen(struct busyobj *, struct dstat *, ssize_t l); void VBO_setstate(struct busyobj *bo, enum busyobj_state_e next); void VBO_waitstate(struct busyobj *bo, enum busyobj_state_e want); @@ -1061,6 +1061,7 @@ enum objiter_status { struct objiter *ObjIterBegin(struct worker *, struct objcore *); enum objiter_status ObjIter(struct objiter *, void **, ssize_t *); void ObjIterEnd(struct objiter **); +void ObjExtend(struct objcore *, struct dstat *, ssize_t l); void ObjTrimStore(struct objcore *, struct dstat *); unsigned ObjGetXID(struct objcore *, struct dstat *); uint64_t ObjGetLen(struct objcore *oc, struct dstat *ds); diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index abbf03f..a3f4092 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -218,7 +218,6 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) void VBO_extend(struct busyobj *bo, ssize_t l) { - struct storage *st; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo->vfc, VFP_CTX_MAGIC); @@ -226,27 +225,29 @@ VBO_extend(struct busyobj *bo, ssize_t l) return; assert(l > 0); Lck_Lock(&bo->mtx); - st = VTAILQ_LAST(&bo->vfc->body->list, storagehead); - CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - st->len += l; - bo->vfc->body->len += l; + ObjExtend(bo->vfc->oc, bo->stats, l); AZ(pthread_cond_broadcast(&bo->cond)); Lck_Unlock(&bo->mtx); } ssize_t -VBO_waitlen(struct busyobj *bo, ssize_t l) +VBO_waitlen(struct busyobj *bo, struct dstat *ds, ssize_t l) { + ssize_t rv; + + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AN(ds); Lck_Lock(&bo->mtx); + rv = ObjGetLen(bo->fetch_objcore, ds); while (1) { - assert(l <= bo->vfc->body->len || bo->state == BOS_FAILED); - if (bo->vfc->body->len > l || bo->state >= BOS_FINISHED) + assert(l <= rv || bo->state == BOS_FAILED); + if (rv > l || bo->state >= BOS_FINISHED) break; (void)Lck_CondWait(&bo->cond, &bo->mtx, 0); + rv = ObjGetLen(bo->fetch_objcore, ds); } - l = bo->vfc->body->len; Lck_Unlock(&bo->mtx); - return (l); + return (rv); } void diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 202ae12..e4d26b1 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -97,7 +97,7 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r) /* We must snapshot the length if we're streaming from the backend */ if (bo != NULL) - len = VBO_waitlen(bo, -1); + len = VBO_waitlen(bo, &req->wrk->stats, -1); else len = ObjGetLen(req->objcore, &req->wrk->stats); @@ -340,7 +340,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo) l = -1; while (req->objcore->busyobj) { assert(bo != NULL); - l = VBO_waitlen(bo, l); + l = VBO_waitlen(bo, &req->wrk->stats, l); } ESI_DeliverChild(req); } else if (req->res_mode & RES_GUNZIP || diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 04fd764..ed47b1e 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -117,7 +117,7 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l) } else { ol = oi->len; while (1) { - nl = VBO_waitlen(oi->bo, ol); + nl = VBO_waitlen(oi->bo, &oi->wrk->stats, ol); if (nl != ol) break; if (oi->bo->state == BOS_FINISHED) @@ -166,6 +166,29 @@ ObjIterEnd(struct objiter **oi) *oi = NULL; } +/*-------------------------------------------------------------------- + */ + +void +ObjExtend(struct objcore *oc, struct dstat *ds, ssize_t l) +{ + struct object *o; + struct storage *st; + + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + + o = obj_getobj(oc, ds); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + st = VTAILQ_LAST(&o->body->list, storagehead); + CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); + assert(st->len + l <= st->space); + st->len += l; + o->body->len += l; +} + +/*-------------------------------------------------------------------- + */ + void ObjTrimStore(struct objcore *oc, struct dstat *ds) { From phk at FreeBSD.org Tue Aug 19 09:43:47 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 11:43:47 +0200 Subject: [master] 9268784 Push space allocation for objects into cache_obj.c as well. Message-ID: commit 9268784cb4be73b328ac294cf78e0a6d2b0932c9 Author: Poul-Henning Kamp Date: Tue Aug 19 09:43:28 2014 +0000 Push space allocation for objects into cache_obj.c as well. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 2026cd8..b85cde6 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1061,6 +1061,8 @@ enum objiter_status { struct objiter *ObjIterBegin(struct worker *, struct objcore *); enum objiter_status ObjIter(struct objiter *, void **, ssize_t *); void ObjIterEnd(struct objiter **); +struct storage *ObjGetSpace(struct objcore *, struct vsl_log *vsl, + struct dstat *, ssize_t sz); void ObjExtend(struct objcore *, struct dstat *, ssize_t l); void ObjTrimStore(struct objcore *, struct dstat *); unsigned ObjGetXID(struct objcore *, struct dstat *); @@ -1245,7 +1247,7 @@ void RFC2616_Weaken_Etag(struct http *hp); /* stevedore.c */ struct object *STV_NewObject(struct busyobj *, const char *hint, unsigned len); -struct storage *STV_alloc(const struct vfp_ctx *, size_t size); +struct storage *STV_alloc(struct stevedore *, size_t size); void STV_trim(struct storage *st, size_t size, int move_ok); void STV_free(struct storage *st); void STV_open(void); diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 5c42c83..7462105 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -92,15 +92,9 @@ VFP_GetStorage(struct vfp_ctx *vc, ssize_t sz) l = sz; if (l == 0) l = cache_param->fetch_chunksize; - st = STV_alloc(vc, l); - if (st == NULL) { + st = ObjGetSpace(vc->oc, vc->vsl, vc->stats, l); + if (st == NULL) (void)VFP_Error(vc, "Could not get storage"); - } else { - AZ(st->len); - Lck_Lock(&vc->bo->mtx); - VTAILQ_INSERT_TAIL(&vc->body->list, st, list); - Lck_Unlock(&vc->bo->mtx); - } return (st); } diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index ed47b1e..a89a4ab 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -35,7 +35,6 @@ #include "storage/storage.h" #include "hash/hash_slinger.h" - static const struct objcore_methods * obj_getmethods(const struct objcore *oc) { @@ -169,6 +168,73 @@ ObjIterEnd(struct objiter **oi) /*-------------------------------------------------------------------- */ +static struct storage * +objallocwithnuke(struct stevedore *stv, struct vsl_log *vsl, struct dstat *ds, + size_t size) +{ + struct storage *st = NULL; + unsigned fail; + + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); + + if (size > cache_param->fetch_maxchunksize) + size = cache_param->fetch_maxchunksize; + + assert(size <= UINT_MAX); /* field limit in struct storage */ + + for (fail = 0; fail <= cache_param->nuke_limit; fail++) { + /* try to allocate from it */ + AN(stv->alloc); + st = STV_alloc(stv, size); + if (st != NULL) + break; + + /* no luck; try to free some space and keep trying */ + if (fail < cache_param->nuke_limit && + EXP_NukeOne(vsl, ds, stv->lru) == -1) + break; + } + CHECK_OBJ_ORNULL(st, STORAGE_MAGIC); + return (st); +} + +/*-------------------------------------------------------------------- + */ + +struct storage * +ObjGetSpace(struct objcore *oc, struct vsl_log *vsl, struct dstat *ds, + ssize_t sz) +{ + struct object *o; + struct storage *st; + + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + AN(ds); + o = obj_getobj(oc, ds); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + + st = VTAILQ_LAST(&o->body->list, storagehead); + if (st != NULL && st->len < st->space) + return (st); + + st = objallocwithnuke(o->body->stevedore, vsl, ds, sz); + if (st == NULL) + return (st); + + if (oc->busyobj != NULL) { + CHECK_OBJ_NOTNULL(oc->busyobj, BUSYOBJ_MAGIC); + Lck_Lock(&oc->busyobj->mtx); + VTAILQ_INSERT_TAIL(&o->body->list, st, list); + Lck_Unlock(&oc->busyobj->mtx); + } else { + VTAILQ_INSERT_TAIL(&o->body->list, st, list); + } + return (st); +} + +/*-------------------------------------------------------------------- + */ + void ObjExtend(struct objcore *oc, struct dstat *ds, ssize_t l) { @@ -176,7 +242,6 @@ ObjExtend(struct objcore *oc, struct dstat *ds, ssize_t l) struct storage *st; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - o = obj_getobj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); st = VTAILQ_LAST(&o->body->list, storagehead); @@ -325,7 +390,8 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, ssize_t len, CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); switch (attr) { case OA_ESIDATA: - o->esidata = STV_alloc(vc, len); + o->esidata = objallocwithnuke(o->body->stevedore, vc->vsl, + vc->stats, len); if (o->esidata == NULL) return (NULL); o->esidata->len = len; diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index bbec41a..4fd40a4 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -152,8 +152,8 @@ stv_pick_stevedore(struct vsl_log *vsl, const char **hint) /*-------------------------------------------------------------------*/ -static struct storage * -stv_alloc(struct stevedore *stv, size_t size) +struct storage * +STV_alloc(struct stevedore *stv, size_t size) { struct storage *st; @@ -180,45 +180,6 @@ stv_alloc(struct stevedore *stv, size_t size) return (st); } -/*-------------------------------------------------------------------*/ - -static struct storage * -stv_alloc_obj(const struct vfp_ctx *vc, size_t size) -{ - struct storage *st = NULL; - struct stevedore *stv; - unsigned fail; - - /* - * Always use the stevedore which allocated the object in order to - * keep an object inside the same stevedore. - */ - CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - stv = vc->body->stevedore; - CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); - - if (size > cache_param->fetch_maxchunksize) - size = cache_param->fetch_maxchunksize; - - assert(size <= UINT_MAX); /* field limit in struct storage */ - - for (fail = 0; fail <= cache_param->nuke_limit; fail++) { - /* try to allocate from it */ - AN(stv->alloc); - st = stv_alloc(stv, size); - if (st != NULL) - break; - - /* no luck; try to free some space and keep trying */ - if (fail < cache_param->nuke_limit && - EXP_NukeOne(vc->vsl, vc->stats, stv->lru) == -1) - break; - } - CHECK_OBJ_ORNULL(st, STORAGE_MAGIC); - return (st); -} - - /*-------------------------------------------------------------------* * Structure used to transport internal knowledge from STV_NewObject() * to STV_MkObject(). Nobody else should mess with this struct. @@ -367,17 +328,10 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl) /*-------------------------------------------------------------------*/ struct storage * -STV_alloc(const struct vfp_ctx *vc, size_t size) -{ - - return (stv_alloc_obj(vc, size)); -} - -struct storage * STV_alloc_transient(size_t size) { - return (stv_alloc(stv_transient, size)); + return (STV_alloc(stv_transient, size)); } void From fgsch at lodoss.net Tue Aug 19 09:50:12 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 19 Aug 2014 11:50:12 +0200 Subject: [master] 1dc22f0 Pass the right string to syslog() Message-ID: commit 1dc22f0c75f5546272ac0b06f2a44c4b643d07dd Author: Federico G. Schwindt Date: Tue Aug 19 10:42:46 2014 +0100 Pass the right string to syslog() Fixes #1574 diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index c5d0cfe..a74e6a4 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -156,18 +156,18 @@ vmod_log(const struct vrt_ctx *ctx, const char *fmt, ...) VCL_VOID __match_proto__(td_std_syslog) vmod_syslog(const struct vrt_ctx *ctx, VCL_INT fac, const char *fmt, ...) { - char *p; unsigned u; va_list ap; + txt t; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); u = WS_Reserve(ctx->ws, 0); - p = ctx->ws->f; + t.b = ctx->ws->f; va_start(ap, fmt); - p = VRT_StringList(p, u, fmt, ap); + t.e = VRT_StringList(t.b, u, fmt, ap); va_end(ap); - if (p != NULL) - syslog((int)fac, "%s", p); + if (t.e != NULL) + syslog((int)fac, "%s", t.b); WS_Release(ctx->ws, 0); } From phk at FreeBSD.org Tue Aug 19 09:54:13 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 11:54:13 +0200 Subject: [master] 3fdbad0 Eliminate the body from vfp_ctx, we now only manipulate it through the objcore. Message-ID: commit 3fdbad0318fa2684c9c8f049a4f5b6cc4a6ffe75 Author: Poul-Henning Kamp Date: Tue Aug 19 09:53:48 2014 +0000 Eliminate the body from vfp_ctx, we now only manipulate it through the objcore. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b85cde6..66712b8 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -466,7 +466,6 @@ struct vfp_ctx { struct vsl_log *vsl; struct http *http; struct http *esi_req; - struct body *body; uint64_t bodybytes; }; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index faad2b1..1abc7c0 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -161,8 +161,6 @@ vbf_beresp2obj(struct busyobj *bo) AZ(ObjSetDouble(bo->vfc, OA_LASTMODIFIED, floor(bo->fetch_objcore->exp.t_origin))); - bo->vfc->body = obj->body; - return (0); } diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 7462105..b4338a5 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -81,10 +81,6 @@ VFP_GetStorage(struct vfp_ctx *vc, ssize_t sz) CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); - AN(vc->body); - st = VTAILQ_LAST(&vc->body->list, storagehead); - if (st != NULL && st->len < st->space) - return (st); AN(vc->stats); l = fetchfrag; @@ -224,13 +220,10 @@ VFP_Fetch_Body(struct busyobj *bo) } CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - assert(st == VTAILQ_LAST(&bo->vfc->body->list, - storagehead)); l = st->space - st->len; AZ(bo->vfc->failed); vfps = VFP_Suck(bo->vfc, st->ptr + st->len, &l); if (l > 0 && vfps != VFP_ERROR) { - AZ(VTAILQ_EMPTY(&bo->vfc->body->list)); VBO_extend(bo, l); } if (st->len == st->space) From phk at FreeBSD.org Tue Aug 19 10:23:01 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Aug 2014 12:23:01 +0200 Subject: [master] 5d19015 Push the last bit of struct object firmly into stevedore-space. Message-ID: commit 5d19015c9e2364ae79832f3083329ea12fd130a3 Author: Poul-Henning Kamp Date: Tue Aug 19 10:22:36 2014 +0000 Push the last bit of struct object firmly into stevedore-space. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 66712b8..c22bd14 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -950,7 +950,7 @@ void HTTP_Init(void); void http_PutResponse(struct http *to, const char *proto, uint16_t status, const char *response); void http_FilterReq(struct http *to, const struct http *fm, unsigned how); -uint8_t *HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how); +void HTTP_Encode(const struct http *fm, uint8_t *, unsigned len, unsigned how); int HTTP_Decode(struct http *to, uint8_t *fm); void http_ForceHeader(struct http *to, const char *hdr, const char *val); void http_PrintfHeader(struct http *to, const char *fmt, ...) @@ -1172,7 +1172,6 @@ void VSL_Flush(struct vsl_log *, int overflow); /* cache_vary.c */ int VRY_Create(struct busyobj *bo, struct vsb **psb); int VRY_Match(struct req *, const uint8_t *vary); -unsigned VRY_Validate(const uint8_t *vary); void VRY_Prep(struct req *); void VRY_Clear(struct req *); enum vry_finish_flag { KEEP, DISCARD }; @@ -1245,7 +1244,7 @@ void RFC2616_Weaken_Etag(struct http *hp); /* stevedore.c */ -struct object *STV_NewObject(struct busyobj *, const char *hint, unsigned len); +int STV_NewObject(struct busyobj *, const char *hint, unsigned len); struct storage *STV_alloc(struct stevedore *, size_t size); void STV_trim(struct storage *st, size_t size, int move_ok); void STV_free(struct storage *st); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 1abc7c0..a776730 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -46,10 +46,9 @@ * XXX: Should this be merged over there ? */ -static struct object * +static int vbf_allocobj(struct busyobj *bo, unsigned l) { - struct object *obj; struct objcore *oc; const char *storage_hint; double lifetime; @@ -67,13 +66,11 @@ vbf_allocobj(struct busyobj *bo, unsigned l) bo->storage_hint = NULL; - obj = STV_NewObject(bo, storage_hint, l); - - if (obj != NULL) - return (obj); + if (STV_NewObject(bo, storage_hint, l)) + return (1); if (storage_hint != NULL && !strcmp(storage_hint, TRANSIENT_STORAGE)) - return (NULL); + return (0); /* * Try to salvage the transaction by allocating a shortlived object @@ -84,8 +81,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l) oc->exp.ttl = cache_param->shortlived; oc->exp.grace = 0.0; oc->exp.keep = 0.0; - obj = STV_NewObject(bo, TRANSIENT_STORAGE, l); - return (obj); + return (STV_NewObject(bo, TRANSIENT_STORAGE, l)); } /*-------------------------------------------------------------------- @@ -95,11 +91,11 @@ vbf_allocobj(struct busyobj *bo, unsigned l) static int vbf_beresp2obj(struct busyobj *bo) { - unsigned l; + unsigned l, l2; char *b; + uint8_t *bp; struct vsb *vary = NULL; int varyl = 0; - struct object *obj; l = 0; @@ -125,22 +121,18 @@ vbf_beresp2obj(struct busyobj *bo) AZ(vary); } - l += http_EstimateWS(bo->beresp, + l2 = http_EstimateWS(bo->beresp, bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS); + l += l2; if (bo->uncacheable) bo->fetch_objcore->flags |= OC_F_PASS; - obj = vbf_allocobj(bo, l); - - if (obj == NULL) + if (!vbf_allocobj(bo, l)) return (-1); - CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - if (vary != NULL) { b = ObjSetattr(bo->vfc, OA_VARY, varyl, VSB_data(vary)); - (void)VRY_Validate(obj->oa_vary); VSB_delete(vary); } @@ -151,9 +143,10 @@ vbf_beresp2obj(struct busyobj *bo) bo->beresp->logtag = SLT_ObjMethod; /* Filter into object */ - obj->oa_http = HTTP_Encode(bo->beresp, bo->ws_o, + bp = ObjSetattr(bo->vfc, OA_HEADERS, l2, NULL); + AN(bp); + HTTP_Encode(bo->beresp, bp, l2, bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS); - AN(obj->oa_http); if (http_GetHdr(bo->beresp, H_Last_Modified, &b)) AZ(ObjSetDouble(bo->vfc, OA_LASTMODIFIED, VTIM_parse(b))); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 592d042..16c21bb 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -637,20 +637,18 @@ http_EstimateWS(const struct http *fm, unsigned how) * Encode http struct as byte string. */ -uint8_t * -HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how) +void +HTTP_Encode(const struct http *fm, uint8_t *p0, unsigned l, unsigned how) { unsigned u, w; uint16_t n; uint8_t *p, *e; - u = WS_Reserve(ws, 0); - p = (uint8_t*)ws->f; - e = (uint8_t*)ws->f + u; - if (p + 5 > e) { - WS_Release(ws, 0); - return (NULL); - } + AN(p0); + AN(l); + p = p0; + e = p + l; + assert(p + 5 <= e); assert(fm->nhd < fm->shd); n = HTTP_HDR_FIRST - 3; vbe16enc(p + 2, fm->status); @@ -670,20 +668,14 @@ HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how) #undef HTTPH http_VSLH(fm, u); w = Tlen(fm->hd[u]) + 1L; - if (p + w + 1 > e) { - WS_Release(ws, 0); - return (NULL); - } + assert(p + w + 1 <= e); memcpy(p, fm->hd[u].b, w); p += w; n++; } *p++ = '\0'; assert(p <= e); - e = (uint8_t*)ws->f; - vbe16enc(e, n + 1); - WS_ReleaseP(ws, (void*)p); - return (e); + vbe16enc(p0, n + 1); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index a89a4ab..3a3913a 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -405,6 +405,11 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, ssize_t len, assert(len == sizeof o->oa_gzipbits); retval = o->oa_gzipbits; break; + case OA_HEADERS: + o->oa_http = (void*)WS_Alloc(vc->bo->ws_o, len); + AN(o->oa_http); + retval = o->oa_http; + break; case OA_LASTMODIFIED: assert(len == sizeof o->oa_lastmodified); retval = o->oa_lastmodified; diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index e4a7628..7c783af 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -63,6 +63,8 @@ #include "vct.h" #include "vend.h" +static unsigned VRY_Validate(const uint8_t *vary); + /********************************************************************** * Create a Vary matching string from a Vary header * @@ -368,7 +370,7 @@ VRY_Match(struct req *req, const uint8_t *vary) * Check the validity of a Vary string and return its total length */ -unsigned +static unsigned VRY_Validate(const uint8_t *vary) { unsigned retval = 0; diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 4fd40a4..360d7b6 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -275,7 +275,7 @@ stv_default_allocobj(struct stevedore *stv, struct busyobj *bo, * XXX: for the body in the same allocation while we are at it. */ -struct object * +int STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl) { struct object *o; @@ -315,14 +315,14 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl) } if (o == NULL) - return (NULL); + return (0); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(o->objstore, STORAGE_MAGIC); CHECK_OBJ_NOTNULL(o->objcore, OBJCORE_MAGIC); assert(o->objcore->stevedore == stv); AN(stv->methods); - return (o); + return (1); } /*-------------------------------------------------------------------*/ From phk at FreeBSD.org Thu Aug 21 09:50:48 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 21 Aug 2014 11:50:48 +0200 Subject: [master] ede3d4c Add comment based on discussion yesterday Message-ID: commit ede3d4cf584966b20259710a6d36f5b8a189a883 Author: Poul-Henning Kamp Date: Thu Aug 21 08:50:53 2014 +0000 Add comment based on discussion yesterday diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 3a3913a..a41d089 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -24,6 +24,18 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * Primary API: + * ObjNew Associate stevedore with oc + * ObjGetSpace Add space + * ObjExtend Commit space + * ObjDone Object completed + * ObjGetLen Len of committed space + * ObjIter Iterate over committed space + * ObjReserveAttr Attr will be set later + * ObjSetAttr Set attr now + * ObjGetAttr Get attr no + * ObjRelease Done with attr ptr */ #include "config.h" From phk at FreeBSD.org Thu Aug 21 09:50:48 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 21 Aug 2014 11:50:48 +0200 Subject: [master] 4e56f03 Eliminate struct storage from VFP_GetStorage callers Message-ID: commit 4e56f03ff070be41d64f9d07e0f46091621b12a8 Author: Poul-Henning Kamp Date: Thu Aug 21 09:50:32 2014 +0000 Eliminate struct storage from VFP_GetStorage callers diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index c22bd14..1608454 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -908,7 +908,7 @@ void VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, struct objcore *oldoc, enum vbf_fetch_mode_e); /* cache_fetch_proc.c */ -struct storage *VFP_GetStorage(struct vfp_ctx *, ssize_t sz); +enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr); void VFP_Init(void); void VFP_Fetch_Body(struct busyobj *bo); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index a0d10f8..5fa6835 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -59,9 +59,9 @@ static ssize_t vfp_vep_callback(struct vfp_ctx *vc, void *priv, ssize_t l, enum vgz_flag flg) { struct vef_priv *vef; - size_t dl; + ssize_t dl; const void *dp; - struct storage *st; + uint8_t *ptr; int i; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); @@ -84,13 +84,13 @@ vfp_vep_callback(struct vfp_ctx *vc, void *priv, ssize_t l, enum vgz_flag flg) VGZ_Ibuf(vef->vgz, vef->ibuf_o, l); do { - st = VFP_GetStorage(vc, 0); - if (st == NULL) { + dl = 0; + if (VFP_GetStorage(vc, &dl, &ptr) != VFP_OK) { vef->error = ENOMEM; vef->tot += l; return (vef->tot); } - VGZ_Obuf(vef->vgz, st->ptr + st->len, st->space - st->len); + VGZ_Obuf(vef->vgz, ptr, dl); i = VGZ_Gzip(vef->vgz, &dp, &dl, flg); vef->tot += dl; VBO_extend(vc->bo, dl); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index a776730..001cd79 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -555,9 +555,9 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) { struct objiter *oi; void *sp; - ssize_t sl, al, tl; + ssize_t sl, al, l; + uint8_t *ptr; uint64_t ol; - struct storage *st; enum objiter_status ois; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -577,28 +577,22 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) VBO_setstate(bo, BOS_STREAM); } - st = NULL; al = 0; - ol = ObjGetLen(bo->ims_oc, bo->stats); oi = ObjIterBegin(wrk, bo->ims_oc); do { ois = ObjIter(oi, &sp, &sl); while (sl > 0) { - if (st == NULL) - st = VFP_GetStorage(bo->vfc, ol - al); - if (st == NULL) + l = ol - al; + if (VFP_GetStorage(bo->vfc, &l, &ptr) != VFP_OK) break; - tl = sl; - if (tl > st->space - st->len) - tl = st->space - st->len; - memcpy(st->ptr + st->len, sp, tl); - al += tl; - sp = (char *)sp + tl; - sl -= tl; - VBO_extend(bo, tl); - if (st->len == st->space) - st = NULL; + if (sl < l) + l = sl; + memcpy(ptr, sp, l); + VBO_extend(bo, l); + al += l; + sp = (char *)sp + l; + sl -= l; } } while (!bo->vfc->failed && (ois == OIS_DATA || ois == OIS_STREAM)); ObjIterEnd(&oi); @@ -631,9 +625,9 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) static enum fetch_step vbf_stp_error(struct worker *wrk, struct busyobj *bo) { - struct storage *st; - ssize_t l; + ssize_t l, ll, o; double now; + uint8_t *ptr; char time_str[VTIM_FORMAT_SIZE]; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -687,19 +681,16 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) if (vbf_beresp2obj(bo)) return (F_STP_FAIL); - - l = VSB_len(bo->synth_body); - if (l > 0) { - st = VFP_GetStorage(bo->vfc, l); - if (st != NULL) { - if (st->space < l) { - VSLb(bo->vsl, SLT_Error, - "No space for %zd bytes of synth body", l); - } else { - memcpy(st->ptr, VSB_data(bo->synth_body), l); - VBO_extend(bo, l); - } - } + ll = VSB_len(bo->synth_body); + o = 0; + while (ll > 0) { + l = ll; + if (VFP_GetStorage(bo->vfc, &l, &ptr) != VFP_OK) + break; + memcpy(ptr, VSB_data(bo->synth_body) + o, l); + VBO_extend(bo, l); + ll -= l; + o += l; } VSB_delete(bo->synth_body); bo->synth_body = NULL; diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index b4338a5..08c67c6 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -73,25 +73,34 @@ VFP_Error(struct vfp_ctx *vc, const char *fmt, ...) * */ -struct storage * -VFP_GetStorage(struct vfp_ctx *vc, ssize_t sz) +enum vfp_status +VFP_GetStorage(struct vfp_ctx *vc, ssize_t *sz, uint8_t **ptr) { ssize_t l; struct storage *st; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); + AN(sz); + AN(ptr); AN(vc->stats); l = fetchfrag; if (l == 0) - l = sz; + l = *sz; if (l == 0) l = cache_param->fetch_chunksize; st = ObjGetSpace(vc->oc, vc->vsl, vc->stats, l); - if (st == NULL) - (void)VFP_Error(vc, "Could not get storage"); - return (st); + if (st == NULL) { + *sz = 0; + *ptr = NULL; + return (VFP_Error(vc, "Could not get storage")); + } + *sz = st->space - st->len; + assert(*sz > 0); + *ptr = st->ptr + st->len; + AN(*ptr); + return (VFP_OK); } /********************************************************************** @@ -182,8 +191,8 @@ void VFP_Fetch_Body(struct busyobj *bo) { ssize_t l; + uint8_t *ptr; enum vfp_status vfps = VFP_ERROR; - struct storage *st = NULL; ssize_t est; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -209,25 +218,19 @@ VFP_Fetch_Body(struct busyobj *bo) break; } AZ(bo->vfc->failed); - if (st == NULL) { - st = VFP_GetStorage(bo->vfc, est); - est = 0; - } - if (st == NULL) { + l = est; + if (VFP_GetStorage(bo->vfc, &l, &ptr) != VFP_OK) { bo->doclose = SC_RX_BODY; - (void)VFP_Error(bo->vfc, "Out of storage"); break; } - CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - l = st->space - st->len; AZ(bo->vfc->failed); - vfps = VFP_Suck(bo->vfc, st->ptr + st->len, &l); + vfps = VFP_Suck(bo->vfc, ptr, &l); if (l > 0 && vfps != VFP_ERROR) { VBO_extend(bo, l); + if (est > 0) + est -= l; } - if (st->len == st->space) - st = NULL; } while (vfps == VFP_OK); if (vfps == VFP_ERROR) { diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index a41d089..edf16f3 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -26,16 +26,16 @@ * SUCH DAMAGE. * * Primary API: - * ObjNew Associate stevedore with oc - * ObjGetSpace Add space - * ObjExtend Commit space - * ObjDone Object completed - * ObjGetLen Len of committed space - * ObjIter Iterate over committed space - * ObjReserveAttr Attr will be set later - * ObjSetAttr Set attr now - * ObjGetAttr Get attr no - * ObjRelease Done with attr ptr + * ObjNew Associate stevedore with oc + * ObjGetSpace Add space + * ObjExtend Commit space + * ObjDone Object completed + * ObjGetLen Len of committed space + * ObjIter Iterate over committed space + * ObjReserveAttr Attr will be set later + * ObjSetAttr Set attr now + * ObjGetAttr Get attr no + * ObjRelease Done with attr ptr */ #include "config.h" From phk at FreeBSD.org Thu Aug 21 10:04:14 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 21 Aug 2014 12:04:14 +0200 Subject: [master] 8eea87d Be consistent about size_t and ssize_t, the latter is better. Message-ID: commit 8eea87d13377c3b4a75392866aa5e9e850e123b2 Author: Poul-Henning Kamp Date: Thu Aug 21 10:03:58 2014 +0000 Be consistent about size_t and ssize_t, the latter is better. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 1608454..f5fc9e3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -929,8 +929,9 @@ 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); -enum vgzret_e VGZ_Gzip(struct vgz *, const void **, size_t *len, enum vgz_flag); -enum vgzret_e VGZ_Gunzip(struct vgz *, const void **, size_t *len); +enum vgzret_e VGZ_Gzip(struct vgz *, const void **, ssize_t *len, + enum vgz_flag); +enum vgzret_e VGZ_Gunzip(struct vgz *, const void **, ssize_t *len); enum vgzret_e VGZ_Destroy(struct vgz **); void VGZ_UpdateObj(const struct vfp_ctx *, const struct vgz*); vdp_bytes VDP_gunzip; diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index b3551ca..55c8901 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -257,7 +257,7 @@ ESI_Deliver(struct req *req) uint8_t tailbuf[8 + 5]; int isgzip; struct vgz *vgz = NULL; - size_t dl; + ssize_t dl; const void *dp; int i; struct objiter *oi; diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 119be81..5433fa4 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -193,7 +193,7 @@ VGZ_ObufFull(const struct vgz *vg) /*--------------------------------------------------------------------*/ enum vgzret_e -VGZ_Gunzip(struct vgz *vg, const void **pptr, size_t *plen) +VGZ_Gunzip(struct vgz *vg, const void **pptr, ssize_t *plen) { int i; ssize_t l; @@ -226,7 +226,7 @@ VGZ_Gunzip(struct vgz *vg, const void **pptr, size_t *plen) /*--------------------------------------------------------------------*/ enum vgzret_e -VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags) +VGZ_Gzip(struct vgz *vg, const void **pptr, ssize_t *plen, enum vgz_flag flags) { int i; int zflg; @@ -288,7 +288,7 @@ int __match_proto__(vdp_bytes) VDP_gunzip(struct req *req, enum vdp_action act, const void *ptr, ssize_t len) { enum vgzret_e vr; - size_t dl; + ssize_t dl; const void *dp; struct worker *wrk; struct vgz *vg; @@ -336,7 +336,7 @@ VGZ_WrwGunzip(struct req *req, struct vgz *vg, const void *ibuf, ssize_t ibufl) { enum vgzret_e vr; - size_t dl; + ssize_t dl; const void *dp; struct worker *wrk; @@ -509,7 +509,7 @@ vfp_gunzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, struct vgz *vg; enum vgzret_e vr = VGZ_ERROR; const void *dp; - size_t dl; + ssize_t dl; enum vfp_status vp = VFP_OK; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); @@ -563,7 +563,7 @@ vfp_gzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, struct vgz *vg; enum vgzret_e vr = VGZ_ERROR; const void *dp; - size_t dl; + ssize_t dl; enum vfp_status vp = VFP_ERROR; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); @@ -617,7 +617,7 @@ vfp_testgunzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, struct vgz *vg; enum vgzret_e vr = VGZ_ERROR; const void *dp; - size_t dl; + ssize_t dl; enum vfp_status vp; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); From phk at FreeBSD.org Thu Aug 21 11:19:26 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 21 Aug 2014 13:19:26 +0200 Subject: [master] 4d461ea Also get struct storage out of VFP_GetStorage() Message-ID: commit 4d461eae3c6a6fc6fc56ab135481288ab3139722 Author: Poul-Henning Kamp Date: Thu Aug 21 11:19:14 2014 +0000 Also get struct storage out of VFP_GetStorage() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f5fc9e3..27a0e1b 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1061,8 +1061,8 @@ enum objiter_status { struct objiter *ObjIterBegin(struct worker *, struct objcore *); enum objiter_status ObjIter(struct objiter *, void **, ssize_t *); void ObjIterEnd(struct objiter **); -struct storage *ObjGetSpace(struct objcore *, struct vsl_log *vsl, - struct dstat *, ssize_t sz); +int ObjGetSpace(struct objcore *, struct vsl_log *vsl, + struct dstat *, ssize_t *sz, uint8_t **ptr); void ObjExtend(struct objcore *, struct dstat *, ssize_t l); void ObjTrimStore(struct objcore *, struct dstat *); unsigned ObjGetXID(struct objcore *, struct dstat *); diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 08c67c6..0083510 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -77,11 +77,11 @@ enum vfp_status VFP_GetStorage(struct vfp_ctx *vc, ssize_t *sz, uint8_t **ptr) { ssize_t l; - struct storage *st; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); AN(sz); + assert(*sz >= 0); AN(ptr); AN(vc->stats); @@ -90,15 +90,13 @@ VFP_GetStorage(struct vfp_ctx *vc, ssize_t *sz, uint8_t **ptr) l = *sz; if (l == 0) l = cache_param->fetch_chunksize; - st = ObjGetSpace(vc->oc, vc->vsl, vc->stats, l); - if (st == NULL) { + *sz = l; + if (!ObjGetSpace(vc->oc, vc->vsl, vc->stats, sz, ptr)) { *sz = 0; *ptr = NULL; return (VFP_Error(vc, "Could not get storage")); } - *sz = st->space - st->len; assert(*sz > 0); - *ptr = st->ptr + st->len; AN(*ptr); return (VFP_OK); } @@ -219,6 +217,7 @@ VFP_Fetch_Body(struct busyobj *bo) } AZ(bo->vfc->failed); l = est; + assert(l >= 0); if (VFP_GetStorage(bo->vfc, &l, &ptr) != VFP_OK) { bo->doclose = SC_RX_BODY; break; @@ -228,8 +227,10 @@ VFP_Fetch_Body(struct busyobj *bo) vfps = VFP_Suck(bo->vfc, ptr, &l); if (l > 0 && vfps != VFP_ERROR) { VBO_extend(bo, l); - if (est > 0) + if (est >= l) est -= l; + else + est = 0; } } while (vfps == VFP_OK); diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index edf16f3..a1b2296 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -213,25 +213,32 @@ objallocwithnuke(struct stevedore *stv, struct vsl_log *vsl, struct dstat *ds, /*-------------------------------------------------------------------- */ -struct storage * +int ObjGetSpace(struct objcore *oc, struct vsl_log *vsl, struct dstat *ds, - ssize_t sz) + ssize_t *sz, uint8_t **ptr) { struct object *o; struct storage *st; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(ds); + AN(sz); + AN(ptr); + assert(*sz > 0); o = obj_getobj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); st = VTAILQ_LAST(&o->body->list, storagehead); - if (st != NULL && st->len < st->space) - return (st); + if (st != NULL && st->len < st->space) { + *sz = st->space - st->len; + *ptr = st->ptr + st->len; + assert (*sz > 0); + return (1); + } - st = objallocwithnuke(o->body->stevedore, vsl, ds, sz); + st = objallocwithnuke(o->body->stevedore, vsl, ds, *sz); if (st == NULL) - return (st); + return (0); if (oc->busyobj != NULL) { CHECK_OBJ_NOTNULL(oc->busyobj, BUSYOBJ_MAGIC); @@ -241,7 +248,10 @@ ObjGetSpace(struct objcore *oc, struct vsl_log *vsl, struct dstat *ds, } else { VTAILQ_INSERT_TAIL(&o->body->list, st, list); } - return (st); + *sz = st->space - st->len; + assert (*sz > 0); + *ptr = st->ptr + st->len; + return (1); } /*-------------------------------------------------------------------- From phk at FreeBSD.org Thu Aug 21 19:58:20 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 21 Aug 2014 21:58:20 +0200 Subject: [master] aa45a21 Make the persistent stevedore responsible for finding space for the "NEED_FIXUP" flag in the space dedicated for private bits. Message-ID: commit aa45a2144ccb54754ffde9128bba49e79eba5dfe Author: Poul-Henning Kamp Date: Thu Aug 21 19:57:47 2014 +0000 Make the persistent stevedore responsible for finding space for the "NEED_FIXUP" flag in the space dedicated for private bits. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 27a0e1b..4939941 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -400,7 +400,6 @@ struct objcore { uint16_t flags; #define OC_F_BUSY (1<<1) #define OC_F_PASS (1<<2) -#define OC_F_PRIV (1<<5) /* Stevedore private flag */ #define OC_F_PRIVATE (1<<8) #define OC_F_FAILED (1<<9) diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h index 68f969d..b35bd92 100644 --- a/bin/varnishd/storage/storage_persistent.h +++ b/bin/varnishd/storage/storage_persistent.h @@ -153,8 +153,6 @@ struct smp_object { #define ASSERT_SILO_THREAD(sc) \ do {assert(pthread_equal(pthread_self(), (sc)->thread));} while (0) -#define OC_F_NEEDFIXUP OC_F_PRIV - /* * Context for a signature. * diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 472453f..40b3dc3 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -47,6 +47,13 @@ #include "storage/storage_persistent.h" +/* + * We use the low bit to mark objects still needing fixup + * In theory this may need to be platform dependent + */ + +#define NEED_FIXUP (1U << 31) + /*-------------------------------------------------------------------- * Write the segmentlist back to the silo. * @@ -152,10 +159,10 @@ smp_load_seg(struct worker *wrk, const struct smp_sc *sc, continue; ALLOC_OBJ(oc, OBJCORE_MAGIC); AN(oc); - oc->flags |= OC_F_NEEDFIXUP; oc->flags &= ~OC_F_BUSY; oc->stevedore = sc->parent; smp_init_oc(oc, sg, no); + oc->priv2 |= NEED_FIXUP; oc->ban = BAN_RefBan(oc, so->ban, sc->tailban); HSH_Insert(wrk, so->hash, oc); oc->exp = so->exp; @@ -321,6 +328,7 @@ smp_find_so(const struct smp_seg *sg, unsigned priv2) { struct smp_object *so; + priv2 &= ~NEED_FIXUP; assert(priv2 > 0); assert(priv2 <= sg->p.lobjlist); so = &sg->objs[sg->p.lobjlist - priv2]; @@ -394,7 +402,7 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc) CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); if (ds == NULL) - AZ(oc->flags & OC_F_NEEDFIXUP); + AZ(oc->priv2 & NEED_FIXUP); CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC); so = smp_find_so(sg, oc->priv2); @@ -413,13 +421,13 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc) * If this flag is not set, it will not be, and the lock is not * needed to test it. */ - if (!(oc->flags & OC_F_NEEDFIXUP)) + if (!(oc->priv2 & NEED_FIXUP)) return (o); AN(ds); Lck_Lock(&sg->sc->mtx); /* Check again, we might have raced. */ - if (oc->flags & OC_F_NEEDFIXUP) { + if (oc->priv2 & NEED_FIXUP) { /* We trust caller to have a refcnt for us */ o->objcore = oc; @@ -442,7 +450,7 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc) sg->nfixed++; ds->n_object++; ds->n_vampireobject--; - oc->flags &= ~OC_F_NEEDFIXUP; + oc->priv2 &= ~NEED_FIXUP; } Lck_Unlock(&sg->sc->mtx); EXP_Rearm(oc, NAN, NAN, NAN, NAN); // XXX: Shouldn't be needed @@ -494,7 +502,7 @@ smp_oc_freeobj(struct dstat *ds, struct objcore *oc) assert(sg->nobj > 0); sg->nobj--; - if (oc->flags & OC_F_NEEDFIXUP) { + if (oc->priv2 & NEED_FIXUP) { ds->n_vampireobject--; } else { assert(sg->nfixed > 0); @@ -531,6 +539,7 @@ void smp_init_oc(struct objcore *oc, struct smp_seg *sg, unsigned objidx) { + AZ(objidx & NEED_FIXUP); oc->priv = sg; oc->priv2 = objidx; } From phk at FreeBSD.org Thu Aug 21 20:08:38 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 21 Aug 2014 22:08:38 +0200 Subject: [master] 667e023 Encapsulate the "storage object" identifier which stevedores get to play with. Message-ID: commit 667e02387aafee489226053bf28eb77f2002a495 Author: Poul-Henning Kamp Date: Thu Aug 21 20:08:05 2014 +0000 Encapsulate the "storage object" identifier which stevedores get to play with. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 4939941..474a04f 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -364,33 +364,43 @@ struct storage { unsigned space; }; -/* Object core structure --------------------------------------------- - * Objects have sideways references in the binary heap and the LRU list - * and we want to avoid paging in a lot of objects just to move them up - * or down the binheap or to move a unrelated object on the LRU list. - * To avoid this we use a proxy object, objcore, to hold the relevant - * housekeeping fields parts of an object. +/* Stored object ----------------------------------------------------- + * Pointer to a stored object, and the methods it supports */ +struct storeobj { + unsigned magic; +#define STOREOBJ_MAGIC 0x6faed850 + const struct stevedore *stevedore; + void *priv; + uintptr_t priv2; +}; + typedef struct object *getobj_f(struct dstat *ds, struct objcore *oc); typedef void updatemeta_f(struct objcore *oc, struct dstat *); typedef void freeobj_f(struct dstat *ds, struct objcore *oc); typedef struct lru *getlru_f(const struct objcore *oc); -struct objcore_methods { +struct storeobj_methods { getobj_f *getobj; updatemeta_f *updatemeta; freeobj_f *freeobj; getlru_f *getlru; }; +/* Object core structure --------------------------------------------- + * Objects have sideways references in the binary heap and the LRU list + * and we want to avoid paging in a lot of objects just to move them up + * or down the binheap or to move a unrelated object on the LRU list. + * To avoid this we use a proxy object, objcore, to hold the relevant + * housekeeping fields parts of an object. + */ + struct objcore { unsigned magic; #define OBJCORE_MAGIC 0x4d301302 int refcnt; - const struct stevedore *stevedore; - void *priv; - uintptr_t priv2; + struct storeobj stobj[1]; struct objhead *objhead; struct busyobj *busyobj; double timer_when; diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 4e3fc67..753a646 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -627,7 +627,7 @@ HSH_Fail(struct objcore *oc) * will not consider this oc, or an object hung of the oc * so that it can consider it. */ - assert((oc->flags & OC_F_BUSY) || (oc->stevedore != NULL)); + assert((oc->flags & OC_F_BUSY) || (oc->stobj->stevedore != NULL)); Lck_Lock(&oh->mtx); oc->flags |= OC_F_FAILED; @@ -666,7 +666,7 @@ HSH_Unbusy(struct dstat *ds, struct objcore *oc) oh = oc->objhead; CHECK_OBJ(oh, OBJHEAD_MAGIC); - AN(oc->stevedore); + AN(oc->stobj->stevedore); AN(oc->flags & OC_F_BUSY); assert(oh->refcnt > 0); @@ -768,7 +768,7 @@ HSH_DerefObjCore(struct dstat *ds, struct objcore **ocp) BAN_DestroyObj(oc); AZ(oc->ban); - if (oc->stevedore != NULL) + if (oc->stobj->stevedore != NULL) ObjFreeObj(oc, ds); FREE_OBJ(oc); diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index a1b2296..ee3cf14 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -47,20 +47,20 @@ #include "storage/storage.h" #include "hash/hash_slinger.h" -static const struct objcore_methods * +static const struct storeobj_methods * obj_getmethods(const struct objcore *oc) { CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - CHECK_OBJ_NOTNULL(oc->stevedore, STEVEDORE_MAGIC); - AN(oc->stevedore->methods); - return (oc->stevedore->methods); + CHECK_OBJ_NOTNULL(oc->stobj->stevedore, STEVEDORE_MAGIC); + AN(oc->stobj->stevedore->methods); + return (oc->stobj->stevedore->methods); } static struct object * obj_getobj(struct objcore *oc, struct dstat *ds) { - const struct objcore_methods *m = obj_getmethods(oc); + const struct storeobj_methods *m = obj_getmethods(oc); AN(ds); AN(m->getobj); @@ -285,7 +285,7 @@ ObjTrimStore(struct objcore *oc, struct dstat *ds) CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(ds); - stv = oc->stevedore; + stv = oc->stobj->stevedore; CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); o = obj_getobj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); @@ -329,7 +329,7 @@ ObjSlim(struct objcore *oc, struct dstat *ds) void ObjUpdateMeta(struct objcore *oc, struct dstat *ds) { - const struct objcore_methods *m = obj_getmethods(oc); + const struct storeobj_methods *m = obj_getmethods(oc); if (m->updatemeta != NULL) m->updatemeta(oc, ds); @@ -338,7 +338,7 @@ ObjUpdateMeta(struct objcore *oc, struct dstat *ds) void ObjFreeObj(struct objcore *oc, struct dstat *ds) { - const struct objcore_methods *m = obj_getmethods(oc); + const struct storeobj_methods *m = obj_getmethods(oc); AN(ds); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); @@ -349,7 +349,7 @@ ObjFreeObj(struct objcore *oc, struct dstat *ds) struct lru * ObjGetLRU(const struct objcore *oc) { - const struct objcore_methods *m = obj_getmethods(oc); + const struct storeobj_methods *m = obj_getmethods(oc); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(m->getlru); diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 4a1c880..9d0330f 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -240,11 +240,11 @@ pan_objcore(const char *typ, const struct objcore *oc) VSB_printf(pan_vsp, " refcnt = %d\n", oc->refcnt); VSB_printf(pan_vsp, " flags = 0x%x\n", oc->flags); VSB_printf(pan_vsp, " objhead = %p\n", oc->objhead); - VSB_printf(pan_vsp, " stevedore = %p", oc->stevedore); - if (oc->stevedore != NULL) { - VSB_printf(pan_vsp, " (%s", oc->stevedore->name); - if (strlen(oc->stevedore->ident)) - VSB_printf(pan_vsp, " %s", oc->stevedore->ident); + VSB_printf(pan_vsp, " stevedore = %p", oc->stobj->stevedore); + if (oc->stobj->stevedore != NULL) { + VSB_printf(pan_vsp, " (%s", oc->stobj->stevedore->name); + if (strlen(oc->stobj->stevedore->ident)) + VSB_printf(pan_vsp, " %s", oc->stobj->stevedore->ident); VSB_printf(pan_vsp, ")"); } VSB_printf(pan_vsp, "\n"); diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 360d7b6..8c5981c 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -54,9 +54,9 @@ default_oc_getobj(struct dstat *ds, struct objcore *oc) struct object *o; (void)ds; - if (oc->priv == NULL) + if (oc->stobj->priv == NULL) return (NULL); - CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC); + CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC); return (o); } @@ -68,9 +68,9 @@ default_oc_freeobj(struct dstat *ds, struct objcore *oc) CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(ds); ObjSlim(oc, ds); - CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC); - oc->priv = NULL; - oc->stevedore = NULL; + CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC); + oc->stobj->priv = NULL; + oc->stobj->stevedore = NULL; o->magic = 0; STV_free(o->objstore); @@ -83,11 +83,11 @@ default_oc_getlru(const struct objcore *oc) { struct stevedore *stv; - CAST_OBJ_NOTNULL(stv, (void *)oc->priv2, STEVEDORE_MAGIC); + CAST_OBJ_NOTNULL(stv, (void *)oc->stobj->priv2, STEVEDORE_MAGIC); return (stv->lru); } -const struct objcore_methods default_oc_methods = { +const struct storeobj_methods default_oc_methods = { .getobj = default_oc_getobj, .freeobj = default_oc_freeobj, .getlru = default_oc_getlru, @@ -231,11 +231,11 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo, o->objcore = bo->fetch_objcore; - o->objcore->stevedore = stv; + o->objcore->stobj->stevedore = stv; o->body->stevedore = stv; AN(stv->methods); - o->objcore->priv = o; - o->objcore->priv2 = (uintptr_t)stv; + o->objcore->stobj->priv = o; + o->objcore->stobj->priv2 = (uintptr_t)stv; VSLb(bo->vsl, SLT_Storage, "%s %s", stv->name, stv->ident); return (o); } @@ -320,7 +320,7 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl) CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(o->objstore, STORAGE_MAGIC); CHECK_OBJ_NOTNULL(o->objcore, OBJCORE_MAGIC); - assert(o->objcore->stevedore == stv); + assert(o->objcore->stobj->stevedore == stv); AN(stv->methods); return (1); } diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index 29531b0..1f83998 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -60,7 +60,7 @@ typedef void storage_banexport_f(const struct stevedore *, const uint8_t *bans, extern storage_allocobj_f stv_default_allocobj; -extern const struct objcore_methods default_oc_methods; +extern const struct storeobj_methods default_oc_methods; /*--------------------------------------------------------------------*/ @@ -80,7 +80,7 @@ struct stevedore { storage_baninfo_f *baninfo; /* --//-- */ storage_banexport_f *banexport; /* --//-- */ - const struct objcore_methods + const struct storeobj_methods *methods; struct lru *lru; diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index acc8f84..4ae0d2d 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -535,8 +535,8 @@ smp_allocobj(struct stevedore *stv, struct busyobj *bo, ltot = st->len = st->space; o = STV_MkObject(stv, bo, st->ptr, ltot, soc); - AN(bo->fetch_objcore->stevedore); - assert(bo->fetch_objcore->stevedore == stv); + AN(bo->fetch_objcore->stobj->stevedore); + assert(bo->fetch_objcore->stobj->stevedore == stv); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); o->objstore = st; bo->stats->n_object++; diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h index b35bd92..8dac5e2 100644 --- a/bin/varnishd/storage/storage_persistent.h +++ b/bin/varnishd/storage/storage_persistent.h @@ -309,7 +309,7 @@ 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); void smp_save_segs(struct smp_sc *sc); -extern const struct objcore_methods smp_oc_methods; +extern const struct storeobj_methods smp_oc_methods; /* storage_persistent_subr.c */ diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 40b3dc3..4553185 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -160,9 +160,9 @@ smp_load_seg(struct worker *wrk, const struct smp_sc *sc, ALLOC_OBJ(oc, OBJCORE_MAGIC); AN(oc); oc->flags &= ~OC_F_BUSY; - oc->stevedore = sc->parent; + oc->stobj->stevedore = sc->parent; smp_init_oc(oc, sg, no); - oc->priv2 |= NEED_FIXUP; + oc->stobj->priv2 |= NEED_FIXUP; oc->ban = BAN_RefBan(oc, so->ban, sc->tailban); HSH_Insert(wrk, so->hash, oc); oc->exp = so->exp; @@ -398,14 +398,14 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc) int bad; /* Some calls are direct, but they should match anyway */ - assert(oc->stevedore->methods->getobj == smp_oc_getobj); + assert(oc->stobj->stevedore->methods->getobj == smp_oc_getobj); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); if (ds == NULL) - AZ(oc->priv2 & NEED_FIXUP); + AZ(oc->stobj->priv2 & NEED_FIXUP); - CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC); - so = smp_find_so(sg, oc->priv2); + CAST_OBJ_NOTNULL(sg, oc->stobj->priv, SMP_SEG_MAGIC); + so = smp_find_so(sg, oc->stobj->priv2); o = (void*)(sg->sc->base + so->ptr); /* @@ -421,13 +421,13 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc) * If this flag is not set, it will not be, and the lock is not * needed to test it. */ - if (!(oc->priv2 & NEED_FIXUP)) + if (!(oc->stobj->priv2 & NEED_FIXUP)) return (o); AN(ds); Lck_Lock(&sg->sc->mtx); /* Check again, we might have raced. */ - if (oc->priv2 & NEED_FIXUP) { + if (oc->stobj->priv2 & NEED_FIXUP) { /* We trust caller to have a refcnt for us */ o->objcore = oc; @@ -450,7 +450,7 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc) sg->nfixed++; ds->n_object++; ds->n_vampireobject--; - oc->priv2 &= ~NEED_FIXUP; + oc->stobj->priv2 &= ~NEED_FIXUP; } Lck_Unlock(&sg->sc->mtx); EXP_Rearm(oc, NAN, NAN, NAN, NAN); // XXX: Shouldn't be needed @@ -468,9 +468,9 @@ smp_oc_updatemeta(struct objcore *oc, struct dstat *ds) o = smp_oc_getobj(ds, oc); AN(o); - CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC); + CAST_OBJ_NOTNULL(sg, oc->stobj->priv, SMP_SEG_MAGIC); CHECK_OBJ_NOTNULL(sg->sc, SMP_SC_MAGIC); - so = smp_find_so(sg, oc->priv2); + so = smp_find_so(sg, oc->stobj->priv2); if (sg == sg->sc->cur_seg) { /* Lock necessary, we might race close_seg */ @@ -493,8 +493,8 @@ smp_oc_freeobj(struct dstat *ds, struct objcore *oc) AN(ds); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC); - so = smp_find_so(sg, oc->priv2); + CAST_OBJ_NOTNULL(sg, oc->stobj->priv, SMP_SEG_MAGIC); + so = smp_find_so(sg, oc->stobj->priv2); Lck_Lock(&sg->sc->mtx); EXP_Clr(&so->exp); @@ -502,7 +502,7 @@ smp_oc_freeobj(struct dstat *ds, struct objcore *oc) assert(sg->nobj > 0); sg->nobj--; - if (oc->priv2 & NEED_FIXUP) { + if (oc->stobj->priv2 & NEED_FIXUP) { ds->n_vampireobject--; } else { assert(sg->nfixed > 0); @@ -522,11 +522,11 @@ smp_oc_getlru(const struct objcore *oc) { struct smp_seg *sg; - CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC); + CAST_OBJ_NOTNULL(sg, oc->stobj->priv, SMP_SEG_MAGIC); return (sg->lru); } -const struct objcore_methods smp_oc_methods = { +const struct storeobj_methods smp_oc_methods = { .getobj = smp_oc_getobj, .updatemeta = smp_oc_updatemeta, .freeobj = smp_oc_freeobj, @@ -540,6 +540,6 @@ smp_init_oc(struct objcore *oc, struct smp_seg *sg, unsigned objidx) { AZ(objidx & NEED_FIXUP); - oc->priv = sg; - oc->priv2 = objidx; + oc->stobj->priv = sg; + oc->stobj->priv2 = objidx; } From phk at FreeBSD.org Thu Aug 21 20:36:17 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 21 Aug 2014 22:36:17 +0200 Subject: [master] 16e0798 Remove the object -> objcore link Message-ID: commit 16e07984abbeac8fa5a014175efd164e8e90d1a8 Author: Poul-Henning Kamp Date: Thu Aug 21 20:36:00 2014 +0000 Remove the object -> objcore link diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 474a04f..9de6cfc 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -570,27 +570,18 @@ enum obj_flags { struct object { unsigned magic; #define OBJECT_MAGIC 0x32851d42 - char oa_vxid[4]; struct storage *objstore; - struct objcore *objcore; + char oa_vxid[4]; uint8_t *oa_vary; - uint8_t *oa_http; - - uint8_t oa_flags[1]; - - /* Bit positions in the gzip stream */ char oa_gzipbits[24]; - - /* VCL only variables */ char oa_lastmodified[8]; struct body body[1]; struct storage *esidata; - }; /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index ee3cf14..e05be30 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -74,6 +74,7 @@ struct objiter { unsigned magic; #define OBJITER_MAGIC 0x745fb151 struct busyobj *bo; + struct objcore *oc; struct object *obj; struct storage *st; struct worker *wrk; @@ -92,9 +93,10 @@ ObjIterBegin(struct worker *wrk, struct objcore *oc) ALLOC_OBJ(oi, OBJITER_MAGIC); if (oi == NULL) return (oi); + oi->oc = oc; oi->obj = obj; oi->wrk = wrk; - oi->bo = HSH_RefBusy(obj->objcore); + oi->bo = HSH_RefBusy(oc); return (oi); } @@ -169,7 +171,7 @@ ObjIterEnd(struct objiter **oi) CHECK_OBJ_NOTNULL((*oi), OBJITER_MAGIC); CHECK_OBJ_NOTNULL((*oi)->obj, OBJECT_MAGIC); if ((*oi)->bo != NULL) { - if ((*oi)->obj->objcore->flags & OC_F_PASS) + if ((*oi)->oc->flags & OC_F_PASS) (*oi)->bo->abandon = 1; VBO_DerefBusyObj((*oi)->wrk, &(*oi)->bo); } diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 8c5981c..fbdcda1 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -229,13 +229,12 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo, VTAILQ_INIT(&o->body->list); - o->objcore = bo->fetch_objcore; - - o->objcore->stobj->stevedore = stv; + bo->fetch_objcore->stobj->magic = STOREOBJ_MAGIC; + bo->fetch_objcore->stobj->stevedore = stv; o->body->stevedore = stv; AN(stv->methods); - o->objcore->stobj->priv = o; - o->objcore->stobj->priv2 = (uintptr_t)stv; + bo->fetch_objcore->stobj->priv = o; + bo->fetch_objcore->stobj->priv2 = (uintptr_t)stv; VSLb(bo->vsl, SLT_Storage, "%s %s", stv->name, stv->ident); return (o); } @@ -319,8 +318,6 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl) CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(o->objstore, STORAGE_MAGIC); - CHECK_OBJ_NOTNULL(o->objcore, OBJCORE_MAGIC); - assert(o->objcore->stobj->stevedore == stv); AN(stv->methods); return (1); } diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 4ae0d2d..281561b 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -541,7 +541,7 @@ smp_allocobj(struct stevedore *stv, struct busyobj *bo, o->objstore = st; bo->stats->n_object++; - oc = o->objcore; + oc = bo->fetch_objcore; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); Lck_Lock(&sc->mtx); diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 4553185..440446a 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -429,7 +429,6 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc) /* Check again, we might have raced. */ if (oc->stobj->priv2 & NEED_FIXUP) { /* We trust caller to have a refcnt for us */ - o->objcore = oc; bad = 0; l = 0; From phk at FreeBSD.org Mon Aug 25 08:20:40 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Aug 2014 10:20:40 +0200 Subject: [master] ca6a58d Don't discard the initial bit of the VSL Message-ID: commit ca6a58d22b292917177b46615afebfb0f224cff4 Author: Poul-Henning Kamp Date: Mon Aug 25 08:19:50 2014 +0000 Don't discard the initial bit of the VSL diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 469effd..00c96c6 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -184,7 +184,7 @@ varnishlog_thread(void *priv) uint32_t vxid; unsigned len; const char *tagname, *data; - int type, i; + int type, i, opt; CAST_OBJ_NOTNULL(v, priv, VARNISH_MAGIC); @@ -195,6 +195,7 @@ varnishlog_thread(void *priv) (void)VSM_n_Arg(vsm, v->workdir); c = NULL; + opt = 0; while (v->pid) { if (c == NULL) { VTIM_sleep(0.1); @@ -202,7 +203,7 @@ varnishlog_thread(void *priv) VSM_ResetError(vsm); continue; } - c = VSL_CursorVSM(vsl, vsm, 1); + c = VSL_CursorVSM(vsl, vsm, opt); if (c == NULL) { VSL_ResetError(vsl); continue; @@ -210,6 +211,8 @@ varnishlog_thread(void *priv) } AN(c); + opt = VSL_COPT_TAIL; + i = VSL_Next(c); if (i == 0) { /* Nothing to do but wait */ From phk at FreeBSD.org Mon Aug 25 08:20:40 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Aug 2014 10:20:40 +0200 Subject: [master] 36123ef Do a stat(2) check of inode/dev to detect changed vmod files. Message-ID: commit 36123ef1db0a007fb4dfe5edb485e427a7030da5 Author: Poul-Henning Kamp Date: Mon Aug 25 08:20:05 2014 +0000 Do a stat(2) check of inode/dev to detect changed vmod files. diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index a2dc7c0..b5b76fe 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -31,10 +31,14 @@ #include "config.h" +#include #include #include #include +#include +#include + #include "cache.h" #include "vcli_priv.h" @@ -54,6 +58,8 @@ struct vmod { char *nm; char *path; + intmax_t st_dev; + intmax_t st_ino; void *hdl; const void *funcs; int funclen; @@ -69,28 +75,41 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, const struct vmod_data *d; char buf[256]; void *dlhdl; + int fd; + struct stat st; ASSERT_CLI(); - dlhdl = dlopen(path, RTLD_NOW | RTLD_LOCAL); - if (dlhdl == NULL) { + fd = open(path, O_RDONLY, 0); + if (fd < 0) { VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path); - VCLI_Out(cli, "dlopen() failed: %s\n", dlerror()); + VCLI_Out(cli, "open() failed: %s\n", strerror(errno)); VCLI_Out(cli, "Check child process permissions.\n"); return (1); } + AZ(fstat(fd, &st)); VTAILQ_FOREACH(v, &vmods, list) - if (v->hdl == dlhdl) + if (st.st_dev == v->st_dev && st.st_ino == v->st_ino) break; - if (v == NULL) { - ALLOC_OBJ(v, VMOD_MAGIC); - AN(v); - v->hdl = dlhdl; + if (v != NULL) { + AZ(close(fd)); + } else { + dlhdl = fdlopen(fd, RTLD_NOW | RTLD_LOCAL); + + AZ(close(fd)); + + if (dlhdl == NULL) { + VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path); + VCLI_Out(cli, "fdlopen() failed: %s\n", dlerror()); + VCLI_Out(cli, "Check child process permissions.\n"); + return (1); + } bprintf(buf, "Vmod_%s_Data", nm); - d = dlsym(v->hdl, buf); + + d = dlsym(dlhdl, buf); if (d == NULL || d->file_id == NULL || strcmp(d->file_id, file_id)) { @@ -98,10 +117,10 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, VCLI_Out(cli, "This is no longer the same file seen by" " the VCL-compiler.\n"); - (void)dlclose(v->hdl); - FREE_OBJ(v); + (void)dlclose(dlhdl); return (1); } + if (d->vrt_major != VRT_MAJOR_VERSION || d->vrt_minor > VRT_MINOR_VERSION || d->name == NULL || @@ -113,11 +132,17 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, d->abi == NULL) { VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path); VCLI_Out(cli, "VMOD data is mangled.\n"); - (void)dlclose(v->hdl); - FREE_OBJ(v); + (void)dlclose(dlhdl); return (1); } + ALLOC_OBJ(v, VMOD_MAGIC); + AN(v); + + v->st_dev = st.st_dev; + v->st_ino = st.st_ino; + v->hdl = dlhdl; + v->funclen = d->func_len; v->funcs = d->func; @@ -143,10 +168,14 @@ VRT_Vmod_Fini(void **hdl) ASSERT_CLI(); + AN(*hdl); CAST_OBJ_NOTNULL(v, *hdl, VMOD_MAGIC); *hdl = NULL; + if (--v->ref != 0) + return; + #ifndef DONT_DLCLOSE_VMODS /* * atexit(3) handlers are not called during dlclose(3). We don't @@ -155,8 +184,6 @@ VRT_Vmod_Fini(void **hdl) */ AZ(dlclose(v->hdl)); #endif - if (--v->ref != 0) - return; free(v->nm); free(v->path); VTAILQ_REMOVE(&vmods, v, list); From phk at FreeBSD.org Mon Aug 25 08:39:10 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Aug 2014 10:39:10 +0200 Subject: [master] caa3769 Also insist that the vmod name matches before reusing, to cater for hardlinks. Message-ID: commit caa376943e315def7cee814008f01a0796d8e1d9 Author: Poul-Henning Kamp Date: Mon Aug 25 08:38:45 2014 +0000 Also insist that the vmod name matches before reusing, to cater for hardlinks. diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index b5b76fe..32652ab 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -90,7 +90,9 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, AZ(fstat(fd, &st)); VTAILQ_FOREACH(v, &vmods, list) - if (st.st_dev == v->st_dev && st.st_ino == v->st_ino) + if (st.st_dev == v->st_dev && + st.st_ino == v->st_ino && + !strcmp(v->nm, nm)) break; if (v != NULL) { From phk at FreeBSD.org Mon Aug 25 09:52:44 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Aug 2014 11:52:44 +0200 Subject: [master] 777bf9d Revert "Also insist that the vmod name matches before reusing, to cater for hardlinks." Message-ID: commit 777bf9d31a3ed07f4dce57ce6d6ea07654f119e0 Author: Poul-Henning Kamp Date: Mon Aug 25 09:52:27 2014 +0000 Revert "Also insist that the vmod name matches before reusing, to cater for hardlinks." This reverts commit caa376943e315def7cee814008f01a0796d8e1d9. diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index 32652ab..b5b76fe 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -90,9 +90,7 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, AZ(fstat(fd, &st)); VTAILQ_FOREACH(v, &vmods, list) - if (st.st_dev == v->st_dev && - st.st_ino == v->st_ino && - !strcmp(v->nm, nm)) + if (st.st_dev == v->st_dev && st.st_ino == v->st_ino) break; if (v != NULL) { From phk at FreeBSD.org Mon Aug 25 09:52:44 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Aug 2014 11:52:44 +0200 Subject: [master] d48d032 Revert "Do a stat(2) check of inode/dev to detect changed vmod files." Message-ID: commit d48d03224d9c8e6429e3bb98a25d94615db4b033 Author: Poul-Henning Kamp Date: Mon Aug 25 09:52:39 2014 +0000 Revert "Do a stat(2) check of inode/dev to detect changed vmod files." This reverts commit 36123ef1db0a007fb4dfe5edb485e427a7030da5. diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index b5b76fe..a2dc7c0 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -31,14 +31,10 @@ #include "config.h" -#include #include #include #include -#include -#include - #include "cache.h" #include "vcli_priv.h" @@ -58,8 +54,6 @@ struct vmod { char *nm; char *path; - intmax_t st_dev; - intmax_t st_ino; void *hdl; const void *funcs; int funclen; @@ -75,41 +69,28 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, const struct vmod_data *d; char buf[256]; void *dlhdl; - int fd; - struct stat st; ASSERT_CLI(); - fd = open(path, O_RDONLY, 0); - if (fd < 0) { + dlhdl = dlopen(path, RTLD_NOW | RTLD_LOCAL); + if (dlhdl == NULL) { VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path); - VCLI_Out(cli, "open() failed: %s\n", strerror(errno)); + VCLI_Out(cli, "dlopen() failed: %s\n", dlerror()); VCLI_Out(cli, "Check child process permissions.\n"); return (1); } - AZ(fstat(fd, &st)); VTAILQ_FOREACH(v, &vmods, list) - if (st.st_dev == v->st_dev && st.st_ino == v->st_ino) + if (v->hdl == dlhdl) break; + if (v == NULL) { + ALLOC_OBJ(v, VMOD_MAGIC); + AN(v); - if (v != NULL) { - AZ(close(fd)); - } else { - dlhdl = fdlopen(fd, RTLD_NOW | RTLD_LOCAL); - - AZ(close(fd)); - - if (dlhdl == NULL) { - VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path); - VCLI_Out(cli, "fdlopen() failed: %s\n", dlerror()); - VCLI_Out(cli, "Check child process permissions.\n"); - return (1); - } + v->hdl = dlhdl; bprintf(buf, "Vmod_%s_Data", nm); - - d = dlsym(dlhdl, buf); + d = dlsym(v->hdl, buf); if (d == NULL || d->file_id == NULL || strcmp(d->file_id, file_id)) { @@ -117,10 +98,10 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, VCLI_Out(cli, "This is no longer the same file seen by" " the VCL-compiler.\n"); - (void)dlclose(dlhdl); + (void)dlclose(v->hdl); + FREE_OBJ(v); return (1); } - if (d->vrt_major != VRT_MAJOR_VERSION || d->vrt_minor > VRT_MINOR_VERSION || d->name == NULL || @@ -132,17 +113,11 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, d->abi == NULL) { VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path); VCLI_Out(cli, "VMOD data is mangled.\n"); - (void)dlclose(dlhdl); + (void)dlclose(v->hdl); + FREE_OBJ(v); return (1); } - ALLOC_OBJ(v, VMOD_MAGIC); - AN(v); - - v->st_dev = st.st_dev; - v->st_ino = st.st_ino; - v->hdl = dlhdl; - v->funclen = d->func_len; v->funcs = d->func; @@ -168,14 +143,10 @@ VRT_Vmod_Fini(void **hdl) ASSERT_CLI(); - AN(*hdl); CAST_OBJ_NOTNULL(v, *hdl, VMOD_MAGIC); *hdl = NULL; - if (--v->ref != 0) - return; - #ifndef DONT_DLCLOSE_VMODS /* * atexit(3) handlers are not called during dlclose(3). We don't @@ -184,6 +155,8 @@ VRT_Vmod_Fini(void **hdl) */ AZ(dlclose(v->hdl)); #endif + if (--v->ref != 0) + return; free(v->nm); free(v->path); VTAILQ_REMOVE(&vmods, v, list); From martin at varnish-software.com Mon Aug 25 11:01:25 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 25 Aug 2014 13:01:25 +0200 Subject: [master] 0a6e8a6 Deal with any remaining request body in cnt_synth Message-ID: commit 0a6e8a6cac45ee56a3f69f0e8f3ad4df23d33250 Author: Martin Blix Grydeland Date: Fri Aug 22 15:40:44 2014 +0200 Deal with any remaining request body in cnt_synth Call HTTP1_DiscardReqBody() in cnt_synth before delivery to deal with any lingering request body. Fixes: #1577 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 7ab29ac..0e5d188 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -220,7 +220,6 @@ cnt_synth(struct worker *wrk, struct req *req) wrk->stats.s_synth++; - now = W_TIM_real(wrk); VSLb_ts_req(req, "Process", now); @@ -257,6 +256,9 @@ cnt_synth(struct worker *wrk, struct req *req) if (http_HdrIs(req->resp, H_Connection, "close")) req->doclose = SC_RESP_CLOSE; + /* Discard any lingering request body before delivery */ + (void)HTTP1_DiscardReqBody(req); + V1D_Deliver_Synth(req); VSLb_ts_req(req, "Resp", W_TIM_real(wrk)); diff --git a/bin/varnishtest/tests/r01577.vtc b/bin/varnishtest/tests/r01577.vtc new file mode 100644 index 0000000..9a90ed5 --- /dev/null +++ b/bin/varnishtest/tests/r01577.vtc @@ -0,0 +1,37 @@ +varnishtest "#1577: reqbody and synth from recv" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.url == "/1") { + return (synth(200, "OK")); + } + } + sub vcl_synth { + set resp.http.x-url = req.url; + } + sub vcl_deliver { + set resp.http.x-url = req.url; + } +} -start + +client c1 { + # Send a body that happens to be a valid HTTP request + # This one is answered by synth() + txreq -url "/1" -body "GET /foo HTTP/1.1\r\n\r\n" + rxresp + expect resp.status == 200 + expect resp.http.x-url == "/1" + + # Make sure that a second request on the same connection goes through + # and that the body of the previous one isn't interpreted as the + # next request + txreq -url "/2" + rxresp + expect resp.status == 200 + expect resp.http.x-url == "/2" +} -run From martin at varnish-software.com Mon Aug 25 11:02:34 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 25 Aug 2014 13:02:34 +0200 Subject: [4.0] d11d441 Deal with any remaining request body in cnt_synth Message-ID: commit d11d4419f3f9fa1d70e984f80c2078ea44e9e53c Author: Martin Blix Grydeland Date: Fri Aug 22 15:40:44 2014 +0200 Deal with any remaining request body in cnt_synth Call HTTP1_DiscardReqBody() in cnt_synth before delivery to deal with any lingering request body. Fixes: #1577 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 858406d..32b81a1 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -209,7 +209,6 @@ cnt_synth(struct worker *wrk, struct req *req) wrk->stats.s_synth++; - now = W_TIM_real(wrk); VSLb_ts_req(req, "Process", now); @@ -247,6 +246,9 @@ cnt_synth(struct worker *wrk, struct req *req) if (http_HdrIs(req->resp, H_Connection, "close")) req->doclose = SC_RESP_CLOSE; + /* Discard any lingering request body before delivery */ + (void)HTTP1_DiscardReqBody(req); + V1D_Deliver_Synth(req); VSLb_ts_req(req, "Resp", W_TIM_real(wrk)); diff --git a/bin/varnishtest/tests/r01577.vtc b/bin/varnishtest/tests/r01577.vtc new file mode 100644 index 0000000..9a90ed5 --- /dev/null +++ b/bin/varnishtest/tests/r01577.vtc @@ -0,0 +1,37 @@ +varnishtest "#1577: reqbody and synth from recv" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.url == "/1") { + return (synth(200, "OK")); + } + } + sub vcl_synth { + set resp.http.x-url = req.url; + } + sub vcl_deliver { + set resp.http.x-url = req.url; + } +} -start + +client c1 { + # Send a body that happens to be a valid HTTP request + # This one is answered by synth() + txreq -url "/1" -body "GET /foo HTTP/1.1\r\n\r\n" + rxresp + expect resp.status == 200 + expect resp.http.x-url == "/1" + + # Make sure that a second request on the same connection goes through + # and that the body of the previous one isn't interpreted as the + # next request + txreq -url "/2" + rxresp + expect resp.status == 200 + expect resp.http.x-url == "/2" +} -run From nils.goroll at uplex.de Mon Aug 25 11:03:11 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 25 Aug 2014 13:03:11 +0200 Subject: [master] 4e9fb4b Set default ttl (according to rfc2616 rules) to max-age, do not use Age twice Message-ID: commit 4e9fb4b339b7df0679609d699aa7f5c31aa32595 Author: Nils Goroll Date: Mon Aug 25 12:53:49 2014 +0200 Set default ttl (according to rfc2616 rules) to max-age, do not use Age twice With 160927b690dd076702601b7407eb71bd423c62dd t_origin got corrected by Age, so we already took the age the object had at fetch time into consideration for all other calculations. Fixes #1578 diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index cddab7c..0f9292a 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -136,10 +136,7 @@ RFC2616_Ttl(struct busyobj *bo, double now) else max_age = strtoul(p, NULL, 0); - if (age > max_age) - expp->ttl = 0; - else - expp->ttl = max_age - age; + expp->ttl = max_age; break; } diff --git a/bin/varnishtest/tests/r01578.vtc b/bin/varnishtest/tests/r01578.vtc new file mode 100644 index 0000000..3086b6b --- /dev/null +++ b/bin/varnishtest/tests/r01578.vtc @@ -0,0 +1,41 @@ +varnishtest "max-age and age" + +server s1 { + rxreq + txresp -hdr "Cache-Control: max-age=23" -hdr "Age: 4" -bodylen 40 +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_response { + set beresp.http.x-ttl = beresp.ttl; + } + sub vcl_hit { + set req.http.x-remaining-ttl = obj.ttl; + } + sub vcl_deliver { + set resp.http.x-remaining-ttl = req.http.x-remaining-ttl; + } +} -start + +client c1 { + txreq + rxresp + expect resp.bodylen == 40 + expect resp.http.x-ttl == 23.000 + expect resp.http.Age == 4 + + + delay 2 + txreq + rxresp + expect resp.bodylen == 40 + expect resp.http.x-ttl == 23.000 + expect resp.http.x-remaining-ttl ~ ^17\.0|^16\.9 + + delay 2 + txreq + rxresp + expect resp.bodylen == 40 + expect resp.http.x-ttl == 23.000 + expect resp.http.x-remaining-ttl ~ ^15\.0|^14\.9 +} -run From phk at FreeBSD.org Tue Aug 26 08:20:50 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Aug 2014 10:20:50 +0200 Subject: [master] 920541a Document why updating VMODs on the fly does not work. Message-ID: commit 920541a8fa79b2ce9471571df0f973b1beeb25b8 Author: Poul-Henning Kamp Date: Tue Aug 26 08:20:36 2014 +0000 Document why updating VMODs on the fly does not work. diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 033e04b..5ad685f 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -325,3 +325,33 @@ unless they access VMOD specific global state, shared with other VCLs. Traffic in other VCLs which also import this VMOD, will be happening while housekeeping is going on. + +Updating VMODs +============== + +A compiled VMOD is a shared library file which Varnish dlopen(3)'s +using flags RTLD_NOW | RTLD_LOCAL. + +As a general rule, once a file is opened with dlopen(3) you should +never modify it, but it is safe to rename it and put a new file +under the name it had, which is how most tools installs and updates +shared libraries. + +However, when you call dlopen(3) with the same filename multiple +times it will give you the same single copy of the shared library +file, without checking if it was updated in the meantime. + +This is obviously an oversight in the design of the dlopen(3) library +function, but back in the late 1980ies nobody could imagine why a +program would ever want to have multiple different versions of the +same shared library mapped at the same time. + +Varnish does that, and therefore you must restart the worker process +before Varnish will discover an updated VMOD. + +If you want to test a new version of a VMOD, while being able to +instantly switch back to the old version, you will have to install +each version with a distinct filename or in a distinct subdirectory +and use ``import foo from "...";`` to reference it in your VCL. + +We're not happy about this, but have found no sensible workarounds. From nils.goroll at uplex.de Tue Aug 26 14:47:59 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Aug 2014 16:47:59 +0200 Subject: [master] ed16ec8 some words about exit codes Message-ID: commit ed16ec8acbb74f0be230fcc73832dc47f4828076 Author: Nils Goroll Date: Tue Aug 26 16:47:07 2014 +0200 some words about exit codes diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index dbe5db8..75b50ac 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -249,6 +249,23 @@ here, in order to conserve VM space. .. include:: ../include/params.rst +EXIT CODES +========== + +Varnish and bundled tools will, in most cases, exit with one of the +following codes + +* `0` OK +* `1` Configuration / parameter error +* `2` Some other error which could be system-dependend and/or transient + +In addition to these, when coredumps are disabled, `varnishd` will +exit with status code `4` in a panic situation. + +The `varnishd` master process may also OR its exit code with `0x40` +when the `varnishd` child process was terminated by a signal and with +`0x80` when a core was dumped. + SEE ALSO ======== From nils.goroll at uplex.de Tue Aug 26 16:51:39 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Aug 2014 18:51:39 +0200 Subject: [master] 71ec63f be more precise about status codes Message-ID: commit 71ec63fcfe203929dd2eed197f56fcfec7baf1e0 Author: Nils Goroll Date: Tue Aug 26 16:59:13 2014 +0200 be more precise about status codes diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 75b50ac..3375f3f 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -259,12 +259,19 @@ following codes * `1` Configuration / parameter error * `2` Some other error which could be system-dependend and/or transient -In addition to these, when coredumps are disabled, `varnishd` will -exit with status code `4` in a panic situation. +In addition to these, the `varnishd` child process will exit with +status code `4` -The `varnishd` master process may also OR its exit code with `0x40` -when the `varnishd` child process was terminated by a signal and with -`0x80` when a core was dumped. +* in a panic situation when coredumps are disabled and +* in panic-like situations when triggering an actual panic is not + possible. + +The `varnishd` master process may also OR its exit code + +* with `0x20` when the `varnishd` child process died, +* with `0x40` when the `varnishd` child process was terminated by a + signal and +* with `0x80` when a core was dumped. SEE ALSO ======== From phk at FreeBSD.org Tue Aug 26 21:04:16 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Aug 2014 23:04:16 +0200 Subject: [master] 778d0d1 Make this test 0.1 second more tolerant of timing on loaded systems Message-ID: commit 778d0d1b202d935a1ce3e4d2c3aaa6f0e35404c1 Author: Poul-Henning Kamp Date: Tue Aug 26 20:45:27 2014 +0000 Make this test 0.1 second more tolerant of timing on loaded systems diff --git a/bin/varnishtest/tests/r01578.vtc b/bin/varnishtest/tests/r01578.vtc index 3086b6b..d0835d5 100644 --- a/bin/varnishtest/tests/r01578.vtc +++ b/bin/varnishtest/tests/r01578.vtc @@ -30,12 +30,12 @@ client c1 { rxresp expect resp.bodylen == 40 expect resp.http.x-ttl == 23.000 - expect resp.http.x-remaining-ttl ~ ^17\.0|^16\.9 + expect resp.http.x-remaining-ttl ~ ^17\.0|^16\.[89] delay 2 txreq rxresp expect resp.bodylen == 40 expect resp.http.x-ttl == 23.000 - expect resp.http.x-remaining-ttl ~ ^15\.0|^14\.9 + expect resp.http.x-remaining-ttl ~ ^15\.0|^14\.[89] } -run From phk at FreeBSD.org Tue Aug 26 21:04:16 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Aug 2014 23:04:16 +0200 Subject: [master] 603ad18 White space nit Message-ID: commit 603ad18857af2abf57ca28f45788b47ea4501ff2 Author: Poul-Henning Kamp Date: Tue Aug 26 20:48:00 2014 +0000 White space nit diff --git a/bin/varnishtest/tests/r01578.vtc b/bin/varnishtest/tests/r01578.vtc index d0835d5..a72a3c9 100644 --- a/bin/varnishtest/tests/r01578.vtc +++ b/bin/varnishtest/tests/r01578.vtc @@ -7,7 +7,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_backend_response { - set beresp.http.x-ttl = beresp.ttl; + set beresp.http.x-ttl = beresp.ttl; } sub vcl_hit { set req.http.x-remaining-ttl = obj.ttl; From phk at FreeBSD.org Tue Aug 26 21:04:17 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Aug 2014 23:04:17 +0200 Subject: [master] 5a83b69 Rework how we infer types in the VCC expresion evaluator. Message-ID: commit 5a83b69d8c5d6b08b6de2132df45531c8b7543f1 Author: Poul-Henning Kamp Date: Tue Aug 26 20:48:08 2014 +0000 Rework how we infer types in the VCC expresion evaluator. This mainly (only ?) changes things when we ask for an expression of type STRING or STTRING_LIST. Previously addition and subtraction would follow the general rule, "first argument determines intial type" and that would make an expression like this fail: set resp.http.server_port_foo = std.port(server.ip) + "_foo"; Because the addition tries to evaluate "INT + STRING". The idea was that people would rewrite this as: set resp.http.server_port_foo = "" + std.port(server.ip) + "_foo"; To make the first argument STRING and everything will then just work. However, this is needlessly strict in the case where we are actively desiring the expression to evaluate to STRING -- like above where resp.http.* has type STRING. With the new code, when an impossible addition is encountered, it will look at the type requested of the expression, and if it is STRING, convert the current subexpression to STRING and continue adding. A large number of subtests which are designed to fail started working with this change, they have been fixed by not using *.http.* variables as scaffolding.. You can still get into some weird corner-cases like the difference between: set resp.http.foobar = req.ttl + 1s + "_" + req.ttl + 1s; and set resp.http.foobar = req.ttl + 1s + "_" + req.ttl + 1; and set resp.http.foobar = req.ttl + 1s + "_" + (req.ttl + 1s); (Hint: The last one is the only one which does what you think) Fixes #1579 diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index e63be3f..f9be7ec 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -74,7 +74,7 @@ varnish v1 -errvcl {Operator * not possible on type STRING.} { varnish v1 -errvcl {DURATION + INT not possible.} { sub vcl_backend_response { - set req.http.foo = req.ttl + beresp.status; + set req.ttl = req.ttl + beresp.status; } } @@ -85,7 +85,7 @@ varnish v1 -errvcl {'!' must be followed by BOOL, found DURATION.} { } } -varnish v1 -errvcl {Operator + not possible on type BOOL.} { +varnish v1 -errvcl {BOOL + BOOL not possible.} { sub vcl_backend_response { if (beresp.do_gzip + beresp.do_gunzip) { } @@ -111,7 +111,7 @@ varnish v1 -vcl { } # XXX: not the most clear error message -varnish v1 -errvcl {Expected ';' got '-'} { +varnish v1 -errvcl {STRING - STRING not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = "foo" - "bar"; @@ -121,14 +121,14 @@ varnish v1 -errvcl {Expected ';' got '-'} { varnish v1 -errvcl {TIME + STRING not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { - set req.http.foo = now + "foo"; + set req.ttl = now + "foo"; } } varnish v1 -errvcl {TIME + TIME not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { - set req.http.foo = now + now; + set req.ttl = now + now; } } @@ -142,15 +142,15 @@ varnish v1 -errvcl {Expected ID got ';'} { varnish v1 -errvcl {INT + STRING not possible.} { backend b { .host = "127.0.0.1"; } - sub vcl_recv { - set req.http.foo = 1 + "foo"; + sub vcl_backend_response { + set beresp.status = 1 + "foo"; } } varnish v1 -errvcl {INT + TIME not possible.} { backend b { .host = "127.0.0.1"; } - sub vcl_recv { - set req.http.foo = 1 + now; + sub vcl_backend_response { + set beresp.status = 1 + now; } } diff --git a/bin/varnishtest/tests/v00025.vtc b/bin/varnishtest/tests/v00025.vtc index 67ac41a..2ac4b9d 100644 --- a/bin/varnishtest/tests/v00025.vtc +++ b/bin/varnishtest/tests/v00025.vtc @@ -15,6 +15,9 @@ varnish v1 -arg "-i J.F.Nobody" -vcl+backend { sub vcl_deliver { set resp.http.server_port = std.port(server.ip); + set resp.http.server_port_foo = std.port(server.ip) + "_foo"; + set resp.http.ttl1 = (req.ttl + 10s); + set resp.http.ttl2 = req.ttl + 10s; set resp.http.id = server.identity; set resp.http.esi = req.esi; set resp.http.be = req.backend_hint; diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index c2f9818..c6c75fe 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -660,6 +660,7 @@ vcc_Eval_SymFunc(struct vcc *tl, struct expr **e, const struct symbol *sym) * SYNTAX: * Expr4: * '(' Expr0 ')' + * symbol * CNUM * CSTR */ @@ -704,6 +705,11 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) AN(sym->eval); AZ(*e); sym->eval(tl, e, sym); + /* Unless asked for a HEADER, fold to string here */ + if (*e && fmt != HEADER && (*e)->fmt == HEADER) { + vcc_expr_tostring(tl, e, STRING); + ERRCHK(tl); + } return; default: break; @@ -822,16 +828,21 @@ vcc_expr_mul(struct vcc *tl, struct expr **e, enum var_type fmt) */ static void -vcc_expr_string_add(struct vcc *tl, struct expr **e) +vcc_expr_string_add(struct vcc *tl, struct expr **e, struct expr *e2) { - struct expr *e2; enum var_type f2; + AN(e); + AN(*e); + AN(e2); f2 = (*e)->fmt; + assert (f2 == STRING || f2 == STRING_LIST); - while (tl->t->tok == '+') { - vcc_NextToken(tl); - vcc_expr_mul(tl, &e2, STRING); + while (e2 != NULL || tl->t->tok == '+') { + if (e2 == NULL) { + vcc_NextToken(tl); + vcc_expr_mul(tl, &e2, STRING); + } ERRCHK(tl); if (e2->fmt != STRING && e2->fmt != STRING_LIST) { vcc_expr_tostring(tl, &e2, f2); @@ -858,6 +869,7 @@ vcc_expr_string_add(struct vcc *tl, struct expr **e) *e = vcc_expr_edit(STRING_LIST, "\v1,\n\v2", *e, e2); (*e)->constant = EXPR_VAR; } + e2 = NULL; } } @@ -873,49 +885,36 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) ERRCHK(tl); f2 = (*e)->fmt; - /* Unless we specifically ask for a HEADER, fold them to string here */ - if (fmt != HEADER && f2 == HEADER) { - vcc_expr_tostring(tl, e, STRING); - ERRCHK(tl); - f2 = (*e)->fmt; - assert(f2 == STRING); - } - - if (tl->t->tok != '+' && tl->t->tok != '-') - return; - - switch(f2) { - case STRING: - case STRING_LIST: - vcc_expr_string_add(tl, e); - return; - case INT: break; - case TIME: break; - case DURATION: break; - case BYTES: break; - default: - VSB_printf(tl->sb, "Operator %.*s not possible on type %s.\n", - PF(tl->t), vcc_Type(f2)); - vcc_ErrWhere(tl, tl->t); - return; - } - while (tl->t->tok == '+' || tl->t->tok == '-') { - if (f2 == TIME) - f2 = DURATION; tk = tl->t; vcc_NextToken(tl); - vcc_expr_mul(tl, &e2, f2); + if (f2 == TIME) + vcc_expr_mul(tl, &e2, DURATION); + else + vcc_expr_mul(tl, &e2, f2); ERRCHK(tl); if (tk->tok == '-' && (*e)->fmt == TIME && e2->fmt == TIME) { /* OK */ } else if ((*e)->fmt == TIME && e2->fmt == DURATION) { f2 = TIME; /* OK */ - } else if (tk->tok == '-' && - (*e)->fmt == BYTES && e2->fmt == BYTES) { + } else if ((*e)->fmt == BYTES && e2->fmt == BYTES) { + /* OK */ + } else if ((*e)->fmt == INT && e2->fmt == INT) { + /* OK */ + } else if ((*e)->fmt == DURATION && e2->fmt == DURATION) { /* OK */ - } else if (e2->fmt != f2) { + } else if (tk->tok == '+' && + (*e)->fmt == STRING && e2->fmt == STRING) { + vcc_expr_string_add(tl, e, e2); + return; + } else if (tk->tok == '+' && + (fmt == STRING || fmt == STRING_LIST)) { + /* Time to fold and add as string */ + vcc_expr_tostring(tl, e, STRING); + vcc_expr_string_add(tl, e, e2); + return; + } else { VSB_printf(tl->sb, "%s %.*s %s not possible.\n", vcc_Type((*e)->fmt), PF(tk), vcc_Type(e2->fmt)); vcc_ErrWhere2(tl, tk, tl->t); From phk at FreeBSD.org Wed Aug 27 07:30:34 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Aug 2014 09:30:34 +0200 Subject: [master] 9962996 Fix an issue where the order of symbol definition determined if code could compile or not. Message-ID: commit 996299655c9ed5d94853a495ddaa2ae29094a9e9 Author: Poul-Henning Kamp Date: Wed Aug 27 07:29:49 2014 +0000 Fix an issue where the order of symbol definition determined if code could compile or not. Fixes #1569 diff --git a/bin/varnishtest/tests/r01569.vtc b/bin/varnishtest/tests/r01569.vtc new file mode 100644 index 0000000..7a05938 --- /dev/null +++ b/bin/varnishtest/tests/r01569.vtc @@ -0,0 +1,19 @@ +varnishtest "symbol lookup order issue" + +varnish v1 -vcl { + vcl 4.0; + import ${vmod_debug}; + + backend debug { + .host = "127.0.0.1"; + .port = "80"; + } + + sub debug { + set req.backend_hint = debug; + } + + sub vcl_recv { + call debug; + } +} diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index c6c75fe..3557a4b 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -688,7 +688,15 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) * XXX: what if var and func/proc had same name ? * XXX: look for SYM_VAR first for consistency ? */ - sym = VCC_FindSymbol(tl, tl->t, SYM_NONE); + sym = NULL; + if (fmt == BACKEND) + sym = VCC_FindSymbol(tl, tl->t, SYM_BACKEND); + if (sym == NULL) + sym = VCC_FindSymbol(tl, tl->t, SYM_VAR); + if (sym == NULL) + sym = VCC_FindSymbol(tl, tl->t, SYM_FUNC); + if (sym == NULL) + sym = VCC_FindSymbol(tl, tl->t, SYM_NONE); if (sym == NULL || sym->eval == NULL) { VSB_printf(tl->sb, "Symbol not found: "); vcc_ErrToken(tl, tl->t); diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index c3d8a13..e9d39f0 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -50,7 +50,6 @@ VCC_SymKind(struct vcc *tl, const struct symbol *s) } } - static struct symbol * vcc_AddSymbol(struct vcc *tl, const char *nb, int l, enum symkind kind) { From phk at FreeBSD.org Wed Aug 27 07:59:57 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Aug 2014 09:59:57 +0200 Subject: [master] e8e089f Set Vary: Accept-Encoding if we munge the gzip status. Message-ID: commit e8e089fc1968ee147fb06c60e3caae568bd11e40 Author: Poul-Henning Kamp Date: Wed Aug 27 07:59:17 2014 +0000 Set Vary: Accept-Encoding if we munge the gzip status. Patch by: fgs (with minor modifications) diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 9de6cfc..0d6c958 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1242,7 +1242,7 @@ enum body_status RFC2616_Body(struct busyobj *, struct dstat *); unsigned RFC2616_Req_Gzip(const struct http *); int RFC2616_Do_Cond(const struct req *sp); void RFC2616_Weaken_Etag(struct http *hp); - +void RFC2616_Vary_AE(struct http *hp); /* stevedore.c */ int STV_NewObject(struct busyobj *, const char *hint, unsigned len); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 5fa6835..2963b95 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -165,6 +165,8 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) http_Unset(vc->http, H_Content_Encoding); http_SetHeader(vc->http, "Content-Encoding: gzip"); + RFC2616_Vary_AE(vc->http); + return (VFP_OK); } diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 5433fa4..1e5b806 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -492,6 +492,9 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) if (vfe->vfp->priv2 == VFP_GZIP) http_SetHeader(vc->http, "Content-Encoding: gzip"); + if (vfe->vfp->priv2 == VFP_GZIP || vfe->vfp->priv2 == VFP_TESTGUNZIP) + RFC2616_Vary_AE(vc->http); + return (VFP_OK); } diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 0f9292a..75f74b5 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -387,3 +387,20 @@ RFC2616_Weaken_Etag(struct http *hp) http_Unset(hp, H_ETag); http_PrintfHeader(hp, "ETag: W/%s", p); } + +/*--------------------------------------------------------------------*/ + +void +RFC2616_Vary_AE(struct http *hp) +{ + char *vary; + + if (http_GetHdrData(hp, H_Vary, "Accept-Encoding", NULL)) + return; + if (http_GetHdr(hp, H_Vary, &vary)) { + http_Unset(hp, H_Vary); + http_PrintfHeader(hp, "Vary: %s, Accept-Encoding", vary); + } else { + http_SetHeader(hp, "Vary: Accept-Encoding"); + } +} diff --git a/bin/varnishtest/tests/e00028.vtc b/bin/varnishtest/tests/e00028.vtc new file mode 100644 index 0000000..8841067 --- /dev/null +++ b/bin/varnishtest/tests/e00028.vtc @@ -0,0 +1,98 @@ +varnishtest "Test Vary with ESI and gzip/gunzip" + +server s1 { + rxreq + txresp -body "foo" + rxreq + txresp -gzipbody "bar" + rxreq + txresp -body "baz" + rxreq + txresp -hdr "Vary: qux" -gzipbody "qux" + rxreq + txresp -hdr "Vary: fubar, Accept-Encoding" -gzipbody "fubar" + rxreq + txresp -gzipbody "foobar" + rxreq + txresp -hdr "Vary: foobaz" -gzipbody "foobaz" + rxreq + txresp -hdr "Vary: fooqux, Accept-Encoding" -gzipbody "fooqux" +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_response { + set beresp.do_esi = true; + if (bereq.url ~ "/baz") { + set beresp.do_gzip = true; + } elif (bereq.url ~ "/foo(bar|baz|qux)") { + set beresp.do_gunzip = true; + } + } +} -start + +client c1 { + txreq -url /foo + rxresp + expect resp.body == "foo" + expect resp.http.Vary == + txreq -url /foo -hdr "Accept-Encoding: gzip" + rxresp + expect resp.body == "foo" + expect resp.http.Vary == + txreq -url /bar + rxresp + expect resp.body == "bar" + expect resp.http.Vary == "Accept-Encoding" + txreq -url /bar -hdr "Accept-Encoding: gzip" + rxresp + expect resp.bodylen == 34 + expect resp.http.Vary == "Accept-Encoding" + txreq -url /baz + rxresp + expect resp.body == "baz" + expect resp.http.Vary == "Accept-Encoding" + txreq -url /baz -hdr "Accept-Encoding: gzip" + rxresp + expect resp.bodylen == 34 + expect resp.http.Vary == "Accept-Encoding" + txreq -url /qux + rxresp + expect resp.body == "qux" + expect resp.http.Vary == "qux, Accept-Encoding" + txreq -url /qux -hdr "Accept-Encoding: gzip" + rxresp + expect resp.bodylen == 34 + expect resp.http.Vary == "qux, Accept-Encoding" + txreq -url /fubar + rxresp + expect resp.body == "fubar" + expect resp.http.Vary == "fubar, Accept-Encoding" + txreq -url /fubar -hdr "Accept-Encoding: gzip" + rxresp + expect resp.bodylen == 36 + expect resp.http.Vary == "fubar, Accept-Encoding" + txreq -url /foobar + rxresp + expect resp.body == "foobar" + expect resp.http.Vary == + txreq -url /foobar -hdr "Accept-Encoding: gzip" + rxresp + expect resp.body == "foobar" + expect resp.http.Vary == + txreq -url /foobaz + rxresp + expect resp.body == "foobaz" + expect resp.http.Vary == "foobaz" + txreq -url /foobaz -hdr "Accept-Encoding: gzip" + rxresp + expect resp.body == "foobaz" + expect resp.http.Vary == "foobaz" + txreq -url /fooqux + rxresp + expect resp.body == "fooqux" + expect resp.http.Vary == "fooqux, Accept-Encoding" + txreq -url /fooqux -hdr "Accept-Encoding: gzip" + rxresp + expect resp.body == "fooqux" + expect resp.http.Vary == "fooqux, Accept-Encoding" +} -run diff --git a/bin/varnishtest/tests/g00007.vtc b/bin/varnishtest/tests/g00007.vtc new file mode 100644 index 0000000..276cbd1 --- /dev/null +++ b/bin/varnishtest/tests/g00007.vtc @@ -0,0 +1,97 @@ +varnishtest "Test Vary with gzip/gunzip" + +server s1 { + rxreq + txresp -body "foo" + rxreq + txresp -gzipbody "bar" + rxreq + txresp -body "baz" + rxreq + txresp -hdr "Vary: qux" -gzipbody "qux" + rxreq + txresp -hdr "Vary: fubar, Accept-Encoding" -gzipbody "fubar" + rxreq + txresp -gzipbody "foobar" + rxreq + txresp -hdr "Vary: foobaz" -gzipbody "foobaz" + rxreq + txresp -hdr "Vary: fooqux, Accept-Encoding" -gzipbody "fooqux" +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_response { + if (bereq.url ~ "/baz") { + set beresp.do_gzip = true; + } elif (bereq.url ~ "/foo(bar|baz|qux)") { + set beresp.do_gunzip = true; + } + } +} -start + +client c1 { + txreq -url /foo + rxresp + expect resp.body == "foo" + expect resp.http.Vary == + txreq -url /foo -hdr "Accept-Encoding: gzip" + rxresp + expect resp.body == "foo" + expect resp.http.Vary == + txreq -url /bar + rxresp + expect resp.body == "bar" + expect resp.http.Vary == "Accept-Encoding" + txreq -url /bar -hdr "Accept-Encoding: gzip" + rxresp + expect resp.bodylen == 26 + expect resp.http.Vary == "Accept-Encoding" + txreq -url /baz + rxresp + expect resp.body == "baz" + expect resp.http.Vary == "Accept-Encoding" + txreq -url /baz -hdr "Accept-Encoding: gzip" + rxresp + expect resp.bodylen == 23 + expect resp.http.Vary == "Accept-Encoding" + txreq -url /qux + rxresp + expect resp.body == "qux" + expect resp.http.Vary == "qux, Accept-Encoding" + txreq -url /qux -hdr "Accept-Encoding: gzip" + rxresp + expect resp.bodylen == 26 + expect resp.http.Vary == "qux, Accept-Encoding" + txreq -url /fubar + rxresp + expect resp.body == "fubar" + expect resp.http.Vary == "fubar, Accept-Encoding" + txreq -url /fubar -hdr "Accept-Encoding: gzip" + rxresp + expect resp.bodylen == 28 + expect resp.http.Vary == "fubar, Accept-Encoding" + txreq -url /foobar + rxresp + expect resp.body == "foobar" + expect resp.http.Vary == + txreq -url /foobar -hdr "Accept-Encoding: gzip" + rxresp + expect resp.body == "foobar" + expect resp.http.Vary == + txreq -url /foobaz + rxresp + expect resp.body == "foobaz" + expect resp.http.Vary == "foobaz" + txreq -url /foobaz -hdr "Accept-Encoding: gzip" + rxresp + expect resp.body == "foobaz" + expect resp.http.Vary == "foobaz" + txreq -url /fooqux + rxresp + expect resp.body == "fooqux" + expect resp.http.Vary == "fooqux, Accept-Encoding" + txreq -url /fooqux -hdr "Accept-Encoding: gzip" + rxresp + expect resp.body == "fooqux" + expect resp.http.Vary == "fooqux, Accept-Encoding" +} -run From nils.goroll at uplex.de Wed Aug 27 09:01:02 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 27 Aug 2014 11:01:02 +0200 Subject: [master] 1c238cc improve legibility Message-ID: commit 1c238cc42d97794c5a749cb47ba43935548c1c3a Author: Nils Goroll Date: Wed Aug 27 11:00:32 2014 +0200 improve legibility diff --git a/bin/varnishtest/tests/e00028.vtc b/bin/varnishtest/tests/e00028.vtc index 8841067..a32814c 100644 --- a/bin/varnishtest/tests/e00028.vtc +++ b/bin/varnishtest/tests/e00028.vtc @@ -2,20 +2,35 @@ varnishtest "Test Vary with ESI and gzip/gunzip" server s1 { rxreq + expect req.url == "/foo" txresp -body "foo" + rxreq + expect req.url == "/bar" txresp -gzipbody "bar" + rxreq + expect req.url == "/baz" txresp -body "baz" + rxreq + expect req.url == "/qux" txresp -hdr "Vary: qux" -gzipbody "qux" + rxreq + expect req.url == "/fubar" txresp -hdr "Vary: fubar, Accept-Encoding" -gzipbody "fubar" + rxreq + expect req.url == "/foobar" txresp -gzipbody "foobar" + rxreq + expect req.url == "/foobaz" txresp -hdr "Vary: foobaz" -gzipbody "foobaz" + rxreq + expect req.url == "/fooqux" txresp -hdr "Vary: fooqux, Accept-Encoding" -gzipbody "fooqux" } -start @@ -31,66 +46,89 @@ varnish v1 -vcl+backend { } -start client c1 { + # /foo txreq -url /foo rxresp expect resp.body == "foo" expect resp.http.Vary == + txreq -url /foo -hdr "Accept-Encoding: gzip" rxresp expect resp.body == "foo" expect resp.http.Vary == + + # /bar txreq -url /bar rxresp expect resp.body == "bar" expect resp.http.Vary == "Accept-Encoding" + txreq -url /bar -hdr "Accept-Encoding: gzip" rxresp expect resp.bodylen == 34 expect resp.http.Vary == "Accept-Encoding" + + # /baz txreq -url /baz rxresp expect resp.body == "baz" expect resp.http.Vary == "Accept-Encoding" + txreq -url /baz -hdr "Accept-Encoding: gzip" rxresp expect resp.bodylen == 34 expect resp.http.Vary == "Accept-Encoding" + + # /qux txreq -url /qux rxresp expect resp.body == "qux" expect resp.http.Vary == "qux, Accept-Encoding" + txreq -url /qux -hdr "Accept-Encoding: gzip" rxresp expect resp.bodylen == 34 expect resp.http.Vary == "qux, Accept-Encoding" + + # /fubar txreq -url /fubar rxresp expect resp.body == "fubar" expect resp.http.Vary == "fubar, Accept-Encoding" + txreq -url /fubar -hdr "Accept-Encoding: gzip" rxresp expect resp.bodylen == 36 expect resp.http.Vary == "fubar, Accept-Encoding" + + # /foobar txreq -url /foobar rxresp expect resp.body == "foobar" expect resp.http.Vary == + txreq -url /foobar -hdr "Accept-Encoding: gzip" rxresp expect resp.body == "foobar" expect resp.http.Vary == + + # /foobaz txreq -url /foobaz rxresp expect resp.body == "foobaz" expect resp.http.Vary == "foobaz" + txreq -url /foobaz -hdr "Accept-Encoding: gzip" rxresp expect resp.body == "foobaz" expect resp.http.Vary == "foobaz" + + # /fooqux txreq -url /fooqux rxresp expect resp.body == "fooqux" expect resp.http.Vary == "fooqux, Accept-Encoding" + txreq -url /fooqux -hdr "Accept-Encoding: gzip" rxresp expect resp.body == "fooqux" diff --git a/bin/varnishtest/tests/g00007.vtc b/bin/varnishtest/tests/g00007.vtc index 276cbd1..85002af 100644 --- a/bin/varnishtest/tests/g00007.vtc +++ b/bin/varnishtest/tests/g00007.vtc @@ -2,20 +2,35 @@ varnishtest "Test Vary with gzip/gunzip" server s1 { rxreq + expect req.url == "/foo" txresp -body "foo" + rxreq + expect req.url == "/bar" txresp -gzipbody "bar" + rxreq + expect req.url == "/baz" txresp -body "baz" + rxreq + expect req.url == "/qux" txresp -hdr "Vary: qux" -gzipbody "qux" + rxreq + expect req.url == "/fubar" txresp -hdr "Vary: fubar, Accept-Encoding" -gzipbody "fubar" + rxreq + expect req.url == "/foobar" txresp -gzipbody "foobar" + rxreq + expect req.url == "/foobaz" txresp -hdr "Vary: foobaz" -gzipbody "foobaz" + rxreq + expect req.url == "/fooqux" txresp -hdr "Vary: fooqux, Accept-Encoding" -gzipbody "fooqux" } -start @@ -30,46 +45,62 @@ varnish v1 -vcl+backend { } -start client c1 { + # /foo txreq -url /foo rxresp expect resp.body == "foo" expect resp.http.Vary == + txreq -url /foo -hdr "Accept-Encoding: gzip" rxresp expect resp.body == "foo" expect resp.http.Vary == + + # /bar txreq -url /bar rxresp expect resp.body == "bar" expect resp.http.Vary == "Accept-Encoding" + txreq -url /bar -hdr "Accept-Encoding: gzip" rxresp expect resp.bodylen == 26 expect resp.http.Vary == "Accept-Encoding" + + # /baz txreq -url /baz rxresp expect resp.body == "baz" expect resp.http.Vary == "Accept-Encoding" + txreq -url /baz -hdr "Accept-Encoding: gzip" rxresp expect resp.bodylen == 23 expect resp.http.Vary == "Accept-Encoding" + + # /qux txreq -url /qux rxresp expect resp.body == "qux" expect resp.http.Vary == "qux, Accept-Encoding" + txreq -url /qux -hdr "Accept-Encoding: gzip" rxresp expect resp.bodylen == 26 expect resp.http.Vary == "qux, Accept-Encoding" + + # /fubar txreq -url /fubar rxresp expect resp.body == "fubar" expect resp.http.Vary == "fubar, Accept-Encoding" + txreq -url /fubar -hdr "Accept-Encoding: gzip" rxresp expect resp.bodylen == 28 expect resp.http.Vary == "fubar, Accept-Encoding" + + # /foobar txreq -url /foobar rxresp expect resp.body == "foobar" @@ -78,18 +109,24 @@ client c1 { rxresp expect resp.body == "foobar" expect resp.http.Vary == + + # /foobaz txreq -url /foobaz rxresp expect resp.body == "foobaz" expect resp.http.Vary == "foobaz" + txreq -url /foobaz -hdr "Accept-Encoding: gzip" rxresp expect resp.body == "foobaz" expect resp.http.Vary == "foobaz" + + # /fooqux txreq -url /fooqux rxresp expect resp.body == "fooqux" expect resp.http.Vary == "fooqux, Accept-Encoding" + txreq -url /fooqux -hdr "Accept-Encoding: gzip" rxresp expect resp.body == "fooqux" From phk at FreeBSD.org Wed Aug 27 10:02:21 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Aug 2014 12:02:21 +0200 Subject: [master] ad0ae8e Escape question marks in C-strings to avoid accidentally generating tri-graphs. Message-ID: commit ad0ae8ee6cb158c5aa5f60e5077459d92331677a Author: Poul-Henning Kamp Date: Wed Aug 27 10:01:49 2014 +0000 Escape question marks in C-strings to avoid accidentally generating tri-graphs. Fixes #1566 diff --git a/bin/varnishtest/tests/r01566.vtc b/bin/varnishtest/tests/r01566.vtc new file mode 100644 index 0000000..fdf79a4 --- /dev/null +++ b/bin/varnishtest/tests/r01566.vtc @@ -0,0 +1,9 @@ +varnishtest "escape issue in regexp" + +varnish v1 -vcl { + backend b1 { .host = "127.0.0.1"; } + + sub vcl_recv { + set req.url = regsuball(req.url, "\??(p|pi)=.*?(&|$)", ""); + } +} diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 4077c1c..934943d 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -211,6 +211,7 @@ EncString(struct vsb *sb, const char *b, const char *e, int mode) VSB_cat(sb, "\""); for (; b < e; b++) { switch (*b) { + case '?': // Trigraphs case '\\': case '"': VSB_printf(sb, "\\%c", *b); From phk at FreeBSD.org Wed Aug 27 11:30:08 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Aug 2014 13:30:08 +0200 Subject: [master] 269c143 Fix readline finding on FreeBSD -current Message-ID: commit 269c14355f82c1c9d69b49506270e28f55867ca7 Author: Poul-Henning Kamp Date: Wed Aug 27 11:29:50 2014 +0000 Fix readline finding on FreeBSD -current diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 26019a5..a17961d 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -34,9 +34,11 @@ #include -#ifdef HAVE_LIBEDIT +#if defined(HAVE_EDIT_READLINE_READLINE_H) +# include +#elif defined(HAVE_LIBEDIT) # include -#elif HAVE_READLINE_READLINE_H +#elif defined (HAVE_READLINE_READLINE_H) # include # ifdef HAVE_READLINE_HISTORY_H # include diff --git a/configure.ac b/configure.ac index c8a36f5..d4f5c5b 100644 --- a/configure.ac +++ b/configure.ac @@ -164,6 +164,7 @@ PKG_CHECK_MODULES([LIBEDIT], [libedit], AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_HEADER_TIME +AC_CHECK_HEADERS([edit/readline/readline.h]) AC_CHECK_HEADERS([sys/param.h]) AC_CHECK_HEADERS([sys/types.h]) AC_CHECK_HEADERS([sys/endian.h]) From phk at FreeBSD.org Wed Aug 27 12:13:59 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Aug 2014 14:13:59 +0200 Subject: [master] de4743d Don't bother with busyobj delivering already completed objects. Message-ID: commit de4743dc5c21688385f326bd582c397704a79f71 Author: Poul-Henning Kamp Date: Wed Aug 27 12:13:17 2014 +0000 Don't bother with busyobj delivering already completed objects. (This doesn't _quite_ close the race, but at least test c00034 is much more stable now.) diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 0e5d188..e97d81d 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -169,6 +169,8 @@ cnt_deliver(struct worker *wrk, struct req *req) /* Grab a ref to the bo if there is one, and hand it down */ bo = HSH_RefBusy(req->objcore); + if (bo != NULL && bo->state == BOS_FINISHED) + VBO_DerefBusyObj(wrk, &bo); V1D_Deliver(req, bo); if (bo != NULL) VBO_DerefBusyObj(wrk, &bo); From phk at FreeBSD.org Wed Aug 27 12:15:45 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Aug 2014 14:15:45 +0200 Subject: [master] 785ba2e Disable streaming in this test Message-ID: commit 785ba2ea63b8661bd8216cee889a75526226bbe4 Author: Poul-Henning Kamp Date: Wed Aug 27 12:14:25 2014 +0000 Disable streaming in this test diff --git a/bin/varnishtest/tests/c00034.vtc b/bin/varnishtest/tests/c00034.vtc index 513038c..23910de 100644 --- a/bin/varnishtest/tests/c00034.vtc +++ b/bin/varnishtest/tests/c00034.vtc @@ -6,6 +6,10 @@ server s1 { } -start varnish v1 -vcl+backend { + + sub vcl_backend_response { + set beresp.do_stream = false; + } } -start varnish v1 -cliok "param.set http_range_support off" @@ -18,6 +22,7 @@ client c1 { varnish v1 -cliok "param.set http_range_support on" +varnish v1 -expect s_resp_bodybytes == 100 client c1 { txreq -hdr "Range: bytes =0-9" @@ -40,6 +45,12 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 100 +} -run + +varnish v1 -expect s_resp_bodybytes == 500 + +client c1 { + txreq -hdr "Range: bytes=0-9" rxresp expect resp.status == 206 From phk at FreeBSD.org Wed Aug 27 12:15:45 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Aug 2014 14:15:45 +0200 Subject: [master] cd1c7e8 white space nit Message-ID: commit cd1c7e899082365e31c5e27b85f89cbf07d0e0d3 Author: Poul-Henning Kamp Date: Wed Aug 27 12:15:10 2014 +0000 white space nit diff --git a/bin/varnishtest/tests/r01566.vtc b/bin/varnishtest/tests/r01566.vtc index fdf79a4..d78c8ac 100644 --- a/bin/varnishtest/tests/r01566.vtc +++ b/bin/varnishtest/tests/r01566.vtc @@ -5,5 +5,5 @@ varnish v1 -vcl { sub vcl_recv { set req.url = regsuball(req.url, "\??(p|pi)=.*?(&|$)", ""); - } + } } From phk at FreeBSD.org Wed Aug 27 12:15:45 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Aug 2014 14:15:45 +0200 Subject: [master] a982659 Give vrt_ctx a "double now" timestamp for use in VCL/VRT/VMODs Message-ID: commit a98265912a3b30f76726fa1b5a4ff0b5aabbdb4b Author: Poul-Henning Kamp Date: Wed Aug 27 12:15:23 2014 +0000 Give vrt_ctx a "double now" timestamp for use in VCL/VRT/VMODs diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 345696e..521f291 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -42,6 +42,7 @@ #include "vrt.h" #include "vcli.h" #include "vcli_priv.h" +#include "vtim.h" struct vcls { unsigned magic; @@ -432,6 +433,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, ctx.http_req = req->http; ctx.http_resp = req->resp; ctx.req = req; + ctx.now = req->t_prev; } if (bo != NULL) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -440,7 +442,10 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, ctx.http_bereq = bo->bereq; ctx.http_beresp = bo->beresp; ctx.bo = bo; + ctx.now = bo->t_prev; } + if (ctx.now == 0) + ctx.now = VTIM_real(); ctx.ws = ws; ctx.vsl = vsl; ctx.method = method; diff --git a/include/vrt.h b/include/vrt.h index cb47db9..90e85ea 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -41,7 +41,7 @@ #define VRT_MAJOR_VERSION 2U -#define VRT_MINOR_VERSION 0U +#define VRT_MINOR_VERSION 1U /***********************************************************************/ @@ -101,6 +101,7 @@ struct vrt_ctx { struct http *http_bereq; struct http *http_beresp; + double now; }; /***********************************************************************/ From nils.goroll at uplex.de Wed Aug 27 12:21:14 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 27 Aug 2014 14:21:14 +0200 Subject: [master] b109ee1 Fix sensitivity for header token matching. Rename GetHdrData -> GetHdrToken Message-ID: commit b109ee1c099ebae6a9f9423b1a1f81c634c8f895 Author: Nils Goroll Date: Wed Aug 27 14:11:55 2014 +0200 Fix sensitivity for header token matching. Rename GetHdrData -> GetHdrToken Section 4.2 (Messages Headers) of RFC2616 defines field (header) name as case insensitive, but the field (header) value/content may be case-sensitive. http_GetHdrToken looks up a token in a header value and the rfc does not say explicitly if tokens are to be compared with or without respect to case. But all examples and specific statements regarding tokens follow the rule that unquoted tokens are to be matched case-insensitively and quoted tokens case-sensitively. Fixes #1582 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 0d6c958..4b89207 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -962,8 +962,8 @@ void http_ForceField(const struct http *to, unsigned n, const char *t); void HTTP_Setup(struct http *, struct ws *, struct vsl_log *, enum VSL_tag_e); 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); +int http_GetHdrToken(const struct http *hp, const char *hdr, + const char *token, char **ptr); int http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr); double http_GetHdrQ(const struct http *hp, const char *hdr, const char *field); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 16c21bb..acbee43 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -33,6 +33,7 @@ #include #include +#include #include "cache.h" @@ -381,17 +382,30 @@ http_GetHdr(const struct http *hp, const char *hdr, char **ptr) return (1); } -/*-------------------------------------------------------------------- - * Find a given data element in a header according to RFC2616's #rule +/*----------------------------------------------------------------------------- + * Find a given data element (token) in a header according to RFC2616's #rule * (section 2.1, p15) + * + * On case sensitivity: + * + * Section 4.2 (Messages Headers) defines field (header) name as case + * insensitive, but the field (header) value/content may be case-sensitive. + * + * http_GetHdrToken looks up a token in a header value and the rfc does not say + * explicitly if tokens are to be compared with or without respect to case. + * + * But all examples and specific statements regarding tokens follow the rule + * that unquoted tokens are to be matched case-insensitively and quoted tokens + * case-sensitively. */ int -http_GetHdrData(const struct http *hp, const char *hdr, - const char *field, char **ptr) +http_GetHdrToken(const struct http *hp, const char *hdr, + const char *token, char **ptr) { char *h, *e; unsigned fl; + int quoted; if (ptr != NULL) *ptr = NULL; @@ -399,7 +413,9 @@ http_GetHdrData(const struct http *hp, const char *hdr, return (0); AN(h); e = strchr(h, '\0'); - fl = strlen(field); + fl = strlen(token); + quoted = token[0] == '"' && token[fl] == '"'; + while (h + fl <= e) { /* Skip leading whitespace and commas */ if (vct_islws(*h) || *h == ',') { @@ -408,7 +424,8 @@ http_GetHdrData(const struct http *hp, const char *hdr, } /* Check for substrings before memcmp() */ if ((h + fl == e || vct_issepctl(h[fl])) && - !memcmp(h, field, fl)) { + ((quoted && !memcmp(h, token, fl)) || + !strncasecmp(h, token, fl))) { if (ptr != NULL) { h += fl; while (vct_islws(*h)) @@ -436,7 +453,7 @@ http_GetHdrQ(const struct http *hp, const char *hdr, const char *field) double a, b; h = NULL; - i = http_GetHdrData(hp, hdr, field, &h); + i = http_GetHdrToken(hp, hdr, field, &h); if (!i) return (0.); @@ -489,7 +506,7 @@ http_GetHdrField(const struct http *hp, const char *hdr, *ptr = NULL; h = NULL; - i = http_GetHdrData(hp, hdr, field, &h); + i = http_GetHdrToken(hp, hdr, field, &h); if (!i) return (i); diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 75f74b5..b7737bc 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -322,7 +322,7 @@ RFC2616_Req_Gzip(const struct http *hp) * p104 says to not do q values for x-gzip, so we just test * for its existence. */ - if (http_GetHdrData(hp, H_Accept_Encoding, "x-gzip", NULL)) + if (http_GetHdrToken(hp, H_Accept_Encoding, "x-gzip", NULL)) return (1); /* @@ -395,7 +395,7 @@ RFC2616_Vary_AE(struct http *hp) { char *vary; - if (http_GetHdrData(hp, H_Vary, "Accept-Encoding", NULL)) + if (http_GetHdrToken(hp, H_Vary, "Accept-Encoding", NULL)) return; if (http_GetHdr(hp, H_Vary, &vary)) { http_Unset(hp, H_Vary); From nils.goroll at uplex.de Wed Aug 27 12:25:28 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 27 Aug 2014 14:25:28 +0200 Subject: [master] ceb6198 strings.h doesn't get included anywhere else where strncasecmp() is used Message-ID: commit ceb619862e09ec976278ea9a191d2e22087a19ea Author: Nils Goroll Date: Wed Aug 27 14:24:56 2014 +0200 strings.h doesn't get included anywhere else where strncasecmp() is used diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index acbee43..177919e 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -33,7 +33,6 @@ #include #include -#include #include "cache.h" From fgsch at lodoss.net Wed Aug 27 12:39:50 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 27 Aug 2014 14:39:50 +0200 Subject: [master] 05b7a36 Update filename references Message-ID: commit 05b7a36d8695a4cb55c657ae478c6704d9fd8fbf Author: Federico G. Schwindt Date: Wed Aug 27 13:11:44 2014 +0100 Update filename references diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 4b89207..08e8714 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -885,7 +885,7 @@ void CLI_AddFuncs(struct cli_proto *p); extern pthread_t cli_thread; #define ASSERT_CLI() do {assert(pthread_self() == cli_thread);} while (0) -/* cache_expiry.c */ +/* cache_expire.c */ void EXP_Clr(struct exp *e); double EXP_Ttl(const struct req *, const struct exp*); @@ -1236,7 +1236,7 @@ char *WS_Snapshot(struct ws *ws); int WS_Overflowed(const struct ws *ws); void *WS_Printf(struct ws *ws, const char *fmt, ...) __printflike(2, 3); -/* rfc2616.c */ +/* cache_rfc2616.c */ void RFC2616_Ttl(struct busyobj *, double now); enum body_status RFC2616_Body(struct busyobj *, struct dstat *); unsigned RFC2616_Req_Gzip(const struct http *); From nils.goroll at uplex.de Wed Aug 27 17:22:39 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 27 Aug 2014 19:22:39 +0200 Subject: [master] 6227fdf WS_Reserve shouldn't round down if we're not asking for too much Message-ID: commit 6227fdf3bba468f4645f3152033ce957debcbd2a Author: Nils Goroll Date: Wed Aug 27 18:07:43 2014 +0200 WS_Reserve shouldn't round down if we're not asking for too much diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index ccc887c..956fef4 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -202,13 +202,12 @@ WS_Reserve(struct ws *ws, unsigned bytes) WS_Assert(ws); assert(ws->r == NULL); - if (bytes == 0) - b2 = ws->e - ws->f; - else if (bytes > ws->e - ws->f) - b2 = ws->e - ws->f; - else - b2 = bytes; - b2 = PRNDDN(b2); + + b2 = PRNDDN(ws->e - ws->f); + if ((bytes != 0) && + (bytes < b2)) + b2 = PRNDUP(bytes); + xxxassert(ws->f + b2 <= ws->e); ws->r = ws->f + b2; DSL(DBG_WORKSPACE, 0, "WS_Reserve(%p, %u/%u) = %u", From nils.goroll at uplex.de Wed Aug 27 17:32:59 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 27 Aug 2014 19:32:59 +0200 Subject: [master] f5f1dc8 fight ocpd Message-ID: commit f5f1dc80076eff2348bfbae40faaf9a7faf9af8f Author: Nils Goroll Date: Wed Aug 27 19:30:51 2014 +0200 fight ocpd diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index 956fef4..3930c4d 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -204,8 +204,7 @@ WS_Reserve(struct ws *ws, unsigned bytes) assert(ws->r == NULL); b2 = PRNDDN(ws->e - ws->f); - if ((bytes != 0) && - (bytes < b2)) + if (bytes != 0 && bytes < b2) b2 = PRNDUP(bytes); xxxassert(ws->f + b2 <= ws->e); From nils.goroll at uplex.de Wed Aug 27 20:36:04 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 27 Aug 2014 22:36:04 +0200 Subject: [master] 77e82e8 Change exit code documentation so highest is most severe. Dont mention exit(4) Message-ID: commit 77e82e80d8c2ec638b615f72f005152d2555706b Author: Nils Goroll Date: Wed Aug 27 22:02:59 2014 +0200 Change exit code documentation so highest is most severe. Dont mention exit(4) After discussion with phk: exit(4) is a real exception, we should abort() whenever possible. The error codes patch is still to be committed. diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 3375f3f..6014637 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -256,15 +256,9 @@ Varnish and bundled tools will, in most cases, exit with one of the following codes * `0` OK -* `1` Configuration / parameter error -* `2` Some other error which could be system-dependend and/or transient - -In addition to these, the `varnishd` child process will exit with -status code `4` - -* in a panic situation when coredumps are disabled and -* in panic-like situations when triggering an actual panic is not - possible. +* `1` Some error which could be system-dependend and/or transient +* `2` Serious configuration / parameter error - retrying with the same + configuration / parameters is most likely useless The `varnishd` master process may also OR its exit code From phk at FreeBSD.org Thu Aug 28 08:24:18 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 28 Aug 2014 10:24:18 +0200 Subject: [master] 0c6ef77 Don't optimize out the (completed) bo for esi-children Message-ID: commit 0c6ef776600557f052ccc9532550c1ccf14bf1ae Author: Poul-Henning Kamp Date: Thu Aug 28 07:41:32 2014 +0000 Don't optimize out the (completed) bo for esi-children diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index e97d81d..14b45cf 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -169,7 +169,7 @@ cnt_deliver(struct worker *wrk, struct req *req) /* Grab a ref to the bo if there is one, and hand it down */ bo = HSH_RefBusy(req->objcore); - if (bo != NULL && bo->state == BOS_FINISHED) + if (bo != NULL && req->esi_level == 0 && bo->state == BOS_FINISHED) VBO_DerefBusyObj(wrk, &bo); V1D_Deliver(req, bo); if (bo != NULL) From phk at FreeBSD.org Thu Aug 28 08:24:18 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 28 Aug 2014 10:24:18 +0200 Subject: [master] f2caddc Fix a bug in setting *.ttl variables from VCL and go over testcases at the same time. Message-ID: commit f2caddcff6d2018604b2ab83ec9bf0e12ec4d51a Author: Poul-Henning Kamp Date: Thu Aug 28 08:23:38 2014 +0000 Fix a bug in setting *.ttl variables from VCL and go over testcases at the same time. Spotted by: UPLEX diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 0d639a7..93bbf04 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -483,17 +483,23 @@ VRT_r_bereq_retries(const struct vrt_ctx *ctx) } /*-------------------------------------------------------------------- - * NB: TTL is relative to when object was created, whereas grace and - * keep are relative to ttl. + * In exp.*: + * t_origin is absolute + * ttl is relative to t_origin + * grace&keep are relative to ttl + * In VCL: + * ttl is relative to now + * grace&keep are relative to ttl */ -#define VRT_DO_EXP_L(which, sexp, fld) \ +#define VRT_DO_EXP_L(which, sexp, fld, offset) \ \ void \ VRT_l_##which##_##fld(const struct vrt_ctx *ctx, double a) \ { \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + a += (offset); \ if (a < 0.0) \ a = 0.0; \ sexp.fld = a; \ @@ -506,23 +512,28 @@ VRT_l_##which##_##fld(const struct vrt_ctx *ctx, double a) \ double \ VRT_r_##which##_##fld(const struct vrt_ctx *ctx) \ { \ + double d; \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ - if (sexp.fld > 0.0) \ - return(sexp.fld - offset); \ - return(0.0); \ + d = sexp.fld; \ + if (d <= 0.0) \ + d = 0.0; \ + d -= (offset); \ + return(d); \ } VRT_DO_EXP_R(obj, ctx->req->objcore->exp, ttl, - (ctx->req->t_req - ctx->req->objcore->exp.t_origin)) + ctx->now - ctx->req->objcore->exp.t_origin) VRT_DO_EXP_R(obj, ctx->req->objcore->exp, grace, 0) VRT_DO_EXP_R(obj, ctx->req->objcore->exp, keep, 0) -VRT_DO_EXP_L(beresp, ctx->bo->fetch_objcore->exp, ttl) -VRT_DO_EXP_R(beresp, ctx->bo->fetch_objcore->exp, ttl, 0) -VRT_DO_EXP_L(beresp, ctx->bo->fetch_objcore->exp, grace) +VRT_DO_EXP_L(beresp, ctx->bo->fetch_objcore->exp, ttl, + ctx->now - ctx->bo->fetch_objcore->exp.t_origin) +VRT_DO_EXP_R(beresp, ctx->bo->fetch_objcore->exp, ttl, + ctx->now - ctx->bo->fetch_objcore->exp.t_origin) +VRT_DO_EXP_L(beresp, ctx->bo->fetch_objcore->exp, grace, 0) VRT_DO_EXP_R(beresp, ctx->bo->fetch_objcore->exp, grace, 0) -VRT_DO_EXP_L(beresp, ctx->bo->fetch_objcore->exp, keep) +VRT_DO_EXP_L(beresp, ctx->bo->fetch_objcore->exp, keep, 0) VRT_DO_EXP_R(beresp, ctx->bo->fetch_objcore->exp, keep, 0) /*-------------------------------------------------------------------- diff --git a/bin/varnishtest/tests/c00060.vtc b/bin/varnishtest/tests/c00060.vtc index ece157e..1e6e734 100644 --- a/bin/varnishtest/tests/c00060.vtc +++ b/bin/varnishtest/tests/c00060.vtc @@ -11,6 +11,7 @@ server s1 { txresp -status "304" \ -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ -hdr "Snafu: 2" \ + -hdr "Grifle: 3" \ -nolen } -start @@ -40,6 +41,7 @@ client c1 { rxresp expect resp.bodylen == 13 expect resp.http.foobar == foo0 + expect resp.http.grifle == 3 expect resp.http.snafu == 2a } -run diff --git a/bin/varnishtest/tests/r00956.vtc b/bin/varnishtest/tests/r00956.vtc index 85cca43..71dc617 100644 --- a/bin/varnishtest/tests/r00956.vtc +++ b/bin/varnishtest/tests/r00956.vtc @@ -7,6 +7,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_backend_response { + set beresp.http.fooA = beresp.ttl; set beresp.ttl = 10s; set beresp.http.fooB = beresp.ttl; } @@ -22,21 +23,22 @@ client c1 { txreq rxresp expect resp.bodylen == 40 + expect resp.http.fooA == 19.000 expect resp.http.fooB == 10.000 delay 2 txreq rxresp expect resp.bodylen == 40 - # XXX: should be: < 8 + expect resp.http.fooA == 19.000 expect resp.http.fooB == 10.000 - expect resp.http.foo != 10.000 - expect resp.http.foo != 9.000 + expect resp.http.foo <= 8.000 delay 2 txreq rxresp expect resp.bodylen == 40 + expect resp.http.fooA == 19.000 expect resp.http.fooB == 10.000 - expect resp.http.foo <= 5.000 + expect resp.http.foo <= 6.000 } -run diff --git a/bin/varnishtest/tests/r01578.vtc b/bin/varnishtest/tests/r01578.vtc index a72a3c9..4cf4904 100644 --- a/bin/varnishtest/tests/r01578.vtc +++ b/bin/varnishtest/tests/r01578.vtc @@ -21,7 +21,7 @@ client c1 { txreq rxresp expect resp.bodylen == 40 - expect resp.http.x-ttl == 23.000 + expect resp.http.x-ttl == 19.000 expect resp.http.Age == 4 @@ -29,13 +29,13 @@ client c1 { txreq rxresp expect resp.bodylen == 40 - expect resp.http.x-ttl == 23.000 - expect resp.http.x-remaining-ttl ~ ^17\.0|^16\.[89] + expect resp.http.x-ttl == 19.000 + expect resp.http.x-remaining-ttl <= 17.000 delay 2 txreq rxresp expect resp.bodylen == 40 - expect resp.http.x-ttl == 23.000 - expect resp.http.x-remaining-ttl ~ ^15\.0|^14\.[89] + expect resp.http.x-ttl == 19.000 + expect resp.http.x-remaining-ttl <= 15.000 } -run From nils.goroll at uplex.de Thu Aug 28 09:06:11 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 28 Aug 2014 11:06:11 +0200 Subject: [master] 71e00d5 update gzip docs Message-ID: commit 71e00d506a92bb0217a872fa1f2f18635f88f01b Author: Nils Goroll Date: Thu Aug 28 11:06:06 2014 +0200 update gzip docs diff --git a/doc/sphinx/users-guide/compression.rst b/doc/sphinx/users-guide/compression.rst index bff1ebb..e7cfda2 100644 --- a/doc/sphinx/users-guide/compression.rst +++ b/doc/sphinx/users-guide/compression.rst @@ -9,24 +9,47 @@ encoding. *Before* 3.0, Varnish would never compress objects. In Varnish 4.0 compression defaults to "on", meaning that it tries to be smart and do the sensible thing. -.. XXX:Heavy refactoring to Varnish 4 above. benc - If you don't want Varnish tampering with the encoding you can disable -compression all together by setting the parameter 'http_gzip_support' to +compression all together by setting the parameter `http_gzip_support` to false. Please see man :ref:`ref-varnishd` for details. Default behaviour ~~~~~~~~~~~~~~~~~ -The default behaviour for Varnish is to check if the client supports our -compression scheme (gzip) and if it does it will override the -'Accept-Encoding' header and set it to "gzip". +The default behaviour is active when the `http_gzip_support` parameter +is set to "on" and neither `beresp.do_gzip` nor `beresp.do_gunzip` are +used in VCL. + +Unless returning from `vcl_recv` with `pipe` or `pass`, varnish sets +`req.http.Accept-Encoding` to "gzip". It removes the header otherwise. + +Unless the request is a `pass`, Varnish will set +`bereq.http.Accept-Encoding` to "gzip" before `vcl_backend_fetch` +runs, so the header can be changed in VCL. + +If the server responds with gzip'ed content it will be stored in +memory in its compressed form and `Accept-Encoding` will be added to +the `Vary` header. + +To clients supporting gzip, compressed content is delivered +unmodified. + +For clients not supporting gzip, compressed content gets decompressed +on the fly while delivering. The `Content-Encoding` response header +gets removed and any `Etag` gets weakened (by prepending "W/"). -When Varnish then issues a backend request the 'Accept-Encoding' will -then only consist of "gzip". If the server responds with gzip'ed -content it will be stored in memory in its compressed form. If the -backend sends content in clear text it will be stored in clear text. +For Vary Lookups, `Accept-Encoding` is ignored. + +Turning off gzip support +~~~~~~~~~~~~~~~~~~~~~~~~ + +When the `http_gzip_support` parameter is set to "off", Varnish does +not do any of the header alterations documented above and handles +`Vary: Accept-Encoding` like it would for any other `Vary` value. + +Compressing content if backends don't +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can make Varnish compress content before storing it in cache in `vcl_backend_response` by setting 'do_gzip' to true, like this:: @@ -37,15 +60,41 @@ You can make Varnish compress content before storing it in cache in } } -Please make sure that you don't try to compress content that is -uncompressable, like jpgs, gifs and mp3. You'll only waste CPU -cycles. You can also uncompress objects before storing it in memory by -setting 'do_gunzip' to true but that will usually not be the most sensible thing to do. +With `do_gzip` Varnish will make the following alterations to the +headers of the resulting object which cannot be modified in a backend +VCL (but in `vcl_deliver`): + +* set `obj.http.Content-Encoding` to "gzip" +* add "Accept-Encoding" to `obj.http.Content-Encoding`, unless already + present +* weaken any `Etag` (by prepending "W/") + Generally, Varnish doesn't use much CPU so it might make more sense to have Varnish spend CPU cycles compressing content than doing it in your web- or application servers, which are more likely to be CPU-bound. +Please make sure that you don't try to compress content that is +uncompressable, like jpgs, gifs and mp3. You'll only waste CPU cycles. + +Uncompressing content before entering the cache +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also uncompress objects before storing it in memory by setting +`do_gunzip` to true. One use case for this feature is to work around +badly configured backends uselessly compressing already compressed +content like JPG images (but fixing the misbehaving backend is always +the better option). + +With `do_gzip` Varnish will make the following alterations to the +headers of the resulting object which cannot be modified in a backend +VCL (but in `vcl_deliver`): + +* remove `obj.http.Content-Encoding` to "gzip" +* remove any "Accept-Encoding" from `obj.http.Content-Encoding` + (XXX review when closing #940) +* weaken any `Etag` (by prepending "W/") + GZIP and ESI ~~~~~~~~~~~~ @@ -54,20 +103,6 @@ and GZIP work together really well. Varnish will magically decompress the content to do the ESI-processing, then recompress it for efficient storage and delivery. - -Clients that don't support gzip -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -If the client does not support gzip the 'Accept-Encoding' header is left -alone then we'll end up serving whatever we get from the backend -server. Remember that the backend might tell Varnish to *Vary* on the -'Accept-Encoding'. - -If the client does not support gzip but we've already got a compressed -version of the page in memory Varnish will automatically decompress -the page while delivering it. - - A random outburst ~~~~~~~~~~~~~~~~~ From nils.goroll at uplex.de Thu Aug 28 09:19:53 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 28 Aug 2014 11:19:53 +0200 Subject: [master] 1b952e0 fix a badly worded sentence, make choice of tense more consistent Message-ID: commit 1b952e03f79faf666803544ab50eee7e00b61f0e Author: Nils Goroll Date: Thu Aug 28 11:18:51 2014 +0200 fix a badly worded sentence, make choice of tense more consistent Thanks to fgs for reviewing diff --git a/doc/sphinx/users-guide/compression.rst b/doc/sphinx/users-guide/compression.rst index e7cfda2..2c3699e 100644 --- a/doc/sphinx/users-guide/compression.rst +++ b/doc/sphinx/users-guide/compression.rst @@ -21,10 +21,12 @@ The default behaviour is active when the `http_gzip_support` parameter is set to "on" and neither `beresp.do_gzip` nor `beresp.do_gunzip` are used in VCL. -Unless returning from `vcl_recv` with `pipe` or `pass`, varnish sets -`req.http.Accept-Encoding` to "gzip". It removes the header otherwise. +Unless returning from `vcl_recv` with `pipe` or `pass`, varnish +modifies `req.http.Accept-Encoding`: If the client supports gzip, +`req.http.Accept-Encoding` is set to "gzip". Otherwise, the header is +removed. -Unless the request is a `pass`, Varnish will set +Unless the request is a `pass`, Varnish sets `bereq.http.Accept-Encoding` to "gzip" before `vcl_backend_fetch` runs, so the header can be changed in VCL. From nils.goroll at uplex.de Thu Aug 28 10:28:44 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 28 Aug 2014 12:28:44 +0200 Subject: [master] 95448ac fix errors and clarify that do_g* are ignored when gzip support is off Message-ID: commit 95448acba72a51f7dcbc2da6482f68974ec77bef Author: Nils Goroll Date: Thu Aug 28 12:28:39 2014 +0200 fix errors and clarify that do_g* are ignored when gzip support is off diff --git a/doc/sphinx/users-guide/compression.rst b/doc/sphinx/users-guide/compression.rst index 2c3699e..bea7176 100644 --- a/doc/sphinx/users-guide/compression.rst +++ b/doc/sphinx/users-guide/compression.rst @@ -43,18 +43,11 @@ gets removed and any `Etag` gets weakened (by prepending "W/"). For Vary Lookups, `Accept-Encoding` is ignored. -Turning off gzip support -~~~~~~~~~~~~~~~~~~~~~~~~ - -When the `http_gzip_support` parameter is set to "off", Varnish does -not do any of the header alterations documented above and handles -`Vary: Accept-Encoding` like it would for any other `Vary` value. - Compressing content if backends don't ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can make Varnish compress content before storing it in cache in -`vcl_backend_response` by setting 'do_gzip' to true, like this:: +`vcl_backend_response` by setting `beresp.do_gzip` to true, like this:: sub vcl_backend_response { if (beresp.http.content-type ~ "text") { @@ -62,9 +55,9 @@ You can make Varnish compress content before storing it in cache in } } -With `do_gzip` Varnish will make the following alterations to the -headers of the resulting object which cannot be modified in a backend -VCL (but in `vcl_deliver`): +With `beresp.do_gzip` set to "true", Varnish will make the following +alterations to the headers of the resulting object which cannot be +modified in a backend VCL (but in `vcl_deliver`): * set `obj.http.Content-Encoding` to "gzip" * add "Accept-Encoding" to `obj.http.Content-Encoding`, unless already @@ -83,16 +76,16 @@ Uncompressing content before entering the cache ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also uncompress objects before storing it in memory by setting -`do_gunzip` to true. One use case for this feature is to work around -badly configured backends uselessly compressing already compressed -content like JPG images (but fixing the misbehaving backend is always -the better option). +`beresp.do_gunzip` to true. One use case for this feature is to work +around badly configured backends uselessly compressing already +compressed content like JPG images (but fixing the misbehaving backend +is always the better option). -With `do_gzip` Varnish will make the following alterations to the -headers of the resulting object which cannot be modified in a backend -VCL (but in `vcl_deliver`): +With `beresp.do_gunzip` Varnish will make the following alterations to +the headers of the resulting object which cannot be modified in a +backend VCL (but in `vcl_deliver`): -* remove `obj.http.Content-Encoding` to "gzip" +* remove `obj.http.Content-Encoding` * remove any "Accept-Encoding" from `obj.http.Content-Encoding` (XXX review when closing #940) * weaken any `Etag` (by prepending "W/") @@ -103,7 +96,15 @@ GZIP and ESI If you are using Edge Side Includes (ESIs) you'll be happy to note that ESI and GZIP work together really well. Varnish will magically decompress the content to do the ESI-processing, then recompress it for efficient -storage and delivery. +storage and delivery. + +Turning off gzip support +~~~~~~~~~~~~~~~~~~~~~~~~ + +When the `http_gzip_support` parameter is set to "off", Varnish does +not do any of the header alterations documented above, handles `Vary: +Accept-Encoding` like it would for any other `Vary` value and ignores +`beresp.do_gzip` and `beresp.do_gunzip`. A random outburst ~~~~~~~~~~~~~~~~~ From nils.goroll at uplex.de Thu Aug 28 10:42:27 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 28 Aug 2014 12:42:27 +0200 Subject: [master] 33e6fe7 varnishd: streamline exit codes, fix exit codes for vsubs Message-ID: commit 33e6fe71743059b912d2b00cdbc08196b003e440 Author: Nils Goroll Date: Thu Aug 28 12:32:08 2014 +0200 varnishd: streamline exit codes, fix exit codes for vsubs This should bring us closer to the exit codes now documented in varnishd.rst Fixes #1572 for varnishd diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index ecdc6d8..4f4a8f6 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -117,7 +117,7 @@ void STV_Config_Transient(void); /* mgt_vcc.c */ void mgt_vcc_init(void); -int mgt_vcc_default(const char *bflag, const char *f_arg, char *vcl, int Cflag); +unsigned mgt_vcc_default(const char *bflag, const char *f_arg, char *vcl, int Cflag); int mgt_push_vcls_and_start(unsigned *status, char **p); int mgt_has_vcl(void); extern char *mgt_cc_cmd; diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 1ae0c0e..1fe8473 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -425,7 +425,7 @@ mgt_launch_child(struct cli *cli) child_main(); - exit(1); + exit(0); } assert(pid > 1); REPORT(LOG_NOTICE, "child (%jd) Started", (intmax_t)pid); @@ -683,7 +683,7 @@ mgt_sigint(const struct vev *e, int what) (void)fflush(stdout); if (child_pid >= 0) mgt_stop_child(); - exit (2); + exit(0); } /*--------------------------------------------------------------------*/ @@ -753,6 +753,7 @@ MGT_Run(void) else if (!d_flag) { mgt_launch_child(NULL); if (child_state == CH_STOPPED) { + // XXX correct? or 0? exit_status = 2; return; } diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index e7d7aa2..21fecfb 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -499,17 +499,17 @@ mgt_cli_secret(const char *S_arg) fd = open(S_arg, O_RDONLY); if (fd < 0) { fprintf(stderr, "Can not open secret-file \"%s\"\n", S_arg); - exit (2); + exit(2); } mgt_got_fd(fd); i = read(fd, buf, sizeof buf); if (i == 0) { fprintf(stderr, "Empty secret-file \"%s\"\n", S_arg); - exit (2); + exit(2); } if (i < 0) { fprintf(stderr, "Can not read secret-file \"%s\"\n", S_arg); - exit (2); + exit(2); } AZ(close(fd)); secret_file = S_arg; @@ -644,7 +644,7 @@ mgt_cli_master(const char *M_arg) M_nta = VSS_resolve(M_arg, NULL, &M_ta); if (M_nta <= 0) { fprintf(stderr, "Could resolve -M argument to address\n"); - exit (1); + exit(2); } M_nxt = 0; AZ(M_poker); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 76b702b..ea7f950 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -199,7 +199,7 @@ cli_check(const struct cli *cli) } AZ(VSB_finish(cli->sb)); fprintf(stderr, "Error:\n%s\n", VSB_data(cli->sb)); - exit (2); + exit(2); } /*-------------------------------------------------------------------- @@ -559,11 +559,11 @@ main(int argc, char * const *argv) case 'x': if (!strcmp(optarg, "dumprstparam")) { MCF_DumpRstParam(); - exit (0); + exit(0); } if (!strcmp(optarg, "dumprstvsl")) { mgt_DumpRstVsl(); - exit (0); + exit(0); } usage(); break; @@ -651,11 +651,11 @@ main(int argc, char * const *argv) P_arg, strerror(errno)); if (b_arg != NULL || f_arg != NULL) - if (mgt_vcc_default(b_arg, f_arg, vcl, C_flag)) - exit (2); + if ((o = mgt_vcc_default(b_arg, f_arg, vcl, C_flag)) != 0) + exit(o); if (C_flag) - exit (0); + exit(0); if (!d_flag) { if (MGT_open_sockets()) diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 500916e..abfd86a 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -175,7 +175,7 @@ mcf_wrap(struct cli *cli, const char *text) if (r == NULL) { fprintf(stderr, "LINE with just one TAB: <%s>\n", text); - exit(2); + exit(4); } if (r - q > tw) tw = r - q; @@ -385,11 +385,11 @@ MCF_AddParams(struct parspec *ps) if (isspace(s[-1])) { fprintf(stderr, "Param->descr has trailing space: %s\n", pp->name); - exit(2); + exit(4); } if (mcf_findpar(pp->name) != NULL) { fprintf(stderr, "Duplicate param: %s\n", pp->name); - exit(2); + exit(4); } if (strlen(pp->name) + 1 > margin2) margin2 = strlen(pp->name) + 1; diff --git a/bin/varnishd/mgt/mgt_sandbox_solaris.c b/bin/varnishd/mgt/mgt_sandbox_solaris.c index 9ead087..c664cc2 100644 --- a/bin/varnishd/mgt/mgt_sandbox_solaris.c +++ b/bin/varnishd/mgt/mgt_sandbox_solaris.c @@ -236,7 +236,7 @@ mgt_sandbox_solaris_add_inheritable(priv_set_t *pset, enum sandbox_e who) break; default: REPORT(LOG_ERR, "INCOMPLETE AT: %s(%d)\n", __func__, __LINE__); - exit(1); + exit(4); } } @@ -263,7 +263,7 @@ mgt_sandbox_solaris_add_effective(priv_set_t *pset, enum sandbox_e who) break; default: REPORT(LOG_ERR, "INCOMPLETE AT: %s(%d)\n", __func__, __LINE__); - exit(1); + exit(4); } } @@ -286,7 +286,7 @@ mgt_sandbox_solaris_add_permitted(priv_set_t *pset, enum sandbox_e who) break; default: REPORT(LOG_ERR, "INCOMPLETE AT: %s(%d)\n", __func__, __LINE__); - exit(1); + exit(4); } } diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index 130b48f..ed020f7 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -100,7 +100,7 @@ vsm_n_check(void) struct stat st; pid_t pid; struct VSM_head vsmh; - int retval = 2; + int retval = 1; fd = open(VSM_FILENAME, O_RDWR, 0644); if (fd < 0) @@ -217,7 +217,7 @@ mgt_SHM_Create(void) if (p == MAP_FAILED) { fprintf(stderr, "Mmap error %s: %s\n", fnbuf, strerror(errno)); - exit (-1); + exit(1); } mgt_vsm_p = p; @@ -250,7 +250,7 @@ mgt_SHM_Create(void) fprintf(stderr, "Rename failed %s -> %s: %s\n", fnbuf, VSM_FILENAME, strerror(errno)); (void)unlink(fnbuf); - exit (-1); + exit(1); } #ifdef __OpenBSD__ @@ -325,7 +325,7 @@ mgt_SHM_Init(void) /* Collision check with already running varnishd */ i = vsm_n_check(); if (i) - exit(i); + exit(2); /* Create our static VSM instance */ static_vsm = VSM_common_new(static_vsm_buf, sizeof static_vsm_buf); diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 4d97de6..b76b016 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -151,22 +151,22 @@ run_vcc(void *priv) printf("%s", VSB_data(sb)); VSB_delete(sb); if (csrc == NULL) - exit (1); + exit(2); fd = open(vp->sf, O_WRONLY); if (fd < 0) { fprintf(stderr, "Cannot open %s", vp->sf); - exit (1); + exit(2); } l = strlen(csrc); i = write(fd, csrc, l); if (i != l) { fprintf(stderr, "Cannot write %s", vp->sf); - exit (1); + exit(2); } AZ(close(fd)); free(csrc); - exit (0); + exit(0); } /*-------------------------------------------------------------------- @@ -228,7 +228,7 @@ run_dlopen(void *priv) */ static char * -mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag) +mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag, unsigned *status) { char *csrc; struct vsb *cmdsb; @@ -236,12 +236,16 @@ mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag) char of[sizeof sf + 1]; char *retval; int sfd, i; + unsigned subs; struct vcc_priv vp; + *status = 0; + /* Create temporary C source file */ sfd = VFIL_tmpfile(sf); if (sfd < 0) { VSB_printf(sb, "Failed to create %s: %s", sf, strerror(errno)); + *status = 2; return (NULL); } (void)fchown(sfd, mgt_param.uid, mgt_param.gid); @@ -253,8 +257,10 @@ mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag) vp.magic = VCC_PRIV_MAGIC; vp.sf = sf; vp.vcl = vcl; - if (VSUB_run(sb, run_vcc, &vp, "VCC-compiler", -1)) { + subs = VSUB_run(sb, run_vcc, &vp, "VCC-compiler", -1); + if (subs) { (void)unlink(sf); + *status = subs; return (NULL); } @@ -277,6 +283,7 @@ mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag) VSB_printf(sb, "Failed to create %s: %s", of, strerror(errno)); (void)unlink(sf); + *status = 2; return (NULL); } (void)fchown(i, mgt_param.uid, mgt_param.gid); @@ -286,24 +293,27 @@ mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag) cmdsb = mgt_make_cc_cmd(sf, of); /* Run the C-compiler in a sub-shell */ - i = VSUB_run(sb, run_cc, VSB_data(cmdsb), "C-compiler", 10); + subs = VSUB_run(sb, run_cc, VSB_data(cmdsb), "C-compiler", 10); (void)unlink(sf); VSB_delete(cmdsb); - if (!i) - i = VSUB_run(sb, run_dlopen, of, "dlopen", 10); + if (!subs) + subs = VSUB_run(sb, run_dlopen, of, "dlopen", 10); /* Ensure the file is readable to the unprivileged user */ - if (!i) { + if (!subs) { i = chmod(of, 0755); - if (i) + if (i) { VSB_printf(sb, "Failed to set permissions on %s: %s", of, strerror(errno)); + subs = 2; + } } - if (i) { + if (subs) { (void)unlink(of); + *status = subs; return (NULL); } @@ -315,13 +325,13 @@ mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag) /*--------------------------------------------------------------------*/ static char * -mgt_VccCompile(struct vsb **sb, const char *b, int C_flag) +mgt_VccCompile(struct vsb **sb, const char *b, int C_flag, unsigned *status) { char *vf; *sb = VSB_new_auto(); XXXAN(*sb); - vf = mgt_run_cc(b, *sb, C_flag); + vf = mgt_run_cc(b, *sb, C_flag, status); AZ(VSB_finish(*sb)); return (vf); } @@ -380,13 +390,14 @@ mgt_vcc_delbyname(const char *name) /*--------------------------------------------------------------------*/ -int +unsigned mgt_vcc_default(const char *b_arg, const char *f_arg, char *vcl, int C_flag) { char *vf; struct vsb *sb; struct vclprog *vp; char buf[BUFSIZ]; + unsigned status = 0; /* XXX: annotate vcl with -b/-f arg so people know where it came from */ (void)f_arg; @@ -411,7 +422,7 @@ mgt_vcc_default(const char *b_arg, const char *f_arg, char *vcl, int C_flag) } strcpy(buf, "boot"); - vf = mgt_VccCompile(&sb, vcl, C_flag); + vf = mgt_VccCompile(&sb, vcl, C_flag, &status); free(vcl); if (VSB_len(sb) > 0) fprintf(stderr, "%s", VSB_data(sb)); @@ -419,13 +430,13 @@ mgt_vcc_default(const char *b_arg, const char *f_arg, char *vcl, int C_flag) if (C_flag && vf != NULL) AZ(unlink(vf)); if (vf == NULL) { + assert(status != 0); fprintf(stderr, "\nVCL compilation failed\n"); - return (1); } else { vp = mgt_vcc_add(buf, vf); vp->active = 1; - return (0); } + return (status); } /*--------------------------------------------------------------------*/ @@ -511,11 +522,12 @@ mcf_config_inline(struct cli *cli, const char * const *av, void *priv) return; } - vf = mgt_VccCompile(&sb, av[3], 0); + vf = mgt_VccCompile(&sb, av[3], 0, &status); if (VSB_len(sb) > 0) VCLI_Out(cli, "%s\n", VSB_data(sb)); VSB_delete(sb); if (vf == NULL) { + assert(status != 0); VCLI_Out(cli, "VCL compilation failed"); VCLI_SetResult(cli, CLIS_PARAM); return; @@ -536,7 +548,7 @@ mcf_config_load(struct cli *cli, const char * const *av, void *priv) { char *vf, *vcl; struct vsb *sb; - unsigned status; + unsigned status = 0; char *p = NULL; struct vclprog *vp; @@ -555,13 +567,14 @@ mcf_config_load(struct cli *cli, const char * const *av, void *priv) return; } - vf = mgt_VccCompile(&sb, vcl, 0); + vf = mgt_VccCompile(&sb, vcl, 0, &status); free(vcl); if (VSB_len(sb) > 0) VCLI_Out(cli, "%s", VSB_data(sb)); VSB_delete(sb); if (vf == NULL) { + assert(status != 0); VCLI_Out(cli, "VCL compilation failed"); VCLI_SetResult(cli, CLIS_PARAM); return; diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 3d0e006..863ad25 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -443,7 +443,7 @@ smf_open(const struct stevedore *st) /* XXX */ if (sum < MINPAGES * (off_t)getpagesize()) - exit (2); + exit(4); sc->stats->g_space += sc->filesize; } diff --git a/include/vsub.h b/include/vsub.h index 6705b11..274663a 100644 --- a/include/vsub.h +++ b/include/vsub.h @@ -31,5 +31,5 @@ /* from libvarnish/subproc.c */ typedef void vsub_func_f(void*); -int VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name, +unsigned VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name, int maxlines); diff --git a/lib/libvarnish/vsub.c b/lib/libvarnish/vsub.c index 497119c..ffe93ab 100644 --- a/lib/libvarnish/vsub.c +++ b/lib/libvarnish/vsub.c @@ -64,7 +64,8 @@ vsub_vlu(void *priv, const char *str) return (0); } -int +/* returns an exit code */ +unsigned VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name, int maxlines) { @@ -81,7 +82,7 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name, if (pipe(p) < 0) { VSB_printf(sb, "Starting %s: pipe() failed: %s", name, strerror(errno)); - return (-1); + return (1); } assert(p[0] > STDERR_FILENO); assert(p[1] > STDERR_FILENO); @@ -90,7 +91,7 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name, name, strerror(errno)); AZ(close(p[0])); AZ(close(p[1])); - return (-1); + return (1); } if (pid == 0) { AZ(close(STDIN_FILENO)); @@ -101,7 +102,12 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name, for (sfd = STDERR_FILENO + 1; sfd < 100; sfd++) (void)close(sfd); func(priv); - _exit(1); + /* + * func should either exec or exit, so getting here should be + * treated like an assertion failure - except that we don't know + * if it's save to trigger an acutal assertion + */ + _exit(4); } AZ(close(p[1])); vlu = VLU_New(&sp, vsub_vlu, 0); @@ -117,19 +123,19 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name, if (rv < 0 && errno != EINTR) { VSB_printf(sb, "Running %s: waitpid() failed: %s\n", name, strerror(errno)); - return (-1); + return (1); } } while (rv < 0); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { VSB_printf(sb, "Running %s failed", name); if (WIFEXITED(status)) - VSB_printf(sb, ", exit %d", WEXITSTATUS(status)); + VSB_printf(sb, ", exited with %d", WEXITSTATUS(status)); if (WIFSIGNALED(status)) VSB_printf(sb, ", signal %d", WTERMSIG(status)); if (WCOREDUMP(status)) VSB_printf(sb, ", core dumped"); VSB_printf(sb, "\n"); - return (-1); + return (WEXITSTATUS(status)); } return (0); } diff --git a/lib/libvarnish/vtim.c b/lib/libvarnish/vtim.c index c0efdbd..50033c2 100644 --- a/lib/libvarnish/vtim.c +++ b/lib/libvarnish/vtim.c @@ -224,7 +224,7 @@ tst(const char *s, time_t good) if (t != good) { printf("Parse error! Got: %jd should have %jd diff %jd\n", (intmax_t)t, (intmax_t)good, (intmax_t)(t - good)); - exit (2); + exit(4); } } @@ -267,7 +267,7 @@ tst_delta() if (err) { printf("%d time delta test errrors\n", err); - exit (2); + exit(4); } } From nils.goroll at uplex.de Thu Aug 28 10:42:27 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 28 Aug 2014 12:42:27 +0200 Subject: [master] dae4cee tools: streamline exit codes, fix exit codes for vsubs Message-ID: commit dae4ceeb6b6a310f254c22b60f674c9dfaf3999d Author: Nils Goroll Date: Thu Aug 28 12:35:33 2014 +0200 tools: streamline exit codes, fix exit codes for vsubs This should bring us closer to the exit codes now documented in varnishd.rst Fixes #1572 for tools diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 259094e..fbb2f4d 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -82,7 +82,7 @@ openout(int append) else LOG.fo = fopen(LOG.w_arg, append ? "a" : "w"); if (LOG.fo == NULL) - VUT_Error(1, "Can't open output file (%s)", + VUT_Error(2, "Can't open output file (%s)", LOG.B_opt ? VSL_Error(VUT.vsl) : strerror(errno)); VUT.dispatch_priv = LOG.fo; } diff --git a/lib/libvarnishtools/vut.c b/lib/libvarnishtools/vut.c index d943d8f..50a9f27 100644 --- a/lib/libvarnishtools/vut.c +++ b/lib/libvarnishtools/vut.c @@ -159,7 +159,7 @@ VUT_Arg(int opt, const char *arg) case 'V': /* Print version number and exit */ VCS_Message(VUT.progname); - exit(1); + exit(0); default: AN(VUT.vsl); i = VSL_Arg(VUT.vsl, opt, arg); From nils.goroll at uplex.de Thu Aug 28 11:02:07 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 28 Aug 2014 13:02:07 +0200 Subject: [master] 58c2793 Fix a header name confusion Message-ID: commit 58c27934c430dd1f0bac13dc5ab685f02f885acd Author: Nils Goroll Date: Thu Aug 28 13:01:18 2014 +0200 Fix a header name confusion Thanks to dridi.boukelmoune at zenika.com for reporting. diff --git a/doc/sphinx/users-guide/compression.rst b/doc/sphinx/users-guide/compression.rst index bea7176..a046311 100644 --- a/doc/sphinx/users-guide/compression.rst +++ b/doc/sphinx/users-guide/compression.rst @@ -60,8 +60,7 @@ alterations to the headers of the resulting object which cannot be modified in a backend VCL (but in `vcl_deliver`): * set `obj.http.Content-Encoding` to "gzip" -* add "Accept-Encoding" to `obj.http.Content-Encoding`, unless already - present +* add "Accept-Encoding" to `obj.http.Vary`, unless already present * weaken any `Etag` (by prepending "W/") Generally, Varnish doesn't use much CPU so it might make more sense to @@ -86,7 +85,7 @@ the headers of the resulting object which cannot be modified in a backend VCL (but in `vcl_deliver`): * remove `obj.http.Content-Encoding` -* remove any "Accept-Encoding" from `obj.http.Content-Encoding` +* remove any "Accept-Encoding" from `obj.http.Vary` (XXX review when closing #940) * weaken any `Etag` (by prepending "W/") From fgsch at lodoss.net Thu Aug 28 17:04:55 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 28 Aug 2014 19:04:55 +0200 Subject: [master] d2e6acd Update names and examples for V4 Message-ID: commit d2e6acd15863e33ae450555c8def3cc3807a75f2 Author: Federico G. Schwindt Date: Thu Aug 28 18:04:30 2014 +0100 Update names and examples for V4 diff --git a/doc/sphinx/phk/gzip.rst b/doc/sphinx/phk/gzip.rst index 4200db8..ae244d9 100644 --- a/doc/sphinx/phk/gzip.rst +++ b/doc/sphinx/phk/gzip.rst @@ -55,9 +55,9 @@ Varnish will not gzip any content on its own (but see below), we trust the backend to know what content can be sensibly gzip'ed (html) and what can not (jpeg) -If in vcl_fetch{} we find out that we are trying to deliver a gzip'ed object -to a client that has not indicated willingness to receive gzip, we will -ungzip the object during deliver. +If in vcl_backend_response{} we find out that we are trying to deliver a +gzip'ed object to a client that has not indicated willingness to receive +gzip, we will ungzip the object during deliver. Tuning, tweaking and frobbing ----------------------------- @@ -74,8 +74,8 @@ gunzip the object before delivering to the client. In vcl_miss{} you can remove the "Accept-Encoding: gzip" header, if you do not want the backend to gzip this object. -In vcl_fetch{} two new variables allow you to modify the gzip-ness of -objects during fetch: +In vcl_backend_response{} two new variables allow you to modify the +gzip-ness of objects during fetch: set beresp.do_gunzip = true; @@ -91,8 +91,8 @@ Remember that a lot of content types cannot sensibly be gziped, most notably compressed image formats like jpeg, png and similar, so a typical use would be:: - sub vcl_fetch { - if (req.url ~ "html$") { + sub vcl_backend_response { + if (bereq.url ~ "html$") { set beresp.do_gzip = true; } } @@ -102,7 +102,7 @@ GZIP and ESI First, note the new syntax for activating ESI:: - sub vcl_fetch { + sub vcl_backend_response { set beresp.do_esi = true; } @@ -155,7 +155,7 @@ compression efficiency, you should:: } } - sub vcl_fetch { + sub vcl_backend_response { if (object needs ESI processing) { set beresp.do_esi = true; set beresp.do_gzip = true; From fgsch at lodoss.net Thu Aug 28 17:08:01 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 28 Aug 2014 19:08:01 +0200 Subject: [master] d45a1f5 Wording and whatnot Message-ID: commit d45a1f5e1a57fe65810a567cde5c3389caed7ed4 Author: Federico G. Schwindt Date: Thu Aug 28 18:06:34 2014 +0100 Wording and whatnot Also hide a might-be change until it's really implemented. diff --git a/doc/sphinx/users-guide/compression.rst b/doc/sphinx/users-guide/compression.rst index a046311..50c5c86 100644 --- a/doc/sphinx/users-guide/compression.rst +++ b/doc/sphinx/users-guide/compression.rst @@ -13,7 +13,6 @@ If you don't want Varnish tampering with the encoding you can disable compression all together by setting the parameter `http_gzip_support` to false. Please see man :ref:`ref-varnishd` for details. - Default behaviour ~~~~~~~~~~~~~~~~~ @@ -21,24 +20,23 @@ The default behaviour is active when the `http_gzip_support` parameter is set to "on" and neither `beresp.do_gzip` nor `beresp.do_gunzip` are used in VCL. -Unless returning from `vcl_recv` with `pipe` or `pass`, varnish -modifies `req.http.Accept-Encoding`: If the client supports gzip, -`req.http.Accept-Encoding` is set to "gzip". Otherwise, the header is +Unless returning from `vcl_recv` with `pipe` or `pass`, Varnish +modifies `req.http.Accept-Encoding`: if the client supports gzip +`req.http.Accept-Encoding` is set to "gzip", otherwise the header is removed. -Unless the request is a `pass`, Varnish sets -`bereq.http.Accept-Encoding` to "gzip" before `vcl_backend_fetch` -runs, so the header can be changed in VCL. +Unless the request is a `pass`, Varnish sets `bereq.http.Accept-Encoding` +to "gzip" before `vcl_backend_fetch` runs, so the header can be changed +in VCL. -If the server responds with gzip'ed content it will be stored in -memory in its compressed form and `Accept-Encoding` will be added to -the `Vary` header. +If the server responds with gzip'ed content it will be stored in memory +in its compressed form and `Accept-Encoding` will be added to the +`Vary` header. -To clients supporting gzip, compressed content is delivered -unmodified. +To clients supporting gzip, compressed content is delivered unmodified. For clients not supporting gzip, compressed content gets decompressed -on the fly while delivering. The `Content-Encoding` response header +on the fly while delivering it. The `Content-Encoding` response header gets removed and any `Etag` gets weakened (by prepending "W/"). For Vary Lookups, `Accept-Encoding` is ignored. @@ -46,54 +44,53 @@ For Vary Lookups, `Accept-Encoding` is ignored. Compressing content if backends don't ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -You can make Varnish compress content before storing it in cache in -`vcl_backend_response` by setting `beresp.do_gzip` to true, like this:: +You can tell Varnish to compress content before storing it in cache in +`vcl_backend_response` by setting `beresp.do_gzip` to "true", like this:: - sub vcl_backend_response { + sub vcl_backend_response { if (beresp.http.content-type ~ "text") { - set beresp.do_gzip = true; + set beresp.do_gzip = true; } - } + } With `beresp.do_gzip` set to "true", Varnish will make the following -alterations to the headers of the resulting object which cannot be -modified in a backend VCL (but in `vcl_deliver`): +changes to the headers of the resulting object before inserting it in +the cache: * set `obj.http.Content-Encoding` to "gzip" * add "Accept-Encoding" to `obj.http.Vary`, unless already present * weaken any `Etag` (by prepending "W/") Generally, Varnish doesn't use much CPU so it might make more sense to -have Varnish spend CPU cycles compressing content than doing it in -your web- or application servers, which are more likely to be -CPU-bound. +have Varnish spend CPU cycles compressing content than doing it in your +web- or application servers, which are more likely to be CPU-bound. Please make sure that you don't try to compress content that is -uncompressable, like jpgs, gifs and mp3. You'll only waste CPU cycles. +uncompressable, like JPG, GIF and MP3 files. You'll only waste CPU cycles. Uncompressing content before entering the cache ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -You can also uncompress objects before storing it in memory by setting -`beresp.do_gunzip` to true. One use case for this feature is to work -around badly configured backends uselessly compressing already -compressed content like JPG images (but fixing the misbehaving backend -is always the better option). +You can also uncompress content before storing it in cache by setting +`beresp.do_gunzip` to "true". One use case for this feature is to work +around badly configured backends uselessly compressing already compressed +content like JPG images (but fixing the misbehaving backend is always +the better option). -With `beresp.do_gunzip` Varnish will make the following alterations to -the headers of the resulting object which cannot be modified in a -backend VCL (but in `vcl_deliver`): +With `beresp.do_gunzip` set to "true", Varnish will make the following +changes to the headers of the resulting object before inserting it in +the cache: * remove `obj.http.Content-Encoding` -* remove any "Accept-Encoding" from `obj.http.Vary` - (XXX review when closing #940) * weaken any `Etag` (by prepending "W/") +.. XXX pending closing #940: remove any "Accept-Encoding" from `obj.http.Vary` + GZIP and ESI ~~~~~~~~~~~~ -If you are using Edge Side Includes (ESIs) you'll be happy to note that ESI -and GZIP work together really well. Varnish will magically decompress +If you are using Edge Side Includes (ESI) you'll be happy to note that +ESI and GZIP work together really well. Varnish will magically decompress the content to do the ESI-processing, then recompress it for efficient storage and delivery. @@ -108,5 +105,5 @@ Accept-Encoding` like it would for any other `Vary` value and ignores A random outburst ~~~~~~~~~~~~~~~~~ -Poul-Henning Kamp has written :ref:`phk_gzip` which talks a bit more about how the -implementation works. +Poul-Henning Kamp has written :ref:`phk_gzip` which talks a bit more +about how the implementation works. From nils.goroll at uplex.de Fri Aug 29 12:32:23 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 29 Aug 2014 14:32:23 +0200 Subject: [master] 842f542 fix a typo Message-ID: commit 842f54244a7bb640d8528b14736731c082825d5b Author: Nils Goroll Date: Fri Aug 29 14:32:19 2014 +0200 fix a typo diff --git a/lib/libvarnish/vas.c b/lib/libvarnish/vas.c index d63763d..9380b6c 100644 --- a/lib/libvarnish/vas.c +++ b/lib/libvarnish/vas.c @@ -49,7 +49,7 @@ VAS_Fail_default(const char *func, const char *file, int line, func, file, line, cond); } else if (kind == VAS_INCOMPLETE) { fprintf(stderr, - "Incompelte code in %s(), %s line %d:\n", + "Incomplete code in %s(), %s line %d:\n", func, file, line); } else if (kind == VAS_WRONG) { fprintf(stderr, From nils.goroll at uplex.de Fri Aug 29 12:45:54 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 29 Aug 2014 14:45:54 +0200 Subject: [master] be4def8 Return 2 from VSUB_run() when the sub process dies with a signal. Message-ID: commit be4def865167e6d20fec7f67aa7cfa245928ea95 Author: Nils Goroll Date: Fri Aug 29 14:44:36 2014 +0200 Return 2 from VSUB_run() when the sub process dies with a signal. Fixes a regression from 33e6fe71743059b912d2b00cdbc08196b003e440 Fixes #1585 diff --git a/lib/libvarnish/vsub.c b/lib/libvarnish/vsub.c index ffe93ab..767ec5a 100644 --- a/lib/libvarnish/vsub.c +++ b/lib/libvarnish/vsub.c @@ -127,15 +127,21 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name, } } while (rv < 0); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { + rv = -1; VSB_printf(sb, "Running %s failed", name); - if (WIFEXITED(status)) - VSB_printf(sb, ", exited with %d", WEXITSTATUS(status)); - if (WIFSIGNALED(status)) + if (WIFEXITED(status)) { + rv = WEXITSTATUS(status); + VSB_printf(sb, ", exited with %d", rv); + } + if (WIFSIGNALED(status)) { + rv = 2; VSB_printf(sb, ", signal %d", WTERMSIG(status)); + } if (WCOREDUMP(status)) VSB_printf(sb, ", core dumped"); VSB_printf(sb, "\n"); - return (WEXITSTATUS(status)); + assert(rv != -1); + return (rv); } return (0); } From nils.goroll at uplex.de Fri Aug 29 12:51:16 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 29 Aug 2014 14:51:16 +0200 Subject: [master] b786d41 panic with INCOMPL() rather than exit(4) Message-ID: commit b786d418992467ca97046df9273f3b65d28b6486 Author: Nils Goroll Date: Fri Aug 29 14:50:31 2014 +0200 panic with INCOMPL() rather than exit(4) Fixes #1583 diff --git a/bin/varnishd/mgt/mgt_sandbox_solaris.c b/bin/varnishd/mgt/mgt_sandbox_solaris.c index c664cc2..1d1bb06 100644 --- a/bin/varnishd/mgt/mgt_sandbox_solaris.c +++ b/bin/varnishd/mgt/mgt_sandbox_solaris.c @@ -235,8 +235,7 @@ mgt_sandbox_solaris_add_inheritable(priv_set_t *pset, enum sandbox_e who) case SANDBOX_WORKER: break; default: - REPORT(LOG_ERR, "INCOMPLETE AT: %s(%d)\n", __func__, __LINE__); - exit(4); + INCOMPL(); } } @@ -262,8 +261,7 @@ mgt_sandbox_solaris_add_effective(priv_set_t *pset, enum sandbox_e who) priv_setop_assert(priv_addset(pset, "file_write")); break; default: - REPORT(LOG_ERR, "INCOMPLETE AT: %s(%d)\n", __func__, __LINE__); - exit(4); + INCOMPL(); } } @@ -285,8 +283,7 @@ mgt_sandbox_solaris_add_permitted(priv_set_t *pset, enum sandbox_e who) AZ(priv_addset(pset, PRIV_SYS_RESOURCE)); break; default: - REPORT(LOG_ERR, "INCOMPLETE AT: %s(%d)\n", __func__, __LINE__); - exit(4); + INCOMPL(); } } From nils.goroll at uplex.de Fri Aug 29 13:48:48 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 29 Aug 2014 15:48:48 +0200 Subject: [master] 03e41c5 Add an informative warning when only starting the master process in daemon mode Message-ID: commit 03e41c53a6251bc606c183db2dd1e6ec26c63d2e Author: Nils Goroll Date: Fri Aug 29 15:47:47 2014 +0200 Add an informative warning when only starting the master process in daemon mode Fixes #1580 diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index ea7f950..28b4823 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -661,6 +661,12 @@ main(int argc, char * const *argv) if (MGT_open_sockets()) ARGV_ERR("Failed to open (any) accept sockets.\n"); MGT_close_sockets(); + + if (b_arg == NULL && f_arg == NULL) { + fprintf(stderr, + "Warning: Neither -b nor -f given, won't start a worker child.\n" + " Master process started, use varnishadm to control it.\n"); + } } /* If no -s argument specified, process default -s argument */ From nils.goroll at uplex.de Fri Aug 29 16:05:11 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 29 Aug 2014 18:05:11 +0200 Subject: [master] 7701175 make the update interval a double to allow values < 1 Message-ID: commit 77011756f6619a7f31948887d1ea8cb5acdb778e Author: Nils Goroll Date: Fri Aug 29 18:04:56 2014 +0200 make the update interval a double to allow values < 1 diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 6fa7cc7..2f41daa 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -273,7 +273,8 @@ main(int argc, char * const *argv) { int c; struct VSM_data *vd; - int delay = 1, once = 0, xml = 0, json = 0, do_repeat = 0, f_list = 0; + double delay = 1.0; + int once = 0, xml = 0, json = 0, do_repeat = 0, f_list = 0; vd = VSM_New(); @@ -290,7 +291,7 @@ main(int argc, char * const *argv) exit(0); case 'w': do_repeat = 1; - delay = atoi(optarg); + delay = atof(optarg); break; case 'x': xml = 1; @@ -332,7 +333,7 @@ main(int argc, char * const *argv) // end of output block marker. printf("\n"); - sleep(delay); + usleep(delay * 1e6); } exit(0); } diff --git a/bin/varnishstat/varnishstat.h b/bin/varnishstat/varnishstat.h index 89dee92..18d3def 100644 --- a/bin/varnishstat/varnishstat.h +++ b/bin/varnishstat/varnishstat.h @@ -35,4 +35,4 @@ #include "vas.h" #include "vcs.h" -void do_curses(struct VSM_data *vd, int delay); +void do_curses(struct VSM_data *vd, double delay); diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 8ce35f1..4d63e71 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -908,7 +908,7 @@ handle_keypress(int ch) } void -do_curses(struct VSM_data *vd, int delay) +do_curses(struct VSM_data *vd, double delay) { struct pollfd pollfd; long t; From nils.goroll at uplex.de Fri Aug 29 16:09:13 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 29 Aug 2014 18:09:13 +0200 Subject: [master] bf1fd86 should ignore return value of usleep() Message-ID: commit bf1fd868925020d3213e8915baa8978bf6fdcaa2 Author: Nils Goroll Date: Fri Aug 29 18:09:09 2014 +0200 should ignore return value of usleep() diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 2f41daa..f5153b4 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -333,7 +333,7 @@ main(int argc, char * const *argv) // end of output block marker. printf("\n"); - usleep(delay * 1e6); + (void)usleep(delay * 1e6); } exit(0); }