[master] c277f10 fix the vsc_new / vsc_destroy
Nils Goroll
nils.goroll at uplex.de
Fri Mar 9 17:54:07 UTC 2018
commit c277f10804680069dad5813a20f54d3271e6d17a
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Mar 9 18:48:24 2018 +0100
fix the vsc_new / vsc_destroy
73ba50b89ad9d33f62453667c8e8e93074f0f5cf was incomplete and I confused
vsc_seg and vsc staring at this trivial code
Ref: #2576
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 0534611..3ee5a0e 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -57,8 +57,8 @@ struct priv_vcl {
static VCL_DURATION vcl_release_delay = 0.0;
static pthread_mutex_t vsc_mtx = PTHREAD_MUTEX_INITIALIZER;
-static struct vsc_seg *vsc_seg;
-static struct VSC_debug *vsc;
+static struct vsc_seg *vsc_seg = NULL;
+static struct VSC_debug *vsc = NULL;
VCL_STRING v_matchproto_(td_debug_author)
xyzzy_author(VRT_CTX, VCL_ENUM person, VCL_ENUM someone)
@@ -364,9 +364,12 @@ xyzzy_vsc_new(VRT_CTX)
{
(void)ctx;
AZ(pthread_mutex_lock(&vsc_mtx));
- if (vsc == NULL)
+ if (vsc == NULL) {
+ AZ(vsc_seg);
vsc = VSC_debug_New(NULL, &vsc_seg, "");
+ }
AN(vsc);
+ AN(vsc_seg);
AZ(pthread_mutex_unlock(&vsc_mtx));
}
@@ -375,8 +378,11 @@ xyzzy_vsc_destroy(VRT_CTX)
{
(void)ctx;
AZ(pthread_mutex_lock(&vsc_mtx));
- if (vsc != NULL)
+ if (vsc != NULL) {
+ AN(vsc_seg);
VSC_debug_Destroy(&vsc_seg);
- AZ(vsc);
+ }
+ AZ(vsc_seg);
+ vsc = NULL;
AZ(pthread_mutex_unlock(&vsc_mtx));
}
More information about the varnish-commit
mailing list