[PATCH 3/5] Pass the VRT_CTX down to the vmod init function
Martin Blix Grydeland
martin at varnish-software.com
Wed Jun 10 11:06:00 CEST 2015
This enables the vmod's to access the cli pointer and report errors
back to the user during vcl.load().
Also drop the VCL_conf pointer, as that is already included in the ctx.
This changes the VMOD ABI without backwards compatibility, we should
bump the major before release.
---
include/vrt.h | 3 ++-
lib/libvcc/vcc_vmod.c | 2 +-
lib/libvcc/vmodtool.py | 3 +--
lib/libvmod_debug/vmod_debug.c | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/vrt.h b/include/vrt.h
index dca5902..499eaac 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -40,6 +40,7 @@
*
* changes to consider with next VRT_MAJOR_VERSION bump:
* - cache_vrt.c: -> ssize_t VRT_CacheReqBody(VRT_CTX, size_t)
+ * - cache_vrt.h: vmod_init_f add VRT_CTX param
*/
#define VRT_MAJOR_VERSION 2U
@@ -265,7 +266,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 be36a44..2204f53 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",
p, PF(mod));
VSB_printf(ifp->ini, "\t\treturn (1);");
} else {
diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index bc4c3c4..5380e01 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -188,8 +188,7 @@ class Vmod(object):
if self.init != None:
fo.write("\n")
fo.write("int " + self.init)
- fo.write(
- "(struct vmod_priv *, const struct VCL_conf *);\n")
+ fo.write("(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 ccdcab3..38a8f68 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -237,11 +237,11 @@ 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);
ALLOC_OBJ(priv_vcl, PRIV_VCL_MAGIC);
AN(priv_vcl);
--
2.1.4
More information about the varnish-dev
mailing list