[6.0] 0a1463a23 do not unlock oh before the waitinglist setup is complete

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue Feb 12 10:03:10 UTC 2019


commit 0a1463a2381b2456cc0053d15e5c27a018b58cc9
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Dec 5 13:23:38 2018 +0100

    do not unlock oh before the waitinglist setup is complete
    
    The moment we unlock the oh, another thread could rush req
    
    Partially undoes f35b86bc1d3a9d1b61979667fc07e4fffedc27ae
    
    Huge thank you to @mbgrydeland for spotting my mistake

diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 78b61ce11..f4d2fecce 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -524,11 +524,9 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp)
 
 	/* There are one or more busy objects, wait for them */
 	VTAILQ_INSERT_TAIL(&oh->waitinglist, req, w_list);
-	Lck_Unlock(&oh->mtx);
 
 	AZ(req->hash_ignore_busy);
 
-	wrk->stats->busy_sleep++;
 	/*
 	 * The objhead reference transfers to the sess, we get it
 	 * back when the sess comes off the waiting list and
@@ -541,6 +539,9 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp)
 	if (DO_DEBUG(DBG_WAITINGLIST))
 		VSLb(req->vsl, SLT_Debug, "on waiting list <%p>", oh);
 
+	Lck_Unlock(&oh->mtx);
+
+	wrk->stats->busy_sleep++;
 	return (HSH_BUSY);
 }
 


More information about the varnish-commit mailing list