Skip to content

Commit

Permalink
Allow user defined sub{}'s to return without specifing a handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsdphk committed Feb 22, 2017
1 parent 5f0bc82 commit b00cbb2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
23 changes: 23 additions & 0 deletions bin/varnishtest/tests/v00034.vtc
Expand Up @@ -24,3 +24,26 @@ varnish v1 -errvcl {Probe 'p1' redefined} {
probe p1 { }
backend s1 { .host = "127.0.0.1"; .probe = p1;}
}

varnish v1 -errvcl {Expected '(' got ';'} {
backend s1 { .host = "127.0.0.1"; }
sub vcl_recv { return; }
}

varnish v1 -vcl+backend {

sub foobar {
set resp.http.foo = "foo";
return;
set resp.http.foo = "bar";
}
sub vcl_deliver {
call foobar;
}
}

client c1 {
txreq
rxresp
expect resp.http.foo == "foo"
} -run
5 changes: 5 additions & 0 deletions lib/libvcc/vcc_action.c
Expand Up @@ -284,6 +284,11 @@ parse_return(struct vcc *tl)
const char *h;

vcc_NextToken(tl);
if (tl->t->tok == ';' && tl->fb == tl->fc) {
/* fb == fc means we're in a subroutine */
Fb(tl, 1, "return;\n");
return;
}
ExpectErr(tl, '(');
vcc_NextToken(tl);
ExpectErr(tl, ID);
Expand Down

0 comments on commit b00cbb2

Please sign in to comment.