[experimental-ims] 3a08c3d Add Vmod_Id handle which VMOD can identify themselves to VRT with.
Geoff Simmons
geoff at varnish-cache.org
Mon Jan 9 21:51:47 CET 2012
commit 3a08c3d95cace24133756e5e204ef73545921171
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Sep 8 11:53:05 2011 +0000
Add Vmod_Id handle which VMOD can identify themselves to VRT with.
diff --git a/bin/varnishd/cache_vrt_vmod.c b/bin/varnishd/cache_vrt_vmod.c
index 84a2bb7..bd2e172 100644
--- a/bin/varnishd/cache_vrt_vmod.c
+++ b/bin/varnishd/cache_vrt_vmod.c
@@ -56,6 +56,7 @@ struct vmod {
void *hdl;
const void *funcs;
int funclen;
+ const void *idptr;
};
static VTAILQ_HEAD(,vmod) vmods = VTAILQ_HEAD_INITIALIZER(vmods);
@@ -65,12 +66,12 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
const char *path, struct cli *cli)
{
struct vmod *v;
- void *x, *y, *z;
+ void *x, *y, *z, *w;
ASSERT_CLI();
VTAILQ_FOREACH(v, &vmods, list)
- if (!strcmp(v->nm, nm))
+ if (!strcmp(v->nm, nm)) // Also path, len ?
break;
if (v == NULL) {
ALLOC_OBJ(v, VMOD_MAGIC);
@@ -88,7 +89,8 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
x = dlsym(v->hdl, "Vmod_Name");
y = dlsym(v->hdl, "Vmod_Len");
z = dlsym(v->hdl, "Vmod_Func");
- if (x == NULL || y == NULL || z == NULL) {
+ w = dlsym(v->hdl, "Vmod_Id");
+ if (x == NULL || y == NULL || z == NULL || w == NULL) {
VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path);
VCLI_Out(cli, "VMOD symbols not found\n");
VCLI_Out(cli, "Check relative pathnames.\n");
@@ -99,6 +101,7 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
AN(x);
AN(y);
AN(z);
+ AN(w);
if (strcmp(x, nm)) {
VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path);
VCLI_Out(cli, "File contain wrong VMOD (\"%s\")\n", x);
@@ -116,6 +119,7 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
VSC_C_main->vmods++;
VTAILQ_INSERT_TAIL(&vmods, v, list);
+ v->idptr = w;
}
assert(len == v->funclen);
diff --git a/lib/libvmod_std/vmod.py b/lib/libvmod_std/vmod.py
index 83f8eca..1b0f1c0 100755
--- a/lib/libvmod_std/vmod.py
+++ b/lib/libvmod_std/vmod.py
@@ -308,5 +308,9 @@ fc.write("\n");
fc.write('const char * const Vmod_Spec[] = {\n' + slist + '\t0\n};\n')
fc.write('const char Vmod_Varnish_ABI[] = VMOD_ABI_Version;\n')
+
+fh.write('extern const void * const Vmod_Id;\n')
+fc.write('const void * const Vmod_Id = &Vmod_Id;\n')
+
fc.write("\n")
More information about the varnish-commit
mailing list