[master] 9ed99f61e Move the worker vcl cache to the private part

Poul-Henning Kamp phk at FreeBSD.org
Wed May 5 17:46:04 UTC 2021


commit 9ed99f61ebecb8471e87f3d6bdfde34b9937929d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed May 5 17:44:55 2021 +0000

    Move the worker vcl cache to the private part

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 7c7e0a15e..2ea190180 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -237,8 +237,6 @@ struct worker {
 
 	pthread_cond_t		cond;
 
-	struct vcl		*vcl;
-
 	struct ws		aws[1];
 
 	unsigned		cur_method;
diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index 8ee346cba..a57978e6a 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -445,8 +445,8 @@ vca_accept_task(struct worker *wrk, void *arg)
 		VTIM_sleep(.1);
 
 	/* Dont hold on to (possibly) discarded VCLs */
-	if (wrk->vcl != NULL)
-		VCL_Rel(&wrk->vcl);
+	if (wrk->wpriv->vcl != NULL)
+		VCL_Rel(&wrk->wpriv->vcl);
 
 	while (!ps->pool->die) {
 		INIT_OBJ(&wa, WRK_ACCEPT_MAGIC);
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 63531cd81..0d26f4615 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -1097,9 +1097,9 @@ CNT_Embark(struct worker *wrk, struct req *req)
 	req->vfc->wrk = req->wrk = wrk;
 	wrk->vsl = req->vsl;
 	if (req->req_step == R_STP_TRANSPORT && req->vcl == NULL) {
-		VCL_Refresh(&wrk->vcl);
-		req->vcl = wrk->vcl;
-		wrk->vcl = NULL;
+		VCL_Refresh(&wrk->wpriv->vcl);
+		req->vcl = wrk->wpriv->vcl;
+		wrk->wpriv->vcl = NULL;
 		VSLb(req->vsl, SLT_VCL_use, "%s", VCL_Name(req->vcl));
 	}
 
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index c9ccaabaf..96db999b1 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -81,6 +81,7 @@ struct worker_priv {
 	struct objcore		*nobjcore;
 	void			*nhashpriv;
 	struct vxid_pool	vxid_pool[1];
+	struct vcl		*vcl;
 };
 
 /*--------------------------------------------------------------------
@@ -480,7 +481,7 @@ void VCL_VRT_Init(void);
 const char *VCL_Return_Name(unsigned);
 const char *VCL_Method_Name(unsigned);
 void VCL_Refresh(struct vcl **);
-void VCL_Recache(struct worker *, struct vcl **);
+void VCL_Recache(const struct worker *, struct vcl **);
 void VCL_Ref(struct vcl *);
 void VCL_Rel(struct vcl **);
 VCL_BACKEND VCL_DefaultDirector(const struct vcl *);
diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c
index a862163ef..9dcd5a55b 100644
--- a/bin/varnishd/cache/cache_vrt_vcl.c
+++ b/bin/varnishd/cache/cache_vrt_vcl.c
@@ -91,20 +91,20 @@ VCL_Refresh(struct vcl **vcc)
 }
 
 void
-VCL_Recache(struct worker *wrk, struct vcl **vclp)
+VCL_Recache(const struct worker *wrk, struct vcl **vclp)
 {
 
 	AN(wrk);
 	AN(vclp);
 	CHECK_OBJ_NOTNULL(*vclp, VCL_MAGIC);
 
-	if (*vclp != vcl_active || wrk->vcl == vcl_active) {
+	if (*vclp != vcl_active || wrk->wpriv->vcl == vcl_active) {
 		VCL_Rel(vclp);
 		return;
 	}
-	if (wrk->vcl != NULL)
-		VCL_Rel(&wrk->vcl);
-	wrk->vcl = *vclp;
+	if (wrk->wpriv->vcl != NULL)
+		VCL_Rel(&wrk->wpriv->vcl);
+	wrk->wpriv->vcl = *vclp;
 	*vclp = NULL;
 }
 
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index bdb8d5734..6b4825633 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -155,8 +155,8 @@ WRK_Thread(struct pool *qp, size_t stacksize, unsigned thread_workspace)
 	AZ(w->pool);
 
 	VSL(SLT_WorkThread, 0, "%p end", w);
-	if (w->vcl != NULL)
-		VCL_Rel(&w->vcl);
+	if (w->wpriv->vcl != NULL)
+		VCL_Rel(&w->wpriv->vcl);
 	AZ(pthread_cond_destroy(&w->cond));
 	HSH_Cleanup(w);
 	Pool_Sumstat(w);
@@ -433,7 +433,7 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk)
 					 * so that we'll wake up and get a
 					 * chance to push stats. */
 					tmo = now + 1.;
-				else if (wrk->vcl == NULL)
+				else if (wrk->wpriv->vcl == NULL)
 					tmo = 0;
 				else if (DO_DEBUG(DBG_VTC_MODE))
 					tmo =  now + 1.;
@@ -468,8 +468,8 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk)
 					// Presumably ETIMEDOUT but we do not
 					// assert this because pthread condvars
 					// are not airtight.
-					if (wrk->vcl)
-						VCL_Rel(&wrk->vcl);
+					if (wrk->wpriv->vcl)
+						VCL_Rel(&wrk->wpriv->vcl);
 					now = VTIM_real();
 				}
 			} while (tp == NULL);
@@ -483,8 +483,8 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk)
 			memset(wrk->task, 0, sizeof wrk->task);
 			assert(wrk->pool == pp);
 			tp->func(wrk, tp->priv);
-			if (DO_DEBUG(DBG_VCLREL) && wrk->vcl != NULL)
-				VCL_Rel(&wrk->vcl);
+			if (DO_DEBUG(DBG_VCLREL) && wrk->wpriv->vcl != NULL)
+				VCL_Rel(&wrk->wpriv->vcl);
 			tpx = *wrk->task;
 			tp = &tpx;
 		} while (tp->func != NULL);
diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c
index 26207a3bc..88bc74a95 100644
--- a/bin/varnishd/http2/cache_http2_session.c
+++ b/bin/varnishd/http2/cache_http2_session.c
@@ -347,8 +347,8 @@ h2_new_session(struct worker *wrk, void *arg)
 	sp = req->sp;
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 
-	if (wrk->vcl)
-		VCL_Rel(&wrk->vcl);
+	if (wrk->wpriv->vcl)
+		VCL_Rel(&wrk->wpriv->vcl);
 
 	assert(req->transport == &H2_transport);
 


More information about the varnish-commit mailing list