Mailing List Archive

[master] c096659dd Fix surplus vcldir cleanup
commit c096659dd7b7932ead816d0389c9b24911e25dae
Author: Nils Goroll <nils.goroll@uplex.de>
Date: Wed Jan 31 09:28:13 2024 +0100

Fix surplus vcldir cleanup

in VRT_AddDirector, we create the new vcldir with an initial
reference, which we need to drop if we can not add it.

Compare:

VRT_AddDirector()
...
vdir->refcnt++;

vcldir_free()
...
AZ(vdir->refcnt);

Noticed when testing other experimental changes while working on
https://github.com/nigoroll/libvmod-dynamic/issues/110

#5 0x000055820c8cb845 in VAS_Fail (func=0x55820c904559 "vcldir_free", file=0x55820c903a47 "cache/cache_vrt_vcl.c",
line=150, cond=0x55820c90459a "(vdir->refcnt) == 0", kind=VAS_ASSERT) at vas.c:67
#6 0x000055820c83a442 in vcldir_free (vdir=0x7f662aa53140) at cache/cache_vrt_vcl.c:150
#7 0x000055820c839fe1 in VRT_AddDirector (ctx=0x7f662befe250, m=0x55820c965260 <vbe_methods_noprobe>,
priv=0x7f662aa20780, fmt=0x55820c900f7f "%s") at cache/cache_vrt_vcl.c:219
#8 0x000055820c7c7c4d in VRT_new_backend_clustered (ctx=0x7f662befe250, vc=0x0, vrt=0x7f662befdd10, via=0x0)
at cache/cache_backend.c:737
#9 0x000055820c7c8632 in VRT_new_backend (ctx=0x7f662befe250, vrt=0x7f662befdd10, via=0x0)
at cache/cache_backend.c:755

diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c
index 85b594b7d..fb7043963 100644
--- a/bin/varnishd/cache/cache_vrt_vcl.c
+++ b/bin/varnishd/cache/cache_vrt_vcl.c
@@ -218,6 +218,8 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv,
Lck_Unlock(&vcl_mtx);

if (temp == VCL_TEMP_COOLING) {
+ assert(vdir->refcnt == 1);
+ vdir->refcnt = 0;
vcldir_free(vdir);
return (NULL);
}
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit