[master] f6a324e Pass the CTX to vmods init functions instad of the VCL_conf (which is part of the CTX).
Poul-Henning Kamp
phk at FreeBSD.org
Mon Jun 15 11:02:18 CEST 2015
commit f6a324ebd084332589a6a2bfc8edbd5c2c9c48c2
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jun 15 09:01:35 2015 +0000
Pass the CTX to vmods init functions instad of the VCL_conf (which is
part of the CTX).
Test that failing vmods init functions works.
Based on patch from Martin
diff --git a/bin/varnishtest/tests/m00022.vtc b/bin/varnishtest/tests/m00022.vtc
index c1d3542..29da34e 100644
--- a/bin/varnishtest/tests/m00022.vtc
+++ b/bin/varnishtest/tests/m00022.vtc
@@ -20,6 +20,17 @@ varnish v1 -errvcl "Planned failure in vcl_init" {
}
}
+varnish v1 -cliok "param.set nuke_limit 42"
+
+varnish v1 -errvcl "nuke_limit is not the answer." {
+
+ import ${vmod_debug};
+
+ backend default {
+ .host = "${s1_addr}";
+ }
+}
+
client c1 {
txreq
rxresp
diff --git a/include/vrt.h b/include/vrt.h
index 4ccadbc..36b0165 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -42,9 +42,9 @@
* - cache_vrt.c: -> ssize_t VRT_CacheReqBody(VRT_CTX, size_t)
*/
-#define VRT_MAJOR_VERSION 2U
+#define VRT_MAJOR_VERSION 3U
-#define VRT_MINOR_VERSION 2U
+#define VRT_MINOR_VERSION 0U
/***********************************************************************/
@@ -265,7 +265,7 @@ struct vmod_priv {
vmod_priv_free_f *free;
};
-typedef int vmod_init_f(struct vmod_priv *, const struct VCL_conf *);
+typedef int vmod_init_f(VRT_CTX, struct vmod_priv *);
void VRT_priv_fini(const struct vmod_priv *p);
struct vmod_priv *VRT_priv_task(VRT_CTX, void *vmod_id);
diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c
index c88c2ad..cbae127 100644
--- a/lib/libvcc/vcc_vmod.c
+++ b/lib/libvcc/vcc_vmod.c
@@ -199,7 +199,7 @@ vcc_ParseImport(struct vcc *tl)
if (ifp == NULL)
ifp = New_IniFin(tl);
VSB_printf(ifp->ini,
- "\tif (%s(&vmod_priv_%.*s, &VCL_conf))\n"
+ "\tif (%s(ctx, &vmod_priv_%.*s))\n"
"\t\treturn(1);",
p, PF(mod));
} else {
diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index bc4c3c4..4619f1d 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -189,7 +189,7 @@ class Vmod(object):
fo.write("\n")
fo.write("int " + self.init)
fo.write(
- "(struct vmod_priv *, const struct VCL_conf *);\n")
+ "(VRT_CTX, struct vmod_priv *);\n")
def c_typedefs_(self):
l = list()
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 28f37ab..a91e845 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -248,11 +248,16 @@ priv_vcl_free(void *priv)
}
int __match_proto__(vmod_init_f)
-init_function(struct vmod_priv *priv, const struct VCL_conf *cfg)
+init_function(VRT_CTX, struct vmod_priv *priv)
{
struct priv_vcl *priv_vcl;
- (void)cfg;
+ AN(ctx->msg);
+
+ if (cache_param->nuke_limit == 42) {
+ VSB_printf(ctx->msg, "nuke_limit is not the answer.");
+ return (-1);
+ }
ALLOC_OBJ(priv_vcl, PRIV_VCL_MAGIC);
AN(priv_vcl);
More information about the varnish-commit
mailing list