[master] cfb309c Add a VXID() macro to strip client/backend bit from VXIDs.
Poul-Henning Kamp
phk at FreeBSD.org
Tue Jul 22 15:46:08 CEST 2014
commit cfb309cad60e0239bc7168082d73b4ab6b53744a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Jul 22 13:45:45 2014 +0000
Add a VXID() macro to strip client/backend bit from VXIDs.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index a6c7006..45f2713 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -992,6 +992,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 19326e9..0d72714 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -63,8 +63,8 @@ ved_include(struct req *preq, const char *src, const char *host)
req = SES_GetReq(wrk, preq->sp);
req->req_body_status = REQ_BODY_NONE;
AN(req->vsl->wid & 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 dd3ed1a..6cea948 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -340,8 +340,7 @@ EXP_NukeOne(struct busyobj *bo, struct lru *lru)
exp_mail_it(oc);
- VSLb(bo->vsl, SLT_ExpKill, "LRU x=%u",
- ObjGetXID(oc, bo->stats) & VSL_IDENTMASK);
+ VSLb(bo->vsl, SLT_ExpKill, "LRU x=%u", VXID(ObjGetXID(oc, bo->stats)));
AN(bo->stats);
AN(oc);
(void)HSH_DerefObjCore(bo->stats, &oc);
@@ -473,7 +472,7 @@ exp_expire(struct exp_priv *ep, double now)
o = ObjGetObj(oc, &ep->wrk->stats);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
VSLb(&ep->vsl, SLT_ExpKill, "EXP_Expired x=%u t=%.0f",
- ObjGetXID(oc, &ep->wrk->stats) & VSL_IDENTMASK,
+ VXID(ObjGetXID(oc, &ep->wrk->stats)),
EXP_Ttl(NULL, &oc->exp) - now);
(void)HSH_DerefObjCore(&ep->wrk->stats, &oc);
return (0);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 70efc36..1db32b4 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -238,7 +238,7 @@ vbf_stp_retry(struct worker *wrk, struct busyobj *bo)
VSLb(bo->vsl, SLT_Link, "bereq %u retry", 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);
@@ -272,8 +272,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod);
HTTP_Copy(bo->bereq, bo->bereq0);
- 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);
@@ -871,10 +870,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->refcount = 2;
diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c
index 049ca68..6fd2a8d 100644
--- a/bin/varnishd/cache/cache_http1_fsm.c
+++ b/bin/varnishd/cache/cache_http1_fsm.c
@@ -246,10 +246,9 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req)
if (HTTP1_Reinit(req->htc) == HTTP1_COMPLETE) {
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);
+ VSLb(req->vsl, SLT_Begin, "req %u rxreq", VXID(req->sp->vxid));
VSL(SLT_Link, req->sp->vxid, "req %u rxreq",
- req->vsl->wid & VSL_IDENTMASK);
+ VXID(req->vsl->wid));
VSLb_ts_req(req, "Start", sp->t_idle);
VSLb_ts_req(req, "Req", sp->t_idle);
req->t_req = req->t_prev;
@@ -318,10 +317,9 @@ http1_dissect(struct worker *wrk, struct req *req)
*/
if (req->vsl->wid == 0) {
req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER;
- VSLb(req->vsl, SLT_Begin, "req %u rxreq",
- req->sp->vxid & VSL_IDENTMASK);
+ VSLb(req->vsl, SLT_Begin, "req %u rxreq", VXID(req->sp->vxid));
VSL(SLT_Link, req->sp->vxid, "req %u rxreq",
- req->vsl->wid & VSL_IDENTMASK);
+ VXID(req->vsl->wid));
}
/* Borrow VCL reference from worker thread */
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 9eed031..7d7d10b 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -391,7 +391,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 ebace03..c00559b 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),
+ VXID(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
@@ -221,8 +221,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);
@@ -599,10 +598,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);
@@ -611,7 +609,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);
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 5b8a843..786a26e 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -134,8 +134,8 @@ ses_sess_pool_task(struct worker *wrk, void *arg)
req = SES_GetReq(wrk, sp);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
AN(req->vsl->wid & VSL_CLIENTMARKER);
- VSLb(req->vsl, SLT_Begin, "req %u rxreq", sp->vxid & VSL_IDENTMASK);
- VSL(SLT_Link, sp->vxid, "req %u rxreq", req->vsl->wid & VSL_IDENTMASK);
+ VSLb(req->vsl, SLT_Begin, "req %u rxreq", VXID(sp->vxid));
+ VSL(SLT_Link, sp->vxid, "req %u rxreq", VXID(req->vsl->wid));
sp->sess_step = S_STP_NEWREQ;
ses_req_pool_task(wrk, req);
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 28b131f..6796d8c 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -504,8 +504,7 @@ VRT_r_req_xid(const struct vrt_ctx *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 *
@@ -515,8 +514,7 @@ VRT_r_bereq_xid(const struct vrt_ctx *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