[master] 3469a4c Improve args to VXID_Get()
Poul-Henning Kamp
phk at FreeBSD.org
Tue Jul 22 16:36:55 CEST 2014
commit 3469a4c1296d70525d5e88c423acdcb6e9eb7154
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Jul 22 14:36:41 2014 +0000
Improve args to VXID_Get()
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 84f8c51..53b7c78 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -993,7 +993,7 @@ unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*);
/* cache_main.c */
#define VXID(u) ((u) & VSL_IDENTMASK)
-uint32_t VXID_Get(struct vxid_pool *v);
+uint32_t VXID_Get(struct worker *, uint32_t marker);
extern volatile struct params * cache_param;
void THR_SetName(const char *name);
const char* THR_GetName(void);
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index a3fc0b9..17874f1 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -135,7 +135,7 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req)
sz = cache_param->vsl_buffer;
VSL_Setup(bo->vsl, p, sz);
- bo->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_BACKENDMARKER;
+ bo->vsl->wid = VXID_Get(wrk, VSL_BACKENDMARKER);
p += sz;
p = (void*)PRNDUP(p);
assert(p < bo->end);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index c06b1ec..11b15f5 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -233,8 +233,7 @@ vbf_stp_retry(struct worker *wrk, struct busyobj *bo)
VSLb_ts_busyobj(bo, "Retry", W_TIM_real(wrk));
// XXX: BereqEnd + BereqAcct ?
- VSL_ChgId(bo->vsl, "bereq", "retry",
- VXID_Get(&wrk->vxid_pool) | VSL_BACKENDMARKER);
+ VSL_ChgId(bo->vsl, "bereq", "retry", VXID_Get(wrk, VSL_BACKENDMARKER));
VSLb_ts_busyobj(bo, "Start", bo->t_prev);
return (F_STP_STARTFETCH);
diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c
index 031be54..4139bca 100644
--- a/bin/varnishd/cache/cache_http1_fsm.c
+++ b/bin/varnishd/cache/cache_http1_fsm.c
@@ -241,7 +241,7 @@ 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;
+ 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));
@@ -312,7 +312,7 @@ http1_dissect(struct worker *wrk, struct req *req)
* Allocate a new one only now that we know will need it.
*/
if (req->vsl->wid == 0) {
- req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER;
+ 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));
diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c
index 31d167d..665a024 100644
--- a/bin/varnishd/cache/cache_main.c
+++ b/bin/varnishd/cache/cache_main.c
@@ -116,8 +116,13 @@ static uint32_t vxid_chunk = 32768;
static struct lock vxid_lock;
uint32_t
-VXID_Get(struct vxid_pool *v)
+VXID_Get(struct worker *wrk, uint32_t mask)
{
+ struct vxid_pool *v;
+
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+ v = &wrk->vxid_pool;
+ AZ(VXID(mask));
do {
if (v->count == 0) {
Lck_Lock(&vxid_lock);
@@ -129,7 +134,7 @@ VXID_Get(struct vxid_pool *v)
v->count--;
v->next++;
} while (v->next == 0);
- return (v->next);
+ return (v->next | mask);
}
/*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index f613c5c..4987bda 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -647,7 +647,7 @@ cnt_restart(struct worker *wrk, struct req *req)
// XXX: ReqEnd + ReqAcct ?
VSLb_ts_req(req, "Restart", W_TIM_real(wrk));
VSL_ChgId(req->vsl, "req", "restart",
- VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER);
+ VXID_Get(wrk, VSL_CLIENTMARKER));
VSLb_ts_req(req, "Start", req->t_prev);
req->err_code = 0;
req->req_step = R_STP_RECV;
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index a58aa24..2aaf632 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -207,7 +207,7 @@ SES_pool_accept_task(struct worker *wrk, void *arg)
sp->t_open = VTIM_real();
sp->t_idle = sp->t_open;
- sp->vxid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER;
+ sp->vxid = VXID_Get(wrk, VSL_CLIENTMARKER);
lsockname = VCA_SetupSess(wrk, sp);
ses_vsl_socket(sp, lsockname);
@@ -362,7 +362,7 @@ SES_GetReq(struct worker *wrk, struct sess *sp)
sz = cache_param->vsl_buffer;
VSL_Setup(req->vsl, p, sz);
- req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER;
+ req->vsl->wid = VXID_Get(wrk, VSL_CLIENTMARKER);
p += sz;
p = (void*)PRNDUP(p);
More information about the varnish-commit
mailing list