[master] a4f7faec4 Test that vmod code is still present when calling a task_priv .fini

Nils Goroll nils.goroll at uplex.de
Thu Aug 30 10:33:11 UTC 2018


commit a4f7faec45bf3677e7ddbafcfa3ab672dedcce63
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Thu Aug 30 12:12:42 2018 +0200

    Test that vmod code is still present when calling a task_priv .fini
    
    Tests 20ab2abc36781b03605785c0a9ae463460cdffef

diff --git a/bin/varnishtest/tests/r02451.vtc b/bin/varnishtest/tests/r02451.vtc
index 2ff3facdc..0dc0a5a4c 100644
--- a/bin/varnishtest/tests/r02451.vtc
+++ b/bin/varnishtest/tests/r02451.vtc
@@ -44,8 +44,8 @@ varnish v1 -vcl+backend {
 
 logexpect l1 -v v1 -g raw -d 1 {
 	expect 0 0    CLI		{^Rd vcl.load}
-	expect 0 =    VCL_Log		{^func something to remember}
-	expect 0 =    VCL_Log		{^obj something to remember}
+	expect 4 =    VCL_Log		{^func something to remember}
+	expect 2 =    VCL_Log		{^obj something to remember}
 } -start
 
 client c1 {
diff --git a/bin/varnishtest/tests/v00041.vtc b/bin/varnishtest/tests/v00041.vtc
index 3bac4aa3d..a67928ca9 100644
--- a/bin/varnishtest/tests/v00041.vtc
+++ b/bin/varnishtest/tests/v00041.vtc
@@ -61,7 +61,11 @@ varnish v1 -arg "-p debug=+vclrel" -vcl+backend {
 
 logexpect l1 -v v1 -g raw -d 1 {
 	expect 0 0    CLI		{^Rd vcl.load}
+	expect 0 =    Debug		{^test_priv_task.*new.$}
+	expect 0 =    Debug		{^test_priv_task.*update.$}
+	expect 0 =    Debug		{^test_priv_task.*exists.$}
 	expect 0 =    VCL_Log		{^func something to remember}
+	expect 0 =    Debug		{^test_priv_task.*exists.$}
 	expect 0 =    VCL_Log		{^obj something to remember}
 
 	expect * 1002 Begin		fetch$
@@ -77,8 +81,14 @@ logexpect l1 -v v1 -g raw -d 1 {
 	expect 0 =    VCL_Log		^bar
 
 	expect * 0    Debug		{^vcl1: VCL_EVENT_COLD}
+	expect * 0    CLI		{^Rd vcl.discard}
+	expect 0 =    Debug		{^test_priv_task.*new.$}
+	expect 0 =    Debug		{^test_priv_task.*update.$}
+	expect 0 =    Debug		{^test_priv_task.*exists.$}
 	expect * =    VCL_Log		{^func cleaning up}
+	expect 0 =    Debug		{^test_priv_task.*exists.$}
 	expect 0 =    VCL_Log		{^obj cleaning up}
+	expect 0 =    Debug		{^priv_task_free}
 } -start
 
 client c1 {
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 5d84206fa..a3a78975a 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -123,16 +123,27 @@ xyzzy_test_priv_call(VRT_CTX, struct vmod_priv *priv)
 	}
 }
 
+static void
+priv_task_free(void *ptr)
+{
+	AN(ptr);
+	VSL(SLT_Debug, 0, "priv_task_free(%p)", ptr);
+	free(ptr);
+}
+
 VCL_STRING v_matchproto_(td_debug_test_priv_task)
 xyzzy_test_priv_task(VRT_CTX, struct vmod_priv *priv, VCL_STRING s)
 {
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 	if (s == NULL || *s == '\0') {
-		return priv->priv;
+		VSL(SLT_Debug, 0, "test_priv_task(%p) = %p (exists)",
+		    priv, priv->priv);
 	} else if (priv->priv == NULL) {
 		priv->priv = strdup(s);
-		priv->free = free;
+		priv->free = priv_task_free;
+		VSL(SLT_Debug, 0, "test_priv_task(%p) = %p (new)",
+		    priv, priv->priv);
 	} else {
 		char *n = realloc(priv->priv,
 		    strlen(priv->priv) + strlen(s) + 2);
@@ -141,7 +152,11 @@ xyzzy_test_priv_task(VRT_CTX, struct vmod_priv *priv, VCL_STRING s)
 		strcat(n, " ");
 		strcat(n, s);
 		priv->priv = n;
+		VSL(SLT_Debug, 0, "test_priv_task(%p) = %p (update)",
+		    priv, priv->priv);
 	}
+	if (priv->priv != NULL)
+		assert(priv->free == priv_task_free);
 	return (priv->priv);
 }
 


More information about the varnish-commit mailing list