From phk at FreeBSD.org Tue May 1 09:45:27 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 1 May 2018 09:45:27 +0000 (UTC) Subject: [master] 1d06da5 Generailize VDI_Resolve() Message-ID: <20180501094527.82E6C9818B@lists.varnish-cache.org> commit 1d06da56bb1518a75457535a3abd9dc02b7b0d11 Author: Poul-Henning Kamp Date: Tue May 1 07:48:16 2018 +0000 Generailize VDI_Resolve() diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 985d142..25cff72 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -40,7 +40,6 @@ #include "cache_director.h" #include "vcli_serve.h" -#include "vcl.h" #include "vtim.h" /* -------------------------------------------------------------------*/ @@ -77,8 +76,8 @@ VDI_Ahealth(const struct director *d) /* Resolve director --------------------------------------------------*/ -static const struct director * -vdi_resolve(struct busyobj *bo) +static VCL_BACKEND +VDI_Resolve(struct busyobj *bo) { const struct director *d; const struct director *d2; @@ -104,7 +103,6 @@ vdi_resolve(struct busyobj *bo) VSLb(bo->vsl, SLT_FetchError, "No backend"); else AN(d->vdir); - bo->director_resp = d; return (d); } @@ -119,8 +117,9 @@ VDI_GetHdr(struct worker *wrk, struct busyobj *bo) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - d = vdi_resolve(bo); + d = VDI_Resolve(bo); if (d != NULL) { + bo->director_resp = d; AN(d->methods->gethdrs); bo->director_state = DIR_S_HDRS; i = d->methods->gethdrs(d, wrk, bo); @@ -202,11 +201,12 @@ VDI_Http1Pipe(struct req *req, struct busyobj *bo) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - d = vdi_resolve(bo); + d = VDI_Resolve(bo); if (d == NULL || d->methods->http1pipe == NULL) { VSLb(bo->vsl, SLT_VCL_Error, "Backend does not support pipe"); return (SC_TX_ERROR); } + bo->director_resp = d; return (d->methods->http1pipe(d, req, bo)); } From phk at FreeBSD.org Tue May 1 09:45:27 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 1 May 2018 09:45:27 +0000 (UTC) Subject: [master] 0f28caf Dont lie about being in inside vcl_backend_fetch{} when we're not. Message-ID: <20180501094527.74BBE98182@lists.varnish-cache.org> commit 0f28cafa6fb2f5b2190af9d57abd2b540ef909b2 Author: Poul-Henning Kamp Date: Tue May 1 07:12:18 2018 +0000 Dont lie about being in inside vcl_backend_fetch{} when we're not. diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index e97c174..2c4012e 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -96,7 +96,7 @@ vdi_resolve(struct busyobj *bo) ctx.sp = bo->sp; ctx.now = bo->t_prev; ctx.ws = bo->ws; - ctx.method = VCL_MET_BACKEND_FETCH; // XXX: Not quite true + ctx.method = 0; for (d = bo->director_req; d != NULL && d->methods->resolve != NULL; d = d2) { diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index a470c6e..0eabffa 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -879,7 +879,7 @@ vmod_shard_param_read(VRT_CTX, const void *id, CHECK_OBJ_NOTNULL(p, VMOD_SHARD_SHARD_PARAM_MAGIC); (void) who; // XXX - if (ctx->method & VCL_MET_TASK_B) + if (ctx->method == 0 || (ctx->method & VCL_MET_TASK_B)) p = shard_param_task(ctx, id, p); if (p == NULL) From phk at FreeBSD.org Tue May 1 09:45:27 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 1 May 2018 09:45:27 +0000 (UTC) Subject: [master] 4d0bf7a Give the director methods VMOD friendly arguments Message-ID: <20180501094527.921189818E@lists.varnish-cache.org> commit 4d0bf7ab3f776fc41f48628089c4cb49e24af5bd Author: Poul-Henning Kamp Date: Tue May 1 09:44:21 2018 +0000 Give the director methods VMOD friendly arguments diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index c5bf86a..e1ed9a8 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -154,14 +154,15 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo, } static void v_matchproto_(vdi_finish_f) -vbe_dir_finish(const struct director *d, struct worker *wrk, - struct busyobj *bo) +vbe_dir_finish(VRT_CTX, VCL_BACKEND d) { struct backend *bp; + struct busyobj *bo; struct pfd *pfd; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + bo = ctx->bo; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC); @@ -183,7 +184,7 @@ vbe_dir_finish(const struct director *d, struct worker *wrk, VRT_BACKEND_string(bp->director)); Lck_Lock(&bp->mtx); VSC_C_main->backend_recycle++; - VTP_Recycle(wrk, &pfd); + VTP_Recycle(bo->wrk, &pfd); } assert(bp->n_conn > 0); bp->n_conn--; @@ -196,17 +197,21 @@ vbe_dir_finish(const struct director *d, struct worker *wrk, } static int v_matchproto_(vdi_gethdrs_f) -vbe_dir_gethdrs(const struct director *d, struct worker *wrk, - struct busyobj *bo) +vbe_dir_gethdrs(VRT_CTX, VCL_BACKEND d) { int i, extrachance = 1; struct backend *bp; struct pfd *pfd; + struct busyobj *bo; + struct worker *wrk; char abuf[VTCP_ADDRBUFSIZE], pbuf[VTCP_PORTBUFSIZE]; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + bo = ctx->bo; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + wrk = ctx->bo->wrk; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC); /* @@ -254,7 +259,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk, * that the backend closed it before we got the bereq to it. * In that case do a single automatic retry if req.body allows. */ - vbe_dir_finish(d, wrk, bo); + vbe_dir_finish(ctx, d); AZ(bo->htc); if (i < 0 || extrachance == 0) break; @@ -267,25 +272,24 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk, return (-1); } -static const struct suckaddr * v_matchproto_(vdi_getip_f) -vbe_dir_getip(const struct director *d, struct worker *wrk, - struct busyobj *bo) +static VCL_IP v_matchproto_(vdi_getip_f) +vbe_dir_getip(VRT_CTX, VCL_BACKEND d) { struct pfd *pfd; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC); - pfd = bo->htc->priv; + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo->htc, HTTP_CONN_MAGIC); + pfd = ctx->bo->htc->priv; return (VTP_getip(pfd)); } /*--------------------------------------------------------------------*/ -static enum sess_close -vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo) +static enum sess_close v_matchproto_(vdi_http1pipe_f) +vbe_dir_http1pipe(VRT_CTX, VCL_BACKEND d) { int i; enum sess_close retval; @@ -294,37 +298,38 @@ vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo) struct pfd *pfd; char abuf[VTCP_ADDRBUFSIZE], pbuf[VTCP_PORTBUFSIZE]; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC); memset(&v1a, 0, sizeof v1a); /* This is hackish... */ - v1a.req = req->acct.req_hdrbytes; - req->acct.req_hdrbytes = 0; + v1a.req = ctx->req->acct.req_hdrbytes; + ctx->req->acct.req_hdrbytes = 0; - req->res_mode = RES_PIPE; + ctx->req->res_mode = RES_PIPE; - pfd = vbe_dir_getfd(req->wrk, bp, bo, 0); + pfd = vbe_dir_getfd(ctx->req->wrk, bp, ctx->bo, 0); if (pfd == NULL) { retval = SC_TX_ERROR; } else { - CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo->htc, HTTP_CONN_MAGIC); PFD_RemoteName(pfd, abuf, sizeof abuf, pbuf, sizeof pbuf); - i = V1F_SendReq(req->wrk, bo, &v1a.bereq, &v1a.out, 1, abuf, - pbuf); - VSLb_ts_req(req, "Pipe", W_TIM_real(req->wrk)); + i = V1F_SendReq(ctx->req->wrk, ctx->bo, + &v1a.bereq, &v1a.out, 1, abuf, pbuf); + VSLb_ts_req(ctx->req, "Pipe", W_TIM_real(ctx->req->wrk)); if (i == 0) - V1P_Process(req, *PFD_Fd(pfd), &v1a); - VSLb_ts_req(req, "PipeSess", W_TIM_real(req->wrk)); - bo->htc->doclose = SC_TX_PIPE; - vbe_dir_finish(d, req->wrk, bo); + V1P_Process(ctx->req, *PFD_Fd(pfd), &v1a); + VSLb_ts_req(ctx->req, "PipeSess", W_TIM_real(ctx->req->wrk)); + ctx->bo->htc->doclose = SC_TX_PIPE; + vbe_dir_finish(ctx, d); retval = SC_TX_PIPE; } - V1P_Charge(req, &v1a, bp->vsc); + V1P_Charge(ctx->req, &v1a, bp->vsc); return (retval); } diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 25cff72..cedb41b 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -77,23 +77,21 @@ VDI_Ahealth(const struct director *d) /* Resolve director --------------------------------------------------*/ static VCL_BACKEND -VDI_Resolve(struct busyobj *bo) +VDI_Resolve(VRT_CTX) { const struct director *d; const struct director *d2; - struct vrt_ctx ctx; + struct busyobj *bo; + bo = ctx->bo; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_ORNULL(bo->director_req, DIRECTOR_MAGIC); - INIT_OBJ(&ctx, VRT_CTX_MAGIC); - VCL_Bo2Ctx(&ctx, bo); - for (d = bo->director_req; d != NULL && d->methods->resolve != NULL; d = d2) { CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); AN(d->vdir); - d2 = d->methods->resolve(&ctx, d); + d2 = d->methods->resolve(ctx, d); if (d2 == NULL) VSLb(bo->vsl, SLT_FetchError, "Director %s returned no backend", d->vcl_name); @@ -109,20 +107,22 @@ VDI_Resolve(struct busyobj *bo) /* Get a set of response headers -------------------------------------*/ int -VDI_GetHdr(struct worker *wrk, struct busyobj *bo) +VDI_GetHdr(struct busyobj *bo) { const struct director *d; + struct vrt_ctx ctx[1]; int i = -1; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + INIT_OBJ(ctx, VRT_CTX_MAGIC); + VCL_Bo2Ctx(ctx, bo); - d = VDI_Resolve(bo); + d = VDI_Resolve(ctx); if (d != NULL) { bo->director_resp = d; AN(d->methods->gethdrs); bo->director_state = DIR_S_HDRS; - i = d->methods->gethdrs(d, wrk, bo); + i = d->methods->gethdrs(ctx, d); } if (i) bo->director_state = DIR_S_NULL; @@ -132,12 +132,14 @@ VDI_GetHdr(struct worker *wrk, struct busyobj *bo) /* Setup body fetch --------------------------------------------------*/ int -VDI_GetBody(struct worker *wrk, struct busyobj *bo) +VDI_GetBody(struct busyobj *bo) { const struct director *d; + struct vrt_ctx ctx[1]; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + INIT_OBJ(ctx, VRT_CTX_MAGIC); + VCL_Bo2Ctx(ctx, bo); d = bo->director_resp; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); @@ -147,18 +149,20 @@ VDI_GetBody(struct worker *wrk, struct busyobj *bo) bo->director_state = DIR_S_BODY; if (d->methods->getbody == NULL) return (0); - return (d->methods->getbody(d, wrk, bo)); + return (d->methods->getbody(ctx, d)); } /* Get IP number (if any ) -------------------------------------------*/ -const struct suckaddr * -VDI_GetIP(struct worker *wrk, struct busyobj *bo) +VCL_IP +VDI_GetIP(struct busyobj *bo) { const struct director *d; + struct vrt_ctx ctx[1]; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + INIT_OBJ(ctx, VRT_CTX_MAGIC); + VCL_Bo2Ctx(ctx, bo); d = bo->director_resp; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); @@ -167,18 +171,20 @@ VDI_GetIP(struct worker *wrk, struct busyobj *bo) AZ(d->methods->resolve); if (d->methods->getip == NULL) return (NULL); - return (d->methods->getip(d, wrk, bo)); + return (d->methods->getip(ctx, d)); } /* Finish fetch ------------------------------------------------------*/ void -VDI_Finish(struct worker *wrk, struct busyobj *bo) +VDI_Finish(struct busyobj *bo) { const struct director *d; + struct vrt_ctx ctx[1]; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + INIT_OBJ(ctx, VRT_CTX_MAGIC); + VCL_Bo2Ctx(ctx, bo); d = bo->director_resp; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); @@ -187,7 +193,7 @@ VDI_Finish(struct worker *wrk, struct busyobj *bo) AN(d->methods->finish); assert(bo->director_state != DIR_S_NULL); - d->methods->finish(d, wrk, bo); + d->methods->finish(ctx, d); bo->director_state = DIR_S_NULL; } @@ -197,17 +203,21 @@ enum sess_close VDI_Http1Pipe(struct req *req, struct busyobj *bo) { const struct director *d; + struct vrt_ctx ctx[1]; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + INIT_OBJ(ctx, VRT_CTX_MAGIC); + VCL_Req2Ctx(ctx, req); + VCL_Bo2Ctx(ctx, bo); - d = VDI_Resolve(bo); + d = VDI_Resolve(ctx); if (d == NULL || d->methods->http1pipe == NULL) { VSLb(bo->vsl, SLT_VCL_Error, "Backend does not support pipe"); return (SC_TX_ERROR); } bo->director_resp = d; - return (d->methods->http1pipe(d, req, bo)); + return (d->methods->http1pipe(ctx, d)); } /* Check health -------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index 7cce8cf..9697533 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -41,22 +41,14 @@ struct vcldir; typedef VCL_BOOL vdi_healthy_f(VRT_CTX, VCL_BACKEND, VCL_TIME *); typedef VCL_BACKEND vdi_resolve_f(VRT_CTX, VCL_BACKEND); - -typedef int vdi_gethdrs_f(VCL_BACKEND, struct worker *, struct busyobj *); -typedef int vdi_getbody_f(VCL_BACKEND, struct worker *, struct busyobj *); -typedef const struct suckaddr *vdi_getip_f(VCL_BACKEND, - struct worker *, struct busyobj *); -typedef void vdi_finish_f(VCL_BACKEND, struct worker *, struct busyobj *); - -typedef enum sess_close vdi_http1pipe_f(VCL_BACKEND, struct req *, - struct busyobj *); - +typedef int vdi_gethdrs_f(VRT_CTX, VCL_BACKEND); +typedef int vdi_getbody_f(VRT_CTX, VCL_BACKEND); +typedef VCL_IP vdi_getip_f(VRT_CTX, VCL_BACKEND); +typedef void vdi_finish_f(VRT_CTX, VCL_BACKEND); +typedef enum sess_close vdi_http1pipe_f(VRT_CTX, VCL_BACKEND); typedef void vdi_event_f(VCL_BACKEND, enum vcl_event_e); - typedef void vdi_destroy_f(VCL_BACKEND); - typedef void vdi_panic_f(VCL_BACKEND, struct vsb *); - typedef void vdi_list_f(VCL_BACKEND, struct vsb *, int, int); struct director_methods { diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index f0b5fcf..4427cae 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -290,7 +290,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) bo->vfc->resp = bo->beresp; bo->vfc->req = bo->bereq; - i = VDI_GetHdr(wrk, bo); + i = VDI_GetHdr(bo); now = W_TIM_real(wrk); VSLb_ts_busyobj(bo, "Beresp", now); @@ -304,7 +304,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (bo->htc->body_status == BS_ERROR) { bo->htc->doclose = SC_RX_BODY; - VDI_Finish(bo->wrk, bo); + VDI_Finish(bo); VSLb(bo->vsl, SLT_Error, "Body cannot be fetched"); assert(bo->director_state == DIR_S_NULL); return (F_STP_ERROR); @@ -375,7 +375,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) VSLb(bo->vsl, SLT_Error, "304 response but not conditional fetch"); bo->htc->doclose = SC_RX_BAD; - VDI_Finish(bo->wrk, bo); + VDI_Finish(bo); return (F_STP_ERROR); } } @@ -384,7 +384,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL) { bo->htc->doclose = SC_RESP_CLOSE; - VDI_Finish(bo->wrk, bo); + VDI_Finish(bo); return (F_STP_FAIL); } @@ -392,7 +392,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (bo->htc->body_status != BS_NONE) bo->htc->doclose = SC_RESP_CLOSE; if (bo->director_state != DIR_S_NULL) - VDI_Finish(bo->wrk, bo); + VDI_Finish(bo); if (bo->retries++ < cache_param->max_retries) return (F_STP_RETRY); @@ -483,7 +483,7 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) (void)VFP_Error(vfc, "Fetch pipeline failed to process"); bo->htc->doclose = SC_RX_BODY; VFP_Close(vfc); - VDI_Finish(wrk, bo); + VDI_Finish(bo); if (!bo->do_stream) { assert(bo->fetch_objcore->boc->state < BOS_STREAM); // XXX: doclose = ? @@ -612,7 +612,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->filter_list == NULL || VCL_StackVFP(bo->vfc, bo->vcl, bo->filter_list)) { (bo)->htc->doclose = SC_OVERLOAD; - VDI_Finish((bo)->wrk, bo); + VDI_Finish(bo); return (F_STP_ERROR); } @@ -624,7 +624,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (VFP_Open(bo->vfc)) { (void)VFP_Error(bo->vfc, "Fetch pipeline failed to open"); bo->htc->doclose = SC_RX_BODY; - VDI_Finish(bo->wrk, bo); + VDI_Finish(bo); return (F_STP_ERROR); } @@ -632,7 +632,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) (void)VFP_Error(bo->vfc, "Could not get storage"); bo->htc->doclose = SC_RX_BODY; VFP_Close(bo->vfc); - VDI_Finish(bo->wrk, bo); + VDI_Finish(bo); return (F_STP_ERROR); } @@ -648,12 +648,12 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 1); if (bo->htc->body_status != BS_NONE && - VDI_GetBody(bo->wrk, bo) != 0) { + VDI_GetBody(bo) != 0) { (void)VFP_Error(bo->vfc, "GetBody failed - workspace_backend overflow?"); VFP_Close(bo->vfc); bo->htc->doclose = SC_OVERLOAD; - VDI_Finish(bo->wrk, bo); + VDI_Finish(bo); return (F_STP_ERROR); } @@ -698,7 +698,7 @@ vbf_stp_fetchend(struct worker *wrk, struct busyobj *bo) /* Recycle the backend connection before setting BOS_FINISHED to give predictable backend reuse behavior for varnishtest */ - VDI_Finish(bo->wrk, bo); + VDI_Finish(bo); ObjSetState(wrk, bo->fetch_objcore, BOS_FINISHED); VSLb_ts_busyobj(bo, "BerespBody", W_TIM_real(wrk)); @@ -763,7 +763,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) if (bo->stale_oc->flags & OC_F_FAILED) (void)VFP_Error(bo->vfc, "Template object failed"); if (bo->vfc->failed) { - VDI_Finish(bo->wrk, bo); + VDI_Finish(bo); wrk->stats->fetch_failed++; return (F_STP_FAIL); } diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index 1475686..90b9631 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -116,10 +116,10 @@ struct busyobj *VBO_GetBusyObj(struct worker *, const struct req *); void VBO_ReleaseBusyObj(struct worker *wrk, struct busyobj **busyobj); /* cache_director.c */ -int VDI_GetHdr(struct worker *, struct busyobj *); -int VDI_GetBody(struct worker *, struct busyobj *); -const struct suckaddr *VDI_GetIP(struct worker *, struct busyobj *); -void VDI_Finish(struct worker *wrk, struct busyobj *bo); +int VDI_GetHdr(struct busyobj *); +int VDI_GetBody(struct busyobj *); +VCL_IP VDI_GetIP(struct busyobj *); +void VDI_Finish(struct busyobj *bo); enum sess_close VDI_Http1Pipe(struct req *, struct busyobj *); void VDI_Panic(const struct director *, struct vsb *, const char *nm); void VDI_Event(const struct director *d, enum vcl_event_e ev); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 90d9e0d..d62e9cd 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -337,7 +337,7 @@ VRT_r_beresp_backend_ip(VRT_CTX) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - return (VDI_GetIP(ctx->bo->wrk, ctx->bo)); + return (VDI_GetIP(ctx->bo)); } /*--------------------------------------------------------------------*/ From phk at FreeBSD.org Tue May 1 09:45:27 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 1 May 2018 09:45:27 +0000 (UTC) Subject: [master] 5f7eef6 Make two functions to get from req/bo to VRT_CTX Message-ID: <20180501094527.7E8AB9818A@lists.varnish-cache.org> commit 5f7eef62fdf542bd3e4cda21da102bf83a311367 Author: Poul-Henning Kamp Date: Tue May 1 07:37:27 2018 +0000 Make two functions to get from req/bo to VRT_CTX diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 2c4012e..985d142 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -88,15 +88,7 @@ vdi_resolve(struct busyobj *bo) CHECK_OBJ_ORNULL(bo->director_req, DIRECTOR_MAGIC); INIT_OBJ(&ctx, VRT_CTX_MAGIC); - ctx.vcl = bo->vcl; - ctx.vsl = bo->vsl; - ctx.http_bereq = bo->bereq; - ctx.http_beresp = bo->beresp; - ctx.bo = bo; - ctx.sp = bo->sp; - ctx.now = bo->t_prev; - ctx.ws = bo->ws; - ctx.method = 0; + VCL_Bo2Ctx(&ctx, bo); for (d = bo->director_req; d != NULL && d->methods->resolve != NULL; d = d2) { diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index d80b347..1475686 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -389,6 +389,9 @@ void VCL_Refresh(struct vcl **); void VCL_Rel(struct vcl **); const char *VCL_Return_Name(unsigned); const char *VCL_Method_Name(unsigned); +void VCL_Bo2Ctx(struct vrt_ctx *, struct busyobj *); +void VCL_Req2Ctx(struct vrt_ctx *, struct req *); + #define VCL_MET_MAC(l,u,t,b) \ void VCL_##l##_method(struct vcl *, struct worker *, struct req *, \ struct busyobj *bo, void *specific); diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 178ae2c..ed57193 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -69,6 +69,42 @@ static uintptr_t ws_snapshot_cli; /*--------------------------------------------------------------------*/ +void +VCL_Bo2Ctx(struct vrt_ctx *ctx, struct busyobj *bo) +{ + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + ctx->vcl = bo->vcl; + ctx->vsl = bo->vsl; + ctx->http_bereq = bo->bereq; + ctx->http_beresp = bo->beresp; + ctx->bo = bo; + ctx->sp = bo->sp; + ctx->now = bo->t_prev; + ctx->ws = bo->ws; +} + +void +VCL_Req2Ctx(struct vrt_ctx *ctx, struct req *req) +{ + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + + ctx->vcl = req->vcl; + ctx->vsl = req->vsl; + ctx->http_req = req->http; + ctx->http_req_top = req->top->http; + ctx->http_resp = req->resp; + ctx->req = req; + ctx->sp = req->sp; + ctx->now = req->t_prev; + ctx->ws = req->ws; +} + +/*--------------------------------------------------------------------*/ + static struct vrt_ctx * vcl_get_ctx(unsigned method, int msg) { diff --git a/bin/varnishd/cache/cache_vcl_vrt.c b/bin/varnishd/cache/cache_vcl_vrt.c index 6e45c9f..b97aae1 100644 --- a/bin/varnishd/cache/cache_vcl_vrt.c +++ b/bin/varnishd/cache/cache_vcl_vrt.c @@ -401,7 +401,6 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, void *specific, unsigned method, vcl_func_f *func) { uintptr_t aws; - struct vsl_log *vsl = NULL; struct vrt_ctx ctx; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -410,33 +409,17 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_MAGIC); - vsl = req->vsl; - ctx.vcl = req->vcl; - ctx.http_req = req->http; - ctx.http_req_top = req->top->http; - ctx.http_resp = req->resp; - ctx.req = req; - ctx.sp = req->sp; - ctx.now = req->t_prev; - ctx.ws = req->ws; + VCL_Req2Ctx(&ctx, req); } if (bo != NULL) { if (req) assert(method == VCL_MET_PIPE); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo->vcl, VCL_MAGIC); - vsl = bo->vsl; - ctx.vcl = bo->vcl; - ctx.http_bereq = bo->bereq; - ctx.http_beresp = bo->beresp; - ctx.bo = bo; - ctx.sp = bo->sp; - ctx.now = bo->t_prev; - ctx.ws = bo->ws; + VCL_Bo2Ctx(&ctx, bo); } assert(ctx.now != 0); ctx.syntax = ctx.vcl->conf->syntax; - ctx.vsl = vsl; ctx.specific = specific; ctx.method = method; wrk->handling = 0; @@ -444,10 +427,10 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, aws = WS_Snapshot(wrk->aws); wrk->cur_method = method; wrk->seen_methods |= method; - AN(vsl); - VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method)); + AN(ctx.vsl); + VSLb(ctx.vsl, SLT_VCL_call, "%s", VCL_Method_Name(method)); func(&ctx); - VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); + VSLb(ctx.vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); wrk->cur_method |= 1; // Magic marker if (wrk->handling == VCL_RET_FAIL) wrk->stats->vcl_fail++; From phk at FreeBSD.org Tue May 1 13:06:16 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 1 May 2018 13:06:16 +0000 (UTC) Subject: [master] cc8f349 Chop a part of cache_director.h into vrt.h, taking the rest of the file off-limits for VMODs. Message-ID: <20180501130616.4FD67A30EE@lists.varnish-cache.org> commit cc8f349f809d4a91761bec73d2e4a92792690349 Author: Poul-Henning Kamp Date: Tue May 1 13:04:34 2018 +0000 Chop a part of cache_director.h into vrt.h, taking the rest of the file off-limits for VMODs. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index e1ed9a8..88a28cd 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -40,7 +40,6 @@ #include "vtcp.h" #include "vtim.h" -#include "cache_director.h" #include "cache_backend.h" #include "cache_tcp_pool.h" #include "cache_transport.h" @@ -88,7 +87,7 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo, CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC); AN(bp->vsc); - if (!bp->director->health) { + if (bp->director->sick) { VSLb(bo->vsl, SLT_FetchError, "backend %s: unhealthy", VRT_BACKEND_string(bp->director)); // XXX: per backend stats ? @@ -422,14 +421,14 @@ vbe_list(const struct director *d, struct vsb *vsb, int vflag, int pflag) if (bp->probe != NULL) VBP_Status(vsb, bp, vflag | pflag); else - VSB_printf(vsb, "%-10s", d->health ? "healthy" : "sick"); + VSB_printf(vsb, "%-10s", d->sick ? "sick" : "healthy"); } /*-------------------------------------------------------------------- */ -static const struct director_methods vbe_methods[1] = {{ - .magic = DIRECTOR_METHODS_MAGIC, +static const struct vdi_methods vbe_methods[1] = {{ + .magic = VDI_METHODS_MAGIC, .type = "backend", .http1pipe = vbe_dir_http1pipe, .gethdrs = vbe_dir_gethdrs, diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index dbf0520..37b6016 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -49,7 +49,6 @@ #include "vtcp.h" #include "vtim.h" -#include "cache_director.h" #include "cache_backend.h" #include "cache_tcp_pool.h" @@ -168,22 +167,22 @@ vbp_update_backend(struct vbp_target *vt) assert(i < sizeof bits); if (vt->good >= vt->threshold) { - if (vt->backend->director->health) { - logmsg = "Still healthy"; - } else { + if (vt->backend->director->sick) { logmsg = "Back healthy"; VRT_SetHealth(vt->backend->director, 1); + } else { + logmsg = "Still healthy"; } } else { - if (vt->backend->director->health) { + if (vt->backend->director->sick) { + logmsg = "Still sick"; + } else { logmsg = "Went sick"; VRT_SetHealth(vt->backend->director, 0); - } else { - logmsg = "Still sick"; } } VSL(SLT_Backend_health, 0, "%s %s %s %u %u %u %.6f %.6f %s", - vt->backend->director->cli_name, logmsg, bits, + vt->backend->director->vcl_name, logmsg, bits, vt->good, vt->threshold, vt->window, vt->last, vt->avg, vt->resp_buf); VBE_SetHappy(vt->backend, vt->happy); @@ -485,7 +484,7 @@ VBP_Status(struct vsb *vsb, const struct backend *be, int details) if (!details) { bprintf(buf, "%d/%d %s", vt->good, vt->window, - vt->backend->director->health ? "good" : "bad"); + vt->backend->director->sick ? "bad" : "good"); VSB_printf(vsb, "%-10s", buf); return; } diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index cedb41b..feff1b7 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -65,13 +65,13 @@ VBE_AHEALTH_LIST return (NULL); } -const char * +static const char * VDI_Ahealth(const struct director *d) { CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - AN(d->admin_health); - return (d->admin_health->name); + AN(d->vdir->admin_health); + return (d->vdir->admin_health->name); } /* Resolve director --------------------------------------------------*/ @@ -88,10 +88,10 @@ VDI_Resolve(VRT_CTX) CHECK_OBJ_ORNULL(bo->director_req, DIRECTOR_MAGIC); for (d = bo->director_req; d != NULL && - d->methods->resolve != NULL; d = d2) { + d->vdir->methods->resolve != NULL; d = d2) { CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); AN(d->vdir); - d2 = d->methods->resolve(ctx, d); + d2 = d->vdir->methods->resolve(ctx, d); if (d2 == NULL) VSLb(bo->vsl, SLT_FetchError, "Director %s returned no backend", d->vcl_name); @@ -120,9 +120,9 @@ VDI_GetHdr(struct busyobj *bo) d = VDI_Resolve(ctx); if (d != NULL) { bo->director_resp = d; - AN(d->methods->gethdrs); + AN(d->vdir->methods->gethdrs); bo->director_state = DIR_S_HDRS; - i = d->methods->gethdrs(ctx, d); + i = d->vdir->methods->gethdrs(ctx, d); } if (i) bo->director_state = DIR_S_NULL; @@ -143,13 +143,13 @@ VDI_GetBody(struct busyobj *bo) d = bo->director_resp; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - AZ(d->methods->resolve); + AZ(d->vdir->methods->resolve); assert(bo->director_state == DIR_S_HDRS); bo->director_state = DIR_S_BODY; - if (d->methods->getbody == NULL) + if (d->vdir->methods->getbody == NULL) return (0); - return (d->methods->getbody(ctx, d)); + return (d->vdir->methods->getbody(ctx, d)); } /* Get IP number (if any ) -------------------------------------------*/ @@ -168,10 +168,10 @@ VDI_GetIP(struct busyobj *bo) CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); assert(bo->director_state == DIR_S_HDRS || bo->director_state == DIR_S_BODY); - AZ(d->methods->resolve); - if (d->methods->getip == NULL) + AZ(d->vdir->methods->resolve); + if (d->vdir->methods->getip == NULL) return (NULL); - return (d->methods->getip(ctx, d)); + return (d->vdir->methods->getip(ctx, d)); } /* Finish fetch ------------------------------------------------------*/ @@ -189,11 +189,11 @@ VDI_Finish(struct busyobj *bo) d = bo->director_resp; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - AZ(d->methods->resolve); - AN(d->methods->finish); + AZ(d->vdir->methods->resolve); + AN(d->vdir->methods->finish); assert(bo->director_state != DIR_S_NULL); - d->methods->finish(ctx, d); + d->vdir->methods->finish(ctx, d); bo->director_state = DIR_S_NULL; } @@ -212,12 +212,12 @@ VDI_Http1Pipe(struct req *req, struct busyobj *bo) VCL_Bo2Ctx(ctx, bo); d = VDI_Resolve(ctx); - if (d == NULL || d->methods->http1pipe == NULL) { + if (d == NULL || d->vdir->methods->http1pipe == NULL) { VSLb(bo->vsl, SLT_VCL_Error, "Backend does not support pipe"); return (SC_TX_ERROR); } bo->director_resp = d; - return (d->methods->http1pipe(ctx, d)); + return (d->vdir->methods->http1pipe(ctx, d)); } /* Check health -------------------------------------------------------- @@ -238,19 +238,19 @@ VRT_Healthy(VRT_CTX, VCL_BACKEND d, VCL_TIME *changed) return (0); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - if (d->admin_health->health >= 0) { + if (d->vdir->admin_health->health >= 0) { if (changed != NULL) - *changed = d->health_changed; - return (d->admin_health->health); + *changed = d->vdir->health_changed; + return (d->vdir->admin_health->health); } - if (d->methods->healthy == NULL) { + if (d->vdir->methods->healthy == NULL) { if (changed != NULL) - *changed = d->health_changed; - return (d->health); + *changed = d->vdir->health_changed; + return (!d->sick); } - return (d->methods->healthy(ctx, d, changed)); + return (d->vdir->methods->healthy(ctx, d, changed)); } /* Send Event ---------------------------------------------------------- @@ -261,8 +261,8 @@ VDI_Event(const struct director *d, enum vcl_event_e ev) { CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - if (d->methods->event != NULL) - d->methods->event(d, ev); + if (d->vdir->methods->event != NULL) + d->vdir->methods->event(d, ev); } /* Dump panic info ----------------------------------------------------- @@ -275,14 +275,14 @@ VDI_Panic(const struct director *d, struct vsb *vsb, const char *nm) return; VSB_printf(vsb, "%s = %p {\n", nm, d); VSB_indent(vsb, 2); - VSB_printf(vsb, "cli_name = %s,\n", d->cli_name); - VSB_printf(vsb, "health = %s,\n", d->health ? "healthy" : "sick"); + VSB_printf(vsb, "cli_name = %s,\n", d->vdir->cli_name); + VSB_printf(vsb, "health = %s,\n", d->sick ? "sick" : "healthy"); VSB_printf(vsb, "admin_health = %s, changed = %f,\n", - VDI_Ahealth(d), d->health_changed); - VSB_printf(vsb, "type = %s {\n", d->methods->type); + VDI_Ahealth(d), d->vdir->health_changed); + VSB_printf(vsb, "type = %s {\n", d->vdir->methods->type); VSB_indent(vsb, 2); - if (d->methods->panic != NULL) - d->methods->panic(d, vsb); + if (d->vdir->methods->panic != NULL) + d->vdir->methods->panic(d, vsb); VSB_indent(vsb, -2); VSB_printf(vsb, "},\n"); VSB_indent(vsb, -2); @@ -308,20 +308,20 @@ do_list(struct cli *cli, struct director *d, void *priv) CAST_OBJ_NOTNULL(la, priv, LIST_ARGS_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - if (d->admin_health == VDI_AH_DELETED) + if (d->vdir->admin_health == VDI_AH_DELETED) return (0); - VCLI_Out(cli, "\n%-30s %-7s ", d->cli_name, VDI_Ahealth(d)); + VCLI_Out(cli, "\n%-30s %-7s ", d->vdir->cli_name, VDI_Ahealth(d)); - if (d->methods->list != NULL) - d->methods->list(d, cli->sb, 0, 0); + if (d->vdir->methods->list != NULL) + d->vdir->methods->list(d, cli->sb, 0, 0); else - VCLI_Out(cli, "%-10s", d->health ? "healthy" : "sick"); + VCLI_Out(cli, "%-10s", d->sick ? "sick" : "halthy"); - VTIM_format(d->health_changed, time_str); + VTIM_format(d->vdir->health_changed, time_str); VCLI_Out(cli, " %s", time_str); - if ((la->p || la->v) && d->methods->list != NULL) - d->methods->list(d, cli->sb, la->p, la->v); + if ((la->p || la->v) && d->vdir->methods->list != NULL) + d->vdir->methods->list(d, cli->sb, la->p, la->v); return (0); } @@ -373,12 +373,13 @@ do_set_health(struct cli *cli, struct director *d, void *priv) (void)cli; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(sh, priv, SET_HEALTH_MAGIC); - if (d->admin_health == VDI_AH_DELETED) + if (d->vdir->admin_health == VDI_AH_DELETED) return (0); - if (d->admin_health != sh->ah) { - d->health_changed = VTIM_real(); - d->admin_health = sh->ah; - d->health = sh->ah->health ? 1 : 0; + if (d->vdir->admin_health != sh->ah) { + d->vdir->health_changed = VTIM_real(); + d->vdir->admin_health = sh->ah; + d->sick &= ~0x02; + d->sick |= sh->ah->health ? 0 : 0x02; } return (0); } diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index 9697533..124ff2e 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2015 Varnish Software AS + * Copyright (c) 2006-2018 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp @@ -26,76 +26,26 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Director APIs - * - * A director ("VDI") is an abstract entity which can either satisfy a - * backend fetch request or select another director for the job. - * - * In theory a director does not have to talk HTTP over TCP, it can satisfy - * the backend request using any means it wants, although this is presently - * not implemented. + * This is the private implementation of directors. + * You are not supposed to need anything here. * */ -struct vcldir; - -typedef VCL_BOOL vdi_healthy_f(VRT_CTX, VCL_BACKEND, VCL_TIME *); -typedef VCL_BACKEND vdi_resolve_f(VRT_CTX, VCL_BACKEND); -typedef int vdi_gethdrs_f(VRT_CTX, VCL_BACKEND); -typedef int vdi_getbody_f(VRT_CTX, VCL_BACKEND); -typedef VCL_IP vdi_getip_f(VRT_CTX, VCL_BACKEND); -typedef void vdi_finish_f(VRT_CTX, VCL_BACKEND); -typedef enum sess_close vdi_http1pipe_f(VRT_CTX, VCL_BACKEND); -typedef void vdi_event_f(VCL_BACKEND, enum vcl_event_e); -typedef void vdi_destroy_f(VCL_BACKEND); -typedef void vdi_panic_f(VCL_BACKEND, struct vsb *); -typedef void vdi_list_f(VCL_BACKEND, struct vsb *, int, int); +struct vdi_methods; -struct director_methods { +struct vcldir { unsigned magic; -#define DIRECTOR_METHODS_MAGIC 0x4ec0c4bb - const char *type; - vdi_http1pipe_f *http1pipe; - vdi_healthy_f *healthy; - vdi_resolve_f *resolve; - vdi_gethdrs_f *gethdrs; - vdi_getbody_f *getbody; - vdi_getip_f *getip; - vdi_finish_f *finish; - vdi_event_f *event; - vdi_destroy_f *destroy; - vdi_panic_f *panic; - vdi_list_f *list; -}; - -struct director { - unsigned magic; -#define DIRECTOR_MAGIC 0x3336351d - const struct director_methods *methods; - char *vcl_name; - - void *priv; - - /* Internal Housekeeping fields */ - - struct vcldir *vdir; - - char *cli_name; - +#define VCLDIR_MAGIC 0xbf726c7d + struct director *dir; + struct vcl *vcl; + const struct vdi_methods *methods; + VTAILQ_ENTRY(vcldir) list; unsigned health; const struct vdi_ahealth *admin_health; double health_changed; + char *cli_name; }; - -/* cache_vcl.c */ -VCL_BACKEND VRT_AddDirector(VRT_CTX, const struct director_methods *, - void *, const char *, ...) v_printflike_(4, 5); - -void VRT_SetHealth(VCL_BACKEND d, int health); -void VRT_DisableDirector(VCL_BACKEND); -void VRT_DelDirector(VCL_BACKEND *); - /* cache_director.c */ #define VBE_AHEALTH_LIST \ @@ -107,5 +57,3 @@ void VRT_DelDirector(VCL_BACKEND *); #define VBE_AHEALTH(l,u,h) extern const struct vdi_ahealth * const VDI_AH_##u; VBE_AHEALTH_LIST #undef VBE_AHEALTH - -const char *VDI_Ahealth(const struct director *d); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 4427cae..a402fce 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -30,7 +30,6 @@ #include "config.h" #include "cache_varnishd.h" -#include "cache_director.h" #include "cache_filter.h" #include "cache_objhead.h" #include "hash/hash_slinger.h" diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 00a0249..b36e85d 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -39,7 +39,6 @@ #include "config.h" #include "cache_varnishd.h" -#include "cache_director.h" #include "cache_filter.h" #include "cache_objhead.h" #include "cache_transport.h" diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index ed57193..0a63c04 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -263,7 +263,7 @@ vcl_iterdir(struct cli *cli, const char *pat, const struct vcl *vcl, struct vcldir *vdir; VTAILQ_FOREACH(vdir, &vcl->director_list, list) { - if (fnmatch(pat, vdir->dir->cli_name, 0)) + if (fnmatch(pat, vdir->cli_name, 0)) continue; found++; i = func(cli, vdir->dir, priv); @@ -344,9 +344,9 @@ vcl_KillBackends(struct vcl *vcl) if (vdir == NULL) break; VTAILQ_REMOVE(&vcl->director_list, vdir, list); - REPLACE(vdir->dir->cli_name, NULL); - AN(vdir->dir->methods->destroy); - vdir->dir->methods->destroy(vdir->dir); + REPLACE(vdir->cli_name, NULL); + AN(vdir->methods->destroy); + vdir->methods->destroy(vdir->dir); FREE_OBJ(vdir); } } diff --git a/bin/varnishd/cache/cache_vcl.h b/bin/varnishd/cache/cache_vcl.h index e5a5453..f344c37 100644 --- a/bin/varnishd/cache/cache_vcl.h +++ b/bin/varnishd/cache/cache_vcl.h @@ -35,13 +35,6 @@ struct vfp_filter; VTAILQ_HEAD(vfp_filter_head, vfp_filter); -struct vcldir { - unsigned magic; -#define VCLDIR_MAGIC 0xbf726c7d - struct director *dir; - struct vcl *vcl; - VTAILQ_ENTRY(vcldir) list; -}; struct vcl { unsigned magic; diff --git a/bin/varnishd/cache/cache_vcl_vrt.c b/bin/varnishd/cache/cache_vcl_vrt.c index b97aae1..fc07bfd 100644 --- a/bin/varnishd/cache/cache_vcl_vrt.c +++ b/bin/varnishd/cache/cache_vcl_vrt.c @@ -127,7 +127,7 @@ VCL_Rel(struct vcl **vcc) /*--------------------------------------------------------------------*/ VCL_BACKEND -VRT_AddDirector(VRT_CTX, const struct director_methods *m, void *priv, +VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, const char *fmt, ...) { struct vsb *vsb; @@ -138,7 +138,7 @@ VRT_AddDirector(VRT_CTX, const struct director_methods *m, void *priv, int i; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(m, DIRECTOR_METHODS_MAGIC); + CHECK_OBJ_NOTNULL(m, VDI_METHODS_MAGIC); AN(fmt); vcl = ctx->vcl; CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); @@ -150,9 +150,14 @@ VRT_AddDirector(VRT_CTX, const struct director_methods *m, void *priv, ALLOC_OBJ(d, DIRECTOR_MAGIC); AN(d); - d->methods = m; + ALLOC_OBJ(vdir, VCLDIR_MAGIC); + AN(vdir); + vdir->dir = d; + d->vdir = vdir; + + vdir->methods = m; d->priv = priv; - d->admin_health = VDI_AH_PROBE; + vdir->admin_health = VDI_AH_PROBE; vsb = VSB_new_auto(); AN(vsb); VSB_printf(vsb, "%s.", VCL_Name(vcl)); @@ -161,18 +166,14 @@ VRT_AddDirector(VRT_CTX, const struct director_methods *m, void *priv, VSB_vprintf(vsb, fmt, ap); va_end(ap); AZ(VSB_finish(vsb)); - REPLACE((d->cli_name), VSB_data(vsb)); + REPLACE((vdir->cli_name), VSB_data(vsb)); VSB_destroy(&vsb); - d->vcl_name = d->cli_name + i; + d->vcl_name = vdir->cli_name + i; - ALLOC_OBJ(vdir, VCLDIR_MAGIC); - AN(vdir); - vdir->dir = d; vdir->vcl = vcl; - d->vdir = vdir; - d->health = 1; - d->admin_health = VDI_AH_PROBE; - d->health_changed = VTIM_real(); + d->sick = 0; + vdir->admin_health = VDI_AH_PROBE; + vdir->health_changed = VTIM_real(); Lck_Lock(&vcl_mtx); VTAILQ_INSERT_TAIL(&vcl->director_list, vdir, list); @@ -208,9 +209,9 @@ VRT_DelDirector(VCL_BACKEND *bp) if (VCL_WARM(vcl)) VDI_Event(d, VCL_EVENT_COLD); AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl)); - if(d->methods->destroy != NULL) - d->methods->destroy(d); - free(d->cli_name); + if(vdir->methods->destroy != NULL) + vdir->methods->destroy(d); + free(vdir->cli_name); FREE_OBJ(vdir->dir); FREE_OBJ(vdir); } @@ -224,8 +225,11 @@ VRT_SetHealth(VCL_BACKEND d, int health) vdir = d->vdir; CHECK_OBJ_NOTNULL(vdir, VCLDIR_MAGIC); - vdir->dir->health = health; - vdir->dir->health_changed = VTIM_real(); + if (health) + vdir->dir->sick &= ~0x01; + else + vdir->dir->sick |= 0x01; + vdir->health_changed = VTIM_real(); } void @@ -237,9 +241,9 @@ VRT_DisableDirector(VCL_BACKEND d) vdir = d->vdir; CHECK_OBJ_NOTNULL(vdir, VCLDIR_MAGIC); - vdir->dir->admin_health = VDI_AH_DELETED; - vdir->dir->health = 0; - vdir->dir->health_changed = VTIM_real(); + vdir->admin_health = VDI_AH_DELETED; + vdir->dir->sick |= 0x04; + vdir->health_changed = VTIM_real(); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 6001d32..015c412 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -33,7 +33,6 @@ #include "cache_varnishd.h" -#include "cache_director.h" #include "cache_objhead.h" #include "vav.h" #include "vcl.h" diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index d62e9cd..3205573 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -37,7 +37,6 @@ #include "vcl.h" -#include "cache_director.h" #include "vrt_obj.h" static char vrt_hostname[255] = ""; diff --git a/include/vrt.h b/include/vrt.h index 37a0937..d23ee9e 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -411,14 +411,58 @@ VCL_BACKEND VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *, const struct vrt_backend *); size_t VRT_backend_vsm_need(VRT_CTX); void VRT_delete_backend(VRT_CTX, VCL_BACKEND *); -int VRT_backend_healthy(VRT_CTX, VCL_BACKEND); /* VSM related */ struct vsmw_cluster *VRT_VSM_Cluster_New(VRT_CTX, size_t); void VRT_VSM_Cluster_Destroy(VRT_CTX, struct vsmw_cluster **); -/* cache_director.c */ +/* VDI - Director API */ +typedef VCL_BOOL vdi_healthy_f(VRT_CTX, VCL_BACKEND, VCL_TIME *); +typedef VCL_BACKEND vdi_resolve_f(VRT_CTX, VCL_BACKEND); +typedef int vdi_gethdrs_f(VRT_CTX, VCL_BACKEND); +typedef int vdi_getbody_f(VRT_CTX, VCL_BACKEND); +typedef VCL_IP vdi_getip_f(VRT_CTX, VCL_BACKEND); +typedef void vdi_finish_f(VRT_CTX, VCL_BACKEND); +typedef enum sess_close vdi_http1pipe_f(VRT_CTX, VCL_BACKEND); +typedef void vdi_event_f(VCL_BACKEND, enum vcl_event_e); +typedef void vdi_destroy_f(VCL_BACKEND); +typedef void vdi_panic_f(VCL_BACKEND, struct vsb *); +typedef void vdi_list_f(VCL_BACKEND, struct vsb *, int, int); + +struct vdi_methods { + unsigned magic; +#define VDI_METHODS_MAGIC 0x4ec0c4bb + const char *type; + vdi_http1pipe_f *http1pipe; + vdi_healthy_f *healthy; + vdi_resolve_f *resolve; + vdi_gethdrs_f *gethdrs; + vdi_getbody_f *getbody; + vdi_getip_f *getip; + vdi_finish_f *finish; + vdi_event_f *event; + vdi_destroy_f *destroy; + vdi_panic_f *panic; + vdi_list_f *list; +}; + +struct vcldir; + +struct director { + unsigned magic; +#define DIRECTOR_MAGIC 0x3336351d + unsigned sick; + void *priv; + char *vcl_name; + struct vcldir *vdir; +}; + VCL_BOOL VRT_Healthy(VRT_CTX, VCL_BACKEND, VCL_TIME *); +VCL_BACKEND VRT_AddDirector(VRT_CTX, const struct vdi_methods *, + void *, const char *, ...) v_printflike_(4, 5); +void VRT_SetHealth(VCL_BACKEND d, int health); +void VRT_DisableDirector(VCL_BACKEND); +void VRT_DelDirector(VCL_BACKEND *); /* Suckaddr related */ int VRT_VSA_GetPtr(const struct suckaddr *sua, const unsigned char ** dst); diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index 07d8c97..e4a5a12 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -32,7 +32,6 @@ #include #include "cache/cache.h" -#include "cache/cache_director.h" #include "vcc_if.h" @@ -85,8 +84,8 @@ vmod_fallback_resolve(VRT_CTX, VCL_BACKEND dir) return (be); } -static const struct director_methods vmod_fallback_methods[1] = {{ - .magic = DIRECTOR_METHODS_MAGIC, +static const struct vdi_methods vmod_fallback_methods[1] = {{ + .magic = VDI_METHODS_MAGIC, .type = "fallback", .healthy = vmod_fallback_healthy, .resolve = vmod_fallback_resolve, diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index 1e4d9de..9a362cb 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -32,7 +32,6 @@ #include #include "cache/cache.h" -#include "cache/cache_director.h" #include "vend.h" #include "vsha256.h" @@ -47,8 +46,8 @@ struct vmod_directors_hash { struct vdir *vd; }; -static const struct director_methods vmod_hash_methods[1] = {{ - .magic = DIRECTOR_METHODS_MAGIC, +static const struct vdi_methods vmod_hash_methods[1] = {{ + .magic = VDI_METHODS_MAGIC, .type = "hash", }}; diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index c89fb8e..3968e5c 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -31,7 +31,6 @@ #include #include "cache/cache.h" -#include "cache/cache_director.h" #include "vbm.h" #include "vrnd.h" @@ -73,8 +72,8 @@ vmod_random_resolve(VRT_CTX, VCL_BACKEND dir) return (be); } -static const struct director_methods vmod_random_methods[1] = {{ - .magic = DIRECTOR_METHODS_MAGIC, +static const struct vdi_methods vmod_random_methods[1] = {{ + .magic = VDI_METHODS_MAGIC, .type = "random", .healthy = vmod_random_healthy, .resolve = vmod_random_resolve, diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index c69fbf1..636d88a 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -32,7 +32,6 @@ #include #include "cache/cache.h" -#include "cache/cache_director.h" #include "vcc_if.h" @@ -82,8 +81,8 @@ vmod_rr_resolve(VRT_CTX, VCL_BACKEND dir) return (be); } -static const struct director_methods vmod_rr_methods[1] = {{ - .magic = DIRECTOR_METHODS_MAGIC, +static const struct vdi_methods vmod_rr_methods[1] = {{ + .magic = VDI_METHODS_MAGIC, .type = "round-robin", .healthy = vmod_rr_healthy, .resolve = vmod_rr_resolve, diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c index 152d8df..942932e 100644 --- a/lib/libvmod_directors/shard_cfg.c +++ b/lib/libvmod_directors/shard_cfg.c @@ -35,7 +35,6 @@ #include #include "cache/cache.h" -#include "cache/cache_director.h" #include "shard_dir.h" #include "shard_cfg.h" diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c index 9677546..e0a876c 100644 --- a/lib/libvmod_directors/shard_dir.c +++ b/lib/libvmod_directors/shard_dir.c @@ -37,7 +37,6 @@ #include #include "cache/cache.h" -#include "cache/cache_director.h" #include "vbm.h" #include "vrnd.h" diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 714a655..cf38246 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -51,12 +51,12 @@ vdir_expand(struct vdir *vd, unsigned n) void vdir_new(VRT_CTX, struct vdir **vdp, const char *vcl_name, - const struct director_methods *m, void *priv) + const struct vdi_methods *m, void *priv) { struct vdir *vd; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(m, DIRECTOR_METHODS_MAGIC); + CHECK_OBJ_NOTNULL(m, VDI_METHODS_MAGIC); AN(vcl_name); AN(vdp); AZ(*vdp); diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index 5531931..15d7999 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -42,7 +42,7 @@ struct vdir { }; void vdir_new(VRT_CTX, struct vdir **vdp, const char *vcl_name, - const struct director_methods *, void *priv); + const struct vdi_methods *, void *priv); void vdir_delete(struct vdir **vdp); void vdir_rdlock(struct vdir *vd); void vdir_wrlock(struct vdir *vd); diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index 0eabffa..d54128a 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -191,8 +191,8 @@ shard__assert(void) assert(t2a == t2b); } -static const struct director_methods vmod_shard_methods[1] = {{ - .magic = DIRECTOR_METHODS_MAGIC, +static const struct vdi_methods vmod_shard_methods[1] = {{ + .magic = VDI_METHODS_MAGIC, .type = "shard", .resolve = vmod_shard_resolve, .healthy = vmod_shard_healthy, From fgsch at lodoss.net Tue May 1 14:29:24 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 1 May 2018 14:29:24 +0000 (UTC) Subject: [master] 2ac1163 Print usage on unknown or missing arguments Message-ID: <20180501142924.5E780A48FB@lists.varnish-cache.org> commit 2ac116397eb8a34c0001cb705cf21316cb5056f0 Author: Federico G. Schwindt Date: Mon Apr 30 21:13:23 2018 +0100 Print usage on unknown or missing arguments This seems to be the de-facto way to handle such cases. Fixes #2608. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index cad50a4..aada3ce 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -488,8 +488,7 @@ main(int argc, char * const *argv) do { switch (o) { case '?': - if (optopt == '?') - usage(); + usage(); exit(2); case 'V': case 'x': From nils.goroll at uplex.de Tue May 1 16:50:24 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 1 May 2018 16:50:24 +0000 (UTC) Subject: [master] e621853 another changes.rst pointer Message-ID: <20180501165024.9E8DBA6E05@lists.varnish-cache.org> commit e6218538a35a52f44c84d2e8bd919a18d6d68483 Author: Nils Goroll Date: Tue May 1 18:39:47 2018 +0200 another changes.rst pointer diff --git a/doc/changes.rst b/doc/changes.rst index 4c4db9b..fec13c5 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -31,6 +31,8 @@ C APIs (for vmod and utility authors) * XXX backend add / del +* XXX director api, cache_backend.h off-limits, moved to VRT + ================================ Varnish Cache 6.0.0 (2018-03-15) ================================ From nils.goroll at uplex.de Tue May 1 16:50:24 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 1 May 2018 16:50:24 +0000 (UTC) Subject: [master] 49ff510 move tbl/htc.h to installed headers Message-ID: <20180501165024.98AE3A6E03@lists.varnish-cache.org> commit 49ff510538a1e03b9db5073fae86e0d2ddee5f69 Author: Nils Goroll Date: Tue May 1 18:35:11 2018 +0200 move tbl/htc.h to installed headers consequence of 90c4b747ced9053353c13d827ef0a0df5ab4445f: if cache_varnishd.h is installed, we also need table files used therein. diff --git a/include/Makefile.am b/include/Makefile.am index 3a6bb82..27f40ec 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -16,6 +16,7 @@ nobase_pkginclude_HEADERS = \ tbl/h2_frames.h \ tbl/h2_settings.h \ tbl/h2_stream.h \ + tbl/htc.h \ tbl/http_headers.h \ tbl/http_response.h \ tbl/locks.h \ @@ -98,8 +99,7 @@ nobase_noinst_HEADERS = \ vss.h \ vtcp.h \ vtree.h \ - vus.h \ - tbl/htc.h + vus.h ## keep in sync with lib/libvcc/Makefile.am vcl.h: \ From nils.goroll at uplex.de Tue May 1 17:16:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 1 May 2018 17:16:08 +0000 (UTC) Subject: [master] 2ed3250 avoid interactive mv Message-ID: <20180501171608.CC489A75A9@lists.varnish-cache.org> commit 2ed32506ea82270ea09b44109e59b8a7d8296eff Author: Nils Goroll Date: Tue May 1 19:15:42 2018 +0200 avoid interactive mv diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 2556501..e6e0537 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -229,7 +229,7 @@ EXTRA_DIST = builtin.vcl vhp_hufdec.h: vhp_gen_hufdec $(AM_V_GEN) ./vhp_gen_hufdec > vhp_hufdec.h_ - mv vhp_hufdec.h_ vhp_hufdec.h + mv -f vhp_hufdec.h_ vhp_hufdec.h DISTCLEANFILES = builtin_vcl.c From dridi.boukelmoune at gmail.com Wed May 2 06:37:16 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 2 May 2018 06:37:16 +0000 (UTC) Subject: [master] 4cc4a78 Simplify o5.vtc Message-ID: <20180502063716.A2AF5B6F9F@lists.varnish-cache.org> commit 4cc4a78d74b1f7ec4a7fba252f212d2a1bfe7555 Author: Dridi Boukelmoune Date: Wed May 2 08:36:16 2018 +0200 Simplify o5.vtc diff --git a/bin/varnishtest/tests/o00005.vtc b/bin/varnishtest/tests/o00005.vtc index c9598fd..f1e92fc 100644 --- a/bin/varnishtest/tests/o00005.vtc +++ b/bin/varnishtest/tests/o00005.vtc @@ -9,18 +9,10 @@ varnish v1 -proto "PROXY" -vcl+backend { import proxy; sub vcl_deliver { - if (proxy.is_ssl()) { - set resp.http.is_ssl = "yes"; - } - if (!proxy.client_has_cert_sess()) { - set resp.http.client_has_cert_sess = "no"; - } - if (!proxy.client_has_cert_conn()) { - set resp.http.client_has_cert_conn = "no"; - } - if (proxy.ssl_verify_result() == 0) { - set resp.http.verify = "ok"; - } + set resp.http.is_ssl = proxy.is_ssl(); + set resp.http.client_has_cert_sess = proxy.client_has_cert_sess(); + set resp.http.client_has_cert_conn = proxy.client_has_cert_conn(); + set resp.http.ssl_verify_result = proxy.ssl_verify_result() == 0; set resp.http.alpn = proxy.alpn(); set resp.http.authority = proxy.authority(); set resp.http.ssl-version = proxy.ssl_version(); @@ -60,10 +52,10 @@ client c1 { txreq rxresp expect resp.status == 200 - expect resp.http.is_ssl == yes - expect resp.http.client_has_cert_sess == no - expect resp.http.client_has_cert_conn == no - expect resp.http.verify == ok + expect resp.http.is_ssl == true + expect resp.http.client_has_cert_sess == false + expect resp.http.client_has_cert_conn == false + expect resp.http.ssl_verify_result == true expect resp.http.alpn == h2 expect resp.http.authority == hocdet.net expect resp.http.ssl-version == TLSv1.3 From dridi.boukelmoune at gmail.com Wed May 2 06:37:16 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 2 May 2018 06:37:16 +0000 (UTC) Subject: [master] dafd5b0 Whitespace OCD Message-ID: <20180502063716.95F6BB6F79@lists.varnish-cache.org> commit dafd5b03b40556cdff9d160896fbd788b38aca6f Author: Dridi Boukelmoune Date: Wed May 2 08:29:23 2018 +0200 Whitespace OCD diff --git a/bin/varnishtest/tests/o00005.vtc b/bin/varnishtest/tests/o00005.vtc index 96154e8..c9598fd 100644 --- a/bin/varnishtest/tests/o00005.vtc +++ b/bin/varnishtest/tests/o00005.vtc @@ -9,25 +9,25 @@ varnish v1 -proto "PROXY" -vcl+backend { import proxy; sub vcl_deliver { - if (proxy.is_ssl()) { - set resp.http.is_ssl = "yes"; - } - if (!proxy.client_has_cert_sess()) { - set resp.http.client_has_cert_sess = "no"; - } - if (!proxy.client_has_cert_conn()) { - set resp.http.client_has_cert_conn = "no"; - } - if (proxy.ssl_verify_result() == 0) { - set resp.http.verify = "ok"; - } - set resp.http.alpn = proxy.alpn(); - set resp.http.authority = proxy.authority(); - set resp.http.ssl-version = proxy.ssl_version(); - set resp.http.cipher = proxy.ssl_cipher(); - set resp.http.key = proxy.cert_key(); - set resp.http.sign = proxy.cert_sign(); - set resp.http.cn = proxy.client_cert_cn(); + if (proxy.is_ssl()) { + set resp.http.is_ssl = "yes"; + } + if (!proxy.client_has_cert_sess()) { + set resp.http.client_has_cert_sess = "no"; + } + if (!proxy.client_has_cert_conn()) { + set resp.http.client_has_cert_conn = "no"; + } + if (proxy.ssl_verify_result() == 0) { + set resp.http.verify = "ok"; + } + set resp.http.alpn = proxy.alpn(); + set resp.http.authority = proxy.authority(); + set resp.http.ssl-version = proxy.ssl_version(); + set resp.http.cipher = proxy.ssl_cipher(); + set resp.http.key = proxy.cert_key(); + set resp.http.sign = proxy.cert_sign(); + set resp.http.cn = proxy.client_cert_cn(); } } -start @@ -40,21 +40,22 @@ logexpect l1 -v v1 -g raw { client c1 { # PROXY2 with CRC32C TLV sendhex { - 0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a - 21 11 00 65 - d9 46 b5 21 - 5f 8e a8 22 - ed 96 - 01 bb - 03 00 04 95 03 ee 75 - 01 00 02 68 32 - 02 00 0a 68 6f 63 64 65 74 2e 6e 65 74 - 20 00 3d + 0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a + 21 11 00 65 + d9 46 b5 21 + 5f 8e a8 22 + ed 96 + 01 bb + 03 00 04 95 03 ee 75 + 01 00 02 68 32 + 02 00 0a 68 6f 63 64 65 74 2e 6e 65 74 + 20 00 3d 01 00 00 00 00 21 00 07 54 4c 53 76 31 2e 33 25 00 05 45 43 32 35 36 24 00 0a 52 53 41 2d 53 48 41 32 35 36 - 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 2d 47 43 4d 2d 53 48 41 32 35 36 + 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 + 2d 47 43 4d 2d 53 48 41 32 35 36 } txreq rxresp @@ -84,21 +85,22 @@ logexpect l1 -v v1 -g raw { client c1 { # PROXY2 with CRC32C TLV and bad checksum sendhex { - 0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a - 21 11 00 65 - d9 46 b5 21 - 5f 8e a8 22 - ed 96 - 01 bb - 03 00 04 95 03 ee 74 - 01 00 02 68 32 - 02 00 0a 68 6f 63 64 65 74 2e 6e 65 74 - 20 00 3d + 0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a + 21 11 00 65 + d9 46 b5 21 + 5f 8e a8 22 + ed 96 + 01 bb + 03 00 04 95 03 ee 74 + 01 00 02 68 32 + 02 00 0a 68 6f 63 64 65 74 2e 6e 65 74 + 20 00 3d 01 00 00 00 00 21 00 07 54 4c 53 76 31 2e 33 25 00 05 45 43 32 35 36 24 00 0a 52 53 41 2d 53 48 41 32 35 36 - 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 2d 47 43 4d 2d 53 48 41 32 35 36 + 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 + 2d 47 43 4d 2d 53 48 41 32 35 36 } txreq expect_close @@ -116,22 +118,23 @@ logexpect l1 -v v1 -g raw { client c1 { # PROXY2 with CRC32C TLV and bad checksum sendhex { - 0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a - 21 11 00 67 - d9 46 b5 21 - 5f 8e a8 22 - ed 96 - 01 bb - ff 00 04 95 03 ee 74 - 01 00 02 68 32 - 02 00 0a 68 6f 63 64 65 74 2e 6e 65 74 - 20 00 3d + 0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a + 21 11 00 67 + d9 46 b5 21 + 5f 8e a8 22 + ed 96 + 01 bb + ff 00 04 95 03 ee 74 + 01 00 02 68 32 + 02 00 0a 68 6f 63 64 65 74 2e 6e 65 74 + 20 00 3d 01 00 00 00 00 21 00 07 54 4c 53 76 31 2e 33 25 00 05 45 43 32 35 36 24 00 0a 52 53 41 2d 53 48 41 32 35 36 - 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 2d 47 43 4d 2d 53 48 41 32 35 36 - ff ff + 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 + 2d 47 43 4d 2d 53 48 41 32 35 36 + ff ff } txreq expect_close @@ -149,21 +152,22 @@ logexpect l1 -v v1 -g raw { client c1 { # PROXY2 with CRC32C TLV and bad checksum sendhex { - 0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a - 21 11 00 60 - d9 46 b5 21 - 5f 8e a8 22 - ed 96 - 01 bb - ff 00 04 95 03 ee 74 - 01 00 02 68 32 - 02 00 0a 68 6f 63 64 65 74 2e 6e 65 74 - 20 00 3d + 0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a + 21 11 00 60 + d9 46 b5 21 + 5f 8e a8 22 + ed 96 + 01 bb + ff 00 04 95 03 ee 74 + 01 00 02 68 32 + 02 00 0a 68 6f 63 64 65 74 2e 6e 65 74 + 20 00 3d 01 00 00 00 00 21 00 07 54 4c 53 76 31 2e 33 25 00 05 45 43 32 35 36 24 00 0a 52 53 41 2d 53 48 41 32 35 36 - 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 2d 47 43 4d 2d 53 48 41 32 35 36 + 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 + 2d 47 43 4d 2d 53 48 41 32 35 36 } txreq expect_close @@ -181,21 +185,22 @@ logexpect l1 -v v1 -g raw { client c1 { # PROXY2 with CRC32C TLV and bad checksum sendhex { - 0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a - 21 11 00 65 - d9 46 b5 21 - 5f 8e a8 22 - ed 96 - 01 bb - ff 00 04 95 03 ee 74 - 01 00 02 68 32 - 02 00 0a 68 6f 63 64 65 74 2e 6e 65 74 - 20 00 3c + 0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a + 21 11 00 65 + d9 46 b5 21 + 5f 8e a8 22 + ed 96 + 01 bb + ff 00 04 95 03 ee 74 + 01 00 02 68 32 + 02 00 0a 68 6f 63 64 65 74 2e 6e 65 74 + 20 00 3c 01 00 00 00 00 21 00 07 54 4c 53 76 31 2e 33 25 00 05 45 43 32 35 36 24 00 0a 52 53 41 2d 53 48 41 32 35 36 - 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 2d 47 43 4d 2d 53 48 41 32 35 36 + 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 + 2d 47 43 4d 2d 53 48 41 32 35 36 } txreq expect_close @@ -204,4 +209,3 @@ client c1 { varnish v1 -vsl_catchup logexpect l1 -wait - From dridi.boukelmoune at gmail.com Wed May 2 06:47:07 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 2 May 2018 06:47:07 +0000 (UTC) Subject: [master] 6bce301 One more take on http_gzip_support=off Message-ID: <20180502064707.7178DB7281@lists.varnish-cache.org> commit 6bce30172ca6c6ac52d27025b47102fae237a02f Author: Dridi Boukelmoune Date: Wed May 2 08:44:11 2018 +0200 One more take on http_gzip_support=off diff --git a/include/tbl/params.h b/include/tbl/params.h index 829f48f..8cfb7f0 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -598,7 +598,11 @@ PARAM( "\n" "Clients that do not support gzip will have their Accept-Encoding " "header removed. For more information on how gzip is implemented " - "please see the chapter on gzip in the Varnish reference.", + "please see the chapter on gzip in the Varnish reference.\n" + "\n" + "When gzip support is disabled the variables beresp.do_gzip and " + "beresp.do_gunzip have no effect in VCL.", + /* XXX: what about the effect on beresp.filters? */ /* l-text */ "", /* func */ NULL ) From dridi.boukelmoune at gmail.com Wed May 2 08:49:11 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 2 May 2018 08:49:11 +0000 (UTC) Subject: [master] d0a2ec9 Only handle signals if we still have a VUT Message-ID: <20180502084911.9709FB937B@lists.varnish-cache.org> commit d0a2ec9e75f4e09d9d40c057d34f66c548766c81 Author: Dridi Boukelmoune Date: Wed May 2 10:37:24 2018 +0200 Only handle signals if we still have a VUT This can happen if a signal is caught after `VUT_Fini` was called, but at this point we should no longer manipulate the VUT being dismantled. Original test case by Geoff, slightly modified. Closes #2650 diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index b33f5ce..5d32d6a 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -494,7 +494,9 @@ profile_error(const char *s) static void vut_sighandler(int sig) { - VUT_Signaled(vut, sig); + + if (vut != NULL) + VUT_Signaled(vut, sig); } int diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index b714f54..d80986b 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -124,8 +124,9 @@ sighup(struct VUT *v) static void vut_sighandler(int sig) { - CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); - VUT_Signaled(vut, sig); + + if (vut != NULL) + VUT_Signaled(vut, sig); } int diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index cd3f5a0..488027d 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -1124,8 +1124,9 @@ sighup(struct VUT *v) static void vut_sighandler(int sig) { - CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); - VUT_Signaled(vut, sig); + + if (vut != NULL) + VUT_Signaled(vut, sig); } static char * diff --git a/bin/varnishtest/tests/r02649.vtc b/bin/varnishtest/tests/r02649.vtc new file mode 100644 index 0000000..e8737b4 --- /dev/null +++ b/bin/varnishtest/tests/r02649.vtc @@ -0,0 +1,18 @@ +varnishtest "Cleanly stop a VUT app via vtc process -stop" + +varnish v1 -vcl { + backend be { + .host = "${bad_backend}"; + } +} -start + +process p1 { + exec varnishncsa -n ${v1_name} -P ${tmpdir}/ncsa.pid -w ${tmpdir}/ncsa.log +} -start + +delay 1 + +process p1 -expect-exit 0 -stop -wait + +# Expect empty stderr output +shell -match {^0\b} "wc -c ${tmpdir}/p1/stderr" diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 61f0e4d..5f030c9 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -195,8 +195,9 @@ sighup(struct VUT *v) static void vut_sighandler(int sig) { - CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); - VUT_Signaled(vut, sig); + + if (vut != NULL) + VUT_Signaled(vut, sig); } static void From dridi.boukelmoune at gmail.com Wed May 2 09:32:09 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 2 May 2018 09:32:09 +0000 (UTC) Subject: [master] 612b641 Align the lifetime of the PID file to the VUT process Message-ID: <20180502093209.2447DBA003@lists.varnish-cache.org> commit 612b641954a3714cb34a665bbf56db99bed49899 Author: Dridi Boukelmoune Date: Wed May 2 11:25:10 2018 +0200 Align the lifetime of the PID file to the VUT process For out-of-tree code that may set up multiple VUTs in a single process, we don't want the VUT that initialized a PID file to remove it if it finishes before other VUTs. A global pseudo-VUT is introduced to keep track of the PID file and the error callback in order to use them in the atexit(3) callback. Original test case by Geoff, slightly modified. Closes #2651 diff --git a/bin/varnishtest/tests/r02646.vtc b/bin/varnishtest/tests/r02646.vtc new file mode 100644 index 0000000..a5c3c43 --- /dev/null +++ b/bin/varnishtest/tests/r02646.vtc @@ -0,0 +1,21 @@ +varnishtest "#2646: VUT should fail gracefully when removing a pid file fails" + +varnish v1 -vcl { + backend be { + .host = "${bad_backend}"; + } +} -start + +process p1 { + exec varnishncsa -n ${v1_name} -P ${tmpdir}/ncsa.pid -w ${tmpdir}/ncsa.log +} -start + +delay 1 + +shell "rm -f ${tmpdir}/ncsa.pid" + +process p1 -expect-exit 1 -stop -wait + +shell -expect "Cannot remove pid file ${tmpdir}/ncsa.pid" { + cat ${tmpdir}/p1/stderr +} diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index e268326..a793e44 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -62,6 +62,8 @@ static int vut_options(const struct vopt_spec *); static struct vpf_fh *pfh; static unsigned daemonized; +static struct VUT pfh_vut; + static int vut_daemon(struct VUT *vut) { @@ -74,10 +76,18 @@ vut_daemon(struct VUT *vut) static void vut_vpf_remove(void) { - if (pfh != NULL) { - AZ(VPF_Remove(pfh)); - pfh = NULL; - } + + assert(VALID_OBJ(&pfh_vut, VUT_MAGIC)); + AN(pfh); + AN(pfh_vut.P_arg); + + if (VPF_Remove(pfh) != 0) + VUT_Error(&pfh_vut, 1, "Cannot remove pid file %s: %s", + pfh_vut.P_arg, strerror(errno)); + + free(pfh_vut.P_arg); + ZERO_OBJ(&pfh_vut, sizeof pfh_vut); + pfh = NULL; } static int v_matchproto_(VSLQ_dispatch_f) @@ -306,6 +316,13 @@ VUT_Setup(struct VUT *vut) if (vut->P_arg) { AN(pfh); AZ(VPF_Write(pfh)); + + /* NB: move ownership to a global pseudo-VUT. */ + INIT_OBJ(&pfh_vut, VUT_MAGIC); + pfh_vut.P_arg = vut->P_arg; + pfh_vut.error_f = vut->error_f; + vut->P_arg = NULL; + AZ(atexit(vut_vpf_remove)); } } @@ -319,13 +336,10 @@ VUT_Fini(struct VUT **vutp) AN(vut->progname); free(vut->n_arg); - free(vut->P_arg); free(vut->q_arg); free(vut->r_arg); free(vut->t_arg); - - vut_vpf_remove(); - AZ(pfh); + AZ(vut->P_arg); if (vut->vslq) VSLQ_Delete(&vut->vslq); From fgsch at lodoss.net Wed May 2 09:43:48 2018 From: fgsch at lodoss.net (Federico Schwindt) Date: Wed, 2 May 2018 10:43:48 +0100 Subject: [master] d0a2ec9 Only handle signals if we still have a VUT In-Reply-To: <20180502084911.9709FB937B@lists.varnish-cache.org> References: <20180502084911.9709FB937B@lists.varnish-cache.org> Message-ID: Why not return earlier in VUT_Signaled if vut is NULL rather than checking in every handler? On Wed, May 2, 2018 at 9:49 AM, Dridi Boukelmoune < dridi.boukelmoune at gmail.com> wrote: > > commit d0a2ec9e75f4e09d9d40c057d34f66c548766c81 > Author: Dridi Boukelmoune > Date: Wed May 2 10:37:24 2018 +0200 > > Only handle signals if we still have a VUT > > This can happen if a signal is caught after `VUT_Fini` was called, but > at this point we should no longer manipulate the VUT being dismantled. > > Original test case by Geoff, slightly modified. > > Closes #2650 > > diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c > index b33f5ce..5d32d6a 100644 > --- a/bin/varnishhist/varnishhist.c > +++ b/bin/varnishhist/varnishhist.c > @@ -494,7 +494,9 @@ profile_error(const char *s) > static void > vut_sighandler(int sig) > { > - VUT_Signaled(vut, sig); > + > + if (vut != NULL) > + VUT_Signaled(vut, sig); > } > > int > diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c > index b714f54..d80986b 100644 > --- a/bin/varnishlog/varnishlog.c > +++ b/bin/varnishlog/varnishlog.c > @@ -124,8 +124,9 @@ sighup(struct VUT *v) > static void > vut_sighandler(int sig) > { > - CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); > - VUT_Signaled(vut, sig); > + > + if (vut != NULL) > + VUT_Signaled(vut, sig); > } > > int > diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c > index cd3f5a0..488027d 100644 > --- a/bin/varnishncsa/varnishncsa.c > +++ b/bin/varnishncsa/varnishncsa.c > @@ -1124,8 +1124,9 @@ sighup(struct VUT *v) > static void > vut_sighandler(int sig) > { > - CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); > - VUT_Signaled(vut, sig); > + > + if (vut != NULL) > + VUT_Signaled(vut, sig); > } > > static char * > diff --git a/bin/varnishtest/tests/r02649.vtc b/bin/varnishtest/tests/ > r02649.vtc > new file mode 100644 > index 0000000..e8737b4 > --- /dev/null > +++ b/bin/varnishtest/tests/r02649.vtc > @@ -0,0 +1,18 @@ > +varnishtest "Cleanly stop a VUT app via vtc process -stop" > + > +varnish v1 -vcl { > + backend be { > + .host = "${bad_backend}"; > + } > +} -start > + > +process p1 { > + exec varnishncsa -n ${v1_name} -P ${tmpdir}/ncsa.pid -w > ${tmpdir}/ncsa.log > +} -start > + > +delay 1 > + > +process p1 -expect-exit 0 -stop -wait > + > +# Expect empty stderr output > +shell -match {^0\b} "wc -c ${tmpdir}/p1/stderr" > diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c > index 61f0e4d..5f030c9 100644 > --- a/bin/varnishtop/varnishtop.c > +++ b/bin/varnishtop/varnishtop.c > @@ -195,8 +195,9 @@ sighup(struct VUT *v) > static void > vut_sighandler(int sig) > { > - CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); > - VUT_Signaled(vut, sig); > + > + if (vut != NULL) > + VUT_Signaled(vut, sig); > } > > static void > _______________________________________________ > varnish-commit mailing list > varnish-commit at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dridi.boukelmoune at gmail.com Wed May 2 09:55:07 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 2 May 2018 09:55:07 +0000 (UTC) Subject: [master] 93e5340 Drop VALID_OBJ for GCC Message-ID: <20180502095507.688B5BA73F@lists.varnish-cache.org> commit 93e53400468d4e4bf287e79df25d76b56be6455d Author: Dridi Boukelmoune Date: Wed May 2 11:53:53 2018 +0200 Drop VALID_OBJ for GCC It complains that &pfh_vut is never NULL... diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index a793e44..a34243b 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -77,7 +77,7 @@ static void vut_vpf_remove(void) { - assert(VALID_OBJ(&pfh_vut, VUT_MAGIC)); + assert(pfh_vut.magic == VUT_MAGIC); AN(pfh); AN(pfh_vut.P_arg); From dridi at varni.sh Wed May 2 09:55:48 2018 From: dridi at varni.sh (Dridi Boukelmoune) Date: Wed, 2 May 2018 11:55:48 +0200 Subject: [master] d0a2ec9 Only handle signals if we still have a VUT In-Reply-To: References: <20180502084911.9709FB937B@lists.varnish-cache.org> Message-ID: On Wed, May 2, 2018 at 11:43 AM, Federico Schwindt wrote: > Why not return earlier in VUT_Signaled if vut is NULL rather than checking > in every handler? Because VUT_Signaled is part of a public API. All our utilities are of the single-VUT-single-thread persuasion, that may not be the case out of tree. I don't think we should relax assertions. Dridi From phk at FreeBSD.org Wed May 2 11:14:07 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 2 May 2018 11:14:07 +0000 (UTC) Subject: [master] 1bad900 Eliminate the VDI->getbody() method, I can't imagine anything it will ever be useful for. Message-ID: <20180502111407.A6E4C61F5F@lists.varnish-cache.org> commit 1bad900ae2ffc78bc40436070ed207b1044b57e7 Author: Poul-Henning Kamp Date: Wed May 2 08:59:45 2018 +0000 Eliminate the VDI->getbody() method, I can't imagine anything it will ever be useful for. diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index feff1b7..f88a33b 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -129,29 +129,6 @@ VDI_GetHdr(struct busyobj *bo) return (i); } -/* Setup body fetch --------------------------------------------------*/ - -int -VDI_GetBody(struct busyobj *bo) -{ - const struct director *d; - struct vrt_ctx ctx[1]; - - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - INIT_OBJ(ctx, VRT_CTX_MAGIC); - VCL_Bo2Ctx(ctx, bo); - - d = bo->director_resp; - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - AZ(d->vdir->methods->resolve); - - assert(bo->director_state == DIR_S_HDRS); - bo->director_state = DIR_S_BODY; - if (d->vdir->methods->getbody == NULL) - return (0); - return (d->vdir->methods->getbody(ctx, d)); -} - /* Get IP number (if any ) -------------------------------------------*/ VCL_IP diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index a402fce..06d9ad9 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -646,16 +646,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) http_GetHdr(bo->beresp, H_ETag, &p))) ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 1); - if (bo->htc->body_status != BS_NONE && - VDI_GetBody(bo) != 0) { - (void)VFP_Error(bo->vfc, - "GetBody failed - workspace_backend overflow?"); - VFP_Close(bo->vfc); - bo->htc->doclose = SC_OVERLOAD; - VDI_Finish(bo); - return (F_STP_ERROR); - } - assert(bo->fetch_objcore->boc->refcount >= 1); assert(bo->fetch_objcore->boc->state == BOS_REQ_DONE); diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index 90b9631..d2f35e3 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -117,7 +117,6 @@ void VBO_ReleaseBusyObj(struct worker *wrk, struct busyobj **busyobj); /* cache_director.c */ int VDI_GetHdr(struct busyobj *); -int VDI_GetBody(struct busyobj *); VCL_IP VDI_GetIP(struct busyobj *); void VDI_Finish(struct busyobj *bo); enum sess_close VDI_Http1Pipe(struct req *, struct busyobj *); diff --git a/include/vrt.h b/include/vrt.h index d23ee9e..a0c142c 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -420,7 +420,6 @@ void VRT_VSM_Cluster_Destroy(VRT_CTX, struct vsmw_cluster **); typedef VCL_BOOL vdi_healthy_f(VRT_CTX, VCL_BACKEND, VCL_TIME *); typedef VCL_BACKEND vdi_resolve_f(VRT_CTX, VCL_BACKEND); typedef int vdi_gethdrs_f(VRT_CTX, VCL_BACKEND); -typedef int vdi_getbody_f(VRT_CTX, VCL_BACKEND); typedef VCL_IP vdi_getip_f(VRT_CTX, VCL_BACKEND); typedef void vdi_finish_f(VRT_CTX, VCL_BACKEND); typedef enum sess_close vdi_http1pipe_f(VRT_CTX, VCL_BACKEND); @@ -437,7 +436,6 @@ struct vdi_methods { vdi_healthy_f *healthy; vdi_resolve_f *resolve; vdi_gethdrs_f *gethdrs; - vdi_getbody_f *getbody; vdi_getip_f *getip; vdi_finish_f *finish; vdi_event_f *event; From phk at FreeBSD.org Wed May 2 11:14:07 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 2 May 2018 11:14:07 +0000 (UTC) Subject: [master] eae4bf6 Allow whitespace before wc(1) output Message-ID: <20180502111407.CBC9A61F62@lists.varnish-cache.org> commit eae4bf619f60c29e0b182a4b253a79dfb8b253fc Author: Poul-Henning Kamp Date: Wed May 2 11:13:06 2018 +0000 Allow whitespace before wc(1) output diff --git a/bin/varnishtest/tests/r02649.vtc b/bin/varnishtest/tests/r02649.vtc index e8737b4..4ee5e41 100644 --- a/bin/varnishtest/tests/r02649.vtc +++ b/bin/varnishtest/tests/r02649.vtc @@ -15,4 +15,4 @@ delay 1 process p1 -expect-exit 0 -stop -wait # Expect empty stderr output -shell -match {^0\b} "wc -c ${tmpdir}/p1/stderr" +shell -match {^[ ]*0\b} "wc -c ${tmpdir}/p1/stderr" From nils.goroll at uplex.de Wed May 2 12:21:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 2 May 2018 12:21:08 +0000 (UTC) Subject: [master] 63b28b1 remove duplicate loc Message-ID: <20180502122108.D5CA263310@lists.varnish-cache.org> commit 63b28b13fce75aec2e6c9c637e8bc6bfcf5dc51a Author: Nils Goroll Date: Wed May 2 14:17:43 2018 +0200 remove duplicate loc diff --git a/bin/varnishd/cache/cache_vcl_vrt.c b/bin/varnishd/cache/cache_vcl_vrt.c index fc07bfd..149d41d 100644 --- a/bin/varnishd/cache/cache_vcl_vrt.c +++ b/bin/varnishd/cache/cache_vcl_vrt.c @@ -157,7 +157,6 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, vdir->methods = m; d->priv = priv; - vdir->admin_health = VDI_AH_PROBE; vsb = VSB_new_auto(); AN(vsb); VSB_printf(vsb, "%s.", VCL_Name(vcl)); From daghf at varnish-software.com Wed May 2 14:41:08 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Wed, 2 May 2018 14:41:08 +0000 (UTC) Subject: [master] 6c53ed3 Fix broken vsl-query example Message-ID: <20180502144108.CB55A65B34@lists.varnish-cache.org> commit 6c53ed3db827a038ae2de5462c1b7e3341daf7e4 Author: Dag Haavi Finstad Date: Wed May 2 16:40:12 2018 +0200 Fix broken vsl-query example diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index 891d361..92b97c9 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -278,7 +278,7 @@ QUERY EXPRESSION EXAMPLES * Transaction group contains a request response status of 304, but where the request did not contain an if-modified-since header :: - ReqStatus == 304 and not ReqHeader:if-modified-since + RespStatus == 304 and not ReqHeader:if-modified-since * Transactions that have had backend failures or long delivery time on their ESI subrequests. (Assumes request grouping mode). :: From nils.goroll at uplex.de Wed May 2 15:54:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 2 May 2018 15:54:08 +0000 (UTC) Subject: [master] dfcb4e3 fix typo Message-ID: <20180502155408.98D9E9262B@lists.varnish-cache.org> commit dfcb4e37739ee04d3187d9eb31882264de63d987 Author: Nils Goroll Date: Wed May 2 15:17:00 2018 +0200 fix typo diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index f88a33b..e5b7439 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -293,7 +293,7 @@ do_list(struct cli *cli, struct director *d, void *priv) if (d->vdir->methods->list != NULL) d->vdir->methods->list(d, cli->sb, 0, 0); else - VCLI_Out(cli, "%-10s", d->sick ? "sick" : "halthy"); + VCLI_Out(cli, "%-10s", d->sick ? "sick" : "healthy"); VTIM_format(d->vdir->health_changed, time_str); VCLI_Out(cli, " %s", time_str); From nils.goroll at uplex.de Wed May 2 15:54:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 2 May 2018 15:54:08 +0000 (UTC) Subject: [master] 0046616 fix garbled output for backend.list [-v|-p] Message-ID: <20180502155408.ADF049262E@lists.varnish-cache.org> commit 0046616ce918d3eae71068b1569e234df482b157 Author: Nils Goroll Date: Wed May 2 15:21:22 2018 +0200 fix garbled output for backend.list [-v|-p] diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 88a28cd..982183b 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -420,7 +420,7 @@ vbe_list(const struct director *d, struct vsb *vsb, int vflag, int pflag) if (bp->probe != NULL) VBP_Status(vsb, bp, vflag | pflag); - else + else if ((vflag | pflag) == 0) VSB_printf(vsb, "%-10s", d->sick ? "sick" : "healthy"); } From nils.goroll at uplex.de Wed May 2 15:54:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 2 May 2018 15:54:08 +0000 (UTC) Subject: [master] ec35c34 note a TODO Message-ID: <20180502155408.C8E2992633@lists.varnish-cache.org> commit ec35c34ff19fcbb150f3b2a11efbddf00cf09385 Author: Nils Goroll Date: Wed May 2 15:32:42 2018 +0200 note a TODO diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index e5b7439..f5552fe 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -288,6 +288,7 @@ do_list(struct cli *cli, struct director *d, void *priv) if (d->vdir->admin_health == VDI_AH_DELETED) return (0); + // XXX admin health "probe" for the no-probe case is confusing VCLI_Out(cli, "\n%-30s %-7s ", d->vdir->cli_name, VDI_Ahealth(d)); if (d->vdir->methods->list != NULL) From phk at FreeBSD.org Wed May 2 22:19:20 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 2 May 2018 22:19:20 +0000 (UTC) Subject: [master] 9fcfa5b Don't bother with the return value from H2_Send(), we rely on h2_errcheck() calls anyway. Message-ID: <20180502221920.E75BD9B8DD@lists.varnish-cache.org> commit 9fcfa5be05ab6846804edb69175f0a7a747b246c Author: Poul-Henning Kamp Date: Wed May 2 22:17:58 2018 +0000 Don't bother with the return value from H2_Send(), we rely on h2_errcheck() calls anyway. diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index cfe8598..a1d6f84 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -220,7 +220,7 @@ h2_error H2_Send_Frame(struct worker *, const struct h2_sess *, h2_frame type, uint8_t flags, uint32_t len, uint32_t stream, const void *); -h2_error H2_Send(struct worker *, struct h2_req *, +void H2_Send(struct worker *, struct h2_req *, h2_frame type, uint8_t flags, uint32_t len, const void *); /* cache_http2_proto.c */ diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index a0ff969..2b7f695 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -91,8 +91,8 @@ h2_bytes(struct req *req, enum vdp_action act, void **priv, H2_F_DATA, act == VDP_FINI ? H2FF_DATA_END_STREAM : H2FF_NONE, len, ptr); - req->acct.resp_bodybytes += len; H2_Send_Rel(r2->h2sess, r2); + req->acct.resp_bodybytes += len; return (0); } @@ -260,8 +260,8 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) H2_Send(req->wrk, r2, H2_F_HEADERS, (sendbody ? 0 : H2FF_HEADERS_END_STREAM) | H2FF_HEADERS_END_HEADERS, sz, req->ws->f); - req->acct.resp_hdrbytes += sz; H2_Send_Rel(r2->h2sess, r2); + req->acct.resp_hdrbytes += sz; WS_Release(req->ws, 0); diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index 839193f..cfbb51b 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -245,7 +245,7 @@ h2_do_window(struct worker *wrk, struct h2_req *r2, * XXX: priority */ -h2_error +void H2_Send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags, uint32_t len, const void *ptr) { @@ -263,9 +263,8 @@ H2_Send(struct worker *wrk, struct h2_req *r2, assert(VTAILQ_FIRST(&h2->txqueue) == r2); - retval = h2_errcheck(r2, h2); - if (retval) - return (retval); + if (h2_errcheck(r2, h2)) + return; AN(ftyp); AZ(flags & ~(ftyp->flags)); @@ -281,15 +280,14 @@ H2_Send(struct worker *wrk, struct h2_req *r2, if (ftyp->respect_window) { tf = h2_do_window(wrk, r2, h2, (len > mfs) ? mfs : len); - retval = h2_errcheck(r2, h2); - if (retval) - return (retval); + if (h2_errcheck(r2, h2)) + return; assert(VTAILQ_FIRST(&h2->txqueue) == r2); } else tf = mfs; if (len <= tf) { - retval = H2_Send_Frame(wrk, h2, + (void)H2_Send_Frame(wrk, h2, ftyp, flags, len, r2->stream, ptr); } else { AN(ptr); @@ -303,9 +301,8 @@ H2_Send(struct worker *wrk, struct h2_req *r2, if (ftyp->respect_window && p != ptr) { tf = h2_do_window(wrk, r2, h2, (len > mfs) ? mfs : len); - retval = h2_errcheck(r2, h2); - if (retval) - return (retval); + if (h2_errcheck(r2, h2)) + return; assert(VTAILQ_FIRST(&h2->txqueue) == r2); } if (tf < len) { @@ -324,5 +321,4 @@ H2_Send(struct worker *wrk, struct h2_req *r2, ftyp = ftyp->continuation; } while (len > 0 && retval == 0); } - return (retval); } From phk at FreeBSD.org Wed May 2 22:54:06 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 2 May 2018 22:54:06 +0000 (UTC) Subject: [master] 867b3c2 Unbogotify slightly Message-ID: <20180502225406.9DB8EA02D1@lists.varnish-cache.org> commit 867b3c23341b2e77e599598458883428c536d94b Author: Poul-Henning Kamp Date: Wed May 2 22:52:55 2018 +0000 Unbogotify slightly diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index 2b7f695..cb9c7d3 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -266,12 +266,10 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) WS_Release(req->ws, 0); /* XXX someone into H2 please add appropriate error handling */ - while (sendbody) { + if (sendbody) { err = VDP_push(req, &h2_vdp, NULL, 1); - if (err) - break; - err = VDP_DeliverObj(req); - break; + if (!err) + err = VDP_DeliverObj(req); } AZ(req->wrk->v1l); From fgsch at lodoss.net Thu May 3 04:51:21 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 3 May 2018 04:51:21 +0000 (UTC) Subject: [master] 773e7b9 Polish Message-ID: <20180503045122.160B9A7A83@lists.varnish-cache.org> commit 773e7b9c0fcba8ba2f20d1215821fbddf0a76374 Author: Federico G. Schwindt Date: Thu May 3 06:32:12 2018 +0200 Polish diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index a34243b..5a04770 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -77,7 +77,7 @@ static void vut_vpf_remove(void) { - assert(pfh_vut.magic == VUT_MAGIC); + CHECK_OBJ(&pfh_vut, VUT_MAGIC); AN(pfh); AN(pfh_vut.P_arg); From fgsch at lodoss.net Thu May 3 06:30:28 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 3 May 2018 06:30:28 +0000 (UTC) Subject: [master] 8b01507 Do not silence address or pointer-sign warnings Message-ID: <20180503063028.5595EA998E@lists.varnish-cache.org> commit 8b015073f03c0b7790141f5e7f2104edc1a6bd73 Author: Federico G. Schwindt Date: Thu May 3 08:02:50 2018 +0200 Do not silence address or pointer-sign warnings After recent failures discovered by travis-ci it should be safe to have this back on. diff --git a/configure.ac b/configure.ac index 3877a49..6e6734c 100644 --- a/configure.ac +++ b/configure.ac @@ -644,15 +644,8 @@ AC_ARG_ENABLE(developer-warnings, [enable_developer_warnings=no]) if test "x$SUNCC" != "xyes" && test "x$enable_developer_warnings" != "xno"; then - # compiler flags not available on gcc3 - AX_CHECK_COMPILE_FLAG([-Wno-pointer-sign], - [DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wno-pointer-sign"], [], []) - # Not available in gcc 4.1.2 - AX_CHECK_COMPILE_FLAG([-Wno-address], - [DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wno-address"]) - - # no known way to specifically disabling missing-field-initializers warnings - # keeping the rest of Wextra + # no known way to specifically disabling missing-field-initializers + # warnings keeping the rest of Wextra AX_CHECK_COMPILE_FLAG([-Wno-missing-field-initializers], [DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wno-missing-field-initializers"], [DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wno-extra"], From nils.goroll at uplex.de Thu May 3 10:00:32 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 3 May 2018 10:00:32 +0000 (UTC) Subject: [master] d324b18 micro-cleanup Message-ID: <20180503100033.04393AF681@lists.varnish-cache.org> commit d324b180e01e786f4a20a40e47db0661a25fc7ab Author: Nils Goroll Date: Thu May 3 11:58:49 2018 +0200 micro-cleanup diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index d54128a..934219e 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -206,7 +206,7 @@ vmod_shard__init(VRT_CTX, struct vmod_directors_shard **vshardp, struct vmod_directors_shard *vshard; shard__assert(); - (void)ctx; + AN(vshardp); AZ(*vshardp); ALLOC_OBJ(vshard, VMOD_SHARD_SHARD_MAGIC); From nils.goroll at uplex.de Thu May 3 11:44:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 3 May 2018 11:44:08 +0000 (UTC) Subject: [master] 7bf48a8 polish Message-ID: <20180503114408.901A7B1FC0@lists.varnish-cache.org> commit 7bf48a8e9f3fe7f92bc166db422d64cbe9bc387b Author: Nils Goroll Date: Thu May 3 13:40:56 2018 +0200 polish diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index 934219e..77b5227 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -789,8 +789,7 @@ shard_param_task(VRT_CTX, const void *id, } if (task->priv) { - p = task->priv; - CHECK_OBJ_NOTNULL(p, VMOD_SHARD_SHARD_PARAM_MAGIC); + CAST_OBJ_NOTNULL(p, task->priv, VMOD_SHARD_SHARD_PARAM_MAGIC); assert(p->scope == SCOPE_TASK); /* XXX VSL(SLT_Debug, 0, From nils.goroll at uplex.de Sat May 5 08:26:21 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 5 May 2018 08:26:21 +0000 (UTC) Subject: [master] 8f83087 constify storage ident Message-ID: <20180505082622.1F52D61CED@lists.varnish-cache.org> commit 8f83087f333109ab12d82864b8e7ac98c132cf82 Author: Nils Goroll Date: Sat May 5 10:11:08 2018 +0200 constify storage ident diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index 08f23c9..212142c 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -119,8 +119,8 @@ struct stevedore { void *priv; VTAILQ_ENTRY(stevedore) list; - char *ident; - char *vclname; + const char *ident; + const char *vclname; }; extern struct stevedore *stv_transient; From nils.goroll at uplex.de Sat May 5 08:26:22 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 5 May 2018 08:26:22 +0000 (UTC) Subject: [master] cf20e04 plug minor leaks reported by coverity Message-ID: <20180505082622.2438561CEE@lists.varnish-cache.org> commit cf20e04efa007be1632c9f137338203f9691d25a Author: Nils Goroll Date: Sat May 5 10:17:56 2018 +0200 plug minor leaks reported by coverity diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index a37ddf3..32779a9 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -189,12 +189,12 @@ STV_Config(const char *spec) *stv = *stv2; AN(stv->name); - if (name == NULL) { + if (name) { + stv->ident = name; + } else { bprintf(buf, "s%u", seq++); - name = buf; + stv->ident = strdup(buf); } - - stv->ident = strdup(name); AN(stv->ident); stv_check_ident(spec, stv->ident); diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 08977af..b0efed5 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -300,6 +300,7 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, struct token *t, ExpectErr(tl, CSTR); p = vcc_regexp(tl); bprintf(buf, "VRT_regsub(ctx, %d,\v+\n\v1,\n%s", all, p); + free(TRUST_ME(p)); *e = vcc_expr_edit(tl, STRING, buf, e2, NULL); SkipToken(tl, ','); vcc_expr0(tl, &e2, STRING); @@ -990,6 +991,7 @@ cmp_regexp(struct vcc *tl, struct expr **e, const struct cmps *cp) re = vcc_regexp(tl); ERRCHK(tl); bprintf(buf, "%sVRT_re_match(ctx, \v1, %s)", cp->emit, re); + free(TRUST_ME(re)); *e = vcc_expr_edit(tl, BOOL, buf, *e, NULL); } From nils.goroll at uplex.de Sat May 5 08:26:22 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 5 May 2018 08:26:22 +0000 (UTC) Subject: [master] 0ffb91a rename variable for clarity Message-ID: <20180505082622.38EE261CF1@lists.varnish-cache.org> commit 0ffb91a2d4ff24ecb1b44933ce280f3034a59d85 Author: Nils Goroll Date: Sat May 5 10:22:01 2018 +0200 rename variable for clarity diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index 32779a9..3f66c3a 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -159,13 +159,13 @@ void STV_Config(const char *spec) { char **av, buf[8]; - const char *name; + const char *ident; struct stevedore *stv; const struct stevedore *stv2; int ac; static unsigned seq = 0; - av = MGT_NamedArg(spec, &name, "-s"); + av = MGT_NamedArg(spec, &ident, "-s"); AN(av); if (av[1] == NULL) @@ -189,8 +189,8 @@ STV_Config(const char *spec) *stv = *stv2; AN(stv->name); - if (name) { - stv->ident = name; + if (ident) { + stv->ident = ident; } else { bprintf(buf, "s%u", seq++); stv->ident = strdup(buf); From phk at phk.freebsd.dk Sat May 5 08:44:05 2018 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Sat, 05 May 2018 08:44:05 +0000 Subject: [master] cf20e04 plug minor leaks reported by coverity In-Reply-To: <20180505082622.2438561CEE@lists.varnish-cache.org> References: <20180505082622.2438561CEE@lists.varnish-cache.org> Message-ID: <83703.1525509845@critter.freebsd.dk> -------- In message <20180505082622.2438561CEE at lists.varnish-cache.org>, Nils Goroll wri tes: >+++ b/lib/libvcc/vcc_expr.c >@@ -300,6 +300,7 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, struct token *t, > ExpectErr(tl, CSTR); > p = vcc_regexp(tl); > bprintf(buf, "VRT_regsub(ctx, %d,\v+\n\v1,\n%s", all, p); >+ free(TRUST_ME(p)); We shouldn't use TRUST_ME for trivial issues like this, it is only for use in the most extreme cases (typically b?rken external APIs we have to work with.) -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From nils.goroll at uplex.de Sat May 5 09:14:26 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 5 May 2018 11:14:26 +0200 Subject: [master] cf20e04 plug minor leaks reported by coverity In-Reply-To: <83703.1525509845@critter.freebsd.dk> References: <20180505082622.2438561CEE@lists.varnish-cache.org> <83703.1525509845@critter.freebsd.dk> Message-ID: <963f365c-3f87-c67d-ab23-ebfe5e3cefe4@uplex.de> On 05/05/18 10:44, Poul-Henning Kamp wrote: > We shouldn't use TRUST_ME for trivial issues I wonder what our options are. Here's what comes to my mind: * don't reference malloc'ed storage as const: No issue with free, but no const safety for the rest of the code * use pointers to const, but keep some other pointer to non-const for the free * don't use TRUST_ME, but effectively use the same double cast to convince the compiler Am I overlooking a better option? Thx, Nils -- ** * * UPLEX - Nils Goroll Systemoptimierung Scheffelstra?e 32 22301 Hamburg tel +49 40 28805731 mob +49 170 2723133 fax +49 40 42949753 xmpp://slink at jabber.int.uplex.de/ http://uplex.de/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From phk at phk.freebsd.dk Sat May 5 09:21:48 2018 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Sat, 05 May 2018 09:21:48 +0000 Subject: [master] cf20e04 plug minor leaks reported by coverity In-Reply-To: <963f365c-3f87-c67d-ab23-ebfe5e3cefe4@uplex.de> References: <20180505082622.2438561CEE@lists.varnish-cache.org> <83703.1525509845@critter.freebsd.dk> <963f365c-3f87-c67d-ab23-ebfe5e3cefe4@uplex.de> Message-ID: <41213.1525512108@critter.freebsd.dk> -------- >* use pointers to const, but keep some other pointer to non-const > for the free That's probably the least wrong way. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From nils.goroll at uplex.de Mon May 7 12:47:13 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 7 May 2018 12:47:13 +0000 (UTC) Subject: [master] aa2a55a MAIN.summs documentation Message-ID: <20180507124714.A1252A5956@lists.varnish-cache.org> commit aa2a55afd470d31cd8426b017121903b6808f9a1 Author: Nils Goroll Date: Mon May 7 14:45:44 2018 +0200 MAIN.summs documentation Ref #2672 diff --git a/bin/varnishd/VSC_main.vsc b/bin/varnishd/VSC_main.vsc index fd9a4e6..4fe84d8 100644 --- a/bin/varnishd/VSC_main.vsc +++ b/bin/varnishd/VSC_main.vsc @@ -11,6 +11,9 @@ :level: debug :oneliner: stat summ operations + Numer of times per-thread statistics were added to the + global counters. + .. varnish_vsc:: uptime :oneliner: Child process uptime :format: duration From nils.goroll at uplex.de Mon May 7 13:07:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 7 May 2018 13:07:08 +0000 (UTC) Subject: [master] f6268c2 fix typo Message-ID: <20180507130708.3C64CA5E73@lists.varnish-cache.org> commit f6268c2a5668d7765381ca3060271236cb856052 Author: Nils Goroll Date: Mon May 7 15:05:47 2018 +0200 fix typo spotted by @lkarsten diff --git a/bin/varnishd/VSC_main.vsc b/bin/varnishd/VSC_main.vsc index 4fe84d8..a2e2d01 100644 --- a/bin/varnishd/VSC_main.vsc +++ b/bin/varnishd/VSC_main.vsc @@ -11,7 +11,7 @@ :level: debug :oneliner: stat summ operations - Numer of times per-thread statistics were added to the + Number of times per-thread statistics were added to the global counters. .. varnish_vsc:: uptime From nils.goroll at uplex.de Mon May 7 13:48:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 7 May 2018 13:48:08 +0000 (UTC) Subject: [master] de2b431 allocate dynamic privs on the appropriate workspace Message-ID: <20180507134808.46057A69C1@lists.varnish-cache.org> commit de2b431086a13b243dc8b3e71cd8697db1df2c7f Author: Nils Goroll Date: Thu May 3 13:27:31 2018 +0200 allocate dynamic privs on the appropriate workspace A show stopper used to be that the top request's workspace was reserved for delivery during ESI processing, but since beeaa19cced3fe1ab79381b2b1b7b0b5594cbb18 the path is clear. diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index 9580a32..245a4b8 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -92,24 +92,25 @@ VRTPRIV_init(struct vrt_privs *privs) } static struct vmod_priv * -vrt_priv_dynamic(VRT_CTX, struct vrt_privs *vps, uintptr_t id, - uintptr_t vmod_id) +vrt_priv_dynamic(const struct vcl *vcl, struct ws *ws, + struct vrt_privs *vps, uintptr_t id, uintptr_t vmod_id) { struct vrt_priv *vp; - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(vps, VRT_PRIVS_MAGIC); AN(vmod_id); VTAILQ_FOREACH(vp, &vps->privs, list) { CHECK_OBJ_NOTNULL(vp, VRT_PRIV_MAGIC); - if (vp->vcl == ctx->vcl && vp->id == id && + if (vp->vcl == vcl && vp->id == id && vp->vmod_id == vmod_id) return (vp->priv); } - ALLOC_OBJ(vp, VRT_PRIV_MAGIC); - AN(vp); - vp->vcl = ctx->vcl; + vp = WS_Alloc(ws, sizeof *vp); + if (vp == NULL) + return NULL; + INIT_OBJ(vp, VRT_PRIV_MAGIC); + vp->vcl = vcl; vp->id = id; vp->vmod_id = vmod_id; VTAILQ_INSERT_TAIL(&vps->privs, vp, list); @@ -129,7 +130,6 @@ VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id) if (id == vp->id) { VTAILQ_REMOVE(&privs->privs, vp, list); VRT_priv_fini(vp->priv); - FREE_OBJ(vp); } } } @@ -154,7 +154,8 @@ VRT_priv_task(VRT_CTX, const void *vmod_id) id = (uintptr_t)cli_task_privs; CAST_OBJ_NOTNULL(vps, cli_task_privs, VRT_PRIVS_MAGIC); } - return (vrt_priv_dynamic(ctx, vps, id, (uintptr_t)vmod_id)); + return (vrt_priv_dynamic(ctx->vcl, ctx->ws, + vps, id, (uintptr_t)vmod_id)); } struct vmod_priv * @@ -169,7 +170,8 @@ VRT_priv_top(VRT_CTX, const void *vmod_id) CHECK_OBJ_NOTNULL(ctx->req->top, REQ_MAGIC); id = (uintptr_t)&ctx->req->top->top; CAST_OBJ_NOTNULL(vps, ctx->req->top->privs, VRT_PRIVS_MAGIC); - return (vrt_priv_dynamic(ctx, vps, id, (uintptr_t)vmod_id)); + return (vrt_priv_dynamic(ctx->vcl, ctx->req->top->ws, + vps, id, (uintptr_t)vmod_id)); } else WRONG("PRIV_TOP is only accessible in client VCL context"); NEEDLESS(return NULL); From phk at FreeBSD.org Mon May 7 21:51:19 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 7 May 2018 21:51:19 +0000 (UTC) Subject: [master] a98d2b5 Add a copyright to this file Message-ID: <20180507215119.89DB4B0CD9@lists.varnish-cache.org> commit a98d2b55c79a9959efd814bd9a316415ebc8dac8 Author: Poul-Henning Kamp Date: Mon May 7 21:44:11 2018 +0000 Add a copyright to this file diff --git a/bin/varnishtest/vtc_h2_priv.h b/bin/varnishtest/vtc_h2_priv.h index 706ba0c..796e940 100644 --- a/bin/varnishtest/vtc_h2_priv.h +++ b/bin/varnishtest/vtc_h2_priv.h @@ -1,3 +1,31 @@ +/*- + * Copyright (c) 2008-2016 Varnish Software AS + * All rights reserved. + * + * Author: Guillaume Quintard + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * 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. + */ + #include "vqueue.h" #define ITER_DONE(iter) (iter->buf == iter->end ? hpk_done : hpk_more) From phk at FreeBSD.org Mon May 7 21:51:19 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 7 May 2018 21:51:19 +0000 (UTC) Subject: [master] 0a1cabf A little bit of flexelintery Message-ID: <20180507215119.9F14BB0CDC@lists.varnish-cache.org> commit 0a1cabfe36862c2d1499aecdff6ec4d09fa3bebe Author: Poul-Henning Kamp Date: Mon May 7 21:50:25 2018 +0000 A little bit of flexelintery diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt index 78c17a9..6e392f2 100644 --- a/bin/varnishtest/flint.lnt +++ b/bin/varnishtest/flint.lnt @@ -10,6 +10,8 @@ -emacro({779}, ENC) // String constant in comparison operator '!=' -emacro({506}, CHKFRAME) // Constant value Boolean +-sem(http_process_cleanup, custodial(1)) + -esym(522, teken_subr_*) -esym(850, av) diff --git a/bin/varnishtest/vtc_h2_hpack.c b/bin/varnishtest/vtc_h2_hpack.c index 9b6f250..403db13 100644 --- a/bin/varnishtest/vtc_h2_hpack.c +++ b/bin/varnishtest/vtc_h2_hpack.c @@ -259,7 +259,7 @@ str_decode(struct hpk_iter *iter, struct txt *t) if (num > iter->end - iter->buf) return (hpk_err); if (huff) { /*Huffman encoding */ - t->ptr = malloc((num * 8) / 5L + 1L); + t->ptr = malloc((num * 8L) / 5L + 1L); AN(t->ptr); num = huff_decode(t->ptr, (num * 8) / 5, iter, num); if (!num) { diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index 5e3816b..95f6c05 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -320,7 +320,7 @@ term_expect_text(struct process *pp, } static void -term_expect_cursor(struct process *pp, const char *lin, const char *col) +term_expect_cursor(const struct process *pp, const char *lin, const char *col) { int x, y; const teken_pos_t *pos; diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c index 2943058..33ead86 100644 --- a/bin/varnishtest/vtc_server.c +++ b/bin/varnishtest/vtc_server.c @@ -327,7 +327,7 @@ server_dispatch_thread(void *priv) vtc_log(vl, 2, "Dispatch started on %s", s->listen); - while (1) { + while (!vtc_stop) { addr = (void*)&addr_s; l = sizeof addr_s; fd = accept(s->sock, addr, &l); From nils.goroll at uplex.de Tue May 8 08:13:20 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 8 May 2018 08:13:20 +0000 (UTC) Subject: [master] dccb56b create a char * argument for umem_cache_create() Message-ID: <20180508081320.D28646172B@lists.varnish-cache.org> commit dccb56bfd9a975d03467d698b66c04ab0758cb43 Author: Nils Goroll Date: Tue May 8 10:09:54 2018 +0200 create a char * argument for umem_cache_create() required after the constification in 8f83087f333109ab12d82864b8e7ac98c132cf82 I have no idea why the umem authors did not make this argument a const, they call strncpy on it diff --git a/bin/varnishd/storage/storage_umem.c b/bin/varnishd/storage/storage_umem.c index e366939..ace9035 100644 --- a/bin/varnishd/storage/storage_umem.c +++ b/bin/varnishd/storage/storage_umem.c @@ -392,6 +392,7 @@ static void v_matchproto_(storage_open_f) smu_open(struct stevedore *st) { struct smu_sc *smu_sc; + char ident[strlen(st->ident) + 1]; ASSERT_CLI(); st->lru = LRU_Alloc(); @@ -405,7 +406,8 @@ smu_open(struct stevedore *st) smu_open_init(); - smu_sc->smu_cache = umem_cache_createf(st->ident, + AN(strcpy(ident, st->ident)); + smu_sc->smu_cache = umem_cache_createf(ident, sizeof(struct smu), 0, // align smu_smu_constructor, From daghf at varnish-software.com Tue May 8 09:51:14 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Tue, 8 May 2018 09:51:14 +0000 (UTC) Subject: [master] 95ab1c5 Formatting Message-ID: <20180508095114.70B1F63341@lists.varnish-cache.org> commit 95ab1c5784a016ec02ee5f53a884badefd170ed3 Author: Dag Haavi Finstad Date: Tue May 8 11:50:23 2018 +0200 Formatting diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index 245a4b8..8d83f17 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -108,7 +108,7 @@ vrt_priv_dynamic(const struct vcl *vcl, struct ws *ws, } vp = WS_Alloc(ws, sizeof *vp); if (vp == NULL) - return NULL; + return (NULL); INIT_OBJ(vp, VRT_PRIV_MAGIC); vp->vcl = vcl; vp->id = id; From nils.goroll at uplex.de Tue May 8 15:55:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 8 May 2018 15:55:08 +0000 (UTC) Subject: [master] e66c5eb avoid TRUST_ME in shard director Message-ID: <20180508155508.8276D94B94@lists.varnish-cache.org> commit e66c5eb5a221144628f3a6a44d5d72f629f68ed2 Author: Nils Goroll Date: Tue May 8 17:13:37 2018 +0200 avoid TRUST_ME in shard director diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c index 942932e..d8ac651 100644 --- a/lib/libvmod_directors/shard_cfg.c +++ b/lib/libvmod_directors/shard_cfg.c @@ -293,8 +293,8 @@ shardcfg_hashcircle(struct sharddir *shardd, VCL_INT replicas) static void shardcfg_backend_free(struct shard_backend *f) { - if (f->ident) - free (TRUST_ME(f->ident)); + if (f->freeptr) + free (f->freeptr); memset(f, 0, sizeof(*f)); } diff --git a/lib/libvmod_directors/shard_dir.h b/lib/libvmod_directors/shard_dir.h index 350437f..7bf5d75 100644 --- a/lib/libvmod_directors/shard_dir.h +++ b/lib/libvmod_directors/shard_dir.h @@ -57,7 +57,10 @@ struct shard_circlepoint { struct shard_backend { VCL_BACKEND backend; - const char *ident; // XXX COPY IN ! + union { + const char *ident; + void *freeptr; + }; VCL_DURATION rampup; uint32_t canon_point; }; From nils.goroll at uplex.de Tue May 8 15:55:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 8 May 2018 15:55:08 +0000 (UTC) Subject: [master] 1fa6b74 use a vsb to return vcc_regexp's result Message-ID: <20180508155508.97A2194B98@lists.varnish-cache.org> commit 1fa6b742df0a1bec4185e05f45a36b11ad75ece1 Author: Nils Goroll Date: Tue May 8 17:50:33 2018 +0200 use a vsb to return vcc_regexp's result to avoid micro-managing memory Follow up cf20e04efa007be1632c9f137338203f9691d25a diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index f530095..fef82ec 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -322,7 +322,7 @@ void vcc_Parse_Init(struct vcc *); sym_act_f vcc_Act_If; /* vcc_utils.c */ -const char *vcc_regexp(struct vcc *tl); +void vcc_regexp(struct vcc *tl, struct vsb *vgc_name); void Resolve_Sockaddr(struct vcc *tl, const char *host, const char *defport, const char **ipv4, const char **ipv4_ascii, const char **ipv6, const char **ipv6_ascii, const char **p_ascii, int maxips, diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index b0efed5..37bfb04 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -288,8 +288,8 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, struct token *t, { struct expr *e2; int all = sym->eval_priv == NULL ? 0 : 1; - const char *p; char buf[128]; + struct vsb vsb; (void)t; (void)fmt; @@ -298,10 +298,13 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, struct token *t, ERRCHK(tl); SkipToken(tl, ','); ExpectErr(tl, CSTR); - p = vcc_regexp(tl); - bprintf(buf, "VRT_regsub(ctx, %d,\v+\n\v1,\n%s", all, p); - free(TRUST_ME(p)); - *e = vcc_expr_edit(tl, STRING, buf, e2, NULL); + + AN(VSB_new(&vsb, buf, sizeof buf, VSB_FIXEDLEN)); + VSB_printf(&vsb, "VRT_regsub(ctx, %d,\v+\n\v1,\n", all); + vcc_regexp(tl, &vsb); + ERRCHK(tl); + AZ(VSB_finish(&vsb)); + *e = vcc_expr_edit(tl, STRING, VSB_data(&vsb), e2, NULL); SkipToken(tl, ','); vcc_expr0(tl, &e2, STRING); ERRCHK(tl); @@ -983,16 +986,18 @@ static void v_matchproto_(cmp_f) cmp_regexp(struct vcc *tl, struct expr **e, const struct cmps *cp) { char buf[128]; - const char *re; + struct vsb vsb; *e = vcc_expr_edit(tl, STRING, "\vS", *e, NULL); vcc_NextToken(tl); ExpectErr(tl, CSTR); - re = vcc_regexp(tl); + AN(VSB_new(&vsb, buf, sizeof buf, VSB_FIXEDLEN)); + VSB_printf(&vsb, "%sVRT_re_match(ctx, \v1, ", cp->emit); + vcc_regexp(tl, &vsb); ERRCHK(tl); - bprintf(buf, "%sVRT_re_match(ctx, \v1, %s)", cp->emit, re); - free(TRUST_ME(re)); - *e = vcc_expr_edit(tl, BOOL, buf, *e, NULL); + VSB_cat(&vsb, ")"); + AZ(VSB_finish(&vsb)); + *e = vcc_expr_edit(tl, BOOL, VSB_data(&vsb), *e, NULL); } static void v_matchproto_(cmp_f) diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c index 33e2aa6..71db6a7 100644 --- a/lib/libvcc/vcc_utils.c +++ b/lib/libvcc/vcc_utils.c @@ -47,10 +47,10 @@ /*--------------------------------------------------------------------*/ -const char * -vcc_regexp(struct vcc *tl) +void +vcc_regexp(struct vcc *tl, struct vsb *vgc_name) { - char buf[BUFSIZ], *p; + char buf[BUFSIZ]; vre_t *t; const char *error; int erroroffset; @@ -58,18 +58,18 @@ vcc_regexp(struct vcc *tl) Expect(tl, CSTR); if (tl->err) - return (NULL); + return; t = VRE_compile(tl->t->dec, 0, &error, &erroroffset); if (t == NULL) { VSB_printf(tl->sb, "Regexp compilation error:\n\n%s\n\n", error); vcc_ErrWhere(tl, tl->t); - return (NULL); + return; } VRE_free(&t); bprintf(buf, "VGC_re_%u", tl->unique++); - p = TlAlloc(tl, strlen(buf) + 1); - strcpy(p, buf); + if (vgc_name) + VSB_cat(vgc_name, buf); Fh(tl, 0, "static void *%s;\n", buf); ifp = New_IniFin(tl); @@ -78,7 +78,6 @@ vcc_regexp(struct vcc *tl) VSB_printf(ifp->ini, ");"); VSB_printf(ifp->fin, "\t\tVRT_re_fini(%s);", buf); vcc_NextToken(tl); - return (p); } /* From phk at FreeBSD.org Sun May 13 19:01:27 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 13 May 2018 19:01:27 +0000 (UTC) Subject: [master] 097daab Whitespace OCD Message-ID: <20180513190127.97DFDB25D9@lists.varnish-cache.org> commit 097daab465288458176a8b74e2e0a52aa53e46a6 Author: Poul-Henning Kamp Date: Sun May 13 14:22:21 2018 +0000 Whitespace OCD diff --git a/bin/varnishtest/tests/o00005.vtc b/bin/varnishtest/tests/o00005.vtc index f1e92fc..3ec7a28 100644 --- a/bin/varnishtest/tests/o00005.vtc +++ b/bin/varnishtest/tests/o00005.vtc @@ -47,7 +47,7 @@ client c1 { 25 00 05 45 43 32 35 36 24 00 0a 52 53 41 2d 53 48 41 32 35 36 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 - 2d 47 43 4d 2d 53 48 41 32 35 36 + 2d 47 43 4d 2d 53 48 41 32 35 36 } txreq rxresp @@ -92,7 +92,7 @@ client c1 { 25 00 05 45 43 32 35 36 24 00 0a 52 53 41 2d 53 48 41 32 35 36 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 - 2d 47 43 4d 2d 53 48 41 32 35 36 + 2d 47 43 4d 2d 53 48 41 32 35 36 } txreq expect_close @@ -125,7 +125,7 @@ client c1 { 25 00 05 45 43 32 35 36 24 00 0a 52 53 41 2d 53 48 41 32 35 36 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 - 2d 47 43 4d 2d 53 48 41 32 35 36 + 2d 47 43 4d 2d 53 48 41 32 35 36 ff ff } txreq @@ -159,7 +159,7 @@ client c1 { 25 00 05 45 43 32 35 36 24 00 0a 52 53 41 2d 53 48 41 32 35 36 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 - 2d 47 43 4d 2d 53 48 41 32 35 36 + 2d 47 43 4d 2d 53 48 41 32 35 36 } txreq expect_close @@ -192,7 +192,7 @@ client c1 { 25 00 05 45 43 32 35 36 24 00 0a 52 53 41 2d 53 48 41 32 35 36 23 00 16 41 45 41 44 2d 41 45 53 31 32 38 - 2d 47 43 4d 2d 53 48 41 32 35 36 + 2d 47 43 4d 2d 53 48 41 32 35 36 } txreq expect_close diff --git a/bin/varnishtest/tests/r02649.vtc b/bin/varnishtest/tests/r02649.vtc index 4ee5e41..71cd348 100644 --- a/bin/varnishtest/tests/r02649.vtc +++ b/bin/varnishtest/tests/r02649.vtc @@ -15,4 +15,4 @@ delay 1 process p1 -expect-exit 0 -stop -wait # Expect empty stderr output -shell -match {^[ ]*0\b} "wc -c ${tmpdir}/p1/stderr" +shell -match {^[ ]*0\b} "wc -c ${tmpdir}/p1/stderr" From phk at FreeBSD.org Sun May 13 19:01:27 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 13 May 2018 19:01:27 +0000 (UTC) Subject: [master] 0f81a95 Give VDI->list() a j_flag argument for JSON output. Message-ID: <20180513190127.9DD4CB25DB@lists.varnish-cache.org> commit 0f81a958212a4062f2894590663d6dd86115b42b Author: Poul-Henning Kamp Date: Sun May 13 14:22:29 2018 +0000 Give VDI->list() a j_flag argument for JSON output. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 982183b..512886a 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -411,12 +411,14 @@ vbe_panic(const struct director *d, struct vsb *vsb) */ static void -vbe_list(const struct director *d, struct vsb *vsb, int vflag, int pflag) +vbe_list(const struct director *d, struct vsb *vsb, int vflag, int pflag, + int jflag) { struct backend *bp; CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC); + AZ(jflag); if (bp->probe != NULL) VBP_Status(vsb, bp, vflag | pflag); diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index f5552fe..671e305 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -36,7 +36,6 @@ #include "config.h" #include "cache_varnishd.h" - #include "cache_director.h" #include "vcli_serve.h" @@ -292,14 +291,14 @@ do_list(struct cli *cli, struct director *d, void *priv) VCLI_Out(cli, "\n%-30s %-7s ", d->vdir->cli_name, VDI_Ahealth(d)); if (d->vdir->methods->list != NULL) - d->vdir->methods->list(d, cli->sb, 0, 0); + d->vdir->methods->list(d, cli->sb, 0, 0, 0); else VCLI_Out(cli, "%-10s", d->sick ? "sick" : "healthy"); VTIM_format(d->vdir->health_changed, time_str); VCLI_Out(cli, " %s", time_str); if ((la->p || la->v) && d->vdir->methods->list != NULL) - d->vdir->methods->list(d, cli->sb, la->p, la->v); + d->vdir->methods->list(d, cli->sb, la->p, la->v, 0); return (0); } diff --git a/include/vrt.h b/include/vrt.h index a0c142c..9af2346 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -426,7 +426,7 @@ typedef enum sess_close vdi_http1pipe_f(VRT_CTX, VCL_BACKEND); typedef void vdi_event_f(VCL_BACKEND, enum vcl_event_e); typedef void vdi_destroy_f(VCL_BACKEND); typedef void vdi_panic_f(VCL_BACKEND, struct vsb *); -typedef void vdi_list_f(VCL_BACKEND, struct vsb *, int, int); +typedef void vdi_list_f(VCL_BACKEND, struct vsb *, int, int, int); struct vdi_methods { unsigned magic; From phk at FreeBSD.org Sun May 13 19:01:27 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 13 May 2018 19:01:27 +0000 (UTC) Subject: [master] 467f10c Implement backend.list -j Message-ID: <20180513190127.D7431B25E0@lists.varnish-cache.org> commit 467f10c5d572add23ff2f7e6ed5746cf89152b76 Author: Poul-Henning Kamp Date: Sun May 13 18:45:34 2018 +0000 Implement backend.list -j diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 512886a..cc3eef8 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -418,11 +418,12 @@ vbe_list(const struct director *d, struct vsb *vsb, int vflag, int pflag, CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC); - AZ(jflag); if (bp->probe != NULL) - VBP_Status(vsb, bp, vflag | pflag); - else if ((vflag | pflag) == 0) + VBP_Status(vsb, bp, vflag | pflag, jflag); + else if ((vflag | pflag) == 0 && jflag) + VSB_printf(vsb, "\"%s\",\n", d->sick ? "sick" : "healthy"); + else VSB_printf(vsb, "%-10s", d->sick ? "sick" : "healthy"); } diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index 1872c70..940e242 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -81,4 +81,4 @@ void VBP_Insert(struct backend *b, struct vrt_backend_probe const *p, struct tcp_pool *); void VBP_Remove(struct backend *b); void VBP_Control(const struct backend *b, int stop); -void VBP_Status(struct vsb *, const struct backend *, int details); +void VBP_Status(struct vsb *, const struct backend *, int details, int json); diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 37b6016..2299d1b 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -473,7 +473,7 @@ vbp_bitmap(struct vsb *vsb, char c, uint64_t map, const char *lbl) /*lint -e{506} constant value boolean */ /*lint -e{774} constant value boolean */ void -VBP_Status(struct vsb *vsb, const struct backend *be, int details) +VBP_Status(struct vsb *vsb, const struct backend *be, int details, int json) { struct vbp_target *vt; char buf[12]; @@ -483,9 +483,27 @@ VBP_Status(struct vsb *vsb, const struct backend *be, int details) CHECK_OBJ_NOTNULL(vt, VBP_TARGET_MAGIC); if (!details) { - bprintf(buf, "%d/%d %s", vt->good, vt->window, - vt->backend->director->sick ? "bad" : "good"); - VSB_printf(vsb, "%-10s", buf); + if (json) { + VSB_printf(vsb, "[%u, %u, \"%s\"]", + vt->good, vt->window, + vt->backend->director->sick ? "bad" : "good"); + } else { + bprintf(buf, "%u/%u %s", vt->good, vt->window, + vt->backend->director->sick ? "bad" : "good"); + VSB_printf(vsb, "%-10s", buf); + } + return; + } + + if (json) { + VSB_printf(vsb, "{\n"); +#define BITMAP(nn, cc, tt, bb) \ + VSB_printf(vsb, "\t \"bits_%c\": %ju,\n", cc, vt->nn); +#include "tbl/backend_poll.h" + VSB_printf(vsb, "\t \"good\": %u,\n", vt->good); + VSB_printf(vsb, "\t \"threshold\": %u,\n", vt->threshold); + VSB_printf(vsb, "\t \"window\": %u\n", vt->window); + VSB_printf(vsb, "\t },\n"); return; } diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 671e305..51723a0 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -273,6 +273,8 @@ struct list_args { #define LIST_ARGS_MAGIC 0x7e7cefeb int p; int v; + int j; + const char *jsep; }; static int v_matchproto_(vcl_be_func) @@ -302,6 +304,39 @@ do_list(struct cli *cli, struct director *d, void *priv) return (0); } +static int v_matchproto_(vcl_be_func) +do_list_json(struct cli *cli, struct director *d, void *priv) +{ + struct list_args *la; + + CAST_OBJ_NOTNULL(la, priv, LIST_ARGS_MAGIC); + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + + if (d->vdir->admin_health == VDI_AH_DELETED) + return (0); + + VCLI_Out(cli, "%s", la->jsep); + la->jsep = ",\n "; + // XXX admin health "probe" for the no-probe case is confusing + VCLI_Out(cli, "\"%s\": {\n", d->vdir->cli_name); + VCLI_Out(cli, "\t\"type\": \"%s\",\n", d->vdir->methods->type); + VCLI_Out(cli, "\t\"admin_health\": \"%s\",\n", VDI_Ahealth(d)); + VCLI_Out(cli, "\t\"probe_health\": "); + if (d->vdir->methods->list != NULL) + d->vdir->methods->list(d, cli->sb, 0, 0, 1); + else + VCLI_Out(cli, "\"%s\"", d->sick ? "sick" : "healthy"); + VCLI_Out(cli, ",\n"); + + if ((la->p || la->v) && d->vdir->methods->list != NULL) { + VCLI_Out(cli, "\t\"probe_details\": "); + d->vdir->methods->list(d, cli->sb, la->p, la->v, 1); + } + VCLI_Out(cli, "\t\"last_change\": %.3f\n }", + d->vdir->health_changed); + return (0); +} + static void v_matchproto_(cli_func_t) cli_backend_list(struct cli *cli, const char * const *av, void *priv) { @@ -311,9 +346,11 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv) (void)priv; ASSERT_CLI(); INIT_OBJ(la, LIST_ARGS_MAGIC); + la->jsep = "\n "; while (av[2] != NULL && av[2][0] == '-') { for(p = av[2] + 1; *p; p++) { switch(*p) { + case 'j': la->j = 1; break; case 'p': la->p = !la->p; break; case 'v': la->p = !la->p; break; default: @@ -329,9 +366,15 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv) VCLI_SetResult(cli, CLIS_PARAM); return; } - VCLI_Out(cli, "%-30s %-7s %-10s %s", - "Backend name", "Admin", "Probe", "Last change"); - (void)VCL_IterDirector(cli, av[2], do_list, la); + if (la->j) { + VCLI_Out(cli, "{"); + (void)VCL_IterDirector(cli, av[2], do_list_json, la); + VCLI_Out(cli, "\n}\n"); + } else { + VCLI_Out(cli, "%-30s %-7s %-10s %s", + "Backend name", "Admin", "Probe", "Last change"); + (void)VCL_IterDirector(cli, av[2], do_list, la); + } } /*---------------------------------------------------------------------*/ @@ -389,7 +432,8 @@ cli_backend_set_health(struct cli *cli, const char * const *av, void *priv) /*---------------------------------------------------------------------*/ static struct cli_proto backend_cmds[] = { - { CLICMD_BACKEND_LIST, "", cli_backend_list }, + { CLICMD_BACKEND_LIST, "", + cli_backend_list, cli_backend_list }, { CLICMD_BACKEND_SET_HEALTH, "", cli_backend_set_health }, { NULL } }; diff --git a/bin/varnishtest/tests/d00005.vtc b/bin/varnishtest/tests/d00005.vtc index 1706901..202b57b 100644 --- a/bin/varnishtest/tests/d00005.vtc +++ b/bin/varnishtest/tests/d00005.vtc @@ -94,3 +94,6 @@ client c1 { rxresp expect resp.body == "4444" } -run + +varnish v1 -vsl_catchup +varnish v1 -cliok "backend.list -j" diff --git a/bin/varnishtest/tests/v00014.vtc b/bin/varnishtest/tests/v00014.vtc index 01c8251..7b9212a 100644 --- a/bin/varnishtest/tests/v00014.vtc +++ b/bin/varnishtest/tests/v00014.vtc @@ -50,6 +50,7 @@ varnish v1 -vcl { } -start varnish v1 -cliok "backend.list -p" +varnish v1 -cliok "backend.list -j -p" client c1 { txreq From phk at FreeBSD.org Sun May 13 19:01:27 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 13 May 2018 19:01:27 +0000 (UTC) Subject: [master] 6aacf4d Pass -j args to child Message-ID: <20180513190127.B3F98B25DD@lists.varnish-cache.org> commit 6aacf4db6654b533ad4b800ca8d6b6f7651bb68c Author: Poul-Henning Kamp Date: Sun May 13 15:09:04 2018 +0000 Pass -j args to child diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index bc9c2a7..3304ef0 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -162,10 +162,10 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv) } static const struct cli_cmd_desc CLICMD_WILDCARD[1] = - {{ "*", "", "", "", 0, -1 }}; + {{ "*", "", "", "", 0, 999 }}; static struct cli_proto cli_askchild[] = { - { CLICMD_WILDCARD, "h*", mcf_askchild }, + { CLICMD_WILDCARD, "h*", mcf_askchild, mcf_askchild }, { NULL } }; diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c index a5e6714..67c6816 100644 --- a/lib/libvarnish/vcli_serve.c +++ b/lib/libvarnish/vcli_serve.c @@ -215,7 +215,7 @@ cls_dispatch(struct cli *cli, const struct cli_proto *cp, return; } - if (ac - 1> cp->desc->maxarg + json) { + if (ac - 1 > cp->desc->maxarg + json) { VCLI_Out(cli, "Too many parameters\n"); VCLI_SetResult(cli, CLIS_TOOMANY); return; From phk at FreeBSD.org Sun May 13 20:53:21 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 13 May 2018 20:53:21 +0000 (UTC) Subject: [master] a4232d1 Add -clijson, which checks that CLI output can be parsed as JSON Message-ID: <20180513205321.D57CAB47F1@lists.varnish-cache.org> commit a4232d10db070a171057da577d4f102c012fd660 Author: Poul-Henning Kamp Date: Sun May 13 20:30:29 2018 +0000 Add -clijson, which checks that CLI output can be parsed as JSON diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index a688b62..b7304b5 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -47,6 +47,7 @@ #include "vapi/vsl.h" #include "vapi/vsm.h" #include "vcli.h" +#include "vjsn.h" #include "vre.h" #include "vsub.h" #include "vtcp.h" @@ -656,6 +657,34 @@ varnish_wait(struct varnish *v) /********************************************************************** + * Ask a CLI JSON question + */ + +static void +varnish_cli_json(struct varnish *v, const char *cli) +{ + enum VCLI_status_e u; + char *resp = NULL; + const char *errptr; + struct vjsn *vj; + + if (v->cli_fd < 0) + varnish_launch(v); + if (vtc_error) + return; + u = varnish_ask_cli(v, cli, &resp); + vtc_log(v->vl, 2, "CLI %03u <%s>", u, cli); + if (u != CLIS_OK) + vtc_fatal(v->vl, + "FAIL CLI response %u expected %u", u, CLIS_OK); + vj = vjsn_parse(resp, &errptr); + if (vj == NULL) + vtc_fatal(v->vl, "FAIL CLI, not good JSON: %s", errptr); + vjsn_delete(&vj); + free(resp); +} + +/********************************************************************** * Ask a CLI question */ @@ -1005,7 +1034,7 @@ varnish_expect(const struct varnish *v, char * const *av) * ``varnishadm``) with these additional switches:: * * varnish vNAME [-cli STRING] [-cliok STRING] [-clierr STRING] - * [-expect STRING OP NUMBER] + * [-clijson STRING] [-expect STRING OP NUMBER] * * \-cli STRING|-cliok STRING|-clierr STATUS STRING|-cliexpect REGEXP STRING * All four of these will send STRING to the CLI, the only difference @@ -1013,6 +1042,10 @@ varnish_expect(const struct varnish *v, char * const *av) * anything, -cliok expects 200, -clierr expects STATUS, and * -cliexpect expects the REGEXP to match the returned response. * + * \-clijson STRING + * Send STRING to the CLI, expect success (CLIS_OK/200) and check + * that the response is parsable JSON. + * * \-expect PATTERN OP NUMBER * Look into the VSM and make sure the first VSC counter identified by * PATTERN has a correct value. OP can be ==, >, >=, <, <=. For @@ -1099,6 +1132,12 @@ cmd_varnish(CMD_ARGS) av += 2; continue; } + if (!strcmp(*av, "-clijson")) { + AN(av[1]); + varnish_cli_json(v, av[1]); + av++; + continue; + } if (!strcmp(*av, "-cliok")) { AN(av[1]); varnish_cli(v, av[1], (unsigned)CLIS_OK, NULL); From phk at FreeBSD.org Sun May 13 20:53:21 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 13 May 2018 20:53:21 +0000 (UTC) Subject: [master] b55cfa1 Make help -j output real JSON, and push backend.list -j into the schema intended for JSON output. Message-ID: <20180513205321.DDE4AB47F2@lists.varnish-cache.org> commit b55cfa1bee60f14314e9a70da58350299c922d15 Author: Poul-Henning Kamp Date: Sun May 13 20:52:10 2018 +0000 Make help -j output real JSON, and push backend.list -j into the schema intended for JSON output. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index cc3eef8..5b553d2 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -422,7 +422,7 @@ vbe_list(const struct director *d, struct vsb *vsb, int vflag, int pflag, if (bp->probe != NULL) VBP_Status(vsb, bp, vflag | pflag, jflag); else if ((vflag | pflag) == 0 && jflag) - VSB_printf(vsb, "\"%s\",\n", d->sick ? "sick" : "healthy"); + VSB_printf(vsb, "\"%s\"", d->sick ? "sick" : "healthy"); else VSB_printf(vsb, "%-10s", d->sick ? "sick" : "healthy"); } diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 2299d1b..9eb7a7f 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -483,27 +483,27 @@ VBP_Status(struct vsb *vsb, const struct backend *be, int details, int json) CHECK_OBJ_NOTNULL(vt, VBP_TARGET_MAGIC); if (!details) { - if (json) { - VSB_printf(vsb, "[%u, %u, \"%s\"]", - vt->good, vt->window, - vt->backend->director->sick ? "bad" : "good"); - } else { - bprintf(buf, "%u/%u %s", vt->good, vt->window, - vt->backend->director->sick ? "bad" : "good"); + bprintf(buf, "%u/%u %s", vt->good, vt->window, + vt->backend->director->sick ? "bad" : "good"); + if (json) + VSB_printf(vsb, "\"%s\"", buf); + else VSB_printf(vsb, "%-10s", buf); - } return; } if (json) { VSB_printf(vsb, "{\n"); + VSB_indent(vsb, 2); #define BITMAP(nn, cc, tt, bb) \ - VSB_printf(vsb, "\t \"bits_%c\": %ju,\n", cc, vt->nn); + VSB_printf(vsb, "\"bits_%c\": %ju,\n", cc, vt->nn); #include "tbl/backend_poll.h" - VSB_printf(vsb, "\t \"good\": %u,\n", vt->good); - VSB_printf(vsb, "\t \"threshold\": %u,\n", vt->threshold); - VSB_printf(vsb, "\t \"window\": %u\n", vt->window); - VSB_printf(vsb, "\t },\n"); + VSB_printf(vsb, "\"good\": %u,\n", vt->good); + VSB_printf(vsb, "\"threshold\": %u,\n", vt->threshold); + VSB_printf(vsb, "\"window\": %u", vt->window); + VSB_indent(vsb, -2); + VSB_printf(vsb, "\n"); + VSB_printf(vsb, "},\n"); return; } diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 51723a0..a80f751 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -316,12 +316,14 @@ do_list_json(struct cli *cli, struct director *d, void *priv) return (0); VCLI_Out(cli, "%s", la->jsep); - la->jsep = ",\n "; + la->jsep = ",\n"; // XXX admin health "probe" for the no-probe case is confusing - VCLI_Out(cli, "\"%s\": {\n", d->vdir->cli_name); - VCLI_Out(cli, "\t\"type\": \"%s\",\n", d->vdir->methods->type); - VCLI_Out(cli, "\t\"admin_health\": \"%s\",\n", VDI_Ahealth(d)); - VCLI_Out(cli, "\t\"probe_health\": "); + VCLI_JSON_str(cli, d->vdir->cli_name); + VCLI_Out(cli, ": {\n"); + VSB_indent(cli->sb, 2); + VCLI_Out(cli, "\"type\": \"%s\",\n", d->vdir->methods->type); + VCLI_Out(cli, "\"admin_health\": \"%s\",\n", VDI_Ahealth(d)); + VCLI_Out(cli, "\"probe_message\": "); if (d->vdir->methods->list != NULL) d->vdir->methods->list(d, cli->sb, 0, 0, 1); else @@ -329,11 +331,12 @@ do_list_json(struct cli *cli, struct director *d, void *priv) VCLI_Out(cli, ",\n"); if ((la->p || la->v) && d->vdir->methods->list != NULL) { - VCLI_Out(cli, "\t\"probe_details\": "); + VCLI_Out(cli, "\"probe_details\": "); d->vdir->methods->list(d, cli->sb, la->p, la->v, 1); } - VCLI_Out(cli, "\t\"last_change\": %.3f\n }", - d->vdir->health_changed); + VCLI_Out(cli, "\"last_change\": %.3f\n", d->vdir->health_changed); + VSB_indent(cli->sb, -2); + VCLI_Out(cli, "}"); return (0); } @@ -342,13 +345,14 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv) { const char *p; struct list_args la[1]; + int i; (void)priv; ASSERT_CLI(); INIT_OBJ(la, LIST_ARGS_MAGIC); - la->jsep = "\n "; - while (av[2] != NULL && av[2][0] == '-') { - for(p = av[2] + 1; *p; p++) { + la->jsep = ""; + for (i = 2; av[i] != NULL && av[i][0] == '-'; i++) { + for(p = av[i] + 1; *p; p++) { switch(*p) { case 'j': la->j = 1; break; case 'p': la->p = !la->p; break; @@ -359,21 +363,26 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv) return; } } - av++; } - if (av[3] != NULL) { + if (av[i] != NULL && av[i+1] != NULL) { VCLI_Out(cli, "Too many arguments"); VCLI_SetResult(cli, CLIS_PARAM); return; } if (la->j) { - VCLI_Out(cli, "{"); - (void)VCL_IterDirector(cli, av[2], do_list_json, la); - VCLI_Out(cli, "\n}\n"); + VCLI_JSON_begin(cli, 1, av); + VCLI_Out(cli, ",\n"); + VCLI_Out(cli, "{\n"); + VSB_indent(cli->sb, 2); + (void)VCL_IterDirector(cli, av[i], do_list_json, la); + VSB_indent(cli->sb, -2); + VCLI_Out(cli, "\n"); + VCLI_Out(cli, "}"); + VCLI_JSON_end(cli); } else { VCLI_Out(cli, "%-30s %-7s %-10s %s", "Backend name", "Admin", "Probe", "Last change"); - (void)VCL_IterDirector(cli, av[2], do_list, la); + (void)VCL_IterDirector(cli, av[i], do_list, la); } } diff --git a/bin/varnishtest/tests/b00008.vtc b/bin/varnishtest/tests/b00008.vtc index e536a81..1ec3611 100644 --- a/bin/varnishtest/tests/b00008.vtc +++ b/bin/varnishtest/tests/b00008.vtc @@ -26,7 +26,7 @@ varnish v1 -start varnish v1 -cliok "help" -varnish v1 -cliok "help -j" +varnish v1 -clijson "help -j" varnish v1 -clierr 106 "param.set waiter HASH(0x8839c4c)" diff --git a/bin/varnishtest/tests/d00005.vtc b/bin/varnishtest/tests/d00005.vtc index 202b57b..3b249e5 100644 --- a/bin/varnishtest/tests/d00005.vtc +++ b/bin/varnishtest/tests/d00005.vtc @@ -96,4 +96,4 @@ client c1 { } -run varnish v1 -vsl_catchup -varnish v1 -cliok "backend.list -j" +varnish v1 -clijson "backend.list -j" diff --git a/bin/varnishtest/tests/v00014.vtc b/bin/varnishtest/tests/v00014.vtc index 7b9212a..ea41802 100644 --- a/bin/varnishtest/tests/v00014.vtc +++ b/bin/varnishtest/tests/v00014.vtc @@ -50,7 +50,7 @@ varnish v1 -vcl { } -start varnish v1 -cliok "backend.list -p" -varnish v1 -cliok "backend.list -j -p" +varnish v1 -clijson "backend.list -j -p" client c1 { txreq diff --git a/include/vcli_serve.h b/include/vcli_serve.h index 7bc04c3..8378993 100644 --- a/include/vcli_serve.h +++ b/include/vcli_serve.h @@ -85,7 +85,8 @@ int VCLI_Overflow(struct cli *cli); void VCLI_Out(struct cli *cli, const char *fmt, ...) v_printflike_(2, 3); void VCLI_Quote(struct cli *cli, const char *str); void VCLI_JSON_str(struct cli *cli, const char *str); -void VCLI_JSON_ver(struct cli *cli, unsigned ver, const char * const * av); +void VCLI_JSON_begin(struct cli *cli, unsigned ver, const char * const * av); +void VCLI_JSON_end(struct cli *cli); void VCLI_SetResult(struct cli *cli, unsigned r); typedef int cls_cb_f(void *priv); diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c index 67c6816..5171d31 100644 --- a/lib/libvarnish/vcli_serve.c +++ b/lib/libvarnish/vcli_serve.c @@ -159,26 +159,35 @@ VCLS_func_help_json(struct cli *cli, const char * const *av, void *priv) cs = cli->cls; CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); - VCLI_JSON_ver(cli, 1, av); + VCLI_JSON_begin(cli, 1, av); VTAILQ_FOREACH(clp, &cs->funcs, list) { if (clp->auth > cli->auth) continue; - VCLI_Out(cli, ",\n {"); - VCLI_Out(cli, "\n \"request\": "); + VCLI_Out(cli, ",\n {\n"); + VSB_indent(cli->sb, 2); + VCLI_Out(cli, "\"request\": "); VCLI_JSON_str(cli, clp->desc->request); - VCLI_Out(cli, ",\n \"syntax\": "); + VCLI_Out(cli, ",\n"); + VCLI_Out(cli, "\"syntax\": "); VCLI_JSON_str(cli, clp->desc->syntax); - VCLI_Out(cli, ",\n \"help\": "); + VCLI_Out(cli, ",\n"); + VCLI_Out(cli, "\"help\": "); VCLI_JSON_str(cli, clp->desc->help); - VCLI_Out(cli, ",\n \"minarg\": %d", clp->desc->minarg); - VCLI_Out(cli, ", \"maxarg\": %d", clp->desc->maxarg); - VCLI_Out(cli, ", \"flags\": "); + VCLI_Out(cli, ",\n"); + VCLI_Out(cli, "\"minarg\": %d", clp->desc->minarg); + VCLI_Out(cli, ",\n"); + VCLI_Out(cli, "\"maxarg\": %d", clp->desc->maxarg); + VCLI_Out(cli, ",\n"); + VCLI_Out(cli, "\"flags\": "); VCLI_JSON_str(cli, clp->flags); - VCLI_Out(cli, ", \"json\": %s", + VCLI_Out(cli, ",\n"); + VCLI_Out(cli, "\"json\": %s", clp->jsonfunc == NULL ? "false" : "true"); - VCLI_Out(cli, "\n }"); + VCLI_Out(cli, "\n"); + VSB_indent(cli->sb, -2); + VCLI_Out(cli, "}"); } - VCLI_Out(cli, "\n]\n"); + VCLI_JSON_end(cli); } /*-------------------------------------------------------------------- @@ -641,12 +650,14 @@ VCLI_JSON_str(struct cli *cli, const char *s) { CHECK_OBJ_NOTNULL(cli, CLI_MAGIC); + VSB_putc(cli->sb, '"'); VSB_quote(cli->sb, s, -1, VSB_QUOTE_JSON); + VSB_putc(cli->sb, '"'); } /*lint -e{818} cli could be const */ void -VCLI_JSON_ver(struct cli *cli, unsigned ver, const char * const * av) +VCLI_JSON_begin(struct cli *cli, unsigned ver, const char * const * av) { int i; @@ -658,6 +669,15 @@ VCLI_JSON_ver(struct cli *cli, unsigned ver, const char * const * av) VCLI_Out(cli, ", "); } VCLI_Out(cli, "]"); + VSB_indent(cli->sb, 2); +} + +void +VCLI_JSON_end(struct cli *cli) +{ + VSB_indent(cli->sb, -2); + VCLI_Out(cli, "\n"); + VCLI_Out(cli, "]\n"); } /*lint -e{818} cli could be const */ From nils.goroll at uplex.de Mon May 14 09:40:23 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 14 May 2018 09:40:23 +0000 (UTC) Subject: [master] d402971 change probe stats bitmaps to match %ju format Message-ID: <20180514094023.5F7AC94C63@lists.varnish-cache.org> commit d402971580f52a3c74208e882b0916f3c8643747 Author: Nils Goroll Date: Mon May 14 11:37:23 2018 +0200 change probe stats bitmaps to match %ju format or should we use "%" PRIu64 in the format ? reported by Travis via @fgsch diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 9eb7a7f..e9f886e 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -71,7 +71,7 @@ struct vbp_target { unsigned good; /* Collected statistics */ -#define BITMAP(n, c, t, b) uint64_t n; +#define BITMAP(n, c, t, b) uintmax_t n; #include "tbl/backend_poll.h" double last; From nils.goroll at uplex.de Mon May 14 09:40:23 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 14 May 2018 09:40:23 +0000 (UTC) Subject: [master] cea2ad1 sync std.fileread() docs with reality Message-ID: <20180514094023.5B0C494C62@lists.varnish-cache.org> commit cea2ad1eae1890fe8e563e04e0c0b5cdff0821d6 Author: Nils Goroll Date: Mon May 14 09:18:42 2018 +0200 sync std.fileread() docs with reality The blind caching is OBE for six years now, see 344a709ccf9559f3d8e5d7a0a9a35c6e94705f0f diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 34b6399..c8305ae9 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -107,10 +107,8 @@ Example $Function STRING fileread(PRIV_CALL, STRING) Description - Reads a file and returns a string with the content. Please - note that it is not recommended to send variables to this - function the caching in the function doesn't take this into - account. Also, files are not re-read. + Reads a file and returns a string with the content. The result + is cached indefinitely per filename. Example synthetic("Response was served by " + std.fileread("/etc/hostname")); From phk at FreeBSD.org Mon May 14 11:39:27 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 May 2018 11:39:27 +0000 (UTC) Subject: [master] 76241da Flexelintery Message-ID: <20180514113927.6CD9F97A6E@lists.varnish-cache.org> commit 76241da2b87c4258b3950482420d77fb396bdd38 Author: Poul-Henning Kamp Date: Mon May 14 11:38:44 2018 +0000 Flexelintery diff --git a/lib/libvcc/vsctool.py b/lib/libvcc/vsctool.py index 6777032..a665dff 100644 --- a/lib/libvcc/vsctool.py +++ b/lib/libvcc/vsctool.py @@ -163,6 +163,7 @@ class vscset(object): fo = open(fon, "w") genhdr(fo, self.name) fo.write('#include "config.h"\n') + fo.write('#include \n') fo.write('#include \n') fo.write('#include "vdef.h"\n') fo.write('#include "vas.h"\n') diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c index aa78bfb..ba7c974 100644 --- a/lib/libvmod_debug/vmod_debug_dyn.c +++ b/lib/libvmod_debug/vmod_debug_dyn.c @@ -38,7 +38,6 @@ #include #include "cache/cache.h" -#include "cache/cache_director.h" #include "vsa.h" #include "vcc_if.h" From nils.goroll at uplex.de Mon May 14 17:55:24 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 14 May 2018 17:55:24 +0000 (UTC) Subject: [master] acaa2d4 document purpose of doc/changes.rst as agreed upon at vdd18q2 Message-ID: <20180514175524.9A692A65E5@lists.varnish-cache.org> commit acaa2d4027b76a4cb3dfc3ae3f7bea1c6439b0d9 Author: Nils Goroll Date: Mon May 14 19:52:37 2018 +0200 document purpose of doc/changes.rst as agreed upon at vdd18q2 diff --git a/doc/changes.rst b/doc/changes.rst index fec13c5..0b82050 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,3 +1,32 @@ +=================== +About this document +=================== + +.. keep this section at the top! + +This document contains notes from the Varnish developers about ongoing +development and past versions: + +* Developers will note here changes which they consider particularly + relevant or otherwise noteworthy + +* This document is not necessarily up-to-date with the code + +* It serves as a basis for release managers and others involved in + release documentation + +* It is not rendered as part of the official documentation and thus + only available in ReStructuredText (rst) format in the source + repository and -distribution. + +Official information about changes in releases and advise on the +upgrade process can be found in the ``doc/sphinx/whats-new/`` +directory, also available in HTML format at +http://varnish-cache.org/docs/trunk/whats-new/index.html and via +individual releases. These documents are updated as part of the +release process. + + ============================= Varnish Cache Trunk (ongoing) ============================= From fgsch at lodoss.net Thu May 17 08:09:13 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 17 May 2018 08:09:13 +0000 (UTC) Subject: [master] ff86ca7 For HTTP/1.1 requests, Host is mandatory Message-ID: <20180517080913.96D509BB41@lists.varnish-cache.org> commit ff86ca7e1eb8bee3c34c7cf5be5e352780add1d3 Author: Federico G. Schwindt Date: Tue May 1 15:51:28 2018 +0100 For HTTP/1.1 requests, Host is mandatory The check is added to the builtin logic for now. Fixes #2631. diff --git a/bin/varnishd/builtin.vcl b/bin/varnishd/builtin.vcl index 4e74948..a578a9c 100644 --- a/bin/varnishd/builtin.vcl +++ b/bin/varnishd/builtin.vcl @@ -36,8 +36,14 @@ vcl 4.0; sub vcl_recv { if (req.method == "PRI") { - /* This will never happen in properly formed traffic (see: RFC7540) */ - return (synth(405)); + /* This will never happen in properly formed traffic (see: RFC7540) */ + return (synth(405)); + } + if (!req.http.host && + req.esi_level == 0 && + req.proto ~ "^(?i)HTTP/1.1") { + /* In HTTP/1.1, Host is required. */ + return (synth(400)); } if (req.method != "GET" && req.method != "HEAD" && diff --git a/bin/varnishtest/tests/r02633.vtc b/bin/varnishtest/tests/r02633.vtc new file mode 100644 index 0000000..3d15c3a --- /dev/null +++ b/bin/varnishtest/tests/r02633.vtc @@ -0,0 +1,21 @@ +varnishtest "For HTTP/1.1 requests, Host is mandatory" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { +} -start + +client c1 { + txreq -proto HTTP/1.1 + rxresp + expect resp.status == 200 + txreq -proto HTTP/1.1 -nohost + rxresp + expect resp.status == 400 + txreq -proto HTTP/1.0 -nohost + rxresp + expect resp.status == 200 +} -run From nils.goroll at uplex.de Thu May 17 15:59:23 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 17 May 2018 15:59:23 +0000 (UTC) Subject: [master] 128fbe7 ban lurker should back off on seeing a busy object Message-ID: <20180517155923.9D013AC585@lists.varnish-cache.org> commit 128fbe7c88310c2c69c8f8312c6125ad12806ba6 Author: Nils Goroll Date: Thu May 17 17:40:53 2018 +0200 ban lurker should back off on seeing a busy object HSH_Unbusy() calls BAN_NewObjCore() not holding the objhead lock, so the ban lurker may race and grab the ban mtx just after the new oc has been inserted, but the busy flag not yet cleared. While it would be correct to call BAN_NewObjCore() with the objhead mtx held, doing so would increase the pressure on the combined ban & objhead mtx. If the ban lurker encounters a busy object, we know that there must be an unbusy in progress and it would be wiser to rather back off in favor of the it. Fixes #2681 diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c index 52a3c79..f59b888 100644 --- a/bin/varnishd/cache/cache_ban_lurker.c +++ b/bin/varnishd/cache/cache_ban_lurker.c @@ -167,7 +167,7 @@ ban_lurker_getfirst(struct vsl_log *vsl, struct ban *bt) oh = oc->objhead; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); if (!Lck_Trylock(&oh->mtx)) { - if (oc->refcnt == 0) { + if (oc->refcnt == 0 || oc->flags & OC_F_BUSY) { Lck_Unlock(&oh->mtx); } else { /* From nils.goroll at uplex.de Fri May 18 12:34:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 18 May 2018 12:34:08 +0000 (UTC) Subject: [master] 561f73e detail fetch processor state in panics Message-ID: <20180518123408.4313D93836@lists.varnish-cache.org> commit 561f73e870dc89c0dc80d7a59392c114b2db2d02 Author: Nils Goroll Date: Fri May 18 14:33:20 2018 +0200 detail fetch processor state in panics Ref #2683 diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index dea26a6..1dc3d1f 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -355,9 +355,44 @@ pan_wrk(struct vsb *vsb, const struct worker *wrk) } static void -pan_busyobj(struct vsb *vsb, const struct busyobj *bo) +pan_vfp(struct vsb *vsb, const struct vfp_ctx *vfc) { struct vfp_entry *vfe; + + VSB_printf(vsb, "vfc = %p {\n", vfc); + VSB_indent(vsb, 2); + VSB_printf(vsb, "failed = %d,\n", vfc->failed); + VSB_printf(vsb, "req = %p,\n", vfc->req); + VSB_printf(vsb, "resp = %p,\n", vfc->resp); + VSB_printf(vsb, "wrk = %p,\n", vfc->wrk); + VSB_printf(vsb, "oc = %p,\n", vfc->oc); + + if (!VTAILQ_EMPTY(&vfc->vfp)) { + VSB_printf(vsb, "filters = {\n"); + VSB_indent(vsb, 2); + VTAILQ_FOREACH(vfe, &vfc->vfp, list) { + VSB_printf(vsb, "%s = %p {\n", + vfe->vfp->name, vfe); + VSB_indent(vsb, 2); + VSB_printf(vsb, "priv1 = %p,\n", vfe->priv1); + VSB_printf(vsb, "priv2 = %zd,\n", vfe->priv2); + VSB_printf(vsb, "closed = %d\n", vfe->closed); + VSB_indent(vsb, -2); + VSB_printf(vsb, "},\n"); + } + VSB_indent(vsb, -2); + VSB_printf(vsb, "},\n"); + } + + VSB_printf(vsb, "obj_flags = 0x%x,\n", vfc->obj_flags); + VSB_indent(vsb, -2); + VSB_printf(vsb, "},\n"); +}; + + +static void +pan_busyobj(struct vsb *vsb, const struct busyobj *bo) +{ const char *p; VSB_printf(vsb, "busyobj = %p {\n", bo); @@ -380,13 +415,8 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC)) pan_htc(vsb, bo->htc); - if (!VTAILQ_EMPTY(&bo->vfc->vfp)) { - VSB_printf(vsb, "filters ="); - VTAILQ_FOREACH(vfe, &bo->vfc->vfp, list) - VSB_printf(vsb, " %s=%d", - vfe->vfp->name, (int)vfe->closed); - VSB_printf(vsb, "\n"); - } + if (bo->vfc) + pan_vfp(vsb, bo->vfc); VDI_Panic(bo->director_req, vsb, "director_req"); if (bo->director_resp == bo->director_req) From daghf at varnish-software.com Fri May 18 12:40:08 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Fri, 18 May 2018 12:40:08 +0000 (UTC) Subject: [master] efa129a Fix cache_req_body handling for H/2 requests Message-ID: <20180518124008.4B6DF93A6B@lists.varnish-cache.org> commit efa129a67f504517e0556e377a5892517e138952 Author: Dag Haavi Finstad Date: Fri May 18 14:35:40 2018 +0200 Fix cache_req_body handling for H/2 requests The h/2 request body VFP would drop data when the input buffer was too small to fit the data in the received frame. With this fix we have the VFP code call us again with a fresh buffer when we run out. Fixes: #2679 diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 6a0c92b..1da101a 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -770,6 +770,12 @@ h2_vfp_body(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp) h2->rxf_len -= l; } *lp = l; + if (h2->rxf_len > 0) { + /* We ran out of storage: Have VFP call us + * again with a fresh buffer */ + Lck_Unlock(&h2->sess->mtx); + return (VFP_OK); + } if (h2->rxf_len == 0) { if (h2->rxf_flags & H2FF_DATA_END_STREAM) retval = VFP_END; diff --git a/bin/varnishtest/tests/r02679.vtc b/bin/varnishtest/tests/r02679.vtc new file mode 100644 index 0000000..296ce9c --- /dev/null +++ b/bin/varnishtest/tests/r02679.vtc @@ -0,0 +1,31 @@ +varnishtest "#2679: H/2 rxbody vfp drops data" + +server s1 { + rxreq + expect req.http.content-length == "31469" + expect req.bodylen == 31469 + txresp +} -start + +varnish v1 -vcl+backend { + import std; + sub vcl_recv { +# std.cache_req_body(100KB); + } +} -start + +varnish v1 -cliok "param.set feature +http2" + +client c1 { + stream 1 { + txreq -req POST -hdr "content-length" "31469" -nostrend + txdata -datalen 1550 -nostrend + rxwinup + txdata -datalen 16000 -nostrend + rxwinup + txdata -datalen 13919 + rxwinup + rxresp + expect resp.status == 200 + } -run +} -run From daghf at varnish-software.com Fri May 18 12:46:08 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Fri, 18 May 2018 12:46:08 +0000 (UTC) Subject: [master] d489e2b Fix screwup in previous commit Message-ID: <20180518124608.C4ADB93CB8@lists.varnish-cache.org> commit d489e2b8ae2636d8502a0f928d497c96d0d578b7 Author: Dag Haavi Finstad Date: Fri May 18 14:45:25 2018 +0200 Fix screwup in previous commit diff --git a/bin/varnishtest/tests/r02679.vtc b/bin/varnishtest/tests/r02679.vtc index 296ce9c..ca99d75 100644 --- a/bin/varnishtest/tests/r02679.vtc +++ b/bin/varnishtest/tests/r02679.vtc @@ -10,7 +10,7 @@ server s1 { varnish v1 -vcl+backend { import std; sub vcl_recv { -# std.cache_req_body(100KB); + std.cache_req_body(100KB); } } -start From nils.goroll at uplex.de Fri May 18 12:49:07 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 18 May 2018 12:49:07 +0000 (UTC) Subject: [master] a8cf85f fix layer 8 brace overflow error Message-ID: <20180518124907.E3C4993E0A@lists.varnish-cache.org> commit a8cf85f71802909523b2c958cf7b6c9658559bbb Author: Nils Goroll Date: Fri May 18 14:48:35 2018 +0200 fix layer 8 brace overflow error diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 1dc3d1f..0666c89 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -387,7 +387,7 @@ pan_vfp(struct vsb *vsb, const struct vfp_ctx *vfc) VSB_printf(vsb, "obj_flags = 0x%x,\n", vfc->obj_flags); VSB_indent(vsb, -2); VSB_printf(vsb, "},\n"); -}; +} static void From nils.goroll at uplex.de Fri May 18 13:02:06 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 18 May 2018 13:02:06 +0000 (UTC) Subject: [master] 46726b2 gc duplicate statement with no effect Message-ID: <20180518130207.07803942A5@lists.varnish-cache.org> commit 46726b2da26c248084ee02d78a698f3766d6ac11 Author: Nils Goroll Date: Fri May 18 14:58:27 2018 +0200 gc duplicate statement with no effect diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 3694c0a..d5d256d 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -620,7 +620,6 @@ vfp_testgunzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); AN(p); AN(lp); - CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); vp = VFP_Suck(vc, p, lp); if (vp == VFP_ERROR) return (vp); From dridi.boukelmoune at gmail.com Mon May 21 10:49:18 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 21 May 2018 10:49:18 +0000 (UTC) Subject: [master] 9938f01 Multiple -[IX] options may be given to VUTs Message-ID: <20180521104919.1741092539@lists.varnish-cache.org> commit 9938f01fe8a2b148013423c310c221273b8297b4 Author: Dridi Boukelmoune Date: Mon May 21 12:48:05 2018 +0200 Multiple -[IX] options may be given to VUTs diff --git a/include/vapi/vapi_options.h b/include/vapi/vapi_options.h index 98b838b..3d95c31 100644 --- a/include/vapi/vapi_options.h +++ b/include/vapi/vapi_options.h @@ -63,7 +63,7 @@ VOPT("I:", "[-I <[taglist:]regex>]", "Include by regex", \ "Include by regex matching. Output only records matching" \ " taglist and regular expression. Applies to any tag if" \ - " taglist is absent.\n" \ + " taglist is absent. Multiple -I options may be given.\n" \ "\n" \ VSL_iI_PS \ ) @@ -104,5 +104,5 @@ VOPT("X:", "[-X <[taglist:]regex>]", "Exclude by regex", \ "Exclude by regex matching. Do not output records matching" \ " taglist and regular expression. Applies to any tag if" \ - " taglist is absent." \ + " taglist is absent. Multiple -X options may be given.\n" \ ) From phk at FreeBSD.org Tue May 22 13:11:10 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 22 May 2018 13:11:10 +0000 (UTC) Subject: [master] 9171f0c Introduction of '-' CLI prefix allowed empty commands to sneak through. Message-ID: <20180522131110.8948EB8151@lists.varnish-cache.org> commit 9171f0ca77f094fa483f2e0e50803b2d9270b8e7 Author: Poul-Henning Kamp Date: Tue May 22 13:09:31 2018 +0000 Introduction of '-' CLI prefix allowed empty commands to sneak through. Fixes #2647 diff --git a/bin/varnishtest/tests/r02647.vtc b/bin/varnishtest/tests/r02647.vtc new file mode 100644 index 0000000..09c63ce --- /dev/null +++ b/bin/varnishtest/tests/r02647.vtc @@ -0,0 +1,15 @@ +varnishtest "empty cli command" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend {} -start + +varnish v1 -clierr 100 "-" + +client c1 { + txreq + rxresp +} -run diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c index 5171d31..b1084a1 100644 --- a/lib/libvarnish/vcli_serve.c +++ b/lib/libvarnish/vcli_serve.c @@ -278,6 +278,12 @@ cls_exec(struct VCLS_fd *cfd, char * const *av) break; } + if (av[1] == NULL) { + VCLI_Out(cli, "Empty CLI command.\n"); + VCLI_SetResult(cli, CLIS_SYNTAX); + break; + } + if (isupper(av[1][0])) { VCLI_Out(cli, "all commands are in lower-case.\n"); VCLI_SetResult(cli, CLIS_UNKNOWN); From phk at FreeBSD.org Tue May 22 14:28:09 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 22 May 2018 14:28:09 +0000 (UTC) Subject: [master] e8ea815 Handle string literal concatenation correctly. Message-ID: <20180522142809.16DF8B97F6@lists.varnish-cache.org> commit e8ea8155b2d58ed4b2848dee164a0898c610f19f Author: Poul-Henning Kamp Date: Tue May 22 14:27:13 2018 +0000 Handle string literal concatenation correctly. Fixes #2685 diff --git a/bin/varnishtest/tests/c00068.vtc b/bin/varnishtest/tests/c00068.vtc index 88a47b6..5fb3b48 100644 --- a/bin/varnishtest/tests/c00068.vtc +++ b/bin/varnishtest/tests/c00068.vtc @@ -10,6 +10,8 @@ server s1 { } -start varnish v1 -vcl+backend { + import std; + sub vcl_backend_response { if (bereq.url == "/333") { set beresp.status = 333; @@ -18,7 +20,7 @@ varnish v1 -vcl+backend { } sub vcl_deliver { if (req.url == "/332") { - return (synth(332, "FOO")); + return (synth(332, "F" + "OO" + std.tolower("FOO"))); } else if (req.url == "/333") { return (synth(resp.status + 1000, resp.reason)); @@ -64,6 +66,7 @@ client c2 { txreq -url /332 rxresp expect resp.status == 332 + expect resp.reason == "FOOfoo" expect resp.http.restarts == 1 expect resp.bodylen == 1 } -run diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 37bfb04..e5ef674 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -920,6 +920,7 @@ vcc_expr_add(struct vcc *tl, struct expr **e, vcc_type_t fmt) *e = vcc_expr_edit(tl, STRINGS, "\v1\n\v2", *e, e2); (*e)->constant = EXPR_CONST; + (*e)->nstr = 1; if (lit) (*e)->constant |= EXPR_STR_CONST; } else { @@ -1297,6 +1298,8 @@ vcc_Expr(struct vcc *tl, vcc_type_t fmt) assert(fmt != STRINGS); vcc_expr0(tl, &e, fmt); ERRCHK(tl); + assert(e->fmt == fmt); + vcc_expr_fmt(tl->fb, tl->indent, e); VSB_printf(tl->fb, "\n"); vcc_delete_expr(e); From nils.goroll at uplex.de Tue May 22 21:10:20 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 22 May 2018 21:10:20 +0000 (UTC) Subject: [master] 2a70f51 document probe window bits Message-ID: <20180522211020.57BA265809@lists.varnish-cache.org> commit 2a70f51ec14af3e62d6d61ec689011e83e5dd429 Author: Nils Goroll Date: Tue May 22 23:07:03 2018 +0200 document probe window bits See comment on how we could auto-generate the documentation from the include - any less hackish ideas welcome diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 88106bc..1bafbf1 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -370,6 +370,20 @@ SLTM(Hash, SLT_F_UNSAFE, "Value added to hash", NODEF_NOTICE ) +/* + * Probe window bits: + * + * the documentation below could get auto-generated like so: + * + * ( echo '#define PROBE_BITS_DOC \' ; \ + * $CC -D 'BITMAP(n, c, t, b)="\t" #c ": " t "\n" \' \ + * -E ./include/tbl/backend_poll.h | grep -E '^"' ; \ + * echo '""' ) >./include/tbl/backend_poll_doc.h + * + * as this has a hackish feel to it, the documentation is included here as text + * until we find a better solution or the above is accepted + */ + SLTM(Backend_health, 0, "Backend health check", "The result of a backend health probe.\n\n" "The format is::\n\n" @@ -385,6 +399,17 @@ SLTM(Backend_health, 0, "Backend health check", "\t| +---------------------- Status message\n" "\t+------------------------- Backend name\n" "\n" + + "Probe window bits are::\n\n" + "\t" "'4'" ": " "Good IPv4" "\n" + "\t" "'6'" ": " "Good IPv6" "\n" + "\t" "'U'" ": " "Good UNIX" "\n" + "\t" "'x'" ": " "Error Xmit" "\n" + "\t" "'X'" ": " "Good Xmit" "\n" + "\t" "'r'" ": " "Error Recv" "\n" + "\t" "'R'" ": " "Good Recv" "\n" + "\t" "'H'" ": " "Happy" "\n" + "\n" ) SLTM(VCL_Log, 0, "Log statement from VCL", From fgsch at lodoss.net Wed May 23 00:59:13 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 23 May 2018 00:59:13 +0000 (UTC) Subject: [master] 6b8ee35 Reject headers without name Message-ID: <20180523005913.69D4094DDB@lists.varnish-cache.org> commit 6b8ee350522aa316f61e36581d287d3e405883f5 Author: Federico G. Schwindt Date: Wed May 23 01:54:20 2018 +0100 Reject headers without name diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c index b3fbde7..ad44218 100644 --- a/bin/varnishd/http1/cache_http1_proto.c +++ b/bin/varnishd/http1/cache_http1_proto.c @@ -155,16 +155,16 @@ http1_dissect_hdrs(struct http *hp, char *p, struct http_conn *htc, *q++ = ' '; } + /* Empty header = end of headers */ + if (p == q) + break; + if (q - p > maxhdr) { VSLb(hp->vsl, SLT_BogoHeader, "Header too long: %.*s", (int)(q - p > 20 ? 20 : q - p), p); return (400); } - /* Empty header = end of headers */ - if (p == q) - break; - if (vct_islws(*p)) { VSLb(hp->vsl, SLT_BogoHeader, "1st header has white space: %.*s", @@ -172,6 +172,13 @@ http1_dissect_hdrs(struct http *hp, char *p, struct http_conn *htc, return (400); } + if (*p == ':') { + VSLb(hp->vsl, SLT_BogoHeader, + "Missing header name: %.*s", + (int)(q - p > 20 ? 20 : q - p), p); + return (400); + } + if ((p[0] == 'i' || p[0] == 'I') && (p[1] == 'f' || p[1] == 'F') && p[2] == '-') diff --git a/bin/varnishtest/tests/b00040.vtc b/bin/varnishtest/tests/b00040.vtc index 8d5db15..cc7479d 100644 --- a/bin/varnishtest/tests/b00040.vtc +++ b/bin/varnishtest/tests/b00040.vtc @@ -2,7 +2,7 @@ varnishtest "test certain mailformed requests" server s1 { rxreq - # expect req.url == /3 + expect req.url == /4 txresp } -start @@ -15,6 +15,7 @@ logexpect l1 -v v1 -g raw { expect * 1010 BogoHeader {Header has ctrl char 0x01} expect * 1012 BogoHeader {Header has ctrl char 0x0d} expect * 1014 BogoHeader {Header has ctrl char 0x0d} + expect * 1016 BogoHeader {Missing header name:.*} } -start client c1 { @@ -71,6 +72,13 @@ client c1 { rxresp expect resp.status == 400 } -run +delay .1 + +client c1 { + send "GET /8 HTTP/1.1\r\nHost: foo\r\n: Header\r\n\r\n" + rxresp + expect resp.status == 400 +} -run logexpect l1 -wait From fgsch at lodoss.net Wed May 23 00:59:13 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 23 May 2018 00:59:13 +0000 (UTC) Subject: [master] 52bff4e Correctly identify these as non-separators Message-ID: <20180523005913.83DE294DDE@lists.varnish-cache.org> commit 52bff4e2537e2d0076ff054bedcbb0c4b1c61a65 Author: Federico G. Schwindt Date: Wed May 23 01:55:15 2018 +0100 Correctly identify these as non-separators diff --git a/lib/libvarnish/vct.c b/lib/libvarnish/vct.c index 8d36b10..73b784e 100644 --- a/lib/libvarnish/vct.c +++ b/lib/libvarnish/vct.c @@ -54,7 +54,7 @@ const uint16_t vct_typtab[256] = { [0x06] = VCT_CTL, [0x07] = VCT_CTL, [0x08] = VCT_CTL, - [0x09] = VCT_CTL | VCT_SP | VCT_SEPARATOR, + [0x09] = VCT_CTL | VCT_SP, [0x0a] = VCT_CTL | VCT_CRLF, [0x0b] = VCT_CTL | VCT_VT, [0x0c] = VCT_CTL, @@ -77,7 +77,7 @@ const uint16_t vct_typtab[256] = { [0x1d] = VCT_CTL, [0x1e] = VCT_CTL, [0x1f] = VCT_CTL, - [0x20] = VCT_SP | VCT_SEPARATOR, + [0x20] = VCT_SP, [0x21] = VCT_TCHAR, [0x22] = VCT_SEPARATOR, [0x23] = VCT_TCHAR, From fgsch at lodoss.net Wed May 23 09:51:09 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 23 May 2018 09:51:09 +0000 (UTC) Subject: [master] 03a2791 Try to speed things up and misc cleanup Message-ID: <20180523095109.B3BB6A6C21@lists.varnish-cache.org> commit 03a2791b38a8e32f7fa00631b21dad69ec7f903a Author: Federico G. Schwindt Date: Wed May 23 10:49:51 2018 +0100 Try to speed things up and misc cleanup diff --git a/.travis.yml b/.travis.yml index 2cae8db..88a2346 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ --- -sudo: required language: c +sudo: false matrix: fast_finish: true include: @@ -14,6 +14,7 @@ matrix: dist: trusty compiler: clang env: CLANG=6.0 SAN_FLAGS="--enable-asan --enable-ubsan" + sudo: required - os: osx osx_image: xcode9.3 compiler: clang @@ -32,33 +33,38 @@ notifications: on_success: change use_notice: true before_install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - brew update; - brew upgrade python; - brew install docutils sphinx-doc nghttp2; - fi - - if [[ -n "$CLANG" ]]; then + - | + if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + brew update + brew upgrade python + brew install docutils sphinx-doc nghttp2 + elif [[ -n "$CLANG" ]]; then wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | - sudo apt-key add -; + sudo apt-key add - sudo apt-add-repository -y - "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-$CLANG main"; - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA9EF27F; + "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-$CLANG main" + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA9EF27F sudo apt-add-repository -y - "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main"; - sudo apt-get update; - sudo apt-get install -y clang-$CLANG llvm-$CLANG; - export CC=clang-$CLANG; - export CONFIGURE_ARGS="--enable-developer-warnings --enable-debugging-symbols --disable-stack-protector --with-persistent-storage ${SAN_FLAGS}"; - export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=1,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1,handle_segv=0,handle_sigbus=0,use_sigaltstack=0,disable_coredump=0; - export LSAN_OPTIONS=abort_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/lsan.suppr; - export TSAN_OPTIONS=abort_on_error=1,halt_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/tsan.suppr; - export UBSAN_OPTIONS=halt_on_error=1,print_stacktrace=1,use_sigaltstack=0,suppressions=$(pwd)/tools/ubsan.suppr; + "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main" + sudo apt-get update + sudo apt-get install -y clang-$CLANG llvm-$CLANG + export CC=clang-$CLANG + export CONFIGURE_ARGS="--enable-developer-warnings --enable-debugging-symbols --disable-stack-protector --with-persistent-storage ${SAN_FLAGS}" + export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=1,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1,handle_segv=0,handle_sigbus=0,use_sigaltstack=0,disable_coredump=0 + export LSAN_OPTIONS=abort_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/lsan.suppr + export TSAN_OPTIONS=abort_on_error=1,halt_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/tsan.suppr + export UBSAN_OPTIONS=halt_on_error=1,print_stacktrace=1,use_sigaltstack=0,suppressions=$(pwd)/tools/ubsan.suppr fi - ./autogen.sh - ./configure ${CONFIGURE_ARGS} script: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - export PYTHONPATH=`brew --prefix`/lib/python2.7/site-packages; - export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"; fi - - if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then make -j3 distcheck; fi - - if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then make -j3 check VERBOSE=1; fi + - | + if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + export PYTHONPATH=`brew --prefix`/lib/python2.7/site-packages + export PATH="/usr/local/opt/sphinx-doc/bin:$PATH" + fi + if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then + make -j3 distcheck + else + make -j3 check VERBOSE=1 + fi From fgsch at lodoss.net Wed May 23 12:05:16 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 23 May 2018 12:05:16 +0000 (UTC) Subject: [master] 3e601a3 We need line continuation now Message-ID: <20180523120516.425E5A92A9@lists.varnish-cache.org> commit 3e601a3d533ee038e9ea7577716b1f41652f6d21 Author: Federico G. Schwindt Date: Wed May 23 13:04:22 2018 +0100 We need line continuation now diff --git a/.travis.yml b/.travis.yml index 88a2346..021ed0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,12 +39,11 @@ before_install: brew upgrade python brew install docutils sphinx-doc nghttp2 elif [[ -n "$CLANG" ]]; then - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | - sudo apt-key add - - sudo apt-add-repository -y + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo apt-add-repository -y \ "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-$CLANG main" sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA9EF27F - sudo apt-add-repository -y + sudo apt-add-repository -y \ "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main" sudo apt-get update sudo apt-get install -y clang-$CLANG llvm-$CLANG From daghf at varnish-software.com Thu May 24 08:09:07 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Thu, 24 May 2018 08:09:07 +0000 (UTC) Subject: [master] c3bd169 Silence a Coverity non-defect Message-ID: <20180524080907.8AD97657A2@lists.varnish-cache.org> commit c3bd1693c7265fef6fc2dc0f9f1b07b1a18f2e0d Author: Dag Haavi Finstad Date: Thu May 24 10:06:34 2018 +0200 Silence a Coverity non-defect diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 0666c89..cf22c0e 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -401,6 +401,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) VSB_indent(vsb, 2); PAN_CheckMagic(vsb, bo, BUSYOBJ_MAGIC); pan_ws(vsb, bo->ws); + AN(bo->vfc); VSB_printf(vsb, "retries = %d, ", bo->retries); VSB_printf(vsb, "failed = %d, ", bo->vfc->failed); VSB_printf(vsb, "flags = {"); @@ -415,8 +416,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC)) pan_htc(vsb, bo->htc); - if (bo->vfc) - pan_vfp(vsb, bo->vfc); + pan_vfp(vsb, bo->vfc); VDI_Panic(bo->director_req, vsb, "director_req"); if (bo->director_resp == bo->director_req) From dridi at varni.sh Thu May 24 08:22:08 2018 From: dridi at varni.sh (Dridi Boukelmoune) Date: Thu, 24 May 2018 10:22:08 +0200 Subject: [master] c3bd169 Silence a Coverity non-defect In-Reply-To: <20180524080907.8AD97657A2@lists.varnish-cache.org> References: <20180524080907.8AD97657A2@lists.varnish-cache.org> Message-ID: On Thu, May 24, 2018 at 10:09 AM, Dag Haavi Finstad wrote: > > commit c3bd1693c7265fef6fc2dc0f9f1b07b1a18f2e0d > Author: Dag Haavi Finstad > Date: Thu May 24 10:06:34 2018 +0200 > > Silence a Coverity non-defect > > diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c > index 0666c89..cf22c0e 100644 > --- a/bin/varnishd/cache/cache_panic.c > +++ b/bin/varnishd/cache/cache_panic.c > @@ -401,6 +401,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) > VSB_indent(vsb, 2); > PAN_CheckMagic(vsb, bo, BUSYOBJ_MAGIC); > pan_ws(vsb, bo->ws); > + AN(bo->vfc); Is it safe to put an assert here? Shouldn't we guard accesses to bo->vfc if Nils thought it could be NULL? > VSB_printf(vsb, "retries = %d, ", bo->retries); > VSB_printf(vsb, "failed = %d, ", bo->vfc->failed); > VSB_printf(vsb, "flags = {"); > @@ -415,8 +416,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) > if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC)) > pan_htc(vsb, bo->htc); > > - if (bo->vfc) > - pan_vfp(vsb, bo->vfc); > + pan_vfp(vsb, bo->vfc); > > VDI_Panic(bo->director_req, vsb, "director_req"); > if (bo->director_resp == bo->director_req) > _______________________________________________ > varnish-commit mailing list > varnish-commit at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit From phk at phk.freebsd.dk Thu May 24 08:29:37 2018 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Thu, 24 May 2018 08:29:37 +0000 Subject: [master] c3bd169 Silence a Coverity non-defect In-Reply-To: References: <20180524080907.8AD97657A2@lists.varnish-cache.org> Message-ID: <65474.1527150577@critter.freebsd.dk> -------- In message , Dridi Boukelmoune writes: >> --- a/bin/varnishd/cache/cache_panic.c >> +++ b/bin/varnishd/cache/cache_panic.c >> @@ -401,6 +401,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) >> VSB_indent(vsb, 2); >> PAN_CheckMagic(vsb, bo, BUSYOBJ_MAGIC); >> pan_ws(vsb, bo->ws); >> + AN(bo->vfc); > >Is it safe to put an assert here? Shouldn't we guard accesses to >bo->vfc if Nils thought it could be NULL? Actually, it's more that we don't want the panic code to panic because something is wrong: We want it to report with precision that something is wrong. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From dridi at varni.sh Thu May 24 08:48:26 2018 From: dridi at varni.sh (Dridi Boukelmoune) Date: Thu, 24 May 2018 10:48:26 +0200 Subject: [master] c3bd169 Silence a Coverity non-defect In-Reply-To: <65474.1527150577@critter.freebsd.dk> References: <20180524080907.8AD97657A2@lists.varnish-cache.org> <65474.1527150577@critter.freebsd.dk> Message-ID: On Thu, May 24, 2018 at 10:29 AM, Poul-Henning Kamp wrote: > -------- > In message , Dridi Boukelmoune writes: > >>> --- a/bin/varnishd/cache/cache_panic.c >>> +++ b/bin/varnishd/cache/cache_panic.c >>> @@ -401,6 +401,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) >>> VSB_indent(vsb, 2); >>> PAN_CheckMagic(vsb, bo, BUSYOBJ_MAGIC); >>> pan_ws(vsb, bo->ws); >>> + AN(bo->vfc); >> >>Is it safe to put an assert here? Shouldn't we guard accesses to >>bo->vfc if Nils thought it could be NULL? > > Actually, it's more that we don't want the panic code to panic > because something is wrong: We want it to report with > precision that something is wrong. That's exactly why I'm asking! From daghf at varnish-software.com Thu May 24 09:07:50 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Thu, 24 May 2018 11:07:50 +0200 Subject: [master] c3bd169 Silence a Coverity non-defect In-Reply-To: References: <20180524080907.8AD97657A2@lists.varnish-cache.org> Message-ID: On Thu, May 24, 2018 at 10:22 AM, Dridi Boukelmoune wrote: > > --- a/bin/varnishd/cache/cache_panic.c > > +++ b/bin/varnishd/cache/cache_panic.c > > @@ -401,6 +401,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj > *bo) > > VSB_indent(vsb, 2); > > PAN_CheckMagic(vsb, bo, BUSYOBJ_MAGIC); > > pan_ws(vsb, bo->ws); > > + AN(bo->vfc); > > Is it safe to put an assert here? Shouldn't we guard accesses to > bo->vfc if Nils thought it could be NULL? > > bo->vfc has the same lifetime as the bo itself, so that should be OK. -- Dag Haavi Finstad Software Developer | Varnish Software Mobile: +47 476 64 134 We Make Websites Fly! -------------- next part -------------- An HTML attachment was scrubbed... URL: From nils.goroll at uplex.de Thu May 24 09:14:09 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 24 May 2018 09:14:09 +0000 (UTC) Subject: [master] 0ed0f2f In panic code, handle NULL pointers with grace Message-ID: <20180524091409.6ACB491DF7@lists.varnish-cache.org> commit 0ed0f2fa713348daf73c6eddcde9db2a5956b87f Author: Nils Goroll Date: Thu May 24 11:10:12 2018 +0200 In panic code, handle NULL pointers with grace We do not want to cause a panic from the panic handler. It could be argued that bo->vfc cannot possibly be NULL, except when it is - and that's what we got the panic handler for. vfc->failed is output by pan_vfp now so I should have removed that duplication when introducing pan_vfp diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index cf22c0e..8282ed8 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -401,9 +401,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) VSB_indent(vsb, 2); PAN_CheckMagic(vsb, bo, BUSYOBJ_MAGIC); pan_ws(vsb, bo->ws); - AN(bo->vfc); VSB_printf(vsb, "retries = %d, ", bo->retries); - VSB_printf(vsb, "failed = %d, ", bo->vfc->failed); VSB_printf(vsb, "flags = {"); p = ""; /*lint -save -esym(438,p) -e539 */ @@ -416,7 +414,8 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC)) pan_htc(vsb, bo->htc); - pan_vfp(vsb, bo->vfc); + if (bo->vfc) + pan_vfp(vsb, bo->vfc); VDI_Panic(bo->director_req, vsb, "director_req"); if (bo->director_resp == bo->director_req) From dridi.boukelmoune at gmail.com Fri May 25 11:30:34 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 25 May 2018 11:30:34 +0000 (UTC) Subject: [master] bd51f43 Plug a leak of the read end of VSUB pipes Message-ID: <20180525113034.CDAACB904F@lists.varnish-cache.org> commit bd51f43cd13738f384273ccfc20d15372087e12e Author: Dridi Boukelmoune Date: Fri May 25 13:28:04 2018 +0200 Plug a leak of the read end of VSUB pipes diff --git a/lib/libvarnish/vsub.c b/lib/libvarnish/vsub.c index 2792ebc..cafbe40 100644 --- a/lib/libvarnish/vsub.c +++ b/lib/libvarnish/vsub.c @@ -127,6 +127,7 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name, } closefd(&p[1]); (void)VLU_File(p[0], vsub_vlu, &sp, 0); + closefd(&p[0]); if (sp.maxlines >= 0 && sp.lines > sp.maxlines) VSB_printf(sb, "[%d lines truncated]\n", sp.lines - sp.maxlines); From phk at FreeBSD.org Sun May 27 07:10:23 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 27 May 2018 07:10:23 +0000 (UTC) Subject: [master] 34b630f Various Flexelinting Message-ID: <20180527071023.14BF991C89@lists.varnish-cache.org> commit 34b630f357470d16e85dc91597e25ee814c0f1ac Author: Poul-Henning Kamp Date: Sun May 27 07:08:49 2018 +0000 Various Flexelinting diff --git a/bin/varnishhist/flint.lnt b/bin/varnishhist/flint.lnt index a4289bf..1342b8e 100644 --- a/bin/varnishhist/flint.lnt +++ b/bin/varnishhist/flint.lnt @@ -1,3 +1,4 @@ -efile(451, "varnishhist_profiles.h") -efile(451, "varnishhist_options.h") -sem(usage, r_no) +-sem(profile_error, r_no) diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 5d32d6a..6c72a65 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -63,7 +63,7 @@ static struct VUT *vut; static int hist_low; static int hist_high; static int hist_range; -static int hist_buckets; +static unsigned hist_buckets; static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; @@ -143,7 +143,7 @@ update(void) unsigned bm[n], bh[n]; unsigned max; unsigned i, j, scale; - int k, l; + unsigned k, l; erase(); @@ -161,10 +161,11 @@ update(void) mvprintw(0, 0, "%*s", COLS - 1, ident); /* count our flock */ - for (i = 0; i < n; ++i) - bm[i] = bh[i] = 0; + memset(bm, 0, sizeof bm); + memset(bh, 0, sizeof bh); for (k = 0, max = 1; k < hist_buckets; ++k) { l = k * n / hist_buckets; + assert(l < n); bm[l] += bucket_miss[k]; bh[l] += bucket_hit[k]; if (bm[l] + bh[l] > max) @@ -413,13 +414,13 @@ do_curses(void *arg) break; case '\032': /* Ctrl-Z */ endwin(); - raise(SIGTSTP); + AZ(raise(SIGTSTP)); break; case '\003': /* Ctrl-C */ case '\021': /* Ctrl-Q */ case 'Q': case 'q': - raise(SIGINT); + AZ(raise(SIGINT)); endwin(); return (NULL); case '0': @@ -432,7 +433,7 @@ do_curses(void *arg) case '7': case '8': case '9': - delay = 1 << (ch - '0'); + delay = 1U << (ch - '0'); break; case '+': delay /= 2; @@ -483,7 +484,7 @@ usage(int status) exit(status); } -static void +static void v_noreturn_ profile_error(const char *s) { fprintf(stderr, "-P: '%s' is not a valid" @@ -506,7 +507,7 @@ main(int argc, char **argv) char *colon; const char *ptag, *profile = "responsetime"; pthread_t thr; - int fnum = -1; + int fnum; struct profile cli_p = {0}; vut = VUT_InitProg(argc, argv, &vopt_spec); diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index 5c1a534..6e786d4 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -582,7 +582,6 @@ vtx_retire(struct VSLQ *vslq, struct vtx **pvtx) vslq->n_cache++; } else { FREE_OBJ(vtx); - vtx = NULL; } } @@ -693,7 +692,7 @@ vtx_parse_link(const char *str, enum VSL_transaction_e *ptype, return (0); /* transaction type */ - for (et = 0; et < VSL_t__MAX; et++) + for (et = VSL_t_unknown; et < VSL_t__MAX; et++) if (!strcmp(type, vsl_t_names[et])) break; if (et >= VSL_t__MAX) @@ -709,7 +708,7 @@ vtx_parse_link(const char *str, enum VSL_transaction_e *ptype, return (2); /* transaction reason */ - for (er = 0; er < VSL_r__MAX; er++) + for (er = VSL_r_unknown; er < VSL_r__MAX; er++) if (!strcmp(reason, vsl_r_names[er])) break; if (er >= VSL_r__MAX) diff --git a/lib/libvmod_blob/flint.lnt b/lib/libvmod_blob/flint.lnt index 1b6f088..016a832 100644 --- a/lib/libvmod_blob/flint.lnt +++ b/lib/libvmod_blob/flint.lnt @@ -1 +1,4 @@ -efile(451, "tbl_*.h") // No include guard + +-e784 // Nul character truncated from string + From phk at FreeBSD.org Sun May 27 10:19:20 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 27 May 2018 10:19:20 +0000 (UTC) Subject: [master] 1179b18 Use poll(2) instead of select(2) to be consistent with the rest of the source tree. Message-ID: <20180527101920.BAE2495C20@lists.varnish-cache.org> commit 1179b18e797e04c7d1157f6b30eb9b23460963cd Author: Poul-Henning Kamp Date: Sun May 27 10:17:47 2018 +0000 Use poll(2) instead of select(2) to be consistent with the rest of the source tree. diff --git a/bin/varnishtest/vtc_barrier.c b/bin/varnishtest/vtc_barrier.c index 116efdd..3f0f690 100644 --- a/bin/varnishtest/vtc_barrier.c +++ b/bin/varnishtest/vtc_barrier.c @@ -29,6 +29,7 @@ #include "config.h" #include +#include #include #include #include @@ -125,11 +126,10 @@ barrier_sock_thread(void *priv) { struct barrier *b; struct vtclog *vl; - struct timeval tmo; const char *err; char abuf[16], pbuf[6]; int i, sock, *conns; - fd_set rfds; + struct pollfd pfd[1]; CAST_OBJ_NOTNULL(b, priv, BARRIER_MAGIC); assert(b->type == BARRIER_SOCK); @@ -161,12 +161,10 @@ barrier_sock_thread(void *priv) AN(conns); while (b->active) { - FD_ZERO(&rfds); - FD_SET(sock, &rfds); + pfd[0].fd = sock; + pfd[0].events = POLLIN; - tmo.tv_sec = 1; - tmo.tv_usec = 0; - i = select(sock + 1, &rfds, NULL, NULL, &tmo); + i = poll(pfd, 1, 1000); if (i == 0) continue; if (i < 0) { @@ -219,7 +217,8 @@ barrier_sock_thread(void *priv) macro_undef(vl, b->name, "sock"); closefd(&sock); free(conns); - pthread_cleanup_pop(1); + pthread_cleanup_pop(0); + vtc_logclose(vl); return (NULL); } From phk at FreeBSD.org Sun May 27 10:19:20 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 27 May 2018 10:19:20 +0000 (UTC) Subject: [master] 14bd7de Flexelinting Message-ID: <20180527101920.D348E95C22@lists.varnish-cache.org> commit 14bd7de8bfcfab3bc8933697be6db6cf5552a893 Author: Poul-Henning Kamp Date: Sun May 27 10:18:16 2018 +0000 Flexelinting Use pthread_cleanup_pop(0) and an explict call to the cleanup function to make things visible to FlexeLint. diff --git a/bin/varnishtest/hpack.h b/bin/varnishtest/hpack.h index 9df6785..94b7347 100644 --- a/bin/varnishtest/hpack.h +++ b/bin/varnishtest/hpack.h @@ -33,7 +33,7 @@ struct hpk_iter; struct hpk_ctx * HPK_NewCtx(uint32_t tblsize); void HPK_FreeCtx(struct hpk_ctx *ctx); -struct hpk_iter * HPK_NewIter(struct hpk_ctx *ctx, char *buf, int size); +struct hpk_iter * HPK_NewIter(struct hpk_ctx *ctx, void *buf, int size); void HPK_FreeIter(struct hpk_iter *iter); enum hpk_result HPK_DecHdr(struct hpk_iter *iter, struct hpk_hdr *header); diff --git a/bin/varnishtest/vtc_client.c b/bin/varnishtest/vtc_client.c index 4b2f608..d2f72b9 100644 --- a/bin/varnishtest/vtc_client.c +++ b/bin/varnishtest/vtc_client.c @@ -237,7 +237,8 @@ client_thread(void *priv) } vtc_log(vl, 2, "Ending"); VSB_destroy(&vsb); - pthread_cleanup_pop(1); + pthread_cleanup_pop(0); + vtc_logclose(vl); return (NULL); } diff --git a/bin/varnishtest/vtc_h2_hpack.c b/bin/varnishtest/vtc_h2_hpack.c index 403db13..52c8ee9 100644 --- a/bin/varnishtest/vtc_h2_hpack.c +++ b/bin/varnishtest/vtc_h2_hpack.c @@ -26,6 +26,7 @@ * SUCH DAMAGE. */ +#include #include #include #include @@ -34,6 +35,7 @@ #include "vdef.h" #include "vas.h" +#include "vqueue.h" #include "hpack.h" #include "vtc_h2_priv.h" diff --git a/bin/varnishtest/vtc_h2_priv.h b/bin/varnishtest/vtc_h2_priv.h index 796e940..5c646d3 100644 --- a/bin/varnishtest/vtc_h2_priv.h +++ b/bin/varnishtest/vtc_h2_priv.h @@ -26,22 +26,20 @@ * SUCH DAMAGE. */ -#include "vqueue.h" - #define ITER_DONE(iter) (iter->buf == iter->end ? hpk_done : hpk_more) struct dynhdr { - struct hpk_hdr header; - VTAILQ_ENTRY(dynhdr) list; + struct hpk_hdr header; + VTAILQ_ENTRY(dynhdr) list; }; VTAILQ_HEAD(dynamic_table,dynhdr); struct hpk_iter { - struct hpk_ctx *ctx; - char *orig; - char *buf; - char *end; + struct hpk_ctx *ctx; + uint8_t *orig; + uint8_t *buf; + uint8_t *end; }; const struct txt * tbl_get_key(const struct hpk_ctx *ctx, uint32_t index); diff --git a/bin/varnishtest/vtc_h2_tbl.c b/bin/varnishtest/vtc_h2_tbl.c index c0262af..0aaa352 100644 --- a/bin/varnishtest/vtc_h2_tbl.c +++ b/bin/varnishtest/vtc_h2_tbl.c @@ -26,14 +26,15 @@ * SUCH DAMAGE. */ +#include +#include #include #include -#include -#include #include "vdef.h" #include "vas.h" +#include "vqueue.h" #include "hpack.h" #include "vtc_h2_priv.h" @@ -77,7 +78,7 @@ struct hpk_ctx { struct hpk_iter * -HPK_NewIter(struct hpk_ctx *ctx, char *buf, int size) +HPK_NewIter(struct hpk_ctx *ctx, void *buf, int size) { struct hpk_iter *iter = malloc(sizeof(*iter)); assert(iter); @@ -87,7 +88,7 @@ HPK_NewIter(struct hpk_ctx *ctx, char *buf, int size) iter->ctx = ctx; iter->orig = buf; iter->buf = buf; - iter->end = buf + size; + iter->end = iter->buf + size; return (iter); } diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index edfe796..54b2a20 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1924,7 +1924,8 @@ http_process(struct vtclog *vl, const char *spec, int sock, int *sfd, pthread_cleanup_push(http_process_cleanup, hp); parse_string(spec, http_cmds, hp, vl); retval = hp->fd; - pthread_cleanup_pop(1); + pthread_cleanup_pop(0); + http_process_cleanup(hp); return (retval); } diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index b8857b3..fccc8e3 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -374,6 +374,7 @@ parse_data(struct stream *s, struct frame *f) struct http *hp; uint32_t size = f->size; char *data = f->data; + CHECK_OBJ_NOTNULL(f, FRAME_MAGIC); CHECK_OBJ_NOTNULL(s, STREAM_MAGIC); CAST_OBJ_NOTNULL(hp, s->hp, HTTP_MAGIC);; @@ -1366,7 +1367,7 @@ cmd_tx11obj(CMD_ARGS) int scheme_done = 1; uint32_t stid = 0, pstid; uint32_t weight = 16; - int exclusive = 0; + uint32_t exclusive = 0; char *buf; struct hpk_iter *iter; struct frame f; @@ -2257,7 +2258,7 @@ cmd_rxmsg(CMD_ARGS) CHKFRAME(f->type, TYPE_CONTINUATION, rcv, *av); } - while (!end_stream && (f = rxstuff(s))) { + while (!end_stream && (f = rxstuff(s)) != NULL) { rcv++; CHKFRAME(f->type, TYPE_DATA, rcv, *av); end_stream = f->flags & END_STREAM; @@ -2695,25 +2696,27 @@ void b64_settings(const struct http *hp, const char *s) { uint16_t i; - uint64_t v; + uint64_t v, vv; const char *buf; int shift; + while (*s) { v = 0; for (shift = 42; shift >= 0; shift -= 6) { if (*s >= 'A' && *s <= 'Z') - v |= (uint64_t)(*s - 'A') << shift; + vv = (*s - 'A'); else if (*s >= 'a' && *s <= 'z') - v |= (uint64_t)((*s - 'a') + 26) << shift; + vv = (*s - 'a') + 26; else if (*s >= '0' && *s <= '9') - v |= (uint64_t)((*s - '0') + 52) << shift; + vv = (*s - '0') + 52; else if (*s == '-') - v |= (uint64_t)62 << shift; + vv = 62; else if (*s == '_') - v |= (uint64_t)63 << shift; + vv = 63; else vtc_fatal(hp->vl, "Bad \"HTTP2-Settings\" header"); + v |= vv << shift; s++; } i = v >> 32; diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c index add0f1f..4735472 100644 --- a/bin/varnishtest/vtc_logexp.c +++ b/bin/varnishtest/vtc_logexp.c @@ -153,7 +153,7 @@ struct logexp { int tag_last; int d_arg; - int g_arg; + enum VSL_grouping_e g_arg; char *query; struct vsm *vsm; @@ -171,7 +171,8 @@ logexp_delete_tests(struct logexp *le) struct logexp_test *test; CHECK_OBJ_NOTNULL(le, LOGEXP_MAGIC); - while ((test = VTAILQ_FIRST(&le->tests))) { + while (!VTAILQ_EMPTY(&le->tests)) { + test = VTAILQ_FIRST(&le->tests); CHECK_OBJ_NOTNULL(test, LOGEXP_TEST_MAGIC); VTAILQ_REMOVE(&le->tests, test, list); VSB_destroy(&test->str); @@ -262,7 +263,7 @@ logexp_dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], CAST_OBJ_NOTNULL(le, priv, LOGEXP_MAGIC); - for (i = 0; (t = pt[i]); i++) { + for (i = 0; (t = pt[i]) != NULL; i++) { while (1 == VSL_Next(t->c)) { if (!VSL_Match(vsl, t->c)) continue; @@ -510,6 +511,7 @@ void cmd_logexpect(CMD_ARGS) { struct logexp *le, *le2; + int i; (void)priv; (void)cmd; @@ -579,10 +581,11 @@ cmd_logexpect(CMD_ARGS) if (!strcmp(*av, "-g")) { if (av[1] == NULL) vtc_fatal(le->vl, "Missing -g argument"); - le->g_arg = VSLQ_Name2Grouping(av[1], strlen(av[1])); - if (le->g_arg < 0) + i = VSLQ_Name2Grouping(av[1], strlen(av[1])); + if (i < 0) vtc_fatal(le->vl, "Unknown grouping '%s'", av[1]); + le->g_arg = (enum VSL_grouping_e)i; av++; continue; } diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c index 33ead86..4876352 100644 --- a/bin/varnishtest/vtc_server.c +++ b/bin/varnishtest/vtc_server.c @@ -256,7 +256,8 @@ server_thread(void *priv) VTCP_close(&fd); } vtc_log(vl, 2, "Ending"); - pthread_cleanup_pop(1); + pthread_cleanup_pop(0); + vtc_logclose(vl); return (NULL); } @@ -302,7 +303,8 @@ server_dispatch_wrk(void *priv) vtc_fatal(vl, "Shutdown failed: %s", strerror(errno)); VTCP_close(&s->fd); vtc_log(vl, 2, "Ending"); - pthread_cleanup_pop(1); + pthread_cleanup_pop(0); + vtc_logclose(vl); return (NULL); } @@ -321,9 +323,7 @@ server_dispatch_thread(void *priv) assert(s->sock >= 0); vl = vtc_logopen(s->name); -#if !defined(__SUNPRO_C) pthread_cleanup_push(vtc_logclose, vl); -#endif vtc_log(vl, 2, "Dispatch started on %s", s->listen); @@ -342,9 +342,8 @@ server_dispatch_thread(void *priv) s2->run = 1; AZ(pthread_create(&s2->tp, NULL, server_dispatch_wrk, s2)); } -#if !defined(__SUNPRO_C) - pthread_cleanup_pop(1); -#endif + pthread_cleanup_pop(0); + vtc_logclose(vl); NEEDLESS(return(NULL)); } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index b7304b5..ac7e17a 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -223,7 +223,7 @@ varnishlog_thread(void *priv) c = NULL; opt = 0; - while (v->fds[1] > 0 || c != NULL) { + while (v->fds[1] > 0 || c != NULL) { //lint !e845 bug in flint if (c == NULL) { if (vtc_error) break; From nils.goroll at uplex.de Mon May 28 08:43:23 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 28 May 2018 08:43:23 +0000 (UTC) Subject: [master] c14650c Fix assertion in HTTP_create() Message-ID: <20180528084323.A555DB7BC3@lists.varnish-cache.org> commit c14650ca2c380ae4d8869299977d2161caf98e5e Author: Nils Goroll Date: Mon May 28 10:37:05 2018 +0200 Fix assertion in HTTP_create() For the case that http_max_hdr is not a multiple of the pointer size. Ref #2690 diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 6c3e2ce..8e41d37 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -155,7 +155,7 @@ HTTP_create(void *p, uint16_t nhttp, unsigned len) hp->hd = (void*)(hp + 1); hp->shd = nhttp; hp->hdf = (void*)(hp->hd + nhttp); - assert((unsigned char*)p + len == hp->hdf + nhttp); + assert((unsigned char*)p + len == hp->hdf + PRNDUP(nhttp)); return (hp); } diff --git a/bin/varnishtest/tests/r02690.vtc b/bin/varnishtest/tests/r02690.vtc new file mode 100644 index 0000000..fd13305 --- /dev/null +++ b/bin/varnishtest/tests/r02690.vtc @@ -0,0 +1,129 @@ +varnishtest "Check http_max_hdr values" + +server s1 -repeat 17 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + return(pass); + } +} -start + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 33} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 34} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 35} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 36} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 37} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 38} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 39} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 40} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 41} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 42} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 43} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 44} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 45} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 46} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 47} + +client c1 { + txreq + rxresp +} -run + +varnish v1 -cliok {param.set http_max_hdr 48} + +client c1 { + txreq + rxresp +} -run From dridi.boukelmoune at gmail.com Mon May 28 11:08:10 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 28 May 2018 11:08:10 +0000 (UTC) Subject: [master] d1b78e8 Terminate varnishtop -d automatically Message-ID: <20180528110810.7A978BA5AD@lists.varnish-cache.org> commit d1b78e8d13a993931d19f2c11acd19959e258ce9 Author: Dridi Boukelmoune Date: Tue May 22 09:57:54 2018 +0200 Terminate varnishtop -d automatically Following the documentation, the -d option implies that once processing is done the process should exit. We give it the time to do one last refresh of the screen in curses mode. Refs #2686 diff --git a/bin/varnishtest/tests/u00004.vtc b/bin/varnishtest/tests/u00004.vtc index 4bdc41f..28d58eb 100644 --- a/bin/varnishtest/tests/u00004.vtc +++ b/bin/varnishtest/tests/u00004.vtc @@ -12,7 +12,8 @@ client c1 { rxresp } -run -shell -expect "fetch" "varnishtop -n ${v1_name} -1 -d" +shell -expect "fetch" "varnishtop -n ${v1_name} -1" +shell -expect "fetch" "varnishtop -n ${v1_name} -d" shell -match "Usage: .*varnishtop " \ "varnishtop -h" diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 5f030c9..3035487 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -77,13 +77,13 @@ struct top { }; static float period = 60; /* seconds */ -static int end_of_file = 0; static unsigned ntop; static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static int f_flag = 0; static unsigned maxfieldlen = 0; static char *ident; +static volatile sig_atomic_t end_of_file = 0; static volatile sig_atomic_t quit = 0; static VRB_HEAD(t_order, top) h_order = VRB_INITIALIZER(&h_order); @@ -204,7 +204,7 @@ static void update(int p) { struct top *tp, *tp2; - int l, len; + int l, len, eof; double t = 0; static time_t last = 0; static unsigned n; @@ -222,7 +222,8 @@ update(int p) AC(erase()); q = ident; len = COLS - strlen(q); - if (end_of_file) + eof = end_of_file; + if (eof) AC(mvprintw(0, len - (1 + 6), "%s (EOF)", q)); else AC(mvprintw(0, len - 1, "%s", q)); @@ -240,7 +241,7 @@ update(int p) len, len, tp->rec_data)); t = tp->count; } - if (end_of_file) + if (eof) continue; tp->count += (1.0/3.0 - tp->count) / (double)n; if (tp->count * 10 < t || l > LINES * 10) { @@ -252,6 +253,8 @@ update(int p) } } AC(refresh()); + if (eof) + quit = 1; } static void * From dridi.boukelmoune at gmail.com Mon May 28 11:08:10 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 28 May 2018 11:08:10 +0000 (UTC) Subject: [master] 0efdb5c Remove arbitrary 1.0 threshold in varnishtop -1 Message-ID: <20180528110810.9EA5BBA5B0@lists.varnish-cache.org> commit 0efdb5c85bcb60020ea0c538b7d1909034c42dab Author: Dridi Boukelmoune Date: Tue May 22 13:39:38 2018 +0200 Remove arbitrary 1.0 threshold in varnishtop -1 With that both -d and -1 options report the same output, with the former limited to the terminal height. While this increases the risk of "never ending" dumps of log records showing only once, the assumption is that varnishtop is useful when someone is looking for something in particular. Restricting the output to the records someone is interested in mitigates the risk. Fixes #2686 diff --git a/bin/varnishtest/tests/r02686.vtc b/bin/varnishtest/tests/r02686.vtc new file mode 100644 index 0000000..53d1aa1 --- /dev/null +++ b/bin/varnishtest/tests/r02686.vtc @@ -0,0 +1,27 @@ +varnishtest "varnishtop -1/-d" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { } -start + +client c1 { + txreq + rxresp +} -run + +process p1 -dump {varnishtop -n ${v1_name} -d -i ReqMethod} -start +process p1 -winsz 30 80 +delay 2 +process p1 -expect-text 1 1 "list length 1" +process p1 -expect-text 1 75 "(EOF)" +process p1 -expect-text 3 6 "1.00 ReqMethod GET" +process p1 -screen_dump -wait + +process p2 -dump {varnishtop -n ${v1_name} -1 -i ReqMethod} -start +process p2 -winsz 30 80 +delay 2 +process p2 -expect-text 1 6 "1.00 ReqMethod GET" +process p2 -screen_dump -wait diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 3035487..8bdb065 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -322,8 +322,6 @@ dump(void) struct top *tp, *tp2; for (tp = VRB_MIN(t_order, &h_order); tp != NULL; tp = tp2) { tp2 = VRB_NEXT(t_order, &h_order, tp); - if (tp->count <= 1.0) - break; printf("%9.2f %s %*.*s\n", tp->count, VSL_tags[tp->tag], tp->clen, tp->clen, tp->rec_data); From dridi.boukelmoune at gmail.com Mon May 28 11:08:10 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 28 May 2018 11:08:10 +0000 (UTC) Subject: [master] d282ee9 Some varnishtop -f coverage Message-ID: <20180528110810.BF201BA5B4@lists.varnish-cache.org> commit d282ee9279d10cb71d528a35119260701d82e8dc Author: Dridi Boukelmoune Date: Tue May 22 14:02:10 2018 +0200 Some varnishtop -f coverage diff --git a/bin/varnishtest/tests/u00004.vtc b/bin/varnishtest/tests/u00004.vtc index 28d58eb..71ca1f6 100644 --- a/bin/varnishtest/tests/u00004.vtc +++ b/bin/varnishtest/tests/u00004.vtc @@ -15,6 +15,16 @@ client c1 { shell -expect "fetch" "varnishtop -n ${v1_name} -1" shell -expect "fetch" "varnishtop -n ${v1_name} -d" +# without -f +shell -match "1\\.00 RespHeader Date: [^\\n]+\\n" { + varnishtop -n ${v1_name} -1 -i RespHeader +} + +# with -f +shell -match "1\\.00 RespHeader Date\\n" { + varnishtop -n ${v1_name} -1 -f -i RespHeader +} + shell -match "Usage: .*varnishtop " \ "varnishtop -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ diff --git a/bin/varnishtop/varnishtop_options.h b/bin/varnishtop/varnishtop_options.h index dcad737..ebf8912 100644 --- a/bin/varnishtop/varnishtop_options.h +++ b/bin/varnishtop/varnishtop_options.h @@ -40,7 +40,9 @@ #define TOP_OPT_f \ VOPT("f", "[-f]", "First field only", \ "Sort and group only on the first field of each log entry." \ - " This is useful when displaying e.g. stataddr entries," \ + " For log entries in the form ``prefix: value`` it is the" \ + " prefix without the colon that is sorted and grouped." \ + " This is useful when displaying e.g. ReqStart entries," \ " where the first field is the client IP address." \ ) From lasse.karstensen at gmail.com Mon May 28 11:12:07 2018 From: lasse.karstensen at gmail.com (Lasse Karstensen) Date: Mon, 28 May 2018 11:12:07 +0000 (UTC) Subject: [master] 2972b09 Fix some punctation and formatting. Message-ID: <20180528111207.74790BA74A@lists.varnish-cache.org> commit 2972b099a5587c6d4e2b79bbaceda51309c3f2e7 Author: Lasse Karstensen Date: Mon May 28 13:10:42 2018 +0200 Fix some punctation and formatting. diff --git a/doc/changes.rst b/doc/changes.rst index 0b82050..c1e996f 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -101,7 +101,7 @@ VCL and bundled VMODs --------------------- * ``return (fetch)`` is no longer allowed in ``vcl_hit {}``, use - ``return (miss)`` instread. Note that ``return (fetch)`` has been + ``return (miss)`` instead. Note that ``return (fetch)`` has been deprecated since 4.0. * Fix behaviour of restarts to how it was originally intended: @@ -132,11 +132,11 @@ VCL and bundled VMODs * ``beresp.backend.ip`` is retired as of VCL 4.1. -* workspace overflows in ``std.log()`` now trigger a VCL failure +* workspace overflows in ``std.log()`` now trigger a VCL failure. -* workspace overflows in ``std.syslog()`` are ignored +* workspace overflows in ``std.syslog()`` are ignored. -* added ``return(restart)`` from ``vcl_recv{}`` +* added ``return(restart)`` from ``vcl_recv{}``. * The ``alg`` argument of the ``shard`` director ``.reconfigure()`` method has been removed - the consistent hashing ring is now always @@ -209,7 +209,7 @@ VCL and bundled VMODs now need to be named. * Integers in VCL are now 64 bits wide across all platforms - (implemented as ``int64_t`` C type) , but due to implementation + (implemented as ``int64_t`` C type), but due to implementation specifics of the VCL compiler (VCC), integer literals' precision is limited to that of a VCL real (``double`` C type, roughly 53 bits). @@ -225,11 +225,11 @@ Logging / statistics -------------------- * Turned off PROXY protocol debugging by default, can be enabled with - the ``protocol`` debug flag + the ``protocol`` debug flag. -* added ``cache_hit_grace`` statistics counter +* added ``cache_hit_grace`` statistics counter. -* added ``n_lru_limited`` counter +* added ``n_lru_limited`` counter. * The byte counters in ReqAcct now show the numbers reported from the operating system rather than what we anticipated to send. This will give @@ -285,7 +285,7 @@ C APIs (for vmod and utility authors) ``manual``, the auto-SYNOPSIS is left out, for VMOD authors who prefer to write their own. -* All varnish internal ``SHA256*`` symbols have been renamed to +* All Varnish internal ``SHA256*`` symbols have been renamed to ``VSHA256*`` * libvarnish now has ``VNUM_duration()`` to convert from a VCL @@ -300,7 +300,7 @@ C APIs (for vmod and utility authors) * ``__unused`` -> ``v_unused_`` * ``__attribute__((__noreturn__)`` -> ``v_noreturn_`` - * ENUMs are now fixed pointers per vcl +* ENUMs are now fixed pointers per vcl. * Added ``VRT_blob()`` utility function to create a blob as a copy of some chunk of data on the workspace. @@ -313,13 +313,13 @@ Other changes relevant for VMODs -------------------------------- * ``PRIV_*`` function/method arguments are not excluded from - auto-generated vmod documentation + auto-generated vmod documentation. Fixed bugs which may influence VCL behaviour -------------------------------------------- * After reusing a backend connection fails once, a fresh connection - will be opened (2135) + will be opened (2135_). .. _2135: https://github.com/varnishcache/varnish-cache/pull/2135 From nils.goroll at uplex.de Mon May 28 14:08:13 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 28 May 2018 14:08:13 +0000 (UTC) Subject: [master] 3f4cd92 sess_fail_* detailled accept error counters Message-ID: <20180528140813.CCBD861E53@lists.varnish-cache.org> commit 3f4cd9297d53b1e18e594c83d9fd068d4dd4a666 Author: Nils Goroll Date: Mon May 28 16:07:27 2018 +0200 sess_fail_* detailled accept error counters We already emitted Debug log records for accept failures, but for all practical purposes this is useless for forensics. These counters will point directly to the root cause for the most common issues with sess_fail (accept failures). sess_fail is preserved as an overall counter as it will most likely be already monitored for many installations. Ref #2622 diff --git a/bin/varnishd/VSC_main.vsc b/bin/varnishd/VSC_main.vsc index a2e2d01..dbcbcdf 100644 --- a/bin/varnishd/VSC_main.vsc +++ b/bin/varnishd/VSC_main.vsc @@ -33,9 +33,46 @@ .. varnish_vsc:: sess_fail :oneliner: Session accept failures - Count of failures to accept TCP connection. Either the client - changed its mind, or the kernel ran out of some resource like file - descriptors. + Count of failures to accept TCP connection. + + This counter is the sum of the sess_fail_* counters, which + give more detailled information. + +.. varnish_vsc:: sess_fail_econnaborted + :oneliner: Session accept failures: connection aborted + + Detailled reason for sess_fail: Connection aborted by the + client, usually harmless. + +.. varnish_vsc:: sess_fail_eintr + :oneliner: Session accept failures: interrupted system call + + Detailled reason for sess_fail: The accept() call was + interrupted, usually harmless + +.. varnish_vsc:: sess_fail_emfile + :oneliner: Session accept failures: too many open files + + Detailled reason for sess_fail: No file descriptor was + available. Consider raising RLIMIT_NOFILE (see ulimit -n). + +.. varnish_vsc:: sess_fail_ebadf + :oneliner: Session accept failures: bad file descriptor + + Detailled reason for sess_fail: The listen socket file + descriptor was invalid. Should never happen. + +.. varnish_vsc:: sess_fail_enomem + :oneliner: Session accept failures: not enough memory + + Detailled reason for sess_fail: Most likely insufficient + socket buffer memory. Should never happen + +.. varnish_vsc:: sess_fail_other + :oneliner: Session accept failures: other + + Detailled reason for sess_fail: neither of the above, see + Debug log (varnishlog -g raw -I Debug:^Accept). .. varnish_vsc:: client_req_400 :oneliner: Client requests received, subject to 400 errors diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 6973d01..455697f 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -489,23 +489,32 @@ vca_accept_task(struct worker *wrk, void *arg) if (i < 0) { switch (errno) { case ECONNABORTED: + wrk->stats->sess_fail_econnaborted++; + break; + case EINTR: + wrk->stats->sess_fail_eintr++; break; case EMFILE: - VSL(SLT_Debug, ls->sock, "Too many open files"); + wrk->stats->sess_fail_emfile++; vca_pace_bad(); break; case EBADF: - VSL(SLT_Debug, ls->sock, "Accept failed: %s", - strerror(errno)); + wrk->stats->sess_fail_ebadf++; + vca_pace_bad(); + break; + case ENOBUFS: + case ENOMEM: + wrk->stats->sess_fail_enomem++; vca_pace_bad(); break; default: - VSL(SLT_Debug, ls->sock, "Accept failed: %s", - strerror(errno)); + wrk->stats->sess_fail_other++; vca_pace_bad(); break; } wrk->stats->sess_fail++; + VSL(SLT_Debug, ls->sock, "Accept failed: %s", + strerror(errno)); (void)Pool_TrySumstat(wrk); continue; } diff --git a/doc/changes.rst b/doc/changes.rst index c1e996f..97ce466 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -37,6 +37,20 @@ varnishadm * The output format of the ``backend.list`` CLI command has been changed. +varnishstat +----------- + +* The counters + + * ``sess_fail_econnaborted`` + * ``sess_fail_eintr`` + * ``sess_fail_emfile`` + * ``sess_fail_ebadf`` + * ``sess_fail_enomem`` + * ``sess_fail_other`` + + now break down the detailled reason for session accept failures, the + sum of which continues to be counted in ``sess_fail``. VCL and bundled VMODs --------------------- From phk at FreeBSD.org Mon May 28 16:21:22 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 28 May 2018 16:21:22 +0000 (UTC) Subject: [master] 3d7fdf4 Use 'process' when terminal/curses is involved Message-ID: <20180528162122.E298D64B41@lists.varnish-cache.org> commit 3d7fdf49c8e118f55c039e7c423bd4d8b8829b11 Author: Poul-Henning Kamp Date: Mon May 28 16:20:01 2018 +0000 Use 'process' when terminal/curses is involved diff --git a/bin/varnishtest/tests/u00004.vtc b/bin/varnishtest/tests/u00004.vtc index 71ca1f6..5435f98 100644 --- a/bin/varnishtest/tests/u00004.vtc +++ b/bin/varnishtest/tests/u00004.vtc @@ -13,7 +13,9 @@ client c1 { } -run shell -expect "fetch" "varnishtop -n ${v1_name} -1" -shell -expect "fetch" "varnishtop -n ${v1_name} -d" + +process p1 "varnishtop -n ${v1_name} -d" -run -screen_dump +process p1 -expect-text 0 0 fetch # without -f shell -match "1\\.00 RespHeader Date: [^\\n]+\\n" { From fgsch at lodoss.net Mon May 28 20:05:14 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 28 May 2018 20:05:14 +0000 (UTC) Subject: [master] 30b26ae Spelling Message-ID: <20180528200514.06503949CB@lists.varnish-cache.org> commit 30b26aea8f8a292372084ad2a47e179c33df9d46 Author: Federico G. Schwindt Date: Mon May 28 21:04:17 2018 +0100 Spelling diff --git a/bin/varnishd/VSC_main.vsc b/bin/varnishd/VSC_main.vsc index dbcbcdf..4749eb5 100644 --- a/bin/varnishd/VSC_main.vsc +++ b/bin/varnishd/VSC_main.vsc @@ -36,42 +36,42 @@ Count of failures to accept TCP connection. This counter is the sum of the sess_fail_* counters, which - give more detailled information. + give more detailed information. .. varnish_vsc:: sess_fail_econnaborted :oneliner: Session accept failures: connection aborted - Detailled reason for sess_fail: Connection aborted by the + Detailed reason for sess_fail: Connection aborted by the client, usually harmless. .. varnish_vsc:: sess_fail_eintr :oneliner: Session accept failures: interrupted system call - Detailled reason for sess_fail: The accept() call was + Detailed reason for sess_fail: The accept() call was interrupted, usually harmless .. varnish_vsc:: sess_fail_emfile :oneliner: Session accept failures: too many open files - Detailled reason for sess_fail: No file descriptor was + Detailed reason for sess_fail: No file descriptor was available. Consider raising RLIMIT_NOFILE (see ulimit -n). .. varnish_vsc:: sess_fail_ebadf :oneliner: Session accept failures: bad file descriptor - Detailled reason for sess_fail: The listen socket file + Detailed reason for sess_fail: The listen socket file descriptor was invalid. Should never happen. .. varnish_vsc:: sess_fail_enomem :oneliner: Session accept failures: not enough memory - Detailled reason for sess_fail: Most likely insufficient + Detailed reason for sess_fail: Most likely insufficient socket buffer memory. Should never happen .. varnish_vsc:: sess_fail_other :oneliner: Session accept failures: other - Detailled reason for sess_fail: neither of the above, see + Detailed reason for sess_fail: neither of the above, see Debug log (varnishlog -g raw -I Debug:^Accept). .. varnish_vsc:: client_req_400 @@ -374,7 +374,7 @@ .. varnish_vsc:: s_synth - :oneliner: Total synthethic responses made + :oneliner: Total synthetic responses made .. varnish_vsc:: s_req_hdrbytes From phk at FreeBSD.org Tue May 29 12:18:23 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 29 May 2018 12:18:23 +0000 (UTC) Subject: [master] 58be184 Whitespace OCD Message-ID: <20180529121824.1793BB1310@lists.varnish-cache.org> commit 58be1848df977a337239d5304d34cb97b2e471c3 Author: Poul-Henning Kamp Date: Tue May 29 09:56:58 2018 +0000 Whitespace OCD diff --git a/bin/varnishtest/tests/r02686.vtc b/bin/varnishtest/tests/r02686.vtc index 53d1aa1..eb85b99 100644 --- a/bin/varnishtest/tests/r02686.vtc +++ b/bin/varnishtest/tests/r02686.vtc @@ -1,15 +1,15 @@ varnishtest "varnishtop -1/-d" server s1 { - rxreq - txresp + rxreq + txresp } -start varnish v1 -vcl+backend { } -start client c1 { - txreq - rxresp + txreq + rxresp } -run process p1 -dump {varnishtop -n ${v1_name} -d -i ReqMethod} -start From phk at FreeBSD.org Tue May 29 12:18:24 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 29 May 2018 12:18:24 +0000 (UTC) Subject: [master] a871b44 Add a version of VSS_resolver() where you specify the socktype. Message-ID: <20180529121824.34E22B1321@lists.varnish-cache.org> commit a871b44d072b0dd39b6025f64c4edee0cd3fe5a3 Author: Poul-Henning Kamp Date: Tue May 29 11:54:21 2018 +0000 Add a version of VSS_resolver() where you specify the socktype. diff --git a/include/vss.h b/include/vss.h index 14b9356..aa645bd 100644 --- a/include/vss.h +++ b/include/vss.h @@ -32,3 +32,5 @@ struct suckaddr; typedef int vss_resolved_f(void *priv, const struct suckaddr *); int VSS_resolver(const char *addr, const char *def_port, vss_resolved_f *func, void *priv, const char **err); +int VSS_resolver_socktype(const char *addr, const char *def_port, + vss_resolved_f *func, void *priv, const char **err, int socktype); diff --git a/lib/libvarnish/vss.c b/lib/libvarnish/vss.c index 29c66be..7282019 100644 --- a/lib/libvarnish/vss.c +++ b/lib/libvarnish/vss.c @@ -105,8 +105,8 @@ vss_parse(char *str, char **addr, char **port) */ int -VSS_resolver(const char *addr, const char *def_port, vss_resolved_f *func, - void *priv, const char **err) +VSS_resolver_socktype(const char *addr, const char *def_port, + vss_resolved_f *func, void *priv, const char **err, int socktype) { struct addrinfo hints, *res0, *res; struct suckaddr *vsa; @@ -126,7 +126,7 @@ VSS_resolver(const char *addr, const char *def_port, vss_resolved_f *func, def_port = adp; memset(&hints, 0, sizeof hints); - hints.ai_socktype = SOCK_STREAM; + hints.ai_socktype = socktype; hints.ai_flags = AI_PASSIVE; ret = getaddrinfo(hop, def_port, &hints, &res0); free(h); @@ -146,3 +146,11 @@ VSS_resolver(const char *addr, const char *def_port, vss_resolved_f *func, freeaddrinfo(res0); return (ret); } + +int +VSS_resolver(const char *addr, const char *def_port, vss_resolved_f *func, + void *priv, const char **err) +{ + return (VSS_resolver_socktype( + addr, def_port, func, priv, err, SOCK_STREAM)); +} From phk at FreeBSD.org Tue May 29 12:18:24 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 29 May 2018 12:18:24 +0000 (UTC) Subject: [master] a7ee621 Add a syslog-server facility for the benefit of HAproxy testers. Message-ID: <20180529121824.3CB79B1378@lists.varnish-cache.org> commit a7ee62136fe06eae137fb941010d0caeef9647d4 Author: Poul-Henning Kamp Date: Tue May 29 12:11:19 2018 +0000 Add a syslog-server facility for the benefit of HAproxy testers. Submitted by: Fr?d?ric L?caille Hacked to pieces by: phk diff --git a/bin/varnishtest/Makefile.am b/bin/varnishtest/Makefile.am index 392b02a..0deef9c 100644 --- a/bin/varnishtest/Makefile.am +++ b/bin/varnishtest/Makefile.am @@ -57,6 +57,7 @@ varnishtest_SOURCES = \ vtc_proxy.c \ vtc_server.c \ vtc_subr.c \ + vtc_syslog.c \ vtc_varnish.c varnishtest_LDADD = \ diff --git a/bin/varnishtest/Makefile.phk b/bin/varnishtest/Makefile.phk index b50535d..b406cce 100644 --- a/bin/varnishtest/Makefile.phk +++ b/bin/varnishtest/Makefile.phk @@ -6,6 +6,7 @@ PROG_SRC += vtc_logexp.c PROG_SRC += vtc_main.c PROG_SRC += vtc_barrier.c PROG_SRC += vtc_server.c +PROG_SRC += vtc_syslog.c PROG_SRC += vtc_varnish.c PROG_SRC += vtc_process.c diff --git a/bin/varnishtest/cmds.h b/bin/varnishtest/cmds.h index 290237d..e856e60 100644 --- a/bin/varnishtest/cmds.h +++ b/bin/varnishtest/cmds.h @@ -40,6 +40,7 @@ CMD(process) CMD(server) CMD(setenv) CMD(shell) +CMD(syslog) CMD(varnish) CMD(varnishtest) #undef CMD diff --git a/bin/varnishtest/tests/h00005.vtc b/bin/varnishtest/tests/h00005.vtc new file mode 100644 index 0000000..44cf902 --- /dev/null +++ b/bin/varnishtest/tests/h00005.vtc @@ -0,0 +1,45 @@ +varnishtest "Exercise varnishtest syslog facility" + +feature ignore_unknown_macro +feature cmd {haproxy --version 2>&1 | grep -q 'HA-Proxy version'} + +server s1 { + rxreq + txresp +} -start + +syslog sl1 -level notice -bind "127.0.0.1:0" { + recv + recv + recv info + expect ~ \"dip\":\"${h1_fe_1_addr} +} -start + +haproxy h1 -conf { + global + log ${sl1_addr}:${sl1_port} local0 + + defaults + log global + timeout connect 3000 + timeout client 5 + timeout server 10000 + + frontend fe1 + bind "fd@${fe_1}" + mode tcp + log-format {\"dip\":\"%fi\",\"dport\":\"%fp\"} + default_backend be1 + + backend be1 + server srv1 ${s1_addr}:${s1_port} +} -start + +client c1 -connect ${h1_fe_1_sock} { + txreq -url "/" + delay 0.02 + rxresp +} -run + +syslog sl1 -wait + diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index c6c5897..69b2d3d 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -472,6 +472,7 @@ exec_file(const char *fn, const char *script, const char *tmpdir, init_macro(); init_server(); + init_syslog(); vsb = VSB_new_auto(); AN(vsb); diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index 8ad4a5a..6ebff08 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -85,6 +85,7 @@ extern int feature_dns; extern int ign_unknown_macro; void init_server(void); +void init_syslog(void); int http_process(struct vtclog *vl, const char *spec, int sock, int *sfd, const char *addr); diff --git a/bin/varnishtest/vtc_syslog.c b/bin/varnishtest/vtc_syslog.c new file mode 100644 index 0000000..2ef8a85 --- /dev/null +++ b/bin/varnishtest/vtc_syslog.c @@ -0,0 +1,649 @@ +/*- + * Copyright (c) 2008-2010 Varnish Software AS + * All rights reserved. + * + * Author: Fr?d?ric L?caille + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * 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. + */ + +#include "config.h" + +#include +#include + +#include +#include +#include +#include +#include + +#include "vsa.h" +#include "vss.h" +#include "vtcp.h" +#include "vre.h" + +#include "vtc.h" + +struct syslog_srv { + unsigned magic; +#define SYSLOG_SRV_MAGIC 0xbf28a692 + char *name; + struct vtclog *vl; + VTAILQ_ENTRY(syslog_srv) list; + char run; + + unsigned repeat; + char *spec; + + int sock; + char bind[256]; + int lvl; + + pthread_t tp; + ssize_t rxbuf_left; + size_t rxbuf_sz; + char *rxbuf; + double timeout; +}; + +static pthread_mutex_t syslog_mtx; + +static VTAILQ_HEAD(, syslog_srv) syslogs = + VTAILQ_HEAD_INITIALIZER(syslogs); + +static const char * const syslog_levels[] = { + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug", + NULL, +}; + +static int +get_syslog_level(struct vtclog *vl, const char *lvl) +{ + int i; + + for (i = 0; syslog_levels[i]; i++) + if (!strcmp(lvl, syslog_levels[i])) + return (i); + vtc_fatal(vl, "wrong syslog level '%s'\n", lvl); +} + +/*-------------------------------------------------------------------- + * Check if a UDP syscall return value is fatal + * XXX: Largely copied from VTCP, not sure if really applicable + */ + +static int +VUDP_Check(int a) +{ + if (a == 0) + return (1); + if (errno == ECONNRESET) + return (1); +#if (defined (__SVR4) && defined (__sun)) || defined (__NetBSD__) + /* + * Solaris returns EINVAL if the other end unexpectedly reset the + * connection. + * This is a bug in Solaris and documented behaviour on NetBSD. + */ + if (errno == EINVAL || errno == ETIMEDOUT || errno == EPIPE) + return (1); +#elif defined (__APPLE__) + /* + * MacOS returns EINVAL if the other end unexpectedly reset + * the connection. + */ + if (errno == EINVAL) + return (1); +#endif + return (0); +} + +/*-------------------------------------------------------------------- + * When closing a UDP connection, a couple of errno's are legit, we + * can't be held responsible for the other end wanting to talk to us. + */ + +static void +VUDP_close(int *s) +{ + int i; + + i = close(*s); + + assert(VUDP_Check(i)); + *s = -1; +} + +/*-------------------------------------------------------------------- + * Given a struct suckaddr, open a socket of the appropriate type, and bind + * it to the requested address. + * + * If the address is an IPv6 address, the IPV6_V6ONLY option is set to + * avoid conflicts between INADDR_ANY and IN6ADDR_ANY. + */ + +static int +VUDP_bind(const struct suckaddr *sa, const char **errp) +{ + int sd, val, e; + socklen_t sl; + const struct sockaddr *so; + int proto; + + if (errp != NULL) + *errp = NULL; + + proto = VSA_Get_Proto(sa); + sd = socket(proto, SOCK_DGRAM, 0); + if (sd < 0) { + if (errp != NULL) + *errp = "socket(2)"; + return (-1); + } + val = 1; + if (setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val) != 0) { + if (errp != NULL) + *errp = "setsockopt(SO_REUSEADDR, 1)"; + e = errno; + closefd(&sd); + errno = e; + return (-1); + } + +#ifdef IPV6_V6ONLY + /* forcibly use separate sockets for IPv4 and IPv6 */ + val = 1; + if (proto == AF_INET6 && + setsockopt(sd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof val) != 0) { + if (errp != NULL) + *errp = "setsockopt(IPV6_V6ONLY, 1)"; + e = errno; + closefd(&sd); + errno = e; + return (-1); + } +#endif + so = VSA_Get_Sockaddr(sa, &sl); + if (bind(sd, so, sl) != 0) { + if (errp != NULL) + *errp = "bind(2)"; + e = errno; + closefd(&sd); + errno = e; + return (-1); + } + return (sd); +} + +/*--------------------------------------------------------------------*/ + +struct udp_helper { + const char **errp; +}; + +static int v_matchproto_(vss_resolved_f) +vudp_lo_cb(void *priv, const struct suckaddr *sa) +{ + int sock; + struct udp_helper *hp = priv; + + sock = VUDP_bind(sa, hp->errp); + if (sock > 0) { + *hp->errp = NULL; + return (sock); + } + AN(*hp->errp); + return (0); +} + +static int +VUDP_bind_on(const char *addr, const char *def_port, const char **errp) +{ + struct udp_helper h; + int sock; + + h.errp = errp; + + sock = VSS_resolver_socktype( + addr, def_port, vudp_lo_cb, &h, errp, SOCK_DGRAM); + if (*errp != NULL) + return (-1); + return (sock); +} + +/********************************************************************** + * Allocate and initialize a syslog + */ + +static struct syslog_srv * +syslog_new(const char *name, struct vtclog *vl) +{ + struct syslog_srv *s; + + VTC_CHECK_NAME(vl, name, "Syslog", 's'); + ALLOC_OBJ(s, SYSLOG_SRV_MAGIC); + AN(s); + REPLACE(s->name, name); + s->vl = vtc_logopen(s->name); + AN(s->vl); + + bprintf(s->bind, "%s", "127.0.0.1 0"); + s->repeat = 1; + s->sock = -1; + s->lvl = -1; + s->timeout = vtc_maxdur * .5; // XXX + + vl = vtc_logopen(s->name); + AN(vl); + + s->rxbuf_sz = s->rxbuf_left = 2048*1024; + s->rxbuf = malloc(s->rxbuf_sz); /* XXX */ + AN(s->rxbuf); + + AZ(pthread_mutex_lock(&syslog_mtx)); + VTAILQ_INSERT_TAIL(&syslogs, s, list); + AZ(pthread_mutex_unlock(&syslog_mtx)); + return (s); +} + +/********************************************************************** + * Clean up a syslog + */ + +static void +syslog_delete(struct syslog_srv *s) +{ + + CHECK_OBJ_NOTNULL(s, SYSLOG_SRV_MAGIC); + macro_undef(s->vl, s->name, "addr"); + macro_undef(s->vl, s->name, "port"); + macro_undef(s->vl, s->name, "sock"); + vtc_logclose(s->vl); + free(s->name); + free(s->rxbuf); + /* XXX: MEMLEAK (?) (VSS ??) */ + FREE_OBJ(s); +} + +static void +syslog_rx(const struct syslog_srv *s, int lvl) +{ + ssize_t ret; + + while (!vtc_error) { + /* Pointers to syslog priority value (see , rfc5424). */ + char *prib, *prie, *end; + unsigned int prival; + + VTCP_set_read_timeout(s->sock, s->timeout); + + ret = recv(s->sock, s->rxbuf, s->rxbuf_sz - 1, 0); + if (ret < 0) { + if (errno == EINTR) + continue; + + vtc_fatal(s->vl, + "%s: recv failed (fd: %d read: %s", __func__, + s->sock, strerror(errno)); + } + if (ret == 0) + vtc_fatal(s->vl, + "syslog rx timeout (fd: %d %.3fs ret: %zd)", + s->sock, s->timeout, ret); + + s->rxbuf[ret] = '\0'; + vtc_dump(s->vl, 4, "syslog", s->rxbuf, ret); + + prib = s->rxbuf; + if (*prib++ != '<') + vtc_fatal(s->vl, "syslog PRI, no '<'"); + prie = strchr(prib, '>'); + if (prie == NULL) + vtc_fatal(s->vl, "syslog PRI, no '>'"); + + prival = strtoul(prib, &end, 10); + if (end != prie) + vtc_fatal(s->vl, "syslog PRI, bad number"); + + if (lvl >= 0 && lvl == (prival & 0x7)) + return; + } +} + +/********************************************************************** + * Syslog server bind + */ + +static void +syslog_bind(struct syslog_srv *s) +{ + const char *err; + char aaddr[VTCP_ADDRBUFSIZE]; + char aport[VTCP_PORTBUFSIZE]; + + CHECK_OBJ_NOTNULL(s, SYSLOG_SRV_MAGIC); + + if (s->sock >= 0) + VUDP_close(&s->sock); + s->sock = VUDP_bind_on(s->bind, "0", &err); + if (err != NULL) + vtc_fatal(s->vl, + "Syslog server bind address (%s) cannot be resolved: %s", + s->bind, err); + assert(s->sock > 0); + VTCP_myname(s->sock, aaddr, sizeof aaddr, aport, sizeof aport); + macro_def(s->vl, s->name, "addr", "%s", aaddr); + macro_def(s->vl, s->name, "port", "%s", aport); + macro_def(s->vl, s->name, "sock", "%s %s", aaddr, aport); + /* Record the actual port, and reuse it on subsequent starts */ + bprintf(s->bind, "%s %s", aaddr, aport); +} + +static void v_matchproto_(cmd_f) +cmd_syslog_expect(CMD_ARGS) +{ + struct syslog_srv *s; + vre_t *vre; + const char *error; + int erroroffset, i, ret; + char *cmp, *spec; + + (void)vl; + (void)cmd; + CAST_OBJ_NOTNULL(s, priv, SYSLOG_SRV_MAGIC); + AZ(strcmp(av[0], "expect")); + av++; + + cmp = av[0]; + spec = av[1]; + AN(cmp); + AN(spec); + AZ(av[2]); + + assert(!strcmp(cmp, "~") || !strcmp(cmp, "!~")); + + vre = VRE_compile(spec, 0, &error, &erroroffset); + if (!vre) + vtc_fatal(s->vl, "REGEXP error: '%s' (@%d) (%s)", + error, erroroffset, spec); + + i = VRE_exec(vre, s->rxbuf, strlen(s->rxbuf), 0, 0, NULL, 0, 0); + + VRE_free(&vre); + + ret = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!'); + if (!ret) + vtc_fatal(s->vl, "EXPECT FAILED %s \"%s\"", cmp, spec); + else + vtc_log(s->vl, 4, "EXPECT MATCH %s \"%s\"", cmp, spec); +} + +static void v_matchproto_(cmd_f) +cmd_syslog_recv(CMD_ARGS) +{ + int lvl; + struct syslog_srv *s; + + CAST_OBJ_NOTNULL(s, priv, SYSLOG_SRV_MAGIC); + (void)cmd; + (void)vl; + AZ(strcmp(av[0], "recv")); + av++; + if (av[0] == NULL) + lvl = s->lvl; + else + lvl = get_syslog_level(vl, av[0]); + + syslog_rx(s, lvl); +} + +static const struct cmds syslog_cmds[] = { +#define CMD_SYSLOG(n) { #n, cmd_syslog_##n }, + /* session */ + CMD_SYSLOG(expect) + CMD_SYSLOG(recv) +#undef CMD_SYSLOG +}; + +/********************************************************************** + * Syslog server thread + */ + +static void * +syslog_thread(void *priv) +{ + struct syslog_srv *s; + int i; + + CAST_OBJ_NOTNULL(s, priv, SYSLOG_SRV_MAGIC); + assert(s->sock >= 0); + + vtc_log(s->vl, 2, "Started on %s (level: %d)", s->bind, s->lvl); + for (i = 0; i < s->repeat; i++) { + if (s->repeat > 1) + vtc_log(s->vl, 3, "Iteration %d", i); + parse_string(s->spec, syslog_cmds, s, s->vl); + vtc_log(s->vl, 3, "shutting fd %d", s->sock); + } + VUDP_close(&s->sock); + vtc_log(s->vl, 2, "Ending"); + return (NULL); +} + +/********************************************************************** + * Start the syslog thread + */ + +static void +syslog_start(struct syslog_srv *s) +{ + CHECK_OBJ_NOTNULL(s, SYSLOG_SRV_MAGIC); + vtc_log(s->vl, 2, "Starting syslog server"); + if (s->sock == -1) + syslog_bind(s); + vtc_log(s->vl, 1, "Bound on %s", s->bind); + s->run = 1; + AZ(pthread_create(&s->tp, NULL, syslog_thread, s)); +} + +/********************************************************************** + * Force stop the syslog thread + */ + +static void +syslog_stop(struct syslog_srv *s) +{ + void *res; + + CHECK_OBJ_NOTNULL(s, SYSLOG_SRV_MAGIC); + vtc_log(s->vl, 2, "Stopping for syslog server"); + (void)pthread_cancel(s->tp); + AZ(pthread_join(s->tp, &res)); + s->tp = 0; + s->run = 0; +} + +/********************************************************************** + * Wait for syslog thread to stop + */ + +static void +syslog_wait(struct syslog_srv *s) +{ + void *res; + + CHECK_OBJ_NOTNULL(s, SYSLOG_SRV_MAGIC); + vtc_log(s->vl, 2, "Waiting for syslog server (%d)", s->sock); + AZ(pthread_join(s->tp, &res)); + if (res != NULL && !vtc_stop) + vtc_fatal(s->vl, "Syslog server returned \"%p\"", + (char *)res); + s->tp = 0; + s->run = 0; +} + +/* SECTION: syslog syslog + * + * Define and interact with syslog instances. + * + * To define a syslog server, you'll use this syntax:: + * + * syslog sNAME + * + * Arguments: + * + * sNAME + * Identify the syslog server with a string which must start with 's'. + * + * \-level STRING + * Set the default syslog priority level used by any subsequent "recv" + * command. + * Any syslog dgram with a different level will be skipped by + * "recv" command. This default level value may be superseded + * by "recv" command if supplied as first argument: "recv ". + * + * \-start + * Start the syslog server thread in the background. + * + * \-repeat + * Instead of processing the specification only once, do it + * NUMBER times. + * + * \-bind + * Bind the syslog socket to a local address. + * + * \-wait + * Wait for that thread to terminate. + * + * \-stop + * Stop the syslog server thread. + */ + +void v_matchproto_(cmd_f) +cmd_syslog(CMD_ARGS) +{ + struct syslog_srv *s; + + (void)priv; + (void)cmd; + + if (av == NULL) { + /* Reset and free */ + do { + AZ(pthread_mutex_lock(&syslog_mtx)); + s = VTAILQ_FIRST(&syslogs); + CHECK_OBJ_ORNULL(s, SYSLOG_SRV_MAGIC); + if (s != NULL) + VTAILQ_REMOVE(&syslogs, s, list); + AZ(pthread_mutex_unlock(&syslog_mtx)); + if (s != NULL) { + if (s->run) { + (void)pthread_cancel(s->tp); + syslog_wait(s); + } + if (s->sock >= 0) + VUDP_close(&s->sock); + syslog_delete(s); + } + } while (s != NULL); + return; + } + + AZ(strcmp(av[0], "syslog")); + av++; + + AZ(pthread_mutex_lock(&syslog_mtx)); + VTAILQ_FOREACH(s, &syslogs, list) + if (!strcmp(s->name, av[0])) + break; + AZ(pthread_mutex_unlock(&syslog_mtx)); + if (s == NULL) + s = syslog_new(av[0], vl); + CHECK_OBJ_NOTNULL(s, SYSLOG_SRV_MAGIC); + av++; + + for (; *av != NULL; av++) { + if (vtc_error) + break; + if (!strcmp(*av, "-wait")) { + if (!s->run) + vtc_fatal(s->vl, "Syslog server not -started"); + syslog_wait(s); + continue; + } + + if (!strcmp(*av, "-stop")) { + syslog_stop(s); + continue; + } + + /* + * We do an implict -wait if people muck about with a + * running syslog. + * This only works if the previous ->spec has completed + */ + if (s->run) + syslog_wait(s); + + AZ(s->run); + if (!strcmp(*av, "-repeat")) { + AN(av[1]); + s->repeat = atoi(av[1]); + av++; + continue; + } + if (!strcmp(*av, "-bind")) { + AN(av[1]); + bprintf(s->bind, "%s", av[1]); + av++; + syslog_bind(s); + continue; + } + if (!strcmp(*av, "-level")) { + AN(av[1]); + s->lvl = get_syslog_level(vl, av[1]); + av++; + continue; + } + if (!strcmp(*av, "-start")) { + syslog_start(s); + continue; + } + if (**av == '-') + vtc_fatal(s->vl, "Unknown syslog argument: %s", *av); + s->spec = *av; + } +} + +void +init_syslog(void) +{ + AZ(pthread_mutex_init(&syslog_mtx, NULL)); +} From phk at FreeBSD.org Tue May 29 16:02:31 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 29 May 2018 16:02:31 +0000 (UTC) Subject: [master] 5d2cdad Force haproxy onto "localhost" addresses, to make it possible to match syslog-output. Message-ID: <20180529160231.B91DFB5859@lists.varnish-cache.org> commit 5d2cdad654be46ecdf176b124c35c647ebb8860b Author: Poul-Henning Kamp Date: Tue May 29 16:00:21 2018 +0000 Force haproxy onto "localhost" addresses, to make it possible to match syslog-output. diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c index 88162a9..3cc12fe 100644 --- a/bin/varnishtest/vtc_haproxy.c +++ b/bin/varnishtest/vtc_haproxy.c @@ -389,7 +389,7 @@ haproxy_build_backends(const struct haproxy *h, const char *vsb_data) break; *q++ = '\0'; - sock = VTCP_listen_on(":0", NULL, 1, &err); + sock = VTCP_listen_on("localhost:0", NULL, 1, &err); if (err != NULL) vtc_fatal(h->vl, "Create listen socket failed: %s", err); From phk at FreeBSD.org Tue May 29 16:02:31 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 29 May 2018 16:02:31 +0000 (UTC) Subject: [master] eabeb64 Use 'S' as instance-id for syslog. Message-ID: <20180529160231.D1512B585C@lists.varnish-cache.org> commit eabeb64b3695ec62ced4cc56a2da7b626e82bc5a Author: Poul-Henning Kamp Date: Tue May 29 16:00:55 2018 +0000 Use 'S' as instance-id for syslog. diff --git a/bin/varnishtest/tests/h00005.vtc b/bin/varnishtest/tests/h00005.vtc index 44cf902..3af6aa4 100644 --- a/bin/varnishtest/tests/h00005.vtc +++ b/bin/varnishtest/tests/h00005.vtc @@ -8,7 +8,7 @@ server s1 { txresp } -start -syslog sl1 -level notice -bind "127.0.0.1:0" { +syslog S1 -level notice -bind "127.0.0.1:0" { recv recv recv info @@ -17,7 +17,7 @@ syslog sl1 -level notice -bind "127.0.0.1:0" { haproxy h1 -conf { global - log ${sl1_addr}:${sl1_port} local0 + log ${S1_addr}:${S1_port} local0 defaults log global @@ -41,5 +41,5 @@ client c1 -connect ${h1_fe_1_sock} { rxresp } -run -syslog sl1 -wait +syslog S1 -wait diff --git a/bin/varnishtest/vtc_syslog.c b/bin/varnishtest/vtc_syslog.c index 2ef8a85..4221b40 100644 --- a/bin/varnishtest/vtc_syslog.c +++ b/bin/varnishtest/vtc_syslog.c @@ -247,7 +247,7 @@ syslog_new(const char *name, struct vtclog *vl) { struct syslog_srv *s; - VTC_CHECK_NAME(vl, name, "Syslog", 's'); + VTC_CHECK_NAME(vl, name, "Syslog", 'S'); ALLOC_OBJ(s, SYSLOG_SRV_MAGIC); AN(s); REPLACE(s->name, name); @@ -511,16 +511,16 @@ syslog_wait(struct syslog_srv *s) /* SECTION: syslog syslog * - * Define and interact with syslog instances. + * Define and interact with syslog instances (for use with haproxy) * * To define a syslog server, you'll use this syntax:: * - * syslog sNAME + * syslog SNAME * * Arguments: * - * sNAME - * Identify the syslog server with a string which must start with 's'. + * SNAME + * Identify the syslog server with a string which must start with 'S'. * * \-level STRING * Set the default syslog priority level used by any subsequent "recv" From phk at FreeBSD.org Tue May 29 16:02:31 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 29 May 2018 16:02:31 +0000 (UTC) Subject: [master] ca422e8 Include haproxy and syslog in VTC documentation Message-ID: <20180529160231.EC2FDB585F@lists.varnish-cache.org> commit ca422e870a5b3b61ab33e6da668b798c91e3271c Author: Poul-Henning Kamp Date: Tue May 29 16:01:14 2018 +0000 Include haproxy and syslog in VTC documentation diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 04fa9db..f2d0df7 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -184,10 +184,12 @@ BUILT_SOURCES += include/vsl-tags.rst VTCSYN_SRC = $(top_srcdir)/bin/varnishtest/vtc.c \ $(top_srcdir)/bin/varnishtest/vtc_barrier.c \ + $(top_srcdir)/bin/varnishtest/vtc_haproxy.c \ $(top_srcdir)/bin/varnishtest/vtc_http.c \ $(top_srcdir)/bin/varnishtest/vtc_http2.c \ $(top_srcdir)/bin/varnishtest/vtc_logexp.c \ $(top_srcdir)/bin/varnishtest/vtc_process.c \ + $(top_srcdir)/bin/varnishtest/vtc_syslog.c \ $(top_srcdir)/bin/varnishtest/vtc_varnish.c include/vtc-syntax.rst: vtc-syntax.py $(VTCSYN_SRC) $(PYTHON) $(top_srcdir)/doc/sphinx/vtc-syntax.py $(VTCSYN_SRC) > $@ From phk at FreeBSD.org Tue May 29 16:05:09 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 29 May 2018 16:05:09 +0000 (UTC) Subject: [master] f70e31f Match also the ending double-quotes Message-ID: <20180529160509.9341DB5A2A@lists.varnish-cache.org> commit f70e31f59980cdb8dfddeb4b2e946659f6f80cbc Author: Poul-Henning Kamp Date: Tue May 29 16:04:05 2018 +0000 Match also the ending double-quotes diff --git a/bin/varnishtest/tests/h00005.vtc b/bin/varnishtest/tests/h00005.vtc index 3af6aa4..098bf19 100644 --- a/bin/varnishtest/tests/h00005.vtc +++ b/bin/varnishtest/tests/h00005.vtc @@ -12,7 +12,7 @@ syslog S1 -level notice -bind "127.0.0.1:0" { recv recv recv info - expect ~ \"dip\":\"${h1_fe_1_addr} + expect ~ \"dip\":\"${h1_fe_1_addr}\" } -start haproxy h1 -conf { From phk at FreeBSD.org Wed May 30 07:06:23 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 30 May 2018 07:06:23 +0000 (UTC) Subject: [master] cb3cc7b Allow multiple imports of the same VMOD, if the file_id is identical. Message-ID: <20180530070623.F1937977FA@lists.varnish-cache.org> commit cb3cc7b39a45119d62cebc0d9bcc41c32582737b Author: Poul-Henning Kamp Date: Wed May 30 07:05:24 2018 +0000 Allow multiple imports of the same VMOD, if the file_id is identical. diff --git a/bin/varnishtest/tests/m00001.vtc b/bin/varnishtest/tests/m00001.vtc index 7c79f89..6e07812 100644 --- a/bin/varnishtest/tests/m00001.vtc +++ b/bin/varnishtest/tests/m00001.vtc @@ -66,11 +66,6 @@ varnish v1 -cliok "vcl.discard vcl2" varnish v1 -cliok "vcl.list" varnish v1 -cliok "debug.vmod" -varnish v1 -errvcl {Module std already imported.} { - import std; - import std; -} - varnish v1 -errvcl {Symbol type (vmod) can not be used in expression.} { import std; diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index 1699ff7..f34b0f3 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -163,6 +163,7 @@ vcc_ParseImport(struct vcc *tl) struct symbol *msym; const struct vmod_data *vmd; struct vjsn *vj; + int again = 0; t1 = tl->t; SkipToken(tl, ID); /* "import" */ @@ -182,19 +183,15 @@ vcc_ParseImport(struct vcc *tl) return; } if (msym != NULL) { - VSB_printf(tl->sb, "Module %.*s already imported.\n", - PF(mod)); - vcc_ErrWhere2(tl, t1, tl->t); - VSB_printf(tl->sb, "Previous import was here:\n"); - vcc_ErrWhere2(tl, msym->def_b, msym->def_e); - return; - } + again = 1; + } else { - msym = VCC_SymbolGet(tl, SYM_VMOD, SYMTAB_CREATE, XREF_NONE); - ERRCHK(tl); - AN(msym); - msym->def_b = t1; - msym->def_e = tl->t; + msym = VCC_SymbolGet(tl, SYM_VMOD, SYMTAB_CREATE, XREF_NONE); + ERRCHK(tl); + AN(msym); + msym->def_b = t1; + msym->def_e = tl->t; + } if (tl->t->tok == ID) { if (!vcc_IdIs(tl->t, "from")) { @@ -223,6 +220,10 @@ vcc_ParseImport(struct vcc *tl) SkipToken(tl, ';'); + if (!again) + msym->def_e = tl->t; + + if (VFIL_searchpath(tl->vmod_path, vcc_path_dlopen, &hdl, fn, &fnpx)) { VSB_printf(tl->sb, "Could not load VMOD %.*s\n", PF(mod)); @@ -287,6 +288,19 @@ vcc_ParseImport(struct vcc *tl) return; } + if (again && strcmp(vmd->file_id, msym->extra)) { + VSB_printf(tl->sb, + "Different version of module %.*s already imported.\n", + PF(mod)); + vcc_ErrWhere2(tl, t1, tl->t); + VSB_printf(tl->sb, "Previous import was here:\n"); + vcc_ErrWhere2(tl, msym->def_b, msym->def_e); + } + if (again) { + AZ(dlclose(hdl)); + return; + } + ifp = New_IniFin(tl); VSB_printf(ifp->ini, "\tif (VRT_Vmod_Init(ctx,\n"); @@ -317,6 +331,7 @@ vcc_ParseImport(struct vcc *tl) AN(vj); msym->eval_priv = vj; msym->wildcard = vcc_json_wildcard; + msym->extra = TlDup(tl, vmd->file_id); vcc_json_always(tl, msym); From phk at FreeBSD.org Wed May 30 07:30:15 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 30 May 2018 07:30:15 +0000 (UTC) Subject: [master] 3e03ce2 Remove unused includes Message-ID: <20180530073015.0C5A197F0B@lists.varnish-cache.org> commit 3e03ce2d81e8b68337232320cf91f0e77d7867bc Author: Poul-Henning Kamp Date: Wed May 30 07:14:39 2018 +0000 Remove unused includes diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 8bdb065..ca89438 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -48,7 +48,6 @@ #include "vdef.h" -#include "miniobj.h" #include "vcurses.h" #include "vapi/vsl.h" #include "vapi/vsm.h" diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index a4a2e0f..4be62ae 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -46,8 +46,6 @@ #include "vtim.h" #include "vcl.h" -#include "cache/cache_director.h" - #include "vcc_if.h" VCL_VOID v_matchproto_(td_std_set_ip_tos) From daghf at varnish-software.com Wed May 30 09:29:20 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Wed, 30 May 2018 09:29:20 +0000 (UTC) Subject: [master] a9454ef h2: Move the frame completion check up Message-ID: <20180530092920.2A967A04F2@lists.varnish-cache.org> commit a9454ef9bf879a3d6f8e63dc44ac5659dcca5d6d Author: Dag Haavi Finstad Date: Mon May 28 11:14:59 2018 +0200 h2: Move the frame completion check up Avoid failing sessions with pipelined data. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 1da101a..1bba9b3 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -830,11 +830,12 @@ h2_frame_complete(struct http_conn *htc) if (l < 9) return (HTC_S_MORE); u = vbe32dec(htc->rxbuf_b) >> 8; - if (l > h2->local_settings.max_frame_size + 9) + if (l >= u + 9) + return (HTC_S_COMPLETE); + else if (l > h2->local_settings.max_frame_size + 9) return (HTC_S_OVERFLOW); - if (l < u + 9) // XXX: Only for !DATA frames - return (HTC_S_MORE); - return (HTC_S_COMPLETE); + + return (HTC_S_MORE); } /**********************************************************************/ From daghf at varnish-software.com Wed May 30 09:29:20 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Wed, 30 May 2018 09:29:20 +0000 (UTC) Subject: [master] 4b73c5f h2: Fix a possible thread leak scenario Message-ID: <20180530092920.40BB0A04F5@lists.varnish-cache.org> commit 4b73c5f75214e4cd41e1a7a039c9219f6ab1168a Author: Dag Haavi Finstad Date: Tue May 29 14:44:16 2018 +0200 h2: Fix a possible thread leak scenario If we have one or more streams set up because of a PRIORITY frame _and_ for some reason a tcp FIN is lost (or a client merely keeps a connection open), this transaction would be stalled indefinitely. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 1bba9b3..2361c5e 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -964,6 +964,7 @@ static int h2_sweep(struct worker *wrk, struct h2_sess *h2) { int tmo = 0; + int nprio = 0; struct h2_req *r2, *r22; ASSERT_RXTHR(h2); @@ -994,13 +995,21 @@ h2_sweep(struct worker *wrk, struct h2_sess *h2) continue; } break; + case H2_S_IDLE: + /* This stream was created from receiving a + * PRIORITY frame, and should not be counted + * as an active stream keeping the connection + * open. */ + AZ(r2->scheduled); + nprio++; + break; default: break; } } if (tmo) return (0); - return (h2->refcnt > 1); + return ((h2->refcnt - nprio) > 1); } From daghf at varnish-software.com Wed May 30 09:29:20 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Wed, 30 May 2018 09:29:20 +0000 (UTC) Subject: [master] 36dcb10 Pass an h2_req arg to h2_tx_rst Message-ID: <20180530092920.640F9A04F9@lists.varnish-cache.org> commit 36dcb1062730be4b43b8e5d0bdafb7fd8bf56eac Author: Dag Haavi Finstad Date: Wed May 30 11:13:56 2018 +0200 Pass an h2_req arg to h2_tx_rst diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 2361c5e..dc1212a 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -130,6 +130,31 @@ h2_connectionerror(uint32_t u) return (H2NN_ERROR); } +/**********************************************************************/ + +static h2_error +h2_tx_rst(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2, + uint32_t stream, h2_error h2e) +{ + h2_error ret; + char b[4]; + + CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); + CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); + + Lck_Lock(&h2->sess->mtx); + VSLb(h2->vsl, SLT_Debug, "H2: stream %u: %s", stream, h2e->txt); + Lck_Unlock(&h2->sess->mtx); + vbe32enc(b, h2e->val); + + H2_Send_Get(wrk, h2, r2); + ret = H2_Send_Frame(wrk, h2, H2_F_RST_STREAM, + 0, sizeof b, stream, b); + H2_Send_Rel(h2, r2); + + return (ret); +} + /********************************************************************** */ @@ -841,30 +866,6 @@ h2_frame_complete(struct http_conn *htc) /**********************************************************************/ static h2_error -h2_tx_rst(struct worker *wrk, struct h2_sess *h2, - uint32_t stream, h2_error h2e) -{ - h2_error ret; - char b[4]; - - CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); - - Lck_Lock(&h2->sess->mtx); - VSLb(h2->vsl, SLT_Debug, "H2: stream %u: %s", stream, h2e->txt); - Lck_Unlock(&h2->sess->mtx); - vbe32enc(b, h2e->val); - - H2_Send_Get(wrk, h2, h2->req0); - ret = H2_Send_Frame(wrk, h2, H2_F_RST_STREAM, - 0, sizeof b, stream, b); - H2_Send_Rel(h2, h2->req0); - - return (ret); -} - -/**********************************************************************/ - -static h2_error h2_procframe(struct worker *wrk, struct h2_sess *h2, h2_frame h2f) { @@ -904,7 +905,7 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, "H2: stream %u: Hit maximum number of " "concurrent streams", h2->rxf_stream); // rfc7540,l,1200,1205 - return (h2_tx_rst(wrk, h2, h2->rxf_stream, + return (h2_tx_rst(wrk, h2, h2->req0, h2->rxf_stream, H2SE_REFUSED_STREAM)); } h2->highest_stream = h2->rxf_stream; @@ -922,7 +923,7 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, if (h2->rxf_stream == 0 || h2e->connection) return (h2e); // Connection errors one level up - return (h2_tx_rst(wrk, h2, h2->rxf_stream, h2e)); + return (h2_tx_rst(wrk, h2, h2->req0, h2->rxf_stream, h2e)); } static int @@ -982,7 +983,7 @@ h2_sweep(struct worker *wrk, struct h2_sess *h2) break; case H2_S_CLOS_REM: if (!r2->scheduled) { - h2_tx_rst(wrk, h2, r2->stream, + h2_tx_rst(wrk, h2, h2->req0, r2->stream, H2SE_REFUSED_STREAM); h2_del_req(wrk, r2); continue; From daghf at varnish-software.com Wed May 30 09:29:20 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Wed, 30 May 2018 09:29:20 +0000 (UTC) Subject: [master] a56469c Fix an h2 reqbody resource leak Message-ID: <20180530092920.816AEA0501@lists.varnish-cache.org> commit a56469c3f3916b85d6672af6a10a382091e8110e Author: Dag Haavi Finstad Date: Wed May 30 11:17:51 2018 +0200 Fix an h2 reqbody resource leak Properly shut down streams where we could not process a req body (e.g. via a failing cache_req_body). The rxthread may be waiting on this stream to consume a DATA frame - let it know before we go away to avoid it being stuck forever. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index dc1212a..64d55a6 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -812,9 +812,34 @@ h2_vfp_body(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp) return (retval); } +static void +h2_vfp_body_fini(struct vfp_ctx *vc, struct vfp_entry *vfe) +{ + struct h2_req *r2; + struct h2_sess *h2; + + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); + CAST_OBJ_NOTNULL(r2, vfe->priv1, H2_REQ_MAGIC); + CHECK_OBJ_NOTNULL(r2->req, REQ_MAGIC); + h2 = r2->h2sess; + + if (vc->failed) { + CHECK_OBJ_NOTNULL(r2->req->wrk, WORKER_MAGIC); + h2_tx_rst(r2->req->wrk, h2, r2, r2->stream, + H2SE_REFUSED_STREAM); + Lck_Lock(&h2->sess->mtx); + r2->error = H2SE_REFUSED_STREAM; + if (h2->mailcall == r2) + AZ(pthread_cond_signal(h2->cond)); + Lck_Unlock(&h2->sess->mtx); + } +} + static const struct vfp h2_body = { .name = "H2_BODY", .pull = h2_vfp_body, + .fini = h2_vfp_body_fini }; void v_matchproto_(vtr_req_body_t) From nils.goroll at uplex.de Wed May 30 19:48:07 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 30 May 2018 19:48:07 +0000 (UTC) Subject: [master] f93860a make VRT_handling a no-op if no ctx->handling pointer Message-ID: <20180530194807.6A44BB07E7@lists.varnish-cache.org> commit f93860ab17ae239391f7d8e7a5f07c27249d0ab7 Author: Nils Goroll Date: Wed May 30 12:57:44 2018 +0200 make VRT_handling a no-op if no ctx->handling pointer This is the case for the ctx created for director operations as first introduced with 5536f102b677e6b469f191fedab1c4cf51144e2c Alternatively, we could always set ctx->handling to some location with the same scope as the ctx, but as we are not inside VCL (and just happen to use the same context for simplicity and reusability of VRT/vmod functions), adding specific handling appears to be the cleaner solution. Fixes #2692 diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 015c412..adeb349 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -376,6 +376,8 @@ VRT_handling(VRT_CTX, unsigned hand) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (ctx->handling == NULL) + return; assert(hand > 0); assert(hand < VCL_RET_MAX); // XXX:NOTYET assert(*ctx->handling == 0); diff --git a/include/vrt.h b/include/vrt.h index 9af2346..8e8f169 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -179,7 +179,7 @@ struct vrt_ctx { unsigned syntax; unsigned method; - unsigned *handling; + unsigned *handling; // not in director context unsigned vclver; struct vsb *msg; // Only in ...init() From daghf at varnish-software.com Thu May 31 12:27:16 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Thu, 31 May 2018 12:27:16 +0000 (UTC) Subject: [master] 98c316d h2: Make sure an OU request ends up in half-closed state, not idle Message-ID: <20180531122716.E8825948F9@lists.varnish-cache.org> commit 98c316d5e9b668d5738d8b7c1e4c50d82ad3fac4 Author: Dag Haavi Finstad Date: Thu May 31 14:21:55 2018 +0200 h2: Make sure an OU request ends up in half-closed state, not idle Ref: #2693 diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index b2ab70f..b350f05 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -286,6 +286,7 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2, req->task.func = h2_do_req; req->task.priv = req; r2->scheduled = 1; + r2->state = H2_S_CLOS_REM; // rfc7540,l,489,491 req->err_code = 0; http_SetH(req->http, HTTP_HDR_PROTO, "HTTP/2.0");