[6.0] 980e51457 Make worker threads give up their VCL much sooner in VTC-environment and make sure the expects in the test are scrupulusly correct.

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Wed Oct 31 13:08:32 UTC 2018


commit 980e514574e60efb492e04882cc2e55bb59f0752
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Oct 16 10:16:00 2018 +0000

    Make worker threads give up their VCL much sooner in VTC-environment
    and make sure the expects in the test are scrupulusly correct.

diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 50839143b..4d546ffd3 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -321,6 +321,7 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk)
 {
 	struct pool_task *tp = NULL;
 	struct pool_task tpx, tps;
+	vtim_real tmo;
 	int i, prio_lim;
 
 	CHECK_OBJ_NOTNULL(pp, POOL_MAGIC);
@@ -370,8 +371,13 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk)
 			pp->nidle++;
 			do {
 				// see signaling_note at the top for explanation
-				i = Lck_CondWait(&wrk->cond, &pp->mtx,
-				    wrk->vcl == NULL ?  0 : wrk->lastused+60.);
+				if (wrk->vcl == NULL)
+					tmo = 0;
+				else if (DO_DEBUG(DBG_VTC_MODE))
+					tmo =  wrk->lastused+1.;
+				else
+					tmo =  wrk->lastused+60.;
+				i = Lck_CondWait(&wrk->cond, &pp->mtx, tmo);
 				if (i == ETIMEDOUT)
 					VCL_Rel(&wrk->vcl);
 			} while (wrk->task.func == NULL);
diff --git a/bin/varnishtest/tests/v00006.vtc b/bin/varnishtest/tests/v00006.vtc
index 9b84076d0..4a187c8a7 100644
--- a/bin/varnishtest/tests/v00006.vtc
+++ b/bin/varnishtest/tests/v00006.vtc
@@ -18,7 +18,9 @@ varnish v1 -arg "-p thread_pools=1" -vcl+backend { } -start
 
 # Give the varnishd a chance to start and create workers etc.
 # NB: This is important for to avoid mis-ordering of the workers.
-delay 1
+# delay 1
+
+varnish v1 -expect MAIN.threads == 10
 
 client c1 {
 	txreq -url "/bar"
@@ -47,6 +49,8 @@ varnish v1 -vcl {
 	}
 }
 
+varnish v1 -vsl_catchup
+
 varnish v1 -expect n_backend == 2
 varnish v1 -expect n_vcl_avail == 2
 varnish v1 -expect n_vcl_discard == 0
@@ -57,13 +61,17 @@ varnish v1 -cli "vcl.list"
 
 varnish v1 -cli "vcl.discard vcl1"
 
+varnish v1 -vsl_catchup
+
 # Give expiry thread a chance to let go
 delay 2
 
-# It won't go away as long as the workthread holds a VCL reference
-varnish v1 -expect n_backend == 2
-varnish v1 -expect n_vcl_avail == 1
-varnish v1 -expect n_vcl_discard == 1
+varnish v1 -vsl_catchup
+
+# It may not go away as long as the workthread holds a VCL reference
+varnish v1 -expect n_backend >= 1
+varnish v1 -expect n_vcl_avail >= 1
+varnish v1 -expect n_vcl_discard >= 0
 
 # Do another request through the new VCL to the new backend
 client c1 {
@@ -72,6 +80,8 @@ client c1 {
 	expect resp.status == 200
 } -run
 
+varnish v1 -vsl_catchup
+
 server s2 -wait
 
 # The workthread should have released its VCL reference now


More information about the varnish-commit mailing list