Commit 0d587836 authored by Nils Goroll's avatar Nils Goroll

Add a vsc to vmod_debug for testing / troubleshooting

vmod_vtc might be a better place for it, but we should probably get $VSC
support in vmodtool first and generate the am_boilerplate for it.

Ref #2470
parent 8a84960f
......@@ -42,8 +42,21 @@ vcc_if.h vmod_debug.rst vmod_debug.man.rst: vcc_if.c
vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc
@PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc
.vsc.c:
$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $<
VSC_SRC = VSC_debug.vsc
VSC_GEN_C = VSC_debug.c
VSC_GEN_H = VSC_debug.h
BUILT_SOURCES = $(VSC_GEN_C)
libvmod_debug_la_SOURCES += $(VSC_SRC)
$(VSC_GEN_C): $(top_srcdir)/lib/libvcc/vsctool.py
EXTRA_DIST = vmod.vcc
CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \
$(builddir)/vmod_debug.rst \
$(builddir)/vmod_debug.man.rst
$(builddir)/vmod_debug.man.rst \
$(VSC_GEN_C) $(VSC_GEN_H)
#
.. varnish_vsc_begin:: debug
:oneliner: Example Counters
:order: 70
Test counters from vmod_debug
.. varnish_vsc:: foo
:type: counter
:level: debug
:oneliner: arbitrary counter
Just counting something
.. varnish_vsc_end:: debug
......@@ -213,3 +213,11 @@ Returns the size in bytes of a collection of C-datatypes.
* 'z' = size_t
* 'o' = off_t
* 'j' = intmax_t
$Function VOID vsc_new()
Add a vsc
$Function VOID vsc_destroy()
Remove a vsc
......@@ -42,6 +42,7 @@
#include "vtcp.h"
#include "vtim.h"
#include "vcc_if.h"
#include "VSC_debug.h"
#include "common/common_param.h"
......@@ -64,6 +65,9 @@ struct priv_vcl {
static VCL_DURATION vcl_release_delay = 0.0;
pthread_mutex_t vsc_mtx = PTHREAD_MUTEX_INITIALIZER;
static struct VSC_debug *vsc;
VCL_VOID __match_proto__(td_debug_panic)
xyzzy_panic(VRT_CTX, const char *str, ...)
{
......@@ -351,6 +355,10 @@ event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
case VCL_EVENT_LOAD: return (event_load(ctx, priv));
case VCL_EVENT_WARM: return (event_warm(ctx, priv));
case VCL_EVENT_COLD: return (event_cold(ctx, priv));
case VCL_EVENT_DISCARD:
if (vsc)
VSC_debug_Destroy(&vsc);
return (0);
default: return (0);
}
}
......@@ -565,3 +573,25 @@ xyzzy_typesize(VRT_CTX, VCL_STRING s)
}
return ((VCL_INT)i);
}
VCL_VOID
xyzzy_vsc_new(VRT_CTX)
{
(void)ctx;
AZ(pthread_mutex_lock(&vsc_mtx));
if (vsc == NULL)
vsc = VSC_debug_New("");
AN(vsc);
AZ(pthread_mutex_unlock(&vsc_mtx));
}
VCL_VOID
xyzzy_vsc_destroy(VRT_CTX)
{
(void)ctx;
AZ(pthread_mutex_lock(&vsc_mtx));
if (vsc)
VSC_debug_Destroy(&vsc);
AZ(vsc);
AZ(pthread_mutex_unlock(&vsc_mtx));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment