[master] d8cc41bc0 shrink the critical section under the pool mutex by a bit

Nils Goroll nils.goroll at uplex.de
Thu Sep 27 09:21:06 UTC 2018


commit d8cc41bc0bee5a8fd1402963cc693e6890acedf0
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Thu Sep 27 11:17:27 2018 +0200

    shrink the critical section under the pool mutex by a bit
    
    Checking and preparing our worker struct does not need to happen
    under the lock.

diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 5b88a8338..589ce68cb 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -326,13 +326,12 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk)
 	CHECK_OBJ_NOTNULL(pp, POOL_MAGIC);
 	wrk->pool = pp;
 	while (1) {
-		Lck_Lock(&pp->mtx);
-
 		CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 
 		WS_Reset(wrk->aws, 0);
 		AZ(wrk->vsl);
 
+		Lck_Lock(&pp->mtx);
 		if (pp->nidle < pool_reserve())
 			prio_lim = TASK_QUEUE_RESERVE + 1;
 		else


More information about the varnish-commit mailing list