From nils.goroll at uplex.de Mon Oct 3 14:27:06 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Oct 2022 14:27:06 +0000 (UTC) Subject: [master] 53a886cba Include cleanup Message-ID: <20221003142706.79C4611AC24@lists.varnish-cache.org> commit 53a886cba68b590b83cd08a0796a95ce20a46709 Author: Nils Goroll Date: Mon Oct 3 16:24:32 2022 +0200 Include cleanup noticed by: Flexelint we stopped using struct wrk_vpi in e675d1c6b3e73713d5e2c1f6062805bc092bb4c0 diff --git a/vmod/vmod_debug.c b/vmod/vmod_debug.c index 50a2b8eeb..0678cc3ec 100644 --- a/vmod/vmod_debug.c +++ b/vmod/vmod_debug.c @@ -38,8 +38,6 @@ #include "cache/cache_varnishd.h" #include "cache/cache_filter.h" -#include "vcc_interface.h" // struct wrk_vpi - #include "vsa.h" #include "vtim.h" From nils.goroll at uplex.de Mon Oct 3 14:28:06 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Oct 2022 14:28:06 +0000 (UTC) Subject: [master] 58ea56b5b Define Z_PREFIX to prevent collisions with zlib Message-ID: <20221003142806.710B511ADF8@lists.varnish-cache.org> commit 58ea56b5bd22d22754a9c076ddafc16264d83494 Author: Nils Goroll Date: Tue Sep 6 21:37:47 2022 +0200 Define Z_PREFIX to prevent collisions with zlib Trying to use zlib from a vmod would lead to conflicts because the varnish-defined zlib symbols were found first. diff --git a/configure.ac b/configure.ac index e8aa9c757..4de4012ba 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,8 @@ AC_SUBST([PACKAGE_BRANCH]) AC_DEFINE_UNQUOTED([PACKAGE_BRANCH], ["$PACKAGE_BRANCH"], [Define the branch of this package.]) +CFLAGS="$CFLAGS -DZ_PREFIX" + # save command line CFLAGS for use in VCC_CC (to pass through things like -m64) # and make distcheck configure OCFLAGS="$CFLAGS" From nils.goroll at uplex.de Mon Oct 3 14:30:07 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Oct 2022 14:30:07 +0000 (UTC) Subject: [master] 38881a6f3 Polish VRY_Validate() Message-ID: <20221003143007.9BDA111B04C@lists.varnish-cache.org> commit 38881a6f38286044a488a3d4d7c93f28b094825f Author: Nils Goroll Date: Thu Sep 1 13:49:22 2022 +0200 Polish VRY_Validate() Call VRY_Len() only once where the compiler does not eliminate the second call anyway. diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index 88567674d..73bb5e15c 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -382,12 +382,13 @@ VRY_Match(struct req *req, const uint8_t *vary) static unsigned VRY_Validate(const uint8_t *vary) { - unsigned retval = 0; + unsigned l, retval = 0; while (vary[2] != 0) { - assert(strlen((const char*)vary+3) == vary[2]); - retval += VRY_Len(vary); - vary += VRY_Len(vary); + assert(strlen((const char*)vary + 3) == vary[2]); + l = VRY_Len(vary); + retval += l; + vary += l; } return (retval + 3); } From nils.goroll at uplex.de Mon Oct 3 14:30:07 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Oct 2022 14:30:07 +0000 (UTC) Subject: [master] c5e06d6c1 Polish VRY_Match() Message-ID: <20221003143007.B039A11B04F@lists.varnish-cache.org> commit c5e06d6c1dd18b7a37d57b375926c5c1bb602a9c Author: Nils Goroll Date: Thu Sep 1 13:55:12 2022 +0200 Polish VRY_Match() Validate VRY_Validate() diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index 73bb5e15c..2e461ab0e 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -343,11 +343,11 @@ VRY_Match(struct req *req, const uint8_t *vary) memcpy(vsp + 2, vary + 2, vary[2] + 2); if (h != NULL) memcpy(vsp + 2 + vsp[2] + 2, h, lh); - vsp[ln] = 0xff; - vsp[ln + 1] = 0xff; - vsp[ln + 2] = 0; - (void)VRY_Validate(vsp); - req->vary_l = vsp + ln + 3; + vsp[ln++] = 0xff; + vsp[ln++] = 0xff; + vsp[ln++] = 0; + assert(VRY_Validate(vsp) == ln); + req->vary_l = vsp + ln; i = vry_cmp(vary, vsp); assert(i == 0 || i == 2); From nils.goroll at uplex.de Mon Oct 3 14:30:07 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Oct 2022 14:30:07 +0000 (UTC) Subject: [master] dea05fa4a Polish VRY_Finish() Message-ID: <20221003143007.CED3E11B053@lists.varnish-cache.org> commit dea05fa4a855140cd807f75dccfa196b4099fa1a Author: Nils Goroll Date: Thu Sep 1 14:02:17 2022 +0200 Polish VRY_Finish() Assert on the return value of VRY_Validate() and call it only once. (I would like to think that we can trust memcpy()) diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index 2e461ab0e..1edc80436 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -259,6 +259,7 @@ void VRY_Finish(struct req *req, enum vry_finish_flag flg) { uint8_t *p = NULL; + size_t l; if (req->vary_b + 2 >= req->vary_e) { AZ(req->vary_l); @@ -269,13 +270,12 @@ VRY_Finish(struct req *req, enum vry_finish_flag flg) return; } - (void)VRY_Validate(req->vary_b); + l = VRY_Validate(req->vary_b); if (flg == KEEP && req->vary_l != NULL) { - p = malloc(req->vary_l - req->vary_b); - if (p != NULL) { - memcpy(p, req->vary_b, req->vary_l - req->vary_b); - (void)VRY_Validate(p); - } + assert(l == req->vary_l - req->vary_b); + p = malloc(l); + if (p != NULL) + memcpy(p, req->vary_b, l); } WS_Release(req->ws, 0); req->vary_l = NULL; From nils.goroll at uplex.de Mon Oct 3 14:32:06 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Oct 2022 14:32:06 +0000 (UTC) Subject: [master] 6495bc17b Add a utility macro to allocate mini-objects on the workspace Message-ID: <20221003143206.7028911B5E4@lists.varnish-cache.org> commit 6495bc17b0da035759c77b3073f8a874694168de Author: Nils Goroll Date: Thu Jun 2 16:32:57 2022 +0200 Add a utility macro to allocate mini-objects on the workspace isn't this something we would have wanted all along? This simplifies the common pattern to allocate/initialize a miniobj on the workspace to WS_TASK_ALLOC_OBJ(ctx, myobj, MYOBJ_MAGIC); if (myobj == NULL) return (error); diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 7b4d8f9a7..5c690df8f 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -850,6 +850,15 @@ const char *WS_Printf(struct ws *ws, const char *fmt, ...) v_printflike_(2, 3); void WS_VSB_new(struct vsb *, struct ws *); char *WS_VSB_finish(struct vsb *, struct ws *, size_t *); +/* WS utility */ +#define WS_TASK_ALLOC_OBJ(ctx, ptr, magic) do { \ + ptr = WS_Alloc((ctx)->ws, sizeof *(ptr)); \ + if ((ptr) == NULL) \ + VRT_fail(ctx, "Out of workspace for " #magic); \ + else \ + INIT_OBJ(ptr, magic); \ +} while(0) + /* cache_rfc2616.c */ void RFC2616_Ttl(struct busyobj *, vtim_real now, vtim_real *t_origin, float *ttl, float *grace, float *keep); From nils.goroll at uplex.de Mon Oct 3 14:32:06 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Oct 2022 14:32:06 +0000 (UTC) Subject: [master] 9820b1424 Use WS_TASK_ALLOC_OBJ Message-ID: <20221003143206.A9BF711B5E9@lists.varnish-cache.org> commit 9820b1424dc668e62b82ff8dcff25f2879129fd6 Author: Nils Goroll Date: Tue Jun 7 14:33:02 2022 +0200 Use WS_TASK_ALLOC_OBJ diff --git a/vmod/vmod_cookie.c b/vmod/vmod_cookie.c index 7113e6a18..9c8bf2ac1 100644 --- a/vmod/vmod_cookie.c +++ b/vmod/vmod_cookie.c @@ -187,13 +187,10 @@ vmod_set(VRT_CTX, struct vmod_priv *priv, VCL_STRING name, VCL_STRING value) return; } - cookie = WS_Alloc(ctx->ws, sizeof *cookie); - if (cookie == NULL) { - VSLb(ctx->vsl, SLT_Error, - "cookie: unable to get storage for cookie"); + WS_TASK_ALLOC_OBJ(ctx, cookie, VMOD_COOKIE_ENTRY_MAGIC); + if (cookie == NULL) return; - } - INIT_OBJ(cookie, VMOD_COOKIE_ENTRY_MAGIC); + cookie->name = WS_Printf(ctx->ws, "%s", name); cookie->value = WS_Printf(ctx->ws, "%s", value); if (cookie->name == NULL || cookie->value == NULL) { diff --git a/vmod/vmod_debug.c b/vmod/vmod_debug.c index 0678cc3ec..414b58667 100644 --- a/vmod/vmod_debug.c +++ b/vmod/vmod_debug.c @@ -943,12 +943,9 @@ xyzzy_catflap(VRT_CTX, VCL_ENUM type) req = ctx->req; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); XXXAZ(req->vcf); - req->vcf = WS_Alloc(req->ws, sizeof *req->vcf); - if (req->vcf == NULL) { - VRT_fail(ctx, "WS_Alloc failed in debug.catflap()"); + WS_TASK_ALLOC_OBJ(ctx, req->vcf, VCF_MAGIC); + if (req->vcf == NULL) return; - } - INIT_OBJ(req->vcf, VCF_MAGIC); if (type == VENUM(first) || type == VENUM(miss)) { req->vcf->func = xyzzy_catflap_simple; req->vcf->priv = TRUST_ME(type); diff --git a/vmod/vmod_directors_shard.c b/vmod/vmod_directors_shard.c index 744e3552b..bdd3e0134 100644 --- a/vmod/vmod_directors_shard.c +++ b/vmod/vmod_directors_shard.c @@ -924,13 +924,10 @@ shard_param_task_l(VRT_CTX, const void *id, const char *who, return (p); } - p = WS_Alloc(ctx->ws, sizeof *p); - if (p == NULL) { - shard_fail(ctx, who, "%s", "WS_Alloc failed"); + WS_TASK_ALLOC_OBJ(ctx, p, VMOD_SHARD_SHARD_PARAM_MAGIC); + if (p == NULL) return (NULL); - } task->priv = p; - INIT_OBJ(p, VMOD_SHARD_SHARD_PARAM_MAGIC); p->vcl_name = who; p->scope = SCOPE_TASK; diff --git a/vmod/vmod_directors_shard_cfg.c b/vmod/vmod_directors_shard_cfg.c index 6df86b643..35ecfa9c1 100644 --- a/vmod/vmod_directors_shard_cfg.c +++ b/vmod/vmod_directors_shard_cfg.c @@ -127,13 +127,9 @@ shard_change_get(VRT_CTX, struct sharddir * const shardd) return (change); } - change = WS_Alloc(ctx->ws, sizeof(*change)); - if (change == NULL) { - shard_fail(ctx, shardd->name, "%s", "could not get workspace"); + WS_TASK_ALLOC_OBJ(ctx, change, SHARD_CHANGE_MAGIC); + if (change == NULL) return (NULL); - } - - INIT_OBJ(change, SHARD_CHANGE_MAGIC); change->vsl = ctx->vsl; change->shardd = shardd; VSTAILQ_INIT(&change->tasks); @@ -159,13 +155,9 @@ shard_change_task_add(VRT_CTX, struct shard_change *change, CHECK_OBJ_NOTNULL(change, SHARD_CHANGE_MAGIC); - task = WS_Alloc(ctx->ws, sizeof(*task)); - if (task == NULL) { - shard_fail(ctx, change->shardd->name, "%s", - "could not get workspace for task"); + WS_TASK_ALLOC_OBJ(ctx, task, SHARD_CHANGE_TASK_MAGIC); + if (task == NULL) return (NULL); - } - INIT_OBJ(task, SHARD_CHANGE_TASK_MAGIC); task->task = task_e; task->priv = priv; VSTAILQ_INSERT_TAIL(&change->tasks, task, list); From nils.goroll at uplex.de Mon Oct 3 14:33:03 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Oct 2022 14:33:03 +0000 (UTC) Subject: [master] 7028d5298 Cleanup and sum up after bgthread termination Message-ID: <20221003143303.6A16C11B8D8@lists.varnish-cache.org> commit 7028d529887b36c04703b86bd0e59c36cfc824ed Author: Nils Goroll Date: Fri Sep 23 10:40:07 2022 +0200 Cleanup and sum up after bgthread termination Strictly speaking, these calls were already missing before 3a22f5f0ded31f8c7340ac00a382ae9106c20a8c, but now that bgthreads are officially allowed to terminate, we should really finalize & cleanup the wpriv and stats structs to provide a consistent interface. diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 0b8bd087e..b008f95ae 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -89,6 +89,7 @@ wrk_bgthread(void *arg) struct worker wrk; struct worker_priv wpriv[1]; struct VSC_main_wrk ds; + void *r; CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC); THR_SetName(bt->name); @@ -100,7 +101,10 @@ wrk_bgthread(void *arg) memset(&ds, 0, sizeof ds); wrk.stats = &ds; - return (bt->func(&wrk, bt->priv)); + r = bt->func(&wrk, bt->priv); + HSH_Cleanup(&wrk); + Pool_Sumstat(&wrk); + return (r); } void From nils.goroll at uplex.de Mon Oct 3 14:46:05 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Oct 2022 14:46:05 +0000 (UTC) Subject: [master] 6bf7f3d43 Avoid double panic when a client thread does not own the bo any longer Message-ID: <20221003144605.EEABD11C028@lists.varnish-cache.org> commit 6bf7f3d430df30d4ad61d6f7678fa9d75e92657b Author: Nils Goroll Date: Mon Oct 3 16:39:51 2022 +0200 Avoid double panic when a client thread does not own the bo any longer The panic code would panic again because a backend object which it no longer owned was still referenced in thread local storage (don't we all love abiguous acronyms?). Example: #5 0x0000563d8c20d595 in VAS_Fail (func=0x563d8c23fd13 "vsl_sanity", file=0x563d8c23f9f5 "cache/cache_shmlog.c", line=110, cond=0x563d8c23fd1e "(vsl->wlp) != 0", kind=VAS_ASSERT) at vas.c:67 #6 0x0000563d8c1603e9 in vsl_sanity (vsl=0x7fabd08001f0) at cache/cache_shmlog.c:110 ... #7 0x0000563d8c160298 in VSL_Flush (vsl=0x7fabd08001f0, overflow=0) at cache/cache_shmlog.c:314 #8 0x0000563d8c14dd44 in pan_ic (func=0x563d8c23c596 "child_signal_handler", file=0x563d8c23c1b4 "cache/cache_main.c", line=323, cond=0x7fabdf24a590 "Signal 6 (Aborted) received at 0x3e800015528 si_code -6", kind=VAS_WRONG) at cache/cache_panic.c:814 ... #19 0x0000563d8c14bc07 in ObjBocDone (wrk=0x7fabdc9e54b8, oc=0x7fabd0024180, boc=0x7fabdc9e4778) at cache/cache_obj.c:368 #20 0x0000563d8c13f25b in HSH_DerefBoc (wrk=0x7fabdc9e54b8, oc=0x7fabd0024180) at cache/cache_hash.c:1014 #21 0x0000563d8c13158f in VBF_Fetch (wrk=0x7fabdc9e54b8, req=0x7fabd0008b20, oc=0x7fabd0024180, oldoc=0x0, mode=VBF_PASS) at cache/cache_fetch.c:1204 #22 0x0000563d8c158f7d in cnt_pass (wrk=0x7fabdc9e54b8, req=0x7fabd0008b20) at cache/cache_req_fsm.c:742 #23 0x0000563d8c156f53 in CNT_Request (req=0x7fabd0008b20) at cache/cache_req_fsm.c:1182 #24 0x0000563d8c198f9a in HTTP1_Session (wrk=0x7fabdc9e54b8, req=0x7fabd0008b20) at http1/cache_http1_fsm.c:390 #25 0x0000563d8c1984e0 in http1_req (wrk=0x7fabdc9e54b8, arg=0x7fabd0008b20) at http1/cache_http1_fsm.c:88 #26 0x0000563d8c189592 in Pool_Work_Thread (pp=0x7fabdc400140, wrk=0x7fabdc9e54b8) at cache/cache_wrk.c:487 #27 0x0000563d8c188ca7 in WRK_Thread (qp=0x7fabdc400140, stacksize=81920, thread_workspace=2048) at cache/cache_wrk.c:153 diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index ffbc893fc..154563f75 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -1183,8 +1183,10 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, (void)HSH_DerefObjCore(wrk, &bo->stale_oc, 0); HSH_DerefBoc(wrk, oc); SES_Rel(bo->sp); + THR_SetBusyobj(NULL); VBO_ReleaseBusyObj(wrk, &bo); } else { + THR_SetBusyobj(NULL); bo = NULL; /* ref transferred to fetch thread */ if (mode == VBF_BACKGROUND) { ObjWaitState(oc, BOS_REQ_DONE); @@ -1204,5 +1206,4 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, HSH_DerefBoc(wrk, oc); if (mode == VBF_BACKGROUND) (void)HSH_DerefObjCore(wrk, &oc, HSH_RUSH_POLICY); - THR_SetBusyobj(NULL); } From dridi.boukelmoune at gmail.com Wed Oct 5 12:13:07 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 5 Oct 2022 12:13:07 +0000 (UTC) Subject: [master] 80cc45dd7 Add coverage for Keep-Alive header removal Message-ID: <20221005121307.3B8F911F3E3@lists.varnish-cache.org> commit 80cc45dd7a44e20e0b450d7e93eb960fa66cf09f Author: AlveElde Date: Wed Sep 28 14:53:20 2022 +0200 Add coverage for Keep-Alive header removal Signed-off-by: Dridi Boukelmoune diff --git a/bin/varnishtest/tests/b00080.vtc b/bin/varnishtest/tests/b00080.vtc new file mode 100644 index 000000000..d1227f1be --- /dev/null +++ b/bin/varnishtest/tests/b00080.vtc @@ -0,0 +1,77 @@ +varnishtest "Keep-Alive is a hop-by-hop header" + +server s1 { + rxreq + expect req.http.req-keep-alive == "true" + expect req.http.bereq-keep-alive == "false" + expect req.http.Keep-Alive == + txresp -hdr "Keep-Alive: 1" + + rxreq + expect req.http.req-keep-alive == "true" + expect req.http.bereq-keep-alive == "false" + expect req.http.Keep-Alive == + txresp -hdr "Connection: Keep-Alive" -hdr "Keep-Alive: 2" + + rxreq + expect req.http.req-keep-alive == "true" + expect req.http.bereq-keep-alive == "false" + expect req.http.Keep-Alive == + expect req.http.Cookie == "3" + txresp -hdr "Keep-Alive: 3" + + rxreq + expect req.http.req-keep-alive == "true" + expect req.http.bereq-keep-alive == "false" + expect req.http.Keep-Alive == + expect req.http.Cookie == "4" + txresp -hdr "Connection: Keep-Alive" -hdr "Keep-Alive: 4" +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + set req.http.req-keep-alive = !(!req.http.Keep-Alive); + } + + sub vcl_backend_fetch { + set bereq.http.bereq-keep-alive = !(!bereq.http.Keep-Alive); + } + + sub vcl_backend_response { + set beresp.http.beresp-keep-alive = !(!beresp.http.Keep-Alive); + } + + sub vcl_deliver { + set resp.http.resp-keep-alive = !(!resp.http.Keep-Alive); + } +} -start + +client c1 { + txreq -url "/1" -hdr "Keep-Alive: 1" + rxresp + expect resp.status == 200 + expect resp.http.beresp-keep-alive == "true" + expect resp.http.resp-keep-alive == "false" + expect resp.http.Keep-Alive == + + txreq -url "/2" -hdr "Connection: Keep-Alive" -hdr "Keep-Alive: 2" + rxresp + expect resp.status == 200 + expect resp.http.beresp-keep-alive == "true" + expect resp.http.resp-keep-alive == "false" + expect req.http.Keep-Alive == + + txreq -url "/3" -hdr "Keep-Alive: 3" -hdr "Cookie: 3" + rxresp + expect resp.status == 200 + expect resp.http.beresp-keep-alive == "true" + expect resp.http.resp-keep-alive == "false" + expect resp.http.Keep-Alive == + + txreq -url "/4" -hdr "Connection: Keep-Alive" -hdr "Keep-Alive: 4" -hdr "Cookie: 4" + rxresp + expect resp.status == 200 + expect resp.http.beresp-keep-alive == "true" + expect resp.http.resp-keep-alive == "false" + expect req.http.Keep-Alive == +} -run From phk at FreeBSD.org Mon Oct 10 09:40:07 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Oct 2022 09:40:07 +0000 (UTC) Subject: [master] 92a477ac3 Put fd# in VSL text, rather than VXID field. Message-ID: <20221010094007.833C41094D4@lists.varnish-cache.org> commit 92a477ac3374795c003045dce4e5ea0ec5b6c91f Author: Poul-Henning Kamp Date: Mon Oct 10 08:43:22 2022 +0000 Put fd# in VSL text, rather than VXID field. diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 3ff15321e..c3a7f9b78 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -98,7 +98,7 @@ vwp_add(struct vwp *vwp, struct waited *wp) { CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); - VSL(SLT_Debug, wp->fd, "ADD"); + VSL(SLT_Debug, NO_VXID, "vwp: ADD %d", wp->fd); CHECK_OBJ_NOTNULL(vwp, VWP_MAGIC); if (vwp->hpoll == vwp->npoll) vwp_extend_pollspace(vwp); From phk at FreeBSD.org Mon Oct 10 09:40:07 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Oct 2022 09:40:07 +0000 (UTC) Subject: [master] 67dd8c79a Do not use magic values in VSL.VXID field Message-ID: <20221010094007.A22791094D7@lists.varnish-cache.org> commit 67dd8c79a6b899fa2219cfe129694074181a259f Author: Poul-Henning Kamp Date: Mon Oct 10 08:44:40 2022 +0000 Do not use magic values in VSL.VXID field diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index db008a230..036a314e7 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -765,7 +765,7 @@ VPX_Send_Proxy(int fd, int version, const struct sess *sp) VSB_quote(vsb2, VSB_data(vsb), VSB_len(vsb), version == 2 ? VSB_QUOTE_HEX : 0); AZ(VSB_finish(vsb2)); - VSL(SLT_Debug, 999, "PROXY_HDR %s", VSB_data(vsb2)); + VSL(SLT_Debug, 0, "PROXY_HDR %s", VSB_data(vsb2)); VSB_destroy(&vsb2); VSB_fini(vsb); return (r); From phk at FreeBSD.org Mon Oct 10 09:40:07 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Oct 2022 09:40:07 +0000 (UTC) Subject: [master] c1caa6650 Add NO_VXID macro replace all trivial 0s Message-ID: <20221010094007.D09EA1094DD@lists.varnish-cache.org> commit c1caa665098a8ef6b97d5184c6bee9cbba689266 Author: Poul-Henning Kamp Date: Mon Oct 10 08:49:54 2022 +0000 Add NO_VXID macro replace all trivial 0s diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 5c690df8f..450772696 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -690,6 +690,7 @@ extern const char H__Reason[]; #define http_range_at(str, tok, l) http_tok_at(str, #tok, l) /* cache_main.c */ +#define NO_VXID (0U) #define VXID(u) ((u) & VSL_IDENTMASK) uint32_t VXID_Get(const struct worker *, uint32_t marker); extern pthread_key_t witness_key; diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 97e652702..594dc7627 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -179,7 +179,8 @@ VBP_Update_Backend(struct vbp_target *vt) vt->backend->sick = i; AN(vt->backend->vcl_name); - VSL(SLT_Backend_health, 0, "%s %s %s %s %u %u %u %.6f %.6f \"%s\"", + VSL(SLT_Backend_health, NO_VXID, + "%s %s %s %s %u %u %u %.6f %.6f \"%s\"", vt->backend->vcl_name, chg ? "Went" : "Still", i ? "sick" : "healthy", bits, vt->good, vt->threshold, vt->window, diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c index b261d6bcb..e5006f8de 100644 --- a/bin/varnishd/cache/cache_cli.c +++ b/bin/varnishd/cache/cache_cli.c @@ -75,7 +75,7 @@ cli_cb_before(const struct cli *cli) { ASSERT_CLI(); - VSL(SLT_CLI, 0, "Rd %s", VSB_data(cli->cmd)); + VSL(SLT_CLI, NO_VXID, "Rd %s", VSB_data(cli->cmd)); VCL_Poll(); Lck_Lock(&cli_mtx); } @@ -86,7 +86,7 @@ cli_cb_after(const struct cli *cli) ASSERT_CLI(); Lck_Unlock(&cli_mtx); - VSL(SLT_CLI, 0, "Wr %03u %zd %s", + VSL(SLT_CLI, NO_VXID, "Wr %03u %zd %s", cli->result, VSB_len(cli->sb), VSB_data(cli->sb)); } @@ -109,7 +109,7 @@ CLI_Run(void) do { i = VCLS_Poll(cache_cls, cli, -1); } while (i == 0); - VSL(SLT_CLI, 0, "EOF on CLI connection, worker stops"); + VSL(SLT_CLI, NO_VXID, "EOF on CLI connection, worker stops"); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 5aa84a117..21a40a05f 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -241,7 +241,7 @@ EXP_Rearm(struct objcore *oc, vtim_real now, when = EXP_WHEN(oc); - VSL(SLT_ExpKill, 0, "EXP_Rearm p=%p E=%.6f e=%.6f f=0x%x", oc, + VSL(SLT_ExpKill, NO_VXID, "EXP_Rearm p=%p E=%.6f e=%.6f f=0x%x", oc, oc->timer_when, when, oc->flags); if (when < oc->t_origin || when < oc->timer_when) { diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index 6615897eb..46a1f100c 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -81,7 +81,7 @@ Lck_Witness_Lock(const struct ilck *il, const char *p, int l, const char *try) bprintf(t, "%d", l); strcat(q, t); if (emit) - VSL(SLT_Witness, 0, "%s", q); + VSL(SLT_Witness, NO_VXID, "%s", q); } static void @@ -98,7 +98,7 @@ Lck_Witness_Unlock(const struct ilck *il) else *r++ = '\0'; if (memcmp(r, il->w, strlen(il->w))) - VSL(SLT_Witness, 0, "Unlock %s @ %s <%s>", il->w, r, q); + VSL(SLT_Witness, NO_VXID, "Unlock %s @ %s <%s>", il->w, r, q); else *r = '\0'; } diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index a71e0a770..5740c4eb6 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -207,7 +207,7 @@ pool_poolherder(void *priv) nwq--; Lck_Unlock(&pool_mtx); if (!pp->die) { - VSL(SLT_Debug, 0, "XXX Kill Pool %p", pp); + VSL(SLT_Debug, NO_VXID, "XXX Kill Pool %p", pp); pp->die = 1; VCA_DestroyPool(pp); AZ(pthread_cond_signal(&pp->herder_cond)); diff --git a/bin/varnishd/cache/cache_vpi.c b/bin/varnishd/cache/cache_vpi.c index 3b21037fb..0d8e792bf 100644 --- a/bin/varnishd/cache/cache_vpi.c +++ b/bin/varnishd/cache/cache_vpi.c @@ -75,7 +75,7 @@ VPI_count(VRT_CTX, unsigned u) ctx->vcl->loaded_name, u, ctx->vcl->conf->ref[u].source, ctx->vcl->conf->ref[u].line, ctx->vcl->conf->ref[u].pos); else - VSL(SLT_VCL_trace, 0, "%s %u %u.%u.%u", + VSL(SLT_VCL_trace, NO_VXID, "%s %u %u.%u.%u", ctx->vcl->loaded_name, u, ctx->vcl->conf->ref[u].source, ctx->vcl->conf->ref[u].line, ctx->vcl->conf->ref[u].pos); } diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index f6c427ad1..3b9350f6d 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -125,7 +125,7 @@ VPI_acl_log(VRT_CTX, const char *msg) if (ctx->vsl != NULL) VSLbs(ctx->vsl, SLT_VCL_acl, TOSTRAND(msg)); else - VSL(SLT_VCL_acl, 0, "%s", msg); + VSL(SLT_VCL_acl, NO_VXID, "%s", msg); } int diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index b008f95ae..7c2bd8036 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -152,12 +152,12 @@ WRK_Thread(struct pool *qp, size_t stacksize, unsigned thread_workspace) VPI_wrk_init(w, vpi, sizeof vpi); AN(w->vpi); - VSL(SLT_WorkThread, 0, "%p start", w); + VSL(SLT_WorkThread, NO_VXID, "%p start", w); Pool_Work_Thread(qp, w); AZ(w->pool); - VSL(SLT_WorkThread, 0, "%p end", w); + VSL(SLT_WorkThread, NO_VXID, "%p end", w); if (w->wpriv->vcl != NULL) VCL_Rel(&w->wpriv->vcl); AZ(pthread_cond_destroy(&w->cond)); @@ -313,7 +313,7 @@ Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio) retval = reqpoolfail & 1; reqpoolfail >>= 1; if (retval) { - VSL(SLT_Debug, 0, + VSL(SLT_Debug, NO_VXID, "Failing due to reqpoolfail (next= 0x%jx)", reqpoolfail); return (retval); @@ -549,7 +549,7 @@ pool_breed(struct pool *qp) errno = pthread_create(&tp, &tp_attr, pool_thread, pi); if (errno) { FREE_OBJ(pi); - VSL(SLT_Debug, 0, "Create worker thread failed %d %s", + VSL(SLT_Debug, NO_VXID, "Create worker thread failed %d %s", errno, VAS_errtxt(errno)); Lck_Lock(&pool_mtx); VSC_C_main->threads_failed++; @@ -626,7 +626,7 @@ pool_herder(void *priv) dq = pp->ndequeued; dqt = VTIM_mono(); } else if (VTIM_mono() - dqt > cache_param->wthread_watchdog) { - VSL(SLT_Error, 0, + VSL(SLT_Error, NO_VXID, "Pool Herder: Queue does not move ql=%u dt=%f", pp->lqueue, VTIM_mono() - dqt); WRONG("Worker Pool Queue does not move"); @@ -756,7 +756,7 @@ WRK_Log(enum VSL_tag_e tag, const char *fmt, ...) if (wrk != NULL && wrk->vsl != NULL) VSLbv(wrk->vsl, tag, fmt, ap); else - VSLv(tag, 0, fmt, ap); + VSLv(tag, NO_VXID, fmt, ap); va_end(ap); } diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index 036a314e7..b36ae0f6b 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -765,7 +765,7 @@ VPX_Send_Proxy(int fd, int version, const struct sess *sp) VSB_quote(vsb2, VSB_data(vsb), VSB_len(vsb), version == 2 ? VSB_QUOTE_HEX : 0); AZ(VSB_finish(vsb2)); - VSL(SLT_Debug, 0, "PROXY_HDR %s", VSB_data(vsb2)); + VSL(SLT_Debug, NO_VXID, "PROXY_HDR %s", VSB_data(vsb2)); VSB_destroy(&vsb2); VSB_fini(vsb); return (r); diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index c3a7f9b78..545914814 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -75,7 +75,7 @@ vwp_extend_pollspace(struct vwp *vwp) else inc = (1<<16); - VSL(SLT_Debug, 0, "Acceptor poll space increased by %zu to %zu", + VSL(SLT_Debug, NO_VXID, "Acceptor poll space increased by %zu to %zu", inc, vwp->npoll + inc); vwp->pollfd = realloc(vwp->pollfd, diff --git a/vmod/vmod_debug.c b/vmod/vmod_debug.c index 414b58667..f1e2d35cd 100644 --- a/vmod/vmod_debug.c +++ b/vmod/vmod_debug.c @@ -386,7 +386,7 @@ obj_cb(struct worker *wrk, void *priv, struct objcore *oc, unsigned event) } /* We cannot trust %p to be 0x... format as expected by m00021.vtc */ - VSL(SLT_Debug, 0, "Object Event: %s 0x%jx", what, + VSL(SLT_Debug, NO_VXID, "Object Event: %s 0x%jx", what, (intmax_t)(uintptr_t)oc); } @@ -400,7 +400,7 @@ xyzzy_register_obj_events(VRT_CTX, struct vmod_priv *priv) AZ(priv_vcl->obj_cb); priv_vcl->obj_cb = ObjSubscribeEvents(obj_cb, priv_vcl, OEV_INSERT|OEV_EXPIRE); - VSL(SLT_Debug, 0, "Subscribed to Object Events"); + VSL(SLT_Debug, NO_VXID, "Subscribed to Object Events"); } VCL_VOID v_matchproto_(td_debug_fail) @@ -529,7 +529,7 @@ event_warm(VRT_CTX, const struct vmod_priv *priv) const char *vcl_name = VCL_Name(ctx->vcl); // Using VSLs for coverage - VSLs(SLT_Debug, 0, TOSTRANDS(2, vcl_name, ": VCL_EVENT_WARM")); + VSLs(SLT_Debug, NO_VXID, TOSTRANDS(2, vcl_name, ": VCL_EVENT_WARM")); AN(ctx->msg); if (cache_param->max_esi_depth == 42) { @@ -590,7 +590,7 @@ event_cold(VRT_CTX, const struct vmod_priv *priv) CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC); - VSL(SLT_Debug, 0, "%s: VCL_EVENT_COLD", VCL_Name(ctx->vcl)); + VSL(SLT_Debug, NO_VXID, "%s: VCL_EVENT_COLD", VCL_Name(ctx->vcl)); VRT_DelDirector(&priv_vcl->be); @@ -833,7 +833,7 @@ mylog(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...) if (vsl != NULL) VSLbv(vsl, tag, fmt, ap); else - VSLv(tag, 0, fmt, ap); + VSLv(tag, NO_VXID, fmt, ap); va_end(ap); } diff --git a/vmod/vmod_directors_shard_dir.c b/vmod/vmod_directors_shard_dir.c index 9b82722d1..f587cd19c 100644 --- a/vmod/vmod_directors_shard_dir.c +++ b/vmod/vmod_directors_shard_dir.c @@ -86,7 +86,7 @@ sharddir_log(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...) if (vsl != NULL) VSLbv(vsl, tag, fmt, ap); else - VSLv(tag, 0, fmt, ap); + VSLv(tag, NO_VXID, fmt, ap); va_end(ap); } diff --git a/vmod/vmod_directors_shard_dir.h b/vmod/vmod_directors_shard_dir.h index 47a66b92a..d3cc52998 100644 --- a/vmod/vmod_directors_shard_dir.h +++ b/vmod/vmod_directors_shard_dir.h @@ -89,7 +89,7 @@ sharddir_backend(const struct sharddir *shardd, unsigned id) #define SHDBG(flag, shardd, ...) \ do { \ if ((shardd)->debug_flags & (flag)) \ - VSL(SLT_Debug, 0, "vmod_directors: shard: " \ + VSL(SLT_Debug, NO_VXID, "vmod_directors: shard: " \ __VA_ARGS__); \ } while (0) diff --git a/vmod/vmod_std.c b/vmod/vmod_std.c index 78a288d57..14932b0ef 100644 --- a/vmod/vmod_std.c +++ b/vmod/vmod_std.c @@ -149,7 +149,7 @@ vmod_log(VRT_CTX, VCL_STRANDS s) if (ctx->vsl != NULL) VSLbs(ctx->vsl, SLT_VCL_Log, s); else - VSLs(SLT_VCL_Log, 0, s); + VSLs(SLT_VCL_Log, NO_VXID, s); } /* XXX use vsyslog() ? */ From phk at FreeBSD.org Mon Oct 10 09:40:08 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Oct 2022 09:40:08 +0000 (UTC) Subject: [master] 7f2888877 Wrap vxid in a protective struct for type-consistency. Message-ID: <20221010094008.291471094E1@lists.varnish-cache.org> commit 7f28888779fd14f99eb34e50f6fb07ea6bbff999 Author: Poul-Henning Kamp Date: Mon Oct 10 09:05:32 2022 +0000 Wrap vxid in a protective struct for type-consistency. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 450772696..57e243fb8 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -57,6 +57,20 @@ /*--------------------------------------------------------------------*/ +struct vxids { + uint32_t vxid; +}; + +typedef struct vxids vxid_t; + +#define NO_VXID ((struct vxids){0}) +#define IS_NO_VXID(x) ((x).vxid == 0) +#define VXID_TAG(x) ((x).vxid & (VSL_CLIENTMARKER|VSL_BACKENDMARKER)) +#define VXID(u) ((u.vxid) & VSL_IDENTMASK) +#define IS_SAME_VXID(x, y) ((x).vxid == (y).vxid) + +/*--------------------------------------------------------------------*/ + struct body_status { const char *name; int nbr; @@ -179,9 +193,9 @@ struct acct_bereq { /*--------------------------------------------------------------------*/ struct vsl_log { - uint32_t *wlb, *wlp, *wle; - unsigned wlr; - unsigned wid; + uint32_t *wlb, *wlp, *wle; + unsigned wlr; + vxid_t wid; }; /*--------------------------------------------------------------------*/ @@ -557,7 +571,7 @@ struct sess { struct listen_sock *listen_sock; int refcnt; int fd; - uint32_t vxid; + vxid_t vxid; struct lock mtx; @@ -690,9 +704,7 @@ extern const char H__Reason[]; #define http_range_at(str, tok, l) http_tok_at(str, #tok, l) /* cache_main.c */ -#define NO_VXID (0U) -#define VXID(u) ((u) & VSL_IDENTMASK) -uint32_t VXID_Get(const struct worker *, uint32_t marker); +vxid_t VXID_Get(const struct worker *, uint32_t marker); extern pthread_key_t witness_key; /* cache_lck.c */ @@ -761,10 +773,10 @@ ssize_t VRB_Iterate(struct worker *, struct vsl_log *, struct req *, const char *SES_Get_String_Attr(const struct sess *sp, enum sess_attr a); /* cache_shmlog.c */ -void VSLv(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, va_list va); -void VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...) +void VSLv(enum VSL_tag_e tag, vxid_t vxid, const char *fmt, va_list va); +void VSL(enum VSL_tag_e tag, vxid_t vxid, const char *fmt, ...) v_printflike_(3, 4); -void VSLs(enum VSL_tag_e tag, uint32_t vxid, const struct strands *s); +void VSLs(enum VSL_tag_e tag, vxid_t vxid, const struct strands *s); void VSLbv(struct vsl_log *, enum VSL_tag_e tag, const char *fmt, va_list va); void VSLb(struct vsl_log *, enum VSL_tag_e tag, const char *fmt, ...) v_printflike_(3, 4); diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index afdfbf222..67947114b 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -269,7 +269,7 @@ vca_sock_opt_set(const struct listen_sock *ls, const struct sess *sp) { struct conn_heritage *ch; struct sock_opt *so; - unsigned vxid; + vxid_t vxid; int n, sock; CHECK_OBJ_NOTNULL(ls, LISTEN_SOCK_MAGIC); @@ -280,7 +280,7 @@ vca_sock_opt_set(const struct listen_sock *ls, const struct sess *sp) vxid = sp->vxid; } else { sock = ls->sock; - vxid = 0; + vxid = NO_VXID; } for (n = 0; n < n_sock_opts; n++) { @@ -559,7 +559,7 @@ vca_accept_task(struct worker *wrk, void *arg) lport, VTCP_PORTBUFSIZE); } - VSL(SLT_SessError, 0, "%s %s %s %d %d \"%s\"", + VSL(SLT_SessError, NO_VXID, "%s %s %s %d %d \"%s\"", wa.acceptlsock->name, laddr, lport, ls->sock, i, VAS_errtxt(i)); (void)Pool_TrySumstat(wrk); @@ -587,7 +587,7 @@ vca_accept_task(struct worker *wrk, void *arg) } - VSL(SLT_Debug, 0, "XXX Accept thread dies %p", ps); + VSL(SLT_Debug, NO_VXID, "XXX Accept thread dies %p", ps); FREE_OBJ(ps); } @@ -690,7 +690,7 @@ ccf_start(struct cli *cli, const char * const *av, void *priv) assert (ls->sock > 0); // We know where stdin is if (cache_param->tcp_fastopen && VTCP_fastopen(ls->sock, cache_param->listen_depth)) - VSL(SLT_Error, 0, + VSL(SLT_Error, NO_VXID, "Kernel TCP Fast Open: sock=%d, errno=%d %s", ls->sock, errno, VAS_errtxt(errno)); if (listen(ls->sock, cache_param->listen_depth)) { @@ -706,7 +706,7 @@ ccf_start(struct cli *cli, const char * const *av, void *priv) ls->test_heritage = 1; vca_sock_opt_set(ls, NULL); if (cache_param->accept_filter && VTCP_filter_http(ls->sock)) - VSL(SLT_Error, 0, + VSL(SLT_Error, NO_VXID, "Kernel filtering: sock=%d, errno=%d %s", ls->sock, errno, VAS_errtxt(errno)); } diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 33827b916..5a7bba66c 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -133,7 +133,7 @@ ved_include(struct req *preq, const char *src, const char *host, req = Req_New(sp); AN(req); THR_SetRequest(req); - AZ(req->vsl->wid); + assert(IS_NO_VXID(req->vsl->wid)); req->vsl->wid = VXID_Get(wrk, VSL_CLIENTMARKER); wrk->stats->esi_req++; diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 6c9f1da6c..3e78feda6 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -211,7 +211,7 @@ http_VSLH(const struct http *hp, unsigned hdr) int i; if (hp->vsl != NULL) { - AN(hp->vsl->wid & (VSL_CLIENTMARKER|VSL_BACKENDMARKER)); + assert(VXID_TAG(hp->vsl->wid)); i = hdr; if (i > HTTP_HDR_FIRST) i = HTTP_HDR_FIRST; @@ -228,7 +228,7 @@ http_VSLH_del(const struct http *hp, unsigned hdr) if (hp->vsl != NULL) { /* We don't support unsetting stuff in the first line */ assert (hdr >= HTTP_HDR_FIRST); - AN(hp->vsl->wid & (VSL_CLIENTMARKER|VSL_BACKENDMARKER)); + assert(VXID_TAG(hp->vsl->wid)); i = (HTTP_HDR_UNSET - HTTP_HDR_METHOD); i += hp->logtag; VSLbt(hp->vsl, (enum VSL_tag_e)i, hp->hd[hdr]); diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index b8a8174e1..ff6ef5c39 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -183,15 +183,16 @@ static uint32_t vxid_base; static uint32_t vxid_chunk = 32768; static struct lock vxid_lock; -uint32_t +vxid_t VXID_Get(const struct worker *wrk, uint32_t mask) { struct vxid_pool *v; + vxid_t retval; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk->wpriv, WORKER_PRIV_MAGIC); v = wrk->wpriv->vxid_pool; - AZ(VXID(mask)); + AZ(mask & VSL_IDENTMASK); do { if (v->count == 0) { Lck_Lock(&vxid_lock); @@ -203,7 +204,8 @@ VXID_Get(const struct worker *wrk, uint32_t mask) v->count--; v->next++; } while (v->next == 0); - return (v->next | mask); + retval.vxid = v->next | mask; + return (retval); } /*-------------------------------------------------------------------- @@ -272,7 +274,7 @@ static struct cli_proto debug_cmds[] = { static void child_malloc_fail(void *p, const char *s) { - VSL(SLT_Error, 0, "MALLOC ERROR: %s (%p)", s, p); + VSL(SLT_Error, NO_VXID, "MALLOC ERROR: %s (%p)", s, p); fprintf(stderr, "MALLOC ERROR: %s (%p)\n", s, p); WRONG("Malloc Error"); } diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index c5a394ef9..46166956d 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -55,7 +55,7 @@ Req_AcctLogCharge(struct VSC_main_wrk *ds, struct req *req) a = &req->acct; - if (req->vsl->wid && !(req->res_mode & RES_PIPE)) { + if (!IS_NO_VXID(req->vsl->wid) && !(req->res_mode & RES_PIPE)) { VSLb(req->vsl, SLT_ReqAcct, "%ju %ju %ju %ju %ju %ju", (uintmax_t)a->req_hdrbytes, (uintmax_t)a->req_bodybytes, @@ -194,7 +194,7 @@ Req_Release(struct req *req) #include "tbl/acct_fields_req.h" AZ(req->vcl); - if (req->vsl->wid) + if (!IS_NO_VXID(req->vsl->wid)) VSL_End(req->vsl); #ifdef ENABLE_WORKSPACE_EMULATOR WS_Rollback(req->ws, 0); @@ -262,12 +262,12 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req) VCL_Recache(wrk, &req->vcl); /* Charge and log byte counters */ - if (req->vsl->wid) { + if (!IS_NO_VXID(req->vsl->wid)) { Req_AcctLogCharge(wrk->stats, req); - if (req->vsl->wid != sp->vxid) + if (!IS_SAME_VXID(req->vsl->wid, sp->vxid)) VSL_End(req->vsl); else - req->vsl->wid = 0; /* ending an h2 stream 0 */ + req->vsl->wid = NO_VXID; /* ending an h2 stream 0 */ } if (!isnan(req->t_prev) && req->t_prev > 0. && req->t_prev > sp->t_idle) diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 95c108789..1a1fd7e2a 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -1113,7 +1113,7 @@ cnt_diag(struct req *req, const char *state) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); VSLb(req->vsl, SLT_Debug, "vxid %u STP_%s sp %p vcl %p", - req->vsl->wid, state, req->sp, req->vcl); + req->vsl->wid.vxid, state, req->sp, req->vcl); // XXX_VXID VSL_Flush(req->vsl, 0); } @@ -1160,7 +1160,7 @@ CNT_Request(struct req *req) req->req_step == R_STP_LOOKUP || req->req_step == R_STP_TRANSPORT); - AN(req->vsl->wid & VSL_CLIENTMARKER); + AN(VXID_TAG(req->vsl->wid) & VSL_CLIENTMARKER); AN(req->vcl); for (nxt = REQ_FSM_MORE; nxt == REQ_FSM_MORE; ) { @@ -1192,7 +1192,7 @@ CNT_Request(struct req *req) VCL_Recache(wrk, &req->top->vcl0); } VCL_TaskLeave(ctx, req->privs); - AN(req->vsl->wid); + assert(!IS_NO_VXID(req->vsl->wid)); VRB_Free(req); VRT_Assign_Backend(&req->director_hint, NULL); req->wrk = NULL; diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index ca7fc7d1d..8c2ca46c0 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -134,7 +134,7 @@ vsl_tag_is_masked(enum VSL_tag_e tag) */ static inline uint32_t * -vsl_hdr(enum VSL_tag_e tag, uint32_t *p, unsigned len, uint32_t vxid) +vsl_hdr(enum VSL_tag_e tag, uint32_t *p, unsigned len, vxid_t vxid) { AZ((uintptr_t)p & 0x3); @@ -142,7 +142,7 @@ vsl_hdr(enum VSL_tag_e tag, uint32_t *p, unsigned len, uint32_t vxid) assert(tag < SLT__Reserved); AZ(len & ~VSL_LENMASK); - p[1] = vxid; + p[1] = vxid.vxid; p[0] = ((((unsigned)tag & 0xff) << 24) | len); return (VSL_END(p, len)); } @@ -227,7 +227,7 @@ vsl_get(unsigned len, unsigned records, unsigned flushes) */ static void -vslr(enum VSL_tag_e tag, uint32_t vxid, const char *b, unsigned len) +vslr(enum VSL_tag_e tag, vxid_t vxid, const char *b, unsigned len) { uint32_t *p; unsigned mlen; @@ -246,7 +246,7 @@ vslr(enum VSL_tag_e tag, uint32_t vxid, const char *b, unsigned len) * vsl_hdr() writes p[1] again, but we want to make sure it * has hit memory because we work on the live buffer here. */ - p[1] = vxid; + p[1] = vxid.vxid; VWMB(); (void)vsl_hdr(tag, p, len, vxid); } @@ -259,7 +259,7 @@ vslr(enum VSL_tag_e tag, uint32_t vxid, const char *b, unsigned len) */ void -VSLv(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, va_list ap) +VSLv(enum VSL_tag_e tag, vxid_t vxid, const char *fmt, va_list ap) { unsigned n, mlen = cache_param->vsl_reclen; char buf[mlen]; @@ -280,7 +280,7 @@ VSLv(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, va_list ap) } void -VSLs(enum VSL_tag_e tag, uint32_t vxid, const struct strands *s) +VSLs(enum VSL_tag_e tag, vxid_t vxid, const struct strands *s) { unsigned n, mlen = cache_param->vsl_reclen; char buf[mlen]; @@ -294,7 +294,7 @@ VSLs(enum VSL_tag_e tag, uint32_t vxid, const struct strands *s) } void -VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...) +VSL(enum VSL_tag_e tag, vxid_t vxid, const char *fmt, ...) { va_list ap; @@ -567,16 +567,16 @@ VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len) vsl->wle = ptr; vsl->wle += len / sizeof(*vsl->wle); vsl->wlr = 0; - vsl->wid = 0; + vsl->wid = NO_VXID; vsl_sanity(vsl); } /*--------------------------------------------------------------------*/ void -VSL_ChgId(struct vsl_log *vsl, const char *typ, const char *why, uint32_t vxid) +VSL_ChgId(struct vsl_log *vsl, const char *typ, const char *why, vxid_t vxid) { - uint32_t ovxid; + vxid_t ovxid; vsl_sanity(vsl); ovxid = vsl->wid; @@ -595,12 +595,12 @@ VSL_End(struct vsl_log *vsl) char p[] = ""; vsl_sanity(vsl); - AN(vsl->wid); + assert(!IS_NO_VXID(vsl->wid)); t.b = p; t.e = p; VSLbt(vsl, SLT_End, t); VSL_Flush(vsl, 0); - vsl->wid = 0; + vsl->wid = NO_VXID; } static void v_matchproto_(vsm_lock_f) diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index 6d5adea5d..b40e5b43f 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -449,7 +449,7 @@ extern struct VSC_main *VSC_C_main; void VSM_Init(void); void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len); void VSL_ChgId(struct vsl_log *vsl, const char *typ, const char *why, - uint32_t vxid); + vxid_t vxid); void VSL_End(struct vsl_log *vsl); void VSL_Flush(struct vsl_log *, int overflow); diff --git a/bin/varnishd/fuzzers/esi_parse_fuzzer.c b/bin/varnishd/fuzzers/esi_parse_fuzzer.c index 8d2ff3caa..95b25c391 100644 --- a/bin/varnishd/fuzzers/esi_parse_fuzzer.c +++ b/bin/varnishd/fuzzers/esi_parse_fuzzer.c @@ -63,7 +63,7 @@ PAN__DumpStruct(struct vsb *vsb, int block, int track, const void *ptr, } void -VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...) +VSL(enum VSL_tag_e tag, vxid_t vxid, const char *fmt, ...) { (void)tag; (void)vxid; diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index ab92dcf38..f22ffeef7 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -251,7 +251,7 @@ http1_dissect(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC); /* Allocate a new vxid now that we know we'll need it. */ - AZ(req->vsl->wid); + assert(IS_NO_VXID(req->vsl->wid)); req->vsl->wid = VXID_Get(wrk, VSL_CLIENTMARKER); VSLb(req->vsl, SLT_Begin, "req %u rxreq", VXID(req->sp->vxid)); diff --git a/vmod/vmod_vtc.c b/vmod/vmod_vtc.c index 636bdc275..aa1c2b9ad 100644 --- a/vmod/vmod_vtc.c +++ b/vmod/vmod_vtc.c @@ -60,7 +60,7 @@ vmod_barrier_sync(VRT_CTX, VCL_STRING addr, VCL_DURATION tmo) if (ctx->vsl != NULL) VSLb(ctx->vsl, SLT_Debug, "barrier_sync(\"%s\")", addr); else - VSL(SLT_Debug, 0, "barrier_sync(\"%s\")", addr); + VSL(SLT_Debug, NO_VXID, "barrier_sync(\"%s\")", addr); sock = VTCP_open(addr, NULL, 0., &err); if (sock < 0) { @@ -409,7 +409,7 @@ VCL_VOID vmod_vsl(VRT_CTX, VCL_INT id, VCL_STRING tag_s, VCL_ENUM side, VCL_STRANDS s) { struct vsl_tag2enum *te, key; - uint32_t vxid; + vxid_t vxid; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -427,11 +427,11 @@ vmod_vsl(VRT_CTX, VCL_INT id, VCL_STRING tag_s, VCL_ENUM side, VCL_STRANDS s) return; } - vxid = id & VSL_IDENTMASK; + vxid.vxid = id & VSL_IDENTMASK; if (side == VENUM(c)) - vxid |= VSL_CLIENTMARKER; + vxid.vxid |= VSL_CLIENTMARKER; else if (side == VENUM(b)) - vxid |= VSL_BACKENDMARKER; + vxid.vxid |= VSL_BACKENDMARKER; else WRONG("side"); From phk at FreeBSD.org Mon Oct 10 09:48:05 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Oct 2022 09:48:05 +0000 (UTC) Subject: [master] deafd59fc Dont abuse VSL's vxid, put fd# in message. Message-ID: <20221010094805.6938A109F87@lists.varnish-cache.org> commit deafd59fcd36e66f4942e76bb7b6992c45b36056 Author: Poul-Henning Kamp Date: Mon Oct 10 09:46:54 2022 +0000 Dont abuse VSL's vxid, put fd# in message. diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index b53e48e15..dca460ec9 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -134,7 +134,8 @@ vwe_thread(void *priv) active = Wait_HeapDelete(w, wp); Lck_Unlock(&vwe->mtx); if (!active) { - VSL(SLT_Debug, wp->fd, "epoll: spurious event"); + VSL(SLT_Debug, NO_VXID, + "epoll: spurious event (%d)", wp->fd); continue; } AZ(epoll_ctl(vwe->epfd, EPOLL_CTL_DEL, wp->fd, NULL)); From nils.goroll at uplex.de Mon Oct 10 16:30:12 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 10 Oct 2022 16:30:12 +0000 (UTC) Subject: [master] 322941b18 Add debug.vsl_flush() Message-ID: <20221010163012.9D85D118D18@lists.varnish-cache.org> commit 322941b18e34d79331cd53090a75be0466f146d3 Author: Nils Goroll Date: Mon Oct 10 18:21:55 2022 +0200 Add debug.vsl_flush() diff --git a/vmod/vmod_debug.c b/vmod/vmod_debug.c index f1e2d35cd..a94ae3ab3 100644 --- a/vmod/vmod_debug.c +++ b/vmod/vmod_debug.c @@ -886,6 +886,13 @@ xyzzy_return_strands(VRT_CTX, VCL_STRANDS strand) return (strand); } +VCL_VOID +xyzzy_vsl_flush(VRT_CTX) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + VSL_Flush(ctx->vsl, 0); +} + /*---------------------------------------------------------------------*/ static const struct vcf_return * v_matchproto_(vcf_func_f) diff --git a/vmod/vmod_debug.vcc b/vmod/vmod_debug.vcc index 90be677d6..ced0725e9 100644 --- a/vmod/vmod_debug.vcc +++ b/vmod/vmod_debug.vcc @@ -277,6 +277,10 @@ Test object method with all the fancy stuff. $Function STRANDS return_strands(STRANDS strand) +$Function VOID vsl_flush() + +call VSL_Flush(ctx->cts, 0) + $Function VOID catflap(ENUM {miss, first, last} type) Test the HSH_Lookup catflap From nils.goroll at uplex.de Mon Oct 10 16:30:12 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 10 Oct 2022 16:30:12 +0000 (UTC) Subject: [master] 3beb5c8b9 Fix missed adjustments to vsl buffer space checks Message-ID: <20221010163012.AB81B118D1B@lists.varnish-cache.org> commit 3beb5c8b90744319064b09e6c372908e5f49217c Author: Nils Goroll Date: Mon Oct 10 18:21:39 2022 +0200 Fix missed adjustments to vsl buffer space checks Refs 8df30240174b190db2601f4d64c28ee313eae486 Fixes #3856 diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 8c2ca46c0..eccdf69e1 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -382,18 +382,18 @@ VSLbs(struct vsl_log *vsl, enum VSL_tag_e tag, const struct strands *s) /* including NUL */ l = vmin_t(unsigned, strands_len(s) + 1, mlen); - assert(vsl->wlp < vsl->wle); + assert(vsl->wlp <= vsl->wle); /* Flush if necessary */ - if (VSL_END(vsl->wlp, l) >= vsl->wle) + if (VSL_END(vsl->wlp, l) > vsl->wle) VSL_Flush(vsl, 1); - assert(VSL_END(vsl->wlp, l) < vsl->wle); + assert(VSL_END(vsl->wlp, l) <= vsl->wle); mlen = strands_cat(VSL_DATA(vsl->wlp), l, s); assert(l == mlen); vsl->wlp = vsl_hdr(tag, vsl->wlp, l, vsl->wid); - assert(vsl->wlp < vsl->wle); + assert(vsl->wlp <= vsl->wle); vsl->wlr++; if (DO_DEBUG(DBG_SYNCVSL)) diff --git a/bin/varnishtest/tests/r03856.vtc b/bin/varnishtest/tests/r03856.vtc new file mode 100644 index 000000000..06f1c32fe --- /dev/null +++ b/bin/varnishtest/tests/r03856.vtc @@ -0,0 +1,47 @@ +varnishtest "Regression test off-by-one in VSLbs" + +# vsl_buffer=257 bytes - 2 bytes header -> 255 bytes + +varnish v1 -arg "-p vsl_buffer=267" -vcl { + import debug; + backend b None; + sub vcl_recv { + + # Assert error in VSLbs(), cache/cache_shmlog.c line 385: + # Condition(vsl->wlp < vsl->wle) not true. + + debug.vsl_flush(); + set req.http.a = + # 255 = "a: " + 8 * 32 - 4 + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789ab"; + debug.return_strands("xyz"); + + # Assert error in VSLbs(), cache/cache_shmlog.c line 390: + # Condition(VSL_END(vsl->wlp, l) < vsl->wle) not true. + debug.vsl_flush(); + debug.return_strands( + # 255 = 8 * 32 - 1 + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcdef" + + "0123456789abcdef0123456789abcde"); + return (synth(200)); + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 +} -run From nils.goroll at uplex.de Wed Oct 12 09:38:06 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 12 Oct 2022 09:38:06 +0000 (UTC) Subject: [master] 2aacb4cbf Fill some missing bits in panic output Message-ID: <20221012093806.D5A69A5EEB@lists.varnish-cache.org> commit 2aacb4cbfa92557a83c943ef8a4d62c6295e4ea1 Author: Nils Goroll Date: Tue Oct 11 16:10:10 2022 +0200 Fill some missing bits in panic output vary, req ttl/grace limits, storage Motivated by #3858 diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 45384a0bb..8a22fdf48 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -99,6 +99,19 @@ pan_stream_close(struct vsb *vsb, stream_close_t sc) /*--------------------------------------------------------------------*/ +static void +pan_storage(struct vsb *vsb, const char *n, const struct stevedore *stv) +{ + + if (stv != NULL && stv->magic == STEVEDORE_MAGIC) + VSB_printf(vsb, "%s = %s(%s,%s),\n", + n, stv->name, stv->ident, stv->vclname); + else + VSB_printf(vsb, "%s = %p,\n", n, stv); +} + +/*--------------------------------------------------------------------*/ + #define N_ALREADY 256 static const void *already_list[N_ALREADY]; static int already_idx; @@ -400,6 +413,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) // timeouts/timers/acct/storage left out + pan_storage(vsb, "storage", bo->storage); VDI_Panic(bo->director_req, vsb, "director_req"); if (bo->director_resp == bo->director_req) VSB_cat(vsb, "director_resp = director_req,\n"); @@ -465,6 +479,16 @@ pan_req(struct vsb *vsb, const struct req *req) VSB_printf(vsb, "restarts = %u, esi_level = %u,\n", req->restarts, req->esi_level); + VSB_printf(vsb, "vary_b = %p, vary_l = %p, vary_e = %p,\n", + req->vary_b, req->vary_l, req->vary_e); + + VSB_printf(vsb, "d_ttl = %f, d_grace = %f,\n", + req->d_ttl, req->d_grace); + + pan_storage(vsb, "storage", req->storage); + + VDI_Panic(req->director_hint, vsb, "director_hint"); + if (req->sp != NULL) pan_sess(vsb, req->sp); From nils.goroll at uplex.de Wed Oct 12 09:38:06 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 12 Oct 2022 09:38:06 +0000 (UTC) Subject: [master] 43b2397ef Clear vary prediction marker (vary_l) on restarts Message-ID: <20221012093806.EBC02A5EEE@lists.varnish-cache.org> commit 43b2397ef416d112bf0f985cc55072c85775d869 Author: Nils Goroll Date: Tue Oct 11 13:28:24 2022 +0200 Clear vary prediction marker (vary_l) on restarts In dea05fa4a855140cd807f75dccfa196b4099fa1a, an assertion was added that, if a vary prediction exists as marked by vary_l, that marker matches the actual length. This change uncovered an inconsistency where, for waitinglist returns, the predictive vary was cleared unconditionally (req->vary_b[2] = '\0' in VRY_Prep()), but vary_l was not. Consequently, before dea05fa4a855140cd807f75dccfa196b4099fa1a, VRY_Finish() would copy more of the (possibly empty) vary spec than necessary. This commit fixes the inconsistency and adds specific testing for the case. Fixes #3858 diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index 1edc80436..943350eac 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -237,6 +237,7 @@ VRY_Prep(struct req *req) req->vary_e = req->vary_b + WS_ReservationSize(req->ws); if (req->vary_b + 2 < req->vary_e) req->vary_b[2] = '\0'; + req->vary_l = NULL; } void diff --git a/bin/varnishtest/tests/c00004.vtc b/bin/varnishtest/tests/c00004.vtc index c4d7ad5c2..0af46c8b9 100644 --- a/bin/varnishtest/tests/c00004.vtc +++ b/bin/varnishtest/tests/c00004.vtc @@ -1,5 +1,7 @@ varnishtest "Test Vary functionality" +barrier b1 cond 3 + server s1 { rxreq expect req.http.foobar == "1" @@ -20,6 +22,17 @@ server s1 { rxreq expect req.http.foobar == "" txresp -hdr "Vary: Foobar" -hdr "Snafu: 5" -body "5555\n" + + # #3858 test vary prediction turning out wrong + # no Vary, HFM and waitinglist + rxreq + expect req.http.foobar == "x" + barrier b1 sync + txresp -hdr "Cache-Control: no-cache" + + rxreq + expect req.http.foobar == "x" + txresp -hdr "Cache-Control: no-cache" } -start varnish v1 -vcl+backend {} -start @@ -67,5 +80,24 @@ client c1 { expect resp.status == 200 expect resp.http.X-Varnish == "1011" expect resp.http.snafu == "5" - } -run + +client c1 { + txreq -hdr "Foobar: x" + barrier b1 sync + rxresp + expect resp.status == 200 + expect resp.http.Vary == +} -start + +client c2 { + txreq -hdr "Foobar: x" + barrier b1 sync + rxresp + expect resp.status == 200 + expect resp.http.Vary == +} -start + + +client c1 -wait +client c2 -wait From nils.goroll at uplex.de Wed Oct 12 10:00:10 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 12 Oct 2022 10:00:10 +0000 (UTC) Subject: [master] 9b1bd2de5 gc the vary_l pointer, it serves no purpose Message-ID: <20221012100010.64A1CA6D0B@lists.varnish-cache.org> commit 9b1bd2de520f5088c5885734132fb1d9c33a2ed4 Author: Nils Goroll Date: Wed Oct 12 11:51:52 2022 +0200 gc the vary_l pointer, it serves no purpose because we run VRY_Validate() anyway before keeping a vary spec, and rightly so. Ref #3858 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 57e243fb8..7ad710995 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -491,9 +491,8 @@ struct req { /* The busy objhead we sleep on */ struct objhead *hash_objhead; - /* Built Vary string */ + /* Built Vary string == workspace reservation */ uint8_t *vary_b; - uint8_t *vary_l; uint8_t *vary_e; uint8_t digest[DIGEST_LEN]; diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 8a22fdf48..23a961ed2 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -479,8 +479,8 @@ pan_req(struct vsb *vsb, const struct req *req) VSB_printf(vsb, "restarts = %u, esi_level = %u,\n", req->restarts, req->esi_level); - VSB_printf(vsb, "vary_b = %p, vary_l = %p, vary_e = %p,\n", - req->vary_b, req->vary_l, req->vary_e); + VSB_printf(vsb, "vary_b = %p, vary_e = %p,\n", + req->vary_b, req->vary_e); VSB_printf(vsb, "d_ttl = %f, d_grace = %f,\n", req->d_ttl, req->d_grace); diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index 943350eac..e650c653e 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -227,7 +227,6 @@ VRY_Prep(struct req *req) if (req->hash_objhead == NULL) { /* Not a waiting list return */ AZ(req->vary_b); - AZ(req->vary_l); AZ(req->vary_e); (void)WS_ReserveAll(req->ws); } else { @@ -237,7 +236,6 @@ VRY_Prep(struct req *req) req->vary_e = req->vary_b + WS_ReservationSize(req->ws); if (req->vary_b + 2 < req->vary_e) req->vary_b[2] = '\0'; - req->vary_l = NULL; } void @@ -249,7 +247,6 @@ VRY_Clear(struct req *req) free(req->vary_b); req->vary_b = NULL; AZ(req->vary_e); - AZ(req->vary_l); } /********************************************************************** @@ -263,7 +260,6 @@ VRY_Finish(struct req *req, enum vry_finish_flag flg) size_t l; if (req->vary_b + 2 >= req->vary_e) { - AZ(req->vary_l); req->vary_b = NULL; req->vary_e = NULL; WS_Release(req->ws, 0); @@ -272,14 +268,12 @@ VRY_Finish(struct req *req, enum vry_finish_flag flg) } l = VRY_Validate(req->vary_b); - if (flg == KEEP && req->vary_l != NULL) { - assert(l == req->vary_l - req->vary_b); + if (flg == KEEP && l > 3) { p = malloc(l); if (p != NULL) memcpy(p, req->vary_b, l); } WS_Release(req->ws, 0); - req->vary_l = NULL; req->vary_e = NULL; req->vary_b = p; } @@ -348,7 +342,6 @@ VRY_Match(struct req *req, const uint8_t *vary) vsp[ln++] = 0xff; vsp[ln++] = 0; assert(VRY_Validate(vsp) == ln); - req->vary_l = vsp + ln; i = vry_cmp(vary, vsp); assert(i == 0 || i == 2); @@ -364,7 +357,6 @@ VRY_Match(struct req *req, const uint8_t *vary) } if (oflo) { vsp = req->vary_b; - req->vary_l = NULL; if (vsp + 2 < req->vary_e) { vsp[0] = 0xff; vsp[1] = 0xff; From nils.goroll at uplex.de Wed Oct 12 10:46:05 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 12 Oct 2022 10:46:05 +0000 (UTC) Subject: [master] 18151d307 Silence (my) flexelint Message-ID: <20221012104605.A25A3A85BF@lists.varnish-cache.org> commit 18151d307718808d24214e17a7af699e1ab19fba Author: Nils Goroll Date: Wed Oct 12 12:44:29 2022 +0200 Silence (my) flexelint diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index 46a1f100c..3de001cf0 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -61,7 +61,7 @@ struct ilck { static void Lck_Witness_Lock(const struct ilck *il, const char *p, int l, const char *try) { - char *q, t[10]; + char *q, t[10]; //lint -e429 int emit; AN(p); From nils.goroll at uplex.de Wed Oct 12 10:46:05 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 12 Oct 2022 10:46:05 +0000 (UTC) Subject: [master] f1d450cfa Constify Message-ID: <20221012104605.B8808A85C2@lists.varnish-cache.org> commit f1d450cfa57862e080c1f54ec6a3a521bbd192be Author: Nils Goroll Date: Wed Oct 12 12:44:45 2022 +0200 Constify found by flexelint diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index b40e5b43f..b90affc6a 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -462,7 +462,7 @@ void VCP_Panic(struct vsb *, struct conn_pool *); /* cache_vary.c */ int VRY_Create(struct busyobj *bo, struct vsb **psb); -int VRY_Match(struct req *, const uint8_t *vary); +int VRY_Match(const struct req *, const uint8_t *vary); void VRY_Prep(struct req *); void VRY_Clear(struct req *); enum vry_finish_flag { KEEP, DISCARD }; diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index e650c653e..101eca231 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -286,7 +286,7 @@ VRY_Finish(struct req *req, enum vry_finish_flag flg) */ int -VRY_Match(struct req *req, const uint8_t *vary) +VRY_Match(const struct req *req, const uint8_t *vary) { uint8_t *vsp = req->vary_b; const char *h, *e; From phk at FreeBSD.org Tue Oct 25 07:35:10 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Oct 2022 07:35:10 +0000 (UTC) Subject: [master] afbe6b648 Make the internal representation of vxid's 64 bit wide. Message-ID: <20221025073510.310E796F4@lists.varnish-cache.org> commit afbe6b648503687b1e9a2571a9e87ab089fc7bee Author: Poul-Henning Kamp Date: Tue Oct 25 07:33:40 2022 +0000 Make the internal representation of vxid's 64 bit wide. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 7ad710995..de022c726 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -58,7 +58,7 @@ /*--------------------------------------------------------------------*/ struct vxids { - uint32_t vxid; + uint64_t vxid; }; typedef struct vxids vxid_t; @@ -66,7 +66,7 @@ typedef struct vxids vxid_t; #define NO_VXID ((struct vxids){0}) #define IS_NO_VXID(x) ((x).vxid == 0) #define VXID_TAG(x) ((x).vxid & (VSL_CLIENTMARKER|VSL_BACKENDMARKER)) -#define VXID(u) ((u.vxid) & VSL_IDENTMASK) +#define VXID(u) ((uintmax_t)(u.vxid) & VSL_IDENTMASK) #define IS_SAME_VXID(x, y) ((x).vxid == (y).vxid) /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 5a7bba66c..87d85d935 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -139,9 +139,9 @@ ved_include(struct req *preq, const char *src, const char *host, wrk->stats->esi_req++; req->esi_level = preq->esi_level + 1; - VSLb(req->vsl, SLT_Begin, "req %u esi %u", VXID(preq->vsl->wid), + VSLb(req->vsl, SLT_Begin, "req %ju esi %u", VXID(preq->vsl->wid), req->esi_level); - VSLb(preq->vsl, SLT_Link, "req %u esi %u", VXID(req->vsl->wid), + VSLb(preq->vsl, SLT_Link, "req %ju esi %u", VXID(req->vsl->wid), req->esi_level); VSLb_ts_req(req, "Start", W_TIM_real(wrk)); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 154563f75..95bbc27f0 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -404,7 +404,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (bo->retries > 0) http_Unset(bo->bereq, "\012X-Varnish:"); - http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(bo->vsl->wid)); + http_PrintfHeader(bo->bereq, "X-Varnish: %ju", VXID(bo->vsl->wid)); VCL_backend_fetch_method(bo->vcl, wrk, NULL, bo, NULL); @@ -1147,9 +1147,9 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, #define REQ_BEREQ_FLAG(l, r, w, d) bo->l = req->l; #include "tbl/req_bereq_flags.h" - VSLb(bo->vsl, SLT_Begin, "bereq %u %s", VXID(req->vsl->wid), how); + VSLb(bo->vsl, SLT_Begin, "bereq %ju %s", VXID(req->vsl->wid), how); VSLbs(bo->vsl, SLT_VCL_use, TOSTRAND(VCL_Name(bo->vcl))); - VSLb(req->vsl, SLT_Link, "bereq %u %s", VXID(bo->vsl->wid), how); + VSLb(req->vsl, SLT_Link, "bereq %ju %s", VXID(bo->vsl->wid), how); THR_SetBusyobj(bo); diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 23a961ed2..44fd82871 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -452,7 +452,7 @@ pan_req(struct vsb *vsb, const struct req *req) if (PAN_dump_struct(vsb, req, REQ_MAGIC, "req")) return; xp = req->transport; - VSB_printf(vsb, "vxid = %u, transport = %s", VXID(req->vsl->wid), + VSB_printf(vsb, "vxid = %ju, transport = %s", VXID(req->vsl->wid), xp == NULL ? "NULL" : xp->name); if (xp != NULL && xp->req_panic != NULL) { @@ -553,7 +553,7 @@ pan_sess(struct vsb *vsb, const struct sess *sp) if (PAN_dump_struct(vsb, sp, SESS_MAGIC, "sess")) return; - VSB_printf(vsb, "fd = %d, vxid = %u,\n", + VSB_printf(vsb, "fd = %d, vxid = %ju,\n", sp->fd, VXID(sp->vxid)); VSB_printf(vsb, "t_open = %f,\n", sp->t_open); VSB_printf(vsb, "t_idle = %f,\n", sp->t_idle); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 1a1fd7e2a..457506209 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -153,10 +153,10 @@ Resp_Setup_Deliver(struct req *req) http_ForceField(h, HTTP_HDR_PROTO, "HTTP/1.1"); if (req->is_hit) - http_PrintfHeader(h, "X-Varnish: %u %u", VXID(req->vsl->wid), + http_PrintfHeader(h, "X-Varnish: %ju %u", VXID(req->vsl->wid), ObjGetXID(req->wrk, oc)); else - http_PrintfHeader(h, "X-Varnish: %u", VXID(req->vsl->wid)); + http_PrintfHeader(h, "X-Varnish: %ju", VXID(req->vsl->wid)); /* * We base Age calculation upon the last timestamp taken during client @@ -193,7 +193,7 @@ Resp_Setup_Synth(struct req *req) http_TimeHeader(h, "Date: ", W_TIM_real(req->wrk)); http_SetHeader(h, "Server: Varnish"); - http_PrintfHeader(h, "X-Varnish: %u", VXID(req->vsl->wid)); + http_PrintfHeader(h, "X-Varnish: %ju", VXID(req->vsl->wid)); /* * For late 100-continue, we suggest to VCL to close the connection to @@ -767,8 +767,8 @@ cnt_pipe(struct worker *wrk, struct req *req) wrk->stats->s_pipe++; bo = VBO_GetBusyObj(wrk, req); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - VSLb(bo->vsl, SLT_Begin, "bereq %u pipe", VXID(req->vsl->wid)); - VSLb(req->vsl, SLT_Link, "bereq %u pipe", VXID(bo->vsl->wid)); + VSLb(bo->vsl, SLT_Begin, "bereq %ju pipe", VXID(req->vsl->wid)); + VSLb(req->vsl, SLT_Link, "bereq %ju pipe", VXID(bo->vsl->wid)); VSLb_ts_busyobj(bo, "Start", W_TIM_real(wrk)); THR_SetBusyobj(bo); bo->sp = req->sp; @@ -776,7 +776,7 @@ cnt_pipe(struct worker *wrk, struct req *req) HTTP_Setup(bo->bereq, req->ws, bo->vsl, SLT_BereqMethod); http_FilterReq(bo->bereq, req->http, 0); // XXX: 0 ? - http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(req->vsl->wid)); + http_PrintfHeader(bo->bereq, "X-Varnish: %ju", VXID(req->vsl->wid)); http_ForceHeader(bo->bereq, H_Connection, "close"); if (req->want100cont) { @@ -1112,7 +1112,7 @@ cnt_diag(struct req *req, const char *state) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - VSLb(req->vsl, SLT_Debug, "vxid %u STP_%s sp %p vcl %p", + VSLb(req->vsl, SLT_Debug, "vxid %ju STP_%s sp %p vcl %p", req->vsl->wid.vxid, state, req->sp, req->vcl); // XXX_VXID VSL_Flush(req->vsl, 0); } diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index eccdf69e1..955382580 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -580,10 +580,10 @@ VSL_ChgId(struct vsl_log *vsl, const char *typ, const char *why, vxid_t vxid) vsl_sanity(vsl); ovxid = vsl->wid; - VSLb(vsl, SLT_Link, "%s %u %s", typ, VXID(vxid), why); + VSLb(vsl, SLT_Link, "%s %ju %s", typ, VXID(vxid), why); VSL_End(vsl); vsl->wid = vxid; - VSLb(vsl, SLT_Begin, "%s %u %s", typ, VXID(ovxid), why); + VSLb(vsl, SLT_Begin, "%s %ju %s", typ, VXID(ovxid), why); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index cbe280d11..d3880f4af 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -776,7 +776,7 @@ VRT_r_req_xid(VRT_CTX) CHECK_OBJ_NOTNULL(ctx->req->http, HTTP_MAGIC); AN(ctx->req->vsl); - return (WS_Printf(ctx->req->http->ws, "%u", + return (WS_Printf(ctx->req->http->ws, "%ju", VXID(ctx->req->vsl->wid))); } @@ -788,7 +788,7 @@ VRT_r_bereq_xid(VRT_CTX) CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); AN(ctx->bo->vsl); - return (WS_Printf(ctx->ws, "%u", VXID(ctx->bo->vsl->wid))); + return (WS_Printf(ctx->ws, "%ju", VXID(ctx->bo->vsl->wid))); } VCL_STRING @@ -807,7 +807,7 @@ VRT_r_sess_xid(VRT_CTX) } CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - return (WS_Printf(ctx->ws, "%u", VXID(sp->vxid))); + return (WS_Printf(ctx->ws, "%ju", VXID(sp->vxid))); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index f22ffeef7..0d23af1de 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -254,8 +254,8 @@ http1_dissect(struct worker *wrk, struct req *req) assert(IS_NO_VXID(req->vsl->wid)); req->vsl->wid = VXID_Get(wrk, VSL_CLIENTMARKER); - VSLb(req->vsl, SLT_Begin, "req %u rxreq", VXID(req->sp->vxid)); - VSL(SLT_Link, req->sp->vxid, "req %u rxreq", VXID(req->vsl->wid)); + VSLb(req->vsl, SLT_Begin, "req %ju rxreq", VXID(req->sp->vxid)); + VSL(SLT_Link, req->sp->vxid, "req %ju rxreq", VXID(req->vsl->wid)); AZ(isnan(req->t_first)); /* First byte timestamp set by http1_wait */ AZ(isnan(req->t_req)); /* Complete req rcvd set by http1_wait */ req->t_prev = req->t_first; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 63c491fbd..fa50c6ec7 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -672,8 +672,8 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); req->vsl->wid = VXID_Get(wrk, VSL_CLIENTMARKER); - VSLb(req->vsl, SLT_Begin, "req %u rxreq", VXID(req->sp->vxid)); - VSL(SLT_Link, req->sp->vxid, "req %u rxreq", VXID(req->vsl->wid)); + VSLb(req->vsl, SLT_Begin, "req %ju rxreq", VXID(req->sp->vxid)); + VSL(SLT_Link, req->sp->vxid, "req %ju rxreq", VXID(req->vsl->wid)); h2->new_req = req; req->sp = h2->sess; From phk at FreeBSD.org Tue Oct 25 07:55:06 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Oct 2022 07:55:06 +0000 (UTC) Subject: [master] a91736a9a Use VSL_OVERHEAD instead of 2 Message-ID: <20221025075506.4FDC7612D9@lists.varnish-cache.org> commit a91736a9a820bf309732f704b06ae162dfd40802 Author: Poul-Henning Kamp Date: Tue Oct 25 07:54:40 2022 +0000 Use VSL_OVERHEAD instead of 2 diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 955382580..26e148e64 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -240,7 +240,7 @@ vslr(enum VSL_tag_e tag, vxid_t vxid, const char *b, unsigned len) p = vsl_get(len, 1, 0); - memcpy(p + 2, b, len); + memcpy(p + VSL_OVERHEAD, b, len); /* * vsl_hdr() writes p[1] again, but we want to make sure it @@ -320,7 +320,7 @@ VSL_Flush(struct vsl_log *vsl, int overflow) p = vsl_get(l, vsl->wlr, overflow); - memcpy(p + 2, vsl->wlb, l); + memcpy(p + VSL_OVERHEAD, vsl->wlb, l); p[1] = l; VWMB(); p[0] = ((((unsigned)SLT__Batch & 0xff) << 24)); From phk at FreeBSD.org Tue Oct 25 08:01:05 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Oct 2022 08:01:05 +0000 (UTC) Subject: [master] 8e2817645 Use VXID() when printing vxids Message-ID: <20221025080105.79A81617D0@lists.varnish-cache.org> commit 8e2817645ea0683bdffb2c3b2f5965295e00bff5 Author: Poul-Henning Kamp Date: Tue Oct 25 07:59:52 2022 +0000 Use VXID() when printing vxids diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 457506209..c3dbe311f 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -1113,7 +1113,7 @@ cnt_diag(struct req *req, const char *state) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); VSLb(req->vsl, SLT_Debug, "vxid %ju STP_%s sp %p vcl %p", - req->vsl->wid.vxid, state, req->sp, req->vcl); // XXX_VXID + VXID(req->vsl->wid), state, req->sp, req->vcl); VSL_Flush(req->vsl, 0); } From phk at FreeBSD.org Tue Oct 25 17:17:05 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Oct 2022 17:17:05 +0000 (UTC) Subject: [master] fb19c2ce5 Refactor adding records to vsl buffers Message-ID: <20221025171705.6763FA3CA1@lists.varnish-cache.org> commit fb19c2ce5afbd05bdaab9f4a2862fcf6fa4d7a1b Author: Poul-Henning Kamp Date: Tue Oct 25 17:16:23 2022 +0000 Refactor adding records to vsl buffers diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 26e148e64..48ea0f9cc 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -110,6 +110,7 @@ vsl_sanity(const struct vsl_log *vsl) AN(vsl->wlp); AN(vsl->wlb); AN(vsl->wle); + assert(vsl->wlp <= vsl->wle); } /*-------------------------------------------------------------------- @@ -329,72 +330,81 @@ VSL_Flush(struct vsl_log *vsl, int overflow) } /*-------------------------------------------------------------------- - * VSL-buffered-txt + * Buffered VSLs */ -void -VSLbt(struct vsl_log *vsl, enum VSL_tag_e tag, txt t) +static char * +vslb_get(struct vsl_log *vsl, enum VSL_tag_e tag, unsigned *length) { - unsigned l, mlen; - char *p; + unsigned mlen = cache_param->vsl_reclen; + char *retval; vsl_sanity(vsl); - Tcheck(t); - if (vsl_tag_is_masked(tag)) - return; - mlen = cache_param->vsl_reclen; + if (*length < mlen) + mlen = *length; - /* Truncate */ - l = Tlen(t); - if (l > mlen - 1) - l = mlen - 1; + if (VSL_END(vsl->wlp, mlen) > vsl->wle) + VSL_Flush(vsl, 1); - assert(vsl->wlp <= vsl->wle); + retval = VSL_DATA(vsl->wlp); - /* Flush if necessary */ - if (VSL_END(vsl->wlp, l + 1) > vsl->wle) - VSL_Flush(vsl, 1); - assert(VSL_END(vsl->wlp, l + 1) <= vsl->wle); - p = VSL_DATA(vsl->wlp); - memcpy(p, t.b, l); - p[l++] = '\0'; /* NUL-terminated */ - vsl->wlp = vsl_hdr(tag, vsl->wlp, l, vsl->wid); - assert(vsl->wlp <= vsl->wle); + /* If it still doesn't fit, truncate */ + if (VSL_END(vsl->wlp, mlen) > vsl->wle) + *length = mlen = ((char *)vsl->wle) - VSL_DATA(vsl->wlp); + + vsl->wlp = vsl_hdr(tag, vsl->wlp, mlen, vsl->wid); vsl->wlr++; + return (retval); +} + +static void +vslb_simple(struct vsl_log *vsl, enum VSL_tag_e tag, + unsigned length, const char *str) +{ + char *p; + + if (length == 0) + length = strlen(str); + length += 1; // NUL + p = vslb_get(vsl, tag, &length); + memcpy(p, str, length - 1); + p[length - 1] = '\0'; if (DO_DEBUG(DBG_SYNCVSL)) VSL_Flush(vsl, 0); } /*-------------------------------------------------------------------- - * VSL-buffered-strands + * VSL-buffered-txt */ + void -VSLbs(struct vsl_log *vsl, enum VSL_tag_e tag, const struct strands *s) +VSLbt(struct vsl_log *vsl, enum VSL_tag_e tag, txt t) { - unsigned l, mlen; - vsl_sanity(vsl); + Tcheck(t); if (vsl_tag_is_masked(tag)) return; - mlen = cache_param->vsl_reclen; - /* including NUL */ - l = vmin_t(unsigned, strands_len(s) + 1, mlen); + vslb_simple(vsl, tag, Tlen(t), t.b); +} - assert(vsl->wlp <= vsl->wle); +/*-------------------------------------------------------------------- + * VSL-buffered-strands + */ +void +VSLbs(struct vsl_log *vsl, enum VSL_tag_e tag, const struct strands *s) +{ + unsigned l; + char *p; - /* Flush if necessary */ - if (VSL_END(vsl->wlp, l) > vsl->wle) - VSL_Flush(vsl, 1); - assert(VSL_END(vsl->wlp, l) <= vsl->wle); + if (vsl_tag_is_masked(tag)) + return; - mlen = strands_cat(VSL_DATA(vsl->wlp), l, s); - assert(l == mlen); + l = strands_len(s) + 1; + p = vslb_get(vsl, tag, &l); - vsl->wlp = vsl_hdr(tag, vsl->wlp, l, vsl->wid); - assert(vsl->wlp <= vsl->wle); - vsl->wlr++; + (void)strands_cat(p, l, s); if (DO_DEBUG(DBG_SYNCVSL)) VSL_Flush(vsl, 0); @@ -407,14 +417,10 @@ VSLbs(struct vsl_log *vsl, enum VSL_tag_e tag, const struct strands *s) void VSLbv(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, va_list ap) { - char *p; - const char *u, *f; - unsigned n, mlen; - txt t; + char *p, *p1; + unsigned n = 0, mlen; va_list ap2; - int first; - vsl_sanity(vsl); AN(fmt); if (vsl_tag_is_masked(tag)) return; @@ -422,63 +428,43 @@ VSLbv(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, va_list ap) /* * If there are no printf-expansions, don't waste time expanding them */ - f = NULL; - for (u = fmt; *u != '\0'; u++) - if (*u == '%') - f = u; - if (f == NULL) { - t.b = TRUST_ME(fmt); - t.e = TRUST_ME(u); - VSLbt(vsl, tag, t); + if (strchr(fmt, '%') == NULL) { + vslb_simple(vsl, tag, 0, fmt); return; } + /* + * If the format is trivial, deal with it directly + */ if (!strcmp(fmt, "%s")) { - p = va_arg(ap, char *); - t.b = p; - t.e = strchr(p, '\0'); - VSLbt(vsl, tag, t); + p1 = va_arg(ap, char *); + vslb_simple(vsl, tag, 0, p1); return; } - assert(vsl->wlp <= vsl->wle); + vsl_sanity(vsl); - /* Flush if we can't fit any bytes */ - if (vsl->wle - vsl->wlp <= VSL_OVERHEAD) - VSL_Flush(vsl, 1); + mlen = (char *)vsl->wle - VSL_DATA(vsl->wlp); - /* Do the vsnprintf formatting in one or two stages. If the first - stage shows that we overflowed, and the available space to work - with was less than vsl_reclen, flush and do the formatting - again. */ - first = 1; - while (1) { - assert(vsl->wle - vsl->wlp > VSL_OVERHEAD); - mlen = VSL_BYTES((vsl->wle - vsl->wlp) - VSL_OVERHEAD); - if (mlen > cache_param->vsl_reclen) - mlen = cache_param->vsl_reclen; - assert(mlen > 0); - assert(VSL_END(vsl->wlp, mlen) <= vsl->wle); + // First attempt, only if any space at all + if (mlen > 0) { p = VSL_DATA(vsl->wlp); va_copy(ap2, ap); n = vsnprintf(p, mlen, fmt, ap2); va_end(ap2); - - if (first && n >= mlen && mlen < cache_param->vsl_reclen) { - first = 0; - VSL_Flush(vsl, 1); - continue; - } - - break; } - if (n > mlen - 1) - n = mlen - 1; /* we truncate long fields */ - p[n++] = '\0'; /* NUL-terminated */ - vsl->wlp = vsl_hdr(tag, vsl->wlp, n, vsl->wid); - assert(vsl->wlp <= vsl->wle); - vsl->wlr++; + // Second attempt after a flush + if (mlen == 0 || n + 1 > mlen) { + // Second attempt after a flush + VSL_Flush(vsl, 1); + mlen = (char *)vsl->wle - VSL_DATA(vsl->wlp); + p = VSL_DATA(vsl->wlp); + n = vsnprintf(p, mlen, fmt, ap); + } + if (n + 1 < mlen) + mlen = n + 1; + (void)vslb_get(vsl, tag, &mlen); if (DO_DEBUG(DBG_SYNCVSL)) VSL_Flush(vsl, 0); From phk at FreeBSD.org Tue Oct 25 17:48:04 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Oct 2022 17:48:04 +0000 (UTC) Subject: [master] c862063ac Always return whatever length we managed to allocate. Message-ID: <20221025174805.0F27EA4E6A@lists.varnish-cache.org> commit c862063ace8a810dc65af0a7e669f74beeea8f12 Author: Poul-Henning Kamp Date: Tue Oct 25 17:47:39 2022 +0000 Always return whatever length we managed to allocate. diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 48ea0f9cc..c166b5648 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -350,10 +350,11 @@ vslb_get(struct vsl_log *vsl, enum VSL_tag_e tag, unsigned *length) /* If it still doesn't fit, truncate */ if (VSL_END(vsl->wlp, mlen) > vsl->wle) - *length = mlen = ((char *)vsl->wle) - VSL_DATA(vsl->wlp); + mlen = ((char *)vsl->wle) - VSL_DATA(vsl->wlp); vsl->wlp = vsl_hdr(tag, vsl->wlp, mlen, vsl->wid); vsl->wlr++; + *length = mlen; return (retval); } From phk at FreeBSD.org Wed Oct 26 14:09:09 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 26 Oct 2022 14:09:09 +0000 (UTC) Subject: [master] 445b07f5f Use VSL_OVERHEAD when reading binary VSL records back from files. Message-ID: <20221026140909.8C9E4A1FFD@lists.varnish-cache.org> commit 445b07f5f7d98be06989a43ecdb6c3f26aba9c55 Author: Poul-Henning Kamp Date: Wed Oct 26 14:08:07 2022 +0000 Use VSL_OVERHEAD when reading binary VSL records back from files. diff --git a/lib/libvarnishapi/vsl_cursor.c b/lib/libvarnishapi/vsl_cursor.c index b06f7deb5..3d356ad1c 100644 --- a/lib/libvarnishapi/vsl_cursor.c +++ b/lib/libvarnishapi/vsl_cursor.c @@ -362,13 +362,13 @@ vslc_file_next(const struct VSL_cursor *cursor) do { c->cursor.rec.ptr = NULL; assert(c->buflen >= 2); - i = vslc_file_readn(c->fd, c->buf, VSL_BYTES(2)); + i = vslc_file_readn(c->fd, c->buf, VSL_BYTES(VSL_OVERHEAD)); if (i < 0) return (vsl_e_io); if (i == 0) return (vsl_e_eof); - assert(i == VSL_BYTES(2)); - l = 2 + VSL_WORDS(VSL_LEN(c->buf)); + assert(i == VSL_BYTES(VSL_OVERHEAD)); + l = VSL_OVERHEAD + VSL_WORDS(VSL_LEN(c->buf)); if (c->buflen < l) { while (c->buflen < l) c->buflen = 2 * l; @@ -376,13 +376,13 @@ vslc_file_next(const struct VSL_cursor *cursor) AN(c->buf); } if (l > 2) { - i = vslc_file_readn(c->fd, c->buf + 2, - VSL_BYTES(l - 2)); + i = vslc_file_readn(c->fd, c->buf + VSL_OVERHEAD, + VSL_BYTES(l - VSL_OVERHEAD)); if (i < 0) return (vsl_e_io); if (i == 0) return (vsl_e_eof); - assert(i == VSL_BYTES(l - 2)); + assert(i == VSL_BYTES(l - VSL_OVERHEAD)); } c->cursor.rec.ptr = c->buf; } while (VSL_TAG(c->cursor.rec.ptr) == SLT__Batch); From nils.goroll at uplex.de Wed Oct 26 22:04:15 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 26 Oct 2022 22:04:15 +0000 (UTC) Subject: [master] a0bae480d Adjust tests to *.xid type change Message-ID: <20221026220415.52DBFB061E@lists.varnish-cache.org> commit a0bae480da8755daf62ee825bfc084c84f1069f5 Author: Nils Goroll Date: Thu Oct 27 00:02:37 2022 +0200 Adjust tests to *.xid type change diff --git a/bin/varnishtest/tests/r02618.vtc b/bin/varnishtest/tests/r02618.vtc index efe1a23c6..2b8dba60b 100644 --- a/bin/varnishtest/tests/r02618.vtc +++ b/bin/varnishtest/tests/r02618.vtc @@ -7,13 +7,11 @@ server s1 { varnish v1 -vcl+backend { import vtc; - import std; sub vcl_recv { return (hash); } sub vcl_deliver { - vtc.workspace_alloc(client, -4 * - (std.integer(req.xid, 1001) - 1001) / 2); + vtc.workspace_alloc(client, -4 * (req.xid - 1001) / 2); } } -start diff --git a/bin/varnishtest/tests/r02645.vtc b/bin/varnishtest/tests/r02645.vtc index d66573747..982c50a96 100644 --- a/bin/varnishtest/tests/r02645.vtc +++ b/bin/varnishtest/tests/r02645.vtc @@ -7,13 +7,11 @@ server s1 -repeat 100 { varnish v1 -vcl+backend { import vtc; - import std; sub vcl_recv { return (pass); } sub vcl_backend_fetch { - vtc.workspace_alloc(backend, -4 * - (std.integer(bereq.xid, 1002) - 1000) / 2); + vtc.workspace_alloc(backend, -4 * (bereq.xid - 1000) / 2); } } -start diff --git a/bin/varnishtest/tests/r03253.vtc b/bin/varnishtest/tests/r03253.vtc index af72560c5..7d8072aaa 100644 --- a/bin/varnishtest/tests/r03253.vtc +++ b/bin/varnishtest/tests/r03253.vtc @@ -7,13 +7,11 @@ server s1 -repeat 100 { varnish v1 -vcl+backend { import vtc; - import std; sub vcl_recv { return (pass); } sub vcl_backend_response { - vtc.workspace_alloc(backend, -4 * - (std.integer(bereq.xid, 1002) - 1000) / 2); + vtc.workspace_alloc(backend, -4 * (bereq.xid - 1000) / 2); set beresp.do_esi = true; } } -start From nils.goroll at uplex.de Wed Oct 26 22:04:15 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 26 Oct 2022 22:04:15 +0000 (UTC) Subject: [master] 1d670e2f0 VCL xid variables should be integers Message-ID: <20221026220415.3D2D6B061C@lists.varnish-cache.org> commit 1d670e2f04a4ff13615c7e6a4ee800e4ba8ebaf2 Author: Nils Goroll Date: Wed Oct 26 23:52:26 2022 +0200 VCL xid variables should be integers Due to string folding, I expect this change to be fully backwards compatible - even with std.integert(req.xid) as proven by the vtcs which I am about to change. diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index d3880f4af..97e74b9bf 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -767,7 +767,7 @@ VRT_DO_AGE_R(beresp, ctx->bo->fetch_objcore) * [[be]req|sess].xid */ -VCL_STRING +VCL_INT VRT_r_req_xid(VRT_CTX) { @@ -775,12 +775,10 @@ VRT_r_req_xid(VRT_CTX) CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); CHECK_OBJ_NOTNULL(ctx->req->http, HTTP_MAGIC); AN(ctx->req->vsl); - - return (WS_Printf(ctx->req->http->ws, "%ju", - VXID(ctx->req->vsl->wid))); + return (VXID(ctx->req->vsl->wid)); } -VCL_STRING +VCL_INT VRT_r_bereq_xid(VRT_CTX) { @@ -788,10 +786,10 @@ VRT_r_bereq_xid(VRT_CTX) CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); AN(ctx->bo->vsl); - return (WS_Printf(ctx->ws, "%ju", VXID(ctx->bo->vsl->wid))); + return (VXID(ctx->bo->vsl->wid)); } -VCL_STRING +VCL_INT VRT_r_sess_xid(VRT_CTX) { struct sess *sp; @@ -807,7 +805,7 @@ VRT_r_sess_xid(VRT_CTX) } CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - return (WS_Printf(ctx->ws, "%ju", VXID(sp->vxid))); + return (VXID(sp->vxid)); } /*-------------------------------------------------------------------- diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst index d97016976..bf307edd2 100644 --- a/doc/sphinx/reference/vcl_var.rst +++ b/doc/sphinx/reference/vcl_var.rst @@ -434,7 +434,7 @@ req.url req.xid - Type: STRING + Type: INT Readable from: client @@ -720,7 +720,7 @@ bereq.url bereq.xid - Type: STRING + Type: INT Readable from: vcl_pipe, backend @@ -1488,7 +1488,7 @@ sess.timeout_linger sess.xid ``VCL >= 4.1`` - Type: STRING + Type: INT Readable from: client, backend From phk at FreeBSD.org Mon Oct 31 09:45:09 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 31 Oct 2022 09:45:09 +0000 (UTC) Subject: [master] da8ca47a5 Adapt to changes in llvm-gcov output Message-ID: <20221031094509.2384EB0329@lists.varnish-cache.org> commit da8ca47a5cd7756225ec203cdaacab0d4449d8d1 Author: Poul-Henning Kamp Date: Mon Oct 31 09:44:02 2022 +0000 Adapt to changes in llvm-gcov output diff --git a/tools/gcov_digest.py b/tools/gcov_digest.py index 464d56626..17ce3da08 100644 --- a/tools/gcov_digest.py +++ b/tools/gcov_digest.py @@ -35,7 +35,7 @@ found in a subdirectory tree. Options: -g gcov-program - default:gcov6 + default: "llvm-cov gcov" -o output-filename default: stdout @@ -105,31 +105,35 @@ def run_gcov(prog, subdir): # if we find the .o file in a .../.libs the sources # must be found relative to the parent directory - if root[-6:] == "/.libs": - x = subprocess.check_output( - ["cd " + root + "/.. && " + - "exec " + prog + " .libs/" + fn], - stderr=subprocess.STDOUT, shell=True, - universal_newlines=True) - pf = ".." + if "varnishd" in root: + subdir = root.split("/")[-1] + cmd = ["cd " + root + "/.. && " + "exec " + prog + " " + subdir + "/" + fn] + rpath = "/../" + elif root[-6:] == "/.libs": + cmd = ["cd " + root + "/.. && " + "exec " + prog + " .libs/" + fn] + rpath = "/../" else: - x = subprocess.check_output( - ["cd " + root + " && " + - "exec " + prog + " " + fn], + cmd = ["cd " + root + " && " + "exec " + prog + " " + fn] + rpath = "/" + + x = subprocess.check_output( + cmd, stderr=subprocess.STDOUT, shell=True, universal_newlines=True) - pf = "" + pf = "" for ln in x.split("\n"): + if "such file" in ln: + print("LN", ln) + assert "such file" not in ln ln = ln.split() if not ln: continue if ln[0].find("reating") != -1: - gn = ln[1].strip("'") + gn = root + rpath + ln[1].strip("'") assert gn[-5:] == ".gcov" - sn = gn[:-5] - process_gcov( - os.path.join(root, pf, gn), sn) + sn = root + rpath + gn[:-5] + process_gcov(gn, sn) def produce_output(fdo): """ @@ -182,7 +186,7 @@ if __name__ == "__main__": fo = sys.stdout gcovprog = os.environ.get('GCOVPROG') if gcovprog is None: - gcovprog = "gcov6 -r" + gcovprog = "llvm-cov gcov" for f, v in optlist: if f == '-o' and v == '-': From phk at FreeBSD.org Mon Oct 31 12:05:07 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 31 Oct 2022 12:05:07 +0000 (UTC) Subject: [master] b97517728 More gcov fixes Message-ID: <20221031120507.37A3A43D5@lists.varnish-cache.org> commit b97517728bdc709ec59bc727aeae7dad03f7b89e Author: Poul-Henning Kamp Date: Mon Oct 31 12:04:37 2022 +0000 More gcov fixes diff --git a/tools/gcov_digest.py b/tools/gcov_digest.py index 17ce3da08..eb6fa58c3 100644 --- a/tools/gcov_digest.py +++ b/tools/gcov_digest.py @@ -131,8 +131,9 @@ def run_gcov(prog, subdir): continue if ln[0].find("reating") != -1: gn = root + rpath + ln[1].strip("'") + gn = os.path.normpath(gn) assert gn[-5:] == ".gcov" - sn = root + rpath + gn[:-5] + sn = gn[:-5] process_gcov(gn, sn) def produce_output(fdo): From phk at FreeBSD.org Mon Oct 31 15:01:13 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 31 Oct 2022 15:01:13 +0000 (UTC) Subject: [master] ca4573d1a Experimental patch to send function-keys to vtc processes. Message-ID: <20221031150113.88357611C2@lists.varnish-cache.org> commit ca4573d1a6cc6fc3286e7d31208174204226da41 Author: Poul-Henning Kamp Date: Mon Oct 31 14:59:53 2022 +0000 Experimental patch to send function-keys to vtc processes. (May not work due to termcap/terminfo differences) diff --git a/bin/varnishtest/tests/u00008.vtc b/bin/varnishtest/tests/u00008.vtc index 5e6e827ad..59eafd517 100644 --- a/bin/varnishtest/tests/u00008.vtc +++ b/bin/varnishtest/tests/u00008.vtc @@ -11,9 +11,9 @@ varnish v1 -vcl+backend { } } -start -process p1 -dump {varnishstat -n ${v1_name}} -start -process p2 -dump {varnishstat -n ${v1_name}} -start -process p3 -dump {varnishstat -n ${v1_name}} -start +process p1 {varnishstat -n ${v1_name}} -start +process p2 {varnishstat -n ${v1_name}} -start +process p3 {varnishstat -n ${v1_name}} -start process p1 -expect-text 0 0 "VBE.vcl1.s1.happy" process p1 -screen_dump @@ -66,6 +66,24 @@ process p1 -winsz 25 132 process p1 -expect-text 4 124 "AVG_1000" process p1 -expect-text 22 108 "UNSEEN DIAG" +process p1 -key NPAGE +process p1 -expect-text 0 0 "VBE.vcl1.s1.helddown" +process p1 -screen_dump + +process p1 -key PPAGE +process p1 -expect-text 0 0 "VBE.vcl1.s1.happy" +process p1 -screen_dump + +process p1 -key END +process p1 -expect-text 22 1 " " +process p1 -expect-text 4 1 "^^^" +process p1 -screen_dump + +process p1 -key HOME +process p1 -expect-text 22 1 "vvv" +process p1 -expect-text 4 1 " " +process p1 -screen_dump + process p1 -screen_dump -write {q} -wait process p2 -screen_dump -kill TERM -wait process p3 -screen_dump -kill HUP -wait diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index b24404c89..07e9ae4b1 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -964,6 +964,11 @@ process_close(struct process *p) * expression from either output, consider using it if you only need * to match one. * + * \-key KEYSYM + * Send emulated key-press. + * KEYSYM can be one of (NPAGE, PPAGE, HOME, END) + * + * * \-kill SIGNAL * Send a signal to the process. The argument can be either * the string "TERM", "INT", or "KILL" for SIGTERM, SIGINT or SIGKILL @@ -1100,6 +1105,19 @@ cmd_process(CMD_ARGS) p->log = 3; continue; } + if (!strcmp(*av, "-key")) { + if (!strcmp(av[1], "NPAGE")) + process_write(p, "\x1b\x5b\x36\x7e"); + else if (!strcmp(av[1], "PPAGE")) + process_write(p, "\x1b\x5b\x35\x7e"); + else if (!strcmp(av[1], "HOME")) + process_write(p, "\x1b\x4f\x48"); + else if (!strcmp(av[1], "END")) + process_write(p, "\x1b\x4f\x46"); + else + vtc_fatal(p->vl, "Unknown key %s", av[1]); + continue; + } if (!strcmp(*av, "-kill")) { process_kill(p, av[1]); av++;