[6.0] 48d51ff6d Set be->cooled while holding backends_mtx

Reza Naghibi reza at naghibi.com
Tue Apr 20 18:29:05 UTC 2021


commit 48d51ff6d13655e0e6646a4d7aceeca2daaa8fdd
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Tue Dec 3 14:53:51 2019 +0100

    Set be->cooled while holding backends_mtx
    
    Several functions (VBE_Poll and vbe_destroy) tests be->cooled == 0 to
    determine which of the two lists backends and cool_backends a specific
    instance currently lives on. If the flag is in the process of being
    changed, then the wrong list head may be used and will result in strange
    bugs.
    
     Conflicts:
            bin/varnishd/cache/cache_backend.c

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 0e6e1ab59..b64ac8521 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -565,9 +565,9 @@ VRT_delete_backend(VRT_CTX, struct director **dp)
 	Lck_Lock(&be->mtx);
 	be->director->admin_health = VDI_AH_DELETED;
 	be->director->health_changed = VTIM_real();
-	be->cooled = VTIM_real() + 60.;
 	Lck_Unlock(&be->mtx);
 	Lck_Lock(&backends_mtx);
+	be->cooled = VTIM_real() + 60.;
 	VTAILQ_REMOVE(&backends, be, list);
 	VTAILQ_INSERT_TAIL(&cool_backends, be, list);
 	Lck_Unlock(&backends_mtx);


More information about the varnish-commit mailing list