[master] 52e49f1 Rename debug.init_fail() to debug.fail() and make it general purpose.

Poul-Henning Kamp phk at FreeBSD.org
Mon Feb 6 10:24:05 CET 2017


commit 52e49f19898d00aab139acb504ec62e38803b34c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Feb 6 08:31:58 2017 +0000

    Rename debug.init_fail() to debug.fail() and make it general purpose.

diff --git a/bin/varnishtest/tests/m00022.vtc b/bin/varnishtest/tests/m00022.vtc
index 7a2299a..ce60baa 100644
--- a/bin/varnishtest/tests/m00022.vtc
+++ b/bin/varnishtest/tests/m00022.vtc
@@ -13,7 +13,7 @@ logexpect l1 -v v1 -g raw {
 
 } -start
 
-varnish v1 -errvcl "Planned failure in vcl_init" {
+varnish v1 -errvcl "Forced failure" {
 
 	import debug;
 	import std;
@@ -24,7 +24,7 @@ varnish v1 -errvcl "Planned failure in vcl_init" {
 
 	sub vcl_init {
 		std.log("Should happen first");
-		debug.init_fail();
+		debug.fail();
 		std.log("Should not happen");
 	}
 	sub vcl_fini {
diff --git a/bin/varnishtest/tests/m00023.vtc b/bin/varnishtest/tests/m00023.vtc
index 75970d3..919f3cb 100644
--- a/bin/varnishtest/tests/m00023.vtc
+++ b/bin/varnishtest/tests/m00023.vtc
@@ -19,7 +19,7 @@ varnish v1 -vcl+backend {
 
 	sub vcl_init {
 		if (!debug.match_acl(loopback, "127.0.0.127")) {
-			debug.init_fail();
+			debug.fail();
 		}
 	}
 
diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc
index a9d7d57..4fe903f 100644
--- a/lib/libvmod_debug/vmod.vcc
+++ b/lib/libvmod_debug/vmod.vcc
@@ -143,9 +143,9 @@ $Function VOID register_obj_events(PRIV_VCL)
 
 Register the vmod to receive expiry callbacks
 
-$Function VOID init_fail()
+$Function VOID fail()
 
-Function to fail vcl_init{}
+Function to fail vcl code.  (See also: RFC748)
 
 $Function VOID sleep(DURATION)
 
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 023cdc3..8e857fd 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -253,11 +253,13 @@ vmod_register_obj_events(VRT_CTX, struct vmod_priv *priv)
 }
 
 VCL_VOID __match_proto__()
-vmod_init_fail(VRT_CTX)
+vmod_fail(VRT_CTX)
 {
 
-	AN(ctx->msg);
-	VSB_printf(ctx->msg, "Planned failure in vcl_init{}");
+	if(ctx->msg != NULL)
+		VSB_printf(ctx->msg, "Forced failure");
+	else if (ctx->vsl != NULL)
+		VSLb(ctx->vsl, SLT_Debug, "Forced failure");
 	VRT_handling(ctx, VCL_RET_FAIL);
 }
 



More information about the varnish-commit mailing list