]> err.no Git - varnish/commitdiff
When a VCL subroutine does not terminate in an action, the compiled code
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 29 Sep 2008 08:12:19 +0000 (08:12 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 29 Sep 2008 08:12:19 +0000 (08:12 +0000)
needs to explicitly set a return value of zero to say so.

Possibly fix for: #339

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3236 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishtest/tests/v00015.vtc [new file with mode: 0644]
varnish-cache/lib/libvcl/vcc_parse.c

diff --git a/varnish-cache/bin/varnishtest/tests/v00015.vtc b/varnish-cache/bin/varnishtest/tests/v00015.vtc
new file mode 100644 (file)
index 0000000..c60bb45
--- /dev/null
@@ -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
+
index 848cfaae83807e24321a34f8da17263516d1b764..5f8e4d6e27b12608f44dfac5c57ecf6e79656073 100644 (file)
@@ -526,22 +526,31 @@ Function(struct tokenlist *tl)
                        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;
 }