[master] bea2939cd Set be->cooled while holding backends_mtx

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue Dec 24 14:57:06 UTC 2019


commit bea2939cd84f4ea165810e68e4537f65a73bd8b0
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.

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index a2c437416..197065932 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -653,9 +653,9 @@ VRT_delete_backend(VRT_CTX, VCL_BACKEND *dp)
 	CAST_OBJ_NOTNULL(be, d->priv, BACKEND_MAGIC);
 	Lck_Lock(&be->mtx);
 	VRT_DisableDirector(be->director);
-	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