Mailing List Archive

[master] f5d952c6a Consistently lock 'vsc' variable even if not necessary (for Coverity)
commit f5d952c6a3e1a692d913f1ebf0332e18f49ccdf3
Author: Poul-Henning Kamp <phk@FreeBSD.org>
Date: Wed Dec 6 10:10:27 2023 +0000

Consistently lock 'vsc' variable even if not necessary (for Coverity)

diff --git a/vmod/vmod_debug.c b/vmod/vmod_debug.c
index 2f5390f09..9a98fe700 100644
--- a/vmod/vmod_debug.c
+++ b/vmod/vmod_debug.c
@@ -714,8 +714,12 @@ event_discard(VRT_CTX, void *priv)
* of this VMOD, so we should only carry out cleanup on the
* last discard event.
*/
- if (vsc)
+ PTOK(pthread_mutex_lock(&vsc_mtx));
+ if (vsc != NULL) {
VSC_debug_Destroy(&vsc_seg);
+ vsc = NULL;
+ }
+ PTOK(pthread_mutex_unlock(&vsc_mtx));

return (0);
}
@@ -772,8 +776,10 @@ VCL_VOID
xyzzy_vsc_count(VRT_CTX, VCL_INT cnt)
{
(void)ctx;
+ PTOK(pthread_mutex_lock(&vsc_mtx));
AN(vsc);
vsc->count += cnt;
+ PTOK(pthread_mutex_unlock(&vsc_mtx));
}

VCL_VOID
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit