[4.0] ca37d86 Add a VXID() macro to strip client/backend bit from VXIDs.
Nils Goroll
nils.goroll at uplex.de
Mon Jul 13 16:56:07 CEST 2015
commit ca37d86639b90351f98484f2e6eee17a5f3638fa
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Tue Jul 22 13:45:45 2014 +0000
Add a VXID() macro to strip client/backend bit from VXIDs.
backport of master cfb309cad60e0239bc7168082d73b4ab6b53744a
Original commit Author: Poul-Henning Kamp <phk at FreeBSD.org>
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 0fb6206..c22878d 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1054,6 +1054,7 @@ unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*);
#undef HTTPH
/* cache_main.c */
+#define VXID(u) ((u) & VSL_IDENTMASK)
uint32_t VXID_Get(struct vxid_pool *v);
extern volatile struct params * cache_param;
void THR_SetName(const char *name);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index fee1240..45cfb32 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -64,8 +64,8 @@ ved_include(struct req *preq, const char *src, const char *host)
req->req_body_status = REQ_BODY_NONE;
AZ(req->vsl->wid);
req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER;
- VSLb(req->vsl, SLT_Begin, "req %u esi", preq->vsl->wid & VSL_IDENTMASK);
- VSLb(preq->vsl, SLT_Link, "req %u esi", req->vsl->wid & VSL_IDENTMASK);
+ VSLb(req->vsl, SLT_Begin, "req %u esi", VXID(preq->vsl->wid));
+ VSLb(preq->vsl, SLT_Link, "req %u esi", VXID(req->vsl->wid));
req->esi_level = preq->esi_level + 1;
HTTP_Copy(req->http0, preq->http0);
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index a893ecc..e55b6dd 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -334,8 +334,7 @@ EXP_NukeOne(struct busyobj *bo, struct lru *lru)
exp_mail_it(oc);
- VSLb(bo->vsl, SLT_ExpKill, "LRU x=%u",
- oc_getxid(bo->stats, oc) & VSL_IDENTMASK);
+ VSLb(bo->vsl, SLT_ExpKill, "LRU x=%u", VXID(oc_getxid(bo->stats, oc)));
AN(bo->stats);
AN(oc);
(void)HSH_DerefObjCore(bo->stats, &oc);
@@ -535,7 +534,7 @@ exp_expire(struct exp_priv *ep, double now)
o = oc_getobj(&ep->wrk->stats, oc);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
VSLb(&ep->vsl, SLT_ExpKill, "EXP_Expired x=%u t=%.0f",
- oc_getxid(&ep->wrk->stats, oc) & VSL_IDENTMASK,
+ VXID(oc_getxid(&ep->wrk->stats, oc)),
EXP_Ttl(NULL, o) - now);
(void)HSH_DerefObjCore(&ep->wrk->stats, &oc);
return (0);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index fbb7110..973be8d 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -148,7 +148,7 @@ vbf_beresp2obj(struct busyobj *bo)
VSB_delete(vary);
}
- obj->vxid = bo->vsl->wid;
+ obj->vxid = VXID(bo->vsl->wid);
WS_Assert(bo->ws_o);
/* Filter into object */
@@ -257,10 +257,10 @@ vbf_stp_retry(struct worker *wrk, struct busyobj *bo)
// XXX: BereqEnd + BereqAcct ?
wid = VXID_Get(&wrk->vxid_pool);
- VSLb(bo->vsl, SLT_Link, "bereq %u retry", wid);
+ VSLb(bo->vsl, SLT_Link, "bereq %u retry", VXID(wid));
VSLb(bo->vsl, SLT_End, "%s", "");
VSL_Flush(bo->vsl, 0);
- owid = bo->vsl->wid & VSL_IDENTMASK;
+ owid = VXID(bo->vsl->wid);
bo->vsl->wid = wid | VSL_BACKENDMARKER;
VSLb(bo->vsl, SLT_Begin, "bereq %u retry", owid);
VSLb_ts_busyobj(bo, "Start", bo->t_prev);
@@ -291,8 +291,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
else
AZ(bo->req);
- http_PrintfHeader(bo->bereq,
- "X-Varnish: %u", bo->vsl->wid & VSL_IDENTMASK);
+ http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(bo->vsl->wid));
VCL_backend_fetch_method(bo->vcl, wrk, NULL, bo, bo->bereq->ws);
@@ -915,10 +914,8 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
default: WRONG("Wrong fetch mode");
}
- VSLb(bo->vsl, SLT_Begin, "bereq %u %s",
- req->vsl->wid & VSL_IDENTMASK, how);
- VSLb(req->vsl, SLT_Link, "bereq %u %s",
- bo->vsl->wid & VSL_IDENTMASK, how);
+ VSLb(bo->vsl, SLT_Begin, "bereq %u %s", VXID(req->vsl->wid), how);
+ VSLb(req->vsl, SLT_Link, "bereq %u %s", VXID(bo->vsl->wid), how);
bo_fetch = bo;
bo->refcount = 2;
diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c
index f1a6889..1a6c416 100644
--- a/bin/varnishd/cache/cache_http1_fsm.c
+++ b/bin/varnishd/cache/cache_http1_fsm.c
@@ -309,10 +309,8 @@ http1_dissect(struct worker *wrk, struct req *req)
AZ(req->vsl->wid);
req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER;
- VSLb(req->vsl, SLT_Begin, "req %u rxreq",
- req->sp->vxid & VSL_IDENTMASK);
- VSL(SLT_Link, req->sp->vxid, "req %u rxreq",
- req->vsl->wid & VSL_IDENTMASK);
+ 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));
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/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 6d97386..994a426 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -376,7 +376,7 @@ pan_sess(const struct sess *sp)
VSB_printf(pan_vsp, " sp = %p {\n", sp);
VSB_printf(pan_vsp, " fd = %d, vxid = %u,\n",
- sp->fd, sp->vxid & VSL_IDENTMASK);
+ sp->fd, VXID(sp->vxid));
VSB_printf(pan_vsp, " client = %s %s,\n", sp->client_addr_str,
sp->client_port_str);
switch (sp->sess_step) {
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 40551f7..de33be3 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -108,11 +108,11 @@ cnt_deliver(struct worker *wrk, struct req *req)
if (req->wrk->stats.cache_hit)
http_PrintfHeader(req->resp,
- "X-Varnish: %u %u", req->vsl->wid & VSL_IDENTMASK,
- req->obj->vxid & VSL_IDENTMASK);
+ "X-Varnish: %u %u", VXID(req->vsl->wid),
+ req->obj->vxid);
else
http_PrintfHeader(req->resp,
- "X-Varnish: %u", req->vsl->wid & VSL_IDENTMASK);
+ "X-Varnish: %u", VXID(req->vsl->wid));
/* We base Age calculation upon the last timestamp taken during
client request processing. This gives some inaccuracy, but
@@ -231,8 +231,7 @@ cnt_synth(struct worker *wrk, struct req *req)
VTIM_format(now, date);
http_PrintfHeader(h, "Date: %s", date);
http_SetHeader(h, "Server: Varnish");
- http_PrintfHeader(req->resp,
- "X-Varnish: %u", req->vsl->wid & VSL_IDENTMASK);
+ http_PrintfHeader(req->resp, "X-Varnish: %u", VXID(req->vsl->wid));
http_PutResponse(h, "HTTP/1.1", req->err_code, req->err_reason);
AZ(req->synth_body);
@@ -610,10 +609,9 @@ cnt_pipe(struct worker *wrk, struct req *req)
wrk->stats.s_pipe++;
bo = VBO_GetBusyObj(wrk, req);
HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod);
- VSLb(bo->vsl, SLT_Begin, "bereq %u pipe", req->vsl->wid & VSL_IDENTMASK);
+ VSLb(bo->vsl, SLT_Begin, "bereq %u pipe", VXID(req->vsl->wid));
http_FilterReq(bo->bereq, req->http, 0); // XXX: 0 ?
- http_PrintfHeader(bo->bereq,
- "X-Varnish: %u", req->vsl->wid & VSL_IDENTMASK);
+ http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(req->vsl->wid));
http_SetHeader(bo->bereq, "Connection: close");
VCL_pipe_method(req->vcl, wrk, req, bo, req->http->ws);
@@ -622,7 +620,7 @@ cnt_pipe(struct worker *wrk, struct req *req)
INCOMPL();
assert(wrk->handling == VCL_RET_PIPE);
- VSLb(req->vsl, SLT_Link, "bereq %u pipe", bo->vsl->wid & VSL_IDENTMASK);
+ VSLb(req->vsl, SLT_Link, "bereq %u pipe", VXID(bo->vsl->wid));
PipeRequest(req, bo);
assert(WRW_IsReleased(wrk));
http_Teardown(bo->bereq);
@@ -662,10 +660,10 @@ cnt_restart(struct worker *wrk, struct req *req)
wid = VXID_Get(&wrk->vxid_pool);
// XXX: ReqEnd + ReqAcct ?
VSLb_ts_req(req, "Restart", W_TIM_real(wrk));
- VSLb(req->vsl, SLT_Link, "req %u restart", wid);
+ VSLb(req->vsl, SLT_Link, "req %u restart", VXID(wid));
VSLb(req->vsl, SLT_End, "%s", "");
VSL_Flush(req->vsl, 0);
- owid = req->vsl->wid & VSL_IDENTMASK;
+ owid = VXID(req->vsl->wid);
req->vsl->wid = wid | VSL_CLIENTMARKER;
VSLb(req->vsl, SLT_Begin, "req %u restart", owid);
VSLb_ts_req(req, "Start", req->t_prev);
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 45614c8..e875786 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -490,8 +490,7 @@ VRT_r_req_xid(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
- return (WS_Printf(ctx->req->http->ws, "%u",
- ctx->req->vsl->wid & VSL_IDENTMASK));
+ return (WS_Printf(ctx->req->http->ws, "%u", VXID(ctx->req->vsl->wid)));
}
const char *
@@ -501,8 +500,7 @@ VRT_r_bereq_xid(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
- return (WS_Printf(ctx->bo->bereq->ws, "%u",
- ctx->bo->vsl->wid & VSL_IDENTMASK));
+ return (WS_Printf(ctx->bo->bereq->ws, "%u", VXID(ctx->bo->vsl->wid)));
}
/*--------------------------------------------------------------------*/
More information about the varnish-commit
mailing list