Commit 1c21f941 authored by Geoff Simmons's avatar Geoff Simmons

the hosts.token() method may not be called in vcl_init

parent 467c3590
Pipeline #110 skipped
......@@ -154,6 +154,19 @@ client c1 {
} -run
# Usage
varnish v1 -errvcl {h.token() may not be called in vcl_init} {
import hoailona from "${vmod_topbuild}/src/.libs/libvmod_hoailona.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new p = hoailona.policy(OPEN, 1h);
new h = hoailona.hosts();
if (h.token() == "foo") {
return(fail);
}
}
}
varnish v1 -vcl {
import hoailona from "${vmod_topbuild}/src/.libs/libvmod_hoailona.so";
import std;
......
......@@ -626,6 +626,11 @@ vmod_hosts_token(VRT_CTX, struct vmod_hoailona_hosts *hosts,
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
CHECK_OBJ_NOTNULL(hosts, VMOD_HOAILONA_HOSTS_MAGIC);
if (INIT(ctx)) {
VERR(ctx, "%s.token() may not be called in vcl_init",
hosts->vcl_name);
return NULL;
}
if (ttl < 0) {
VERR(ctx, "ttl must not be < 0 in %s.token(): %f",
hosts->vcl_name, ttl);
......
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