[master] 6ab9e9c Add debug bit vmod_so_keep This makes it possible to load VMOD shared objects into a debugger after a varnishd crash.
Geoff Simmons
geoff at uplex.de
Thu Apr 20 15:32:05 CEST 2017
commit 6ab9e9cd6aad14b48224a349a0e801bae30b8f31
Author: Geoff Simmons <geoff at uplex.de>
Date: Thu Apr 20 15:14:40 2017 +0200
Add debug bit vmod_so_keep
This makes it possible to load VMOD shared objects into a debugger
after a varnishd crash.
diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 9a1a42b..618f976 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -272,7 +272,8 @@ mgt_vcl_del(struct vclprog *vp)
FREE_OBJ(vd);
if (VTAILQ_EMPTY(&vf->vcls)) {
- AZ(unlink(vf->fname));
+ if (! MGT_DO_DEBUG(DBG_VMOD_SO_KEEP))
+ AZ(unlink(vf->fname));
VTAILQ_REMOVE(&vmodhead, vf, list);
free(vf->fname);
FREE_OBJ(vf);
diff --git a/bin/varnishtest/tests/m00008.vtc b/bin/varnishtest/tests/m00008.vtc
index 202ce56..abeffb9 100644
--- a/bin/varnishtest/tests/m00008.vtc
+++ b/bin/varnishtest/tests/m00008.vtc
@@ -44,3 +44,9 @@ varnish v1 -errvcl {Malformed VMOD std} {
import std from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so";
}
+# Check creation and cleanup of copied shared objects for VMODs
+shell "test -e ./v1/vmod_cache/_vmod_std.*"
+
+varnish v1 -stop
+varnish v1 -cleanup
+shell -err "test -e ./v1/vmod_cache/_vmod_std.*"
diff --git a/bin/varnishtest/tests/m00030.vtc b/bin/varnishtest/tests/m00030.vtc
new file mode 100644
index 0000000..ff72884
--- /dev/null
+++ b/bin/varnishtest/tests/m00030.vtc
@@ -0,0 +1,17 @@
+varnishtest "debug bit vmod_so_keep"
+
+feature topbuild
+
+varnish v1 -vcl {
+ import std from "${topbuild}/lib/libvmod_std/.libs/";
+ backend b { .host = "${bad_backend}"; }
+} -start
+
+shell "test -e ./v1/vmod_cache/_vmod_std.*"
+
+varnish v1 -cliok "param.set debug +vmod_so_keep"
+
+# cf m00008.vtc
+varnish v1 -stop
+varnish v1 -cleanup
+shell "test -e ./v1/vmod_cache/_vmod_std.*"
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 22b0307..1f6a38f 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -1045,7 +1045,7 @@ varnish_expect(const struct varnish *v, char * const *av)
*
* \-cleanup
* Once Varnish is stopped, clean everything after it. This is only used
- * in one test and you should never need it.
+ * in very few tests and you should never need it.
*
* Once Varnish is started, you can talk to it (as you would through
* ``varnishadm``) with these additional switches::
diff --git a/include/tbl/debug_bits.h b/include/tbl/debug_bits.h
index e089022..50e4839 100644
--- a/include/tbl/debug_bits.h
+++ b/include/tbl/debug_bits.h
@@ -47,6 +47,7 @@ DEBUG_BIT(VSM_KEEP, vsm_keep, "Keep the VSM file on restart")
DEBUG_BIT(DROP_POOLS, drop_pools, "Drop thread pools (testing)")
DEBUG_BIT(SLOW_ACCEPTOR, slow_acceptor, "Slow down Acceptor")
DEBUG_BIT(H2_NOCHECK, h2_nocheck, "Disable various H2 checks")
+DEBUG_BIT(VMOD_SO_KEEP, vmod_so_keep, "Keep copied VMOD libraries")
#undef DEBUG_BIT
/*lint -restore */
More information about the varnish-commit
mailing list