r3236 - in trunk/varnish-cache: bin/varnishtest/tests lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Mon Sep 29 10:12:20 CEST 2008


Author: phk
Date: 2008-09-29 10:12:19 +0200 (Mon, 29 Sep 2008)
New Revision: 3236

Added:
   trunk/varnish-cache/bin/varnishtest/tests/v00015.vtc
Modified:
   trunk/varnish-cache/lib/libvcl/vcc_parse.c
Log:
When a VCL subroutine does not terminate in an action, the compiled code
needs to explicitly set a return value of zero to say so.

Possibly fix for: #339



Added: trunk/varnish-cache/bin/varnishtest/tests/v00015.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00015.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00015.vtc	2008-09-29 08:12:19 UTC (rev 3236)
@@ -0,0 +1,29 @@
+# $Id$
+
+test "Check function calls with no action return"
+
+server s1 {
+	rxreq
+	expect req.url == "/"
+	expect req.http.foobar == "snafu"
+	txresp -body "slash"
+} -start 
+
+varnish v1 -vcl+backend {
+
+	sub vcl_recv {
+		call some_subr;
+	}
+
+	sub some_subr {
+		set req.http.foobar = "snafu";
+	}
+
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 200
+} -run
+

Modified: trunk/varnish-cache/lib/libvcl/vcc_parse.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_parse.c	2008-09-29 08:11:06 UTC (rev 3235)
+++ trunk/varnish-cache/lib/libvcl/vcc_parse.c	2008-09-29 08:12:19 UTC (rev 3236)
@@ -526,22 +526,31 @@
 			vcc_AddRef(tl, tl->t, R_FUNC);
 		}
 		tl->curproc = tl->mprocs[m];
+		Fb(tl, 1, "  /* ... from ");
+		vcc_Coord(tl, tl->fb, NULL);
+		Fb(tl, 0, " */\n");
 	} else {
 		tl->fb = tl->fc;
 		tl->curproc = vcc_AddProc(tl, tl->t);
 		vcc_AddDef(tl, tl->t, R_FUNC);
 		Fh(tl, 0, "static int VGC_function_%.*s (struct sess *sp);\n",
 		    PF(tl->t));
-		Fc(tl, 1, "static int\n");
+		Fc(tl, 1, "\nstatic int\n");
 		Fc(tl, 1, "VGC_function_%.*s (struct sess *sp)\n", PF(tl->t));
 	}
 	vcc_NextToken(tl);
 	tl->indent += INDENT;
 	Fb(tl, 1, "{\n");
 	L(tl, Compound(tl));
+	if (m == -1) {
+		/*
+		 * non-method subroutines must have an explicit non-action
+		 * return in case they just fall through the bottom.
+		 */
+		Fb(tl, 1, "  return(0);\n");
+	}
 	Fb(tl, 1, "}\n");
 	tl->indent -= INDENT;
-	Fb(tl, 0, "\n");
 	tl->fb = NULL;
 	tl->curproc = NULL;
 }




More information about the varnish-commit mailing list