[master] 6972c55b7 Clarify priv_task tear-down

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Wed Dec 26 11:01:06 UTC 2018


commit 6972c55b70da9711fcb46c489edcce5727b1c24e
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Wed Dec 26 11:58:30 2018 +0100

    Clarify priv_task tear-down
    
    Someone should triple-check that it is indeed safe.

diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c
index 9f7612bc4..211990cc3 100644
--- a/bin/varnishd/cache/cache_vrt_priv.c
+++ b/bin/varnishd/cache/cache_vrt_priv.c
@@ -206,8 +206,11 @@ VCL_TaskLeave(const struct vcl *vcl, struct vrt_privs *privs)
 
 	AN(vcl);
 	CHECK_OBJ_NOTNULL(privs, VRT_PRIVS_MAGIC);
-	VRBT_FOREACH_SAFE(vp, vrt_priv_tree, &privs->privs, vp1) {
+	/* NB: We don't bother removing entries as we finish them because it's
+	 * a costly operation. Instead we safely walk the whole tree and clear
+	 * the head at the very end.
+	 */
+	VRBT_FOREACH_SAFE(vp, vrt_priv_tree, &privs->privs, vp1)
 		VRT_priv_fini(vp->priv);
-	}
 	ZERO_OBJ(privs, sizeof *privs);
 }


More information about the varnish-commit mailing list