Commit 80beeb41 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make it possible for (vmod) functions called from vcl_init{} to set

"return(fail)" status, by making the "return(ok)" implicit.

Notice that setting a fail status does not break off vcl_init{} execution,
and that the final status is simply the last status set.
parent 202417a5
......@@ -192,7 +192,6 @@ sub vcl_backend_error {
# Housekeeping
sub vcl_init {
return (ok);
}
sub vcl_fini {
......
varnishtest "Test std & debug vmod"
varnishtest "Test vmod failure in vcl_init{}"
server s1 {
rxreq
......@@ -17,7 +17,6 @@ varnish v1 -errvcl "Planned failure in vcl_init" {
sub vcl_init {
debug.init_fail();
return (fail);
}
}
......
......@@ -700,7 +700,16 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
method_tab[i].name);
AZ(VSB_finish(tl->fm[i]));
Fc(tl, 1, "{\n");
/*
* We want vmods to be able set a FAIL return value
* in members called from vcl_init, so set OK up front
* and return with whatever was set last.
*/
if (method_tab[i].bitval == VCL_MET_INIT)
Fc(tl, 1, " VRT_handling(ctx, VCL_RET_OK);\n");
Fc(tl, 1, "%s", VSB_data(tl->fm[i]));
if (method_tab[i].bitval == VCL_MET_INIT)
Fc(tl, 1, " return(1);\n");
Fc(tl, 1, "}\n");
}
......
......@@ -33,6 +33,7 @@
#include "cache/cache.h"
#include "vcl.h"
#include "vrt.h"
#include "vsb.h"
#include "vcc_if.h"
......@@ -227,6 +228,7 @@ vmod_init_fail(VRT_CTX)
AN(ctx->msg);
VSB_printf(ctx->msg, "Planned failure in vcl_init{}");
VRT_handling(ctx, VCL_RET_FAIL);
}
static void __match_proto__(vmod_priv_free_f)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment