[master] 47d948d Add VSL_ChgId() to do the VSL dance and song for restart/retry

Poul-Henning Kamp phk at FreeBSD.org
Tue Jul 22 16:15:10 CEST 2014


commit 47d948d04e78aea4d8fb948057a5d79340a2d4a8
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Jul 22 14:14:41 2014 +0000

    Add VSL_ChgId() to do the VSL dance and song for restart/retry

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 833e8a0..84f8c51 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1097,6 +1097,8 @@ void VSM_Init(void);
 void *VSM_Alloc(unsigned size, const char *class, const char *type,
     const char *ident);
 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);
 void VSL_End(struct vsl_log *vsl);
 void VSM_Free(void *ptr);
 #ifdef VSL_ENDMARKER
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 859a53c..c06b1ec 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -226,7 +226,6 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo)
 static enum fetch_step
 vbf_stp_retry(struct worker *wrk, struct busyobj *bo)
 {
-	unsigned owid, wid;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
@@ -234,12 +233,8 @@ vbf_stp_retry(struct worker *wrk, struct busyobj *bo)
 	VSLb_ts_busyobj(bo, "Retry", W_TIM_real(wrk));
 
 	// XXX: BereqEnd + BereqAcct ?
-	wid = VXID_Get(&wrk->vxid_pool);
-	VSLb(bo->vsl, SLT_Link, "bereq %u retry", wid);
-	owid = VXID(bo->vsl->wid);
-	VSL_End(bo->vsl);
-	bo->vsl->wid = wid | VSL_BACKENDMARKER;
-	VSLb(bo->vsl, SLT_Begin, "bereq %u retry", owid);
+	VSL_ChgId(bo->vsl, "bereq", "retry",
+	    VXID_Get(&wrk->vxid_pool) | VSL_BACKENDMARKER);
 	VSLb_ts_busyobj(bo, "Start", bo->t_prev);
 
 	return (F_STP_STARTFETCH);
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 146661f..f613c5c 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -634,7 +634,6 @@ DOT err_restart [label="SYNTH",shape=plaintext]
 static enum req_fsm_nxt
 cnt_restart(struct worker *wrk, struct req *req)
 {
-	unsigned wid, owid;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
@@ -645,14 +644,10 @@ cnt_restart(struct worker *wrk, struct req *req)
 		req->err_code = 503;
 		req->req_step = R_STP_SYNTH;
 	} else {
-		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);
-		owid = req->vsl->wid & VSL_IDENTMASK;
-		VSL_End(req->vsl);
-		req->vsl->wid = wid | VSL_CLIENTMARKER;
-		VSLb(req->vsl, SLT_Begin, "req %u restart", owid);
+		VSL_ChgId(req->vsl, "req", "restart",
+		    VXID_Get(&wrk->vxid_pool) | 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_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index eb70686..7eba6ac 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -389,6 +389,20 @@ 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)
+{
+	uint32_t ovxid;
+
+	ovxid = vsl->wid;
+	VSLb(vsl, SLT_Link, "%s %u %s", typ, VXID(vxid), why);
+	VSL_End(vsl);
+	vsl->wid = vxid;
+	VSLb(vsl, SLT_Begin, "%s %u %s", typ, VXID(ovxid), why);
+}
+
+/*--------------------------------------------------------------------*/
+
+void
 VSL_End(struct vsl_log *vsl)
 {
 	txt t;



More information about the varnish-commit mailing list