[master] 2c761ac79 fix: always wake the new head of the waiting queue

Nils Goroll nils.goroll at uplex.de
Fri Dec 13 10:10:06 UTC 2024


commit 2c761ac7952f298f06876e17b99e9da141ecb7c3
Author: Karl von Randow <karl at cactuslab.com>
Date:   Thu Nov 21 13:44:37 2024 +1300

    fix: always wake the new head of the waiting queue
    
    Previously multiple threads could signal completion to one waiting queue head, resulting in underuse of available backend connections.

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index d3a98ac56..c4f64f42e 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -246,6 +246,12 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
 	}
 	if (cw->cw_state != CW_BE_BUSY)
 		bp->n_conn++;
+
+	if (!VTAILQ_EMPTY(&bp->cw_head) && !BE_BUSY(bp)) {
+		/* Signal the new head of the waiting queue */
+		vbe_connwait_signal_locked(bp);
+	}
+
 	Lck_Unlock(bp->director->mtx);
 
 	if (cw->cw_state == CW_BE_BUSY) {


More information about the varnish-commit mailing list