[master] 4e0004e Eliminate some grubbing around inside struct ws

Poul-Henning Kamp phk at FreeBSD.org
Wed Feb 15 12:54:04 CET 2017


commit 4e0004eaa456654975aa0e0a32d51ad57bafd616
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Feb 15 11:28:15 2017 +0000

    Eliminate some grubbing around inside struct ws

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 43d87ca..b2a58a1 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -915,7 +915,7 @@ CNT_Request(struct worker *wrk, struct req *req)
 		 * empty on state-transitions.
 		 */
 		WS_Assert(wrk->aws);
-		assert(wrk->aws->s == wrk->aws->f);
+		AZ(WS_Snapshot(wrk->aws));
 
 		switch (req->req_step) {
 #define REQ_STEP(l,u,arg) \
diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c
index ec6b2bc..c4d64cb 100644
--- a/bin/varnishd/cache/cache_ws.c
+++ b/bin/varnishd/cache/cache_ws.c
@@ -215,7 +215,7 @@ WS_Snapshot(struct ws *ws)
 	WS_Assert(ws);
 	assert(ws->r == NULL);
 	DSL(DBG_WORKSPACE, 0, "WS_Snapshot(%p) = %p", ws, ws->f);
-	return ((uintptr_t)ws->f);
+	return (ws->f == ws->s ? 0 : (uintptr_t)ws->f);
 }
 
 unsigned
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 78dc111..76519f7 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -420,14 +420,17 @@ VCL_INT
 vmod_workspace_free(VRT_CTX, VCL_ENUM which)
 {
 	struct ws *ws;
+	unsigned u;
+
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 
 	ws = wsfind(ctx, which);
 
 	WS_Assert(ws);
-	AZ(ws->r);
+	u = WS_Reserve(ws, 0);
+	WS_Release(ws, 0);
 
-	return (pdiff(ws->f, ws->e));
+	return (u);
 }
 
 VCL_BOOL



More information about the varnish-commit mailing list