[master] 73fd9d730 Register the vmods unique (per-vcl) number

Poul-Henning Kamp phk at FreeBSD.org
Fri Aug 24 19:10:11 UTC 2018


commit 73fd9d730e4937eb0419702357544123b8ef8846
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Aug 23 08:08:17 2018 +0000

    Register the vmods unique (per-vcl) number

diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c
index ffd039ebc..25a119da4 100644
--- a/bin/varnishd/cache/cache_vrt_vmod.c
+++ b/bin/varnishd/cache/cache_vrt_vmod.c
@@ -53,6 +53,7 @@ struct vmod {
 	int			ref;
 
 	char			*nm;
+	unsigned		nbr;
 	char			*path;
 	char			*backup;
 	void			*hdl;
@@ -77,8 +78,8 @@ vmod_abi_mismatch(const struct vmod_data *d)
 }
 
 int
-VRT_Vmod_Init(VRT_CTX, struct vmod **hdl, void *ptr, int len, const char *nm,
-    const char *path, const char *file_id, const char *backup)
+VRT_Vmod_Init(VRT_CTX, struct vmod **hdl, unsigned nbr, void *ptr, int len,
+    const char *nm, const char *path, const char *file_id, const char *backup)
 {
 	struct vmod *v;
 	const struct vmod_data *d;
@@ -138,6 +139,7 @@ VRT_Vmod_Init(VRT_CTX, struct vmod **hdl, void *ptr, int len, const char *nm,
 			return (1);
 		}
 
+		v->nbr = nbr;
 		v->funclen = d->func_len;
 		v->funcs = d->func;
 		v->abi = d->abi;
diff --git a/include/vrt.h b/include/vrt.h
index 4c41976fd..f49478fc2 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -58,6 +58,7 @@
  *	VRT_CollectStrands() added
  *	VRT_STRANDS_string() removed from vrt.h (never implemented)
  *	VRT_Healthy() changed prototype
+ *	VRT_Vmod_Init signature changed
  * 7.0 (2018-03-15)
  *	lots of stuff moved from cache.h to cache_varnishd.h
  *	   (ie: from "$Abi vrt" to "$Abi strict")
@@ -471,7 +472,7 @@ void VRT_DelDirector(VCL_BACKEND *);
 int VRT_VSA_GetPtr(const struct suckaddr *sua, const unsigned char ** dst);
 
 /* VMOD/Modules related */
-int VRT_Vmod_Init(VRT_CTX, struct vmod **hdl, void *ptr, int len,
+int VRT_Vmod_Init(VRT_CTX, struct vmod **hdl, unsigned nbr, void *ptr, int len,
     const char *nm, const char *path, const char *file_id, const char *backup);
 void VRT_Vmod_Fini(struct vmod **hdl);
 
diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c
index a9cef1d71..fd6a7acc6 100644
--- a/lib/libvcc/vcc_vmod.c
+++ b/lib/libvcc/vcc_vmod.c
@@ -305,6 +305,7 @@ vcc_ParseImport(struct vcc *tl)
 
 	VSB_printf(ifp->ini, "\tif (VRT_Vmod_Init(ctx,\n");
 	VSB_printf(ifp->ini, "\t    &VGC_vmod_%.*s,\n", PF(mod));
+	VSB_printf(ifp->ini, "\t    %u,\n", tl->vmod_count++);
 	VSB_printf(ifp->ini, "\t    &Vmod_%.*s_Func,\n", PF(mod));
 	VSB_printf(ifp->ini, "\t    sizeof(Vmod_%.*s_Func),\n", PF(mod));
 	VSB_printf(ifp->ini, "\t    \"%.*s\",\n", PF(mod));
@@ -336,7 +337,6 @@ vcc_ParseImport(struct vcc *tl)
 	vcc_json_always(tl, msym);
 
 	Fh(tl, 0, "\n/* --- BEGIN VMOD %.*s --- */\n\n", PF(mod));
-	Fh(tl, 0, "#define VMOD_NUMBER_%.*s %u\n", PF(mod), tl->vmod_count++);
 	Fh(tl, 0, "static struct vmod *VGC_vmod_%.*s;\n", PF(mod));
 	Fh(tl, 0, "static struct vmod_priv vmod_priv_%.*s;\n", PF(mod));
 	Fh(tl, 0, "\n%s\n", vmd->proto);


More information about the varnish-commit mailing list