Commit 4442b286 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Tollef Fog Heen

Add Vmod_Id handle which VMOD can identify themselves to VRT with.

parent da4c405f
...@@ -56,6 +56,7 @@ struct vmod { ...@@ -56,6 +56,7 @@ struct vmod {
void *hdl; void *hdl;
const void *funcs; const void *funcs;
int funclen; int funclen;
const void *idptr;
}; };
static VTAILQ_HEAD(,vmod) vmods = VTAILQ_HEAD_INITIALIZER(vmods); 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, ...@@ -65,12 +66,12 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
const char *path, struct cli *cli) const char *path, struct cli *cli)
{ {
struct vmod *v; struct vmod *v;
void *x, *y, *z; void *x, *y, *z, *w;
ASSERT_CLI(); ASSERT_CLI();
VTAILQ_FOREACH(v, &vmods, list) VTAILQ_FOREACH(v, &vmods, list)
if (!strcmp(v->nm, nm)) if (!strcmp(v->nm, nm)) // Also path, len ?
break; break;
if (v == NULL) { if (v == NULL) {
ALLOC_OBJ(v, VMOD_MAGIC); ALLOC_OBJ(v, VMOD_MAGIC);
...@@ -88,7 +89,8 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, ...@@ -88,7 +89,8 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
x = dlsym(v->hdl, "Vmod_Name"); x = dlsym(v->hdl, "Vmod_Name");
y = dlsym(v->hdl, "Vmod_Len"); y = dlsym(v->hdl, "Vmod_Len");
z = dlsym(v->hdl, "Vmod_Func"); 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, "Loading VMOD %s from %s:\n", nm, path);
VCLI_Out(cli, "VMOD symbols not found\n"); VCLI_Out(cli, "VMOD symbols not found\n");
VCLI_Out(cli, "Check relative pathnames.\n"); VCLI_Out(cli, "Check relative pathnames.\n");
...@@ -99,6 +101,7 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, ...@@ -99,6 +101,7 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
AN(x); AN(x);
AN(y); AN(y);
AN(z); AN(z);
AN(w);
if (strcmp(x, nm)) { if (strcmp(x, nm)) {
VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path); VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path);
VCLI_Out(cli, "File contain wrong VMOD (\"%s\")\n", x); 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, ...@@ -116,6 +119,7 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm,
VSC_C_main->vmods++; VSC_C_main->vmods++;
VTAILQ_INSERT_TAIL(&vmods, v, list); VTAILQ_INSERT_TAIL(&vmods, v, list);
v->idptr = w;
} }
assert(len == v->funclen); assert(len == v->funclen);
......
...@@ -308,5 +308,9 @@ fc.write("\n"); ...@@ -308,5 +308,9 @@ fc.write("\n");
fc.write('const char * const Vmod_Spec[] = {\n' + slist + '\t0\n};\n') fc.write('const char * const Vmod_Spec[] = {\n' + slist + '\t0\n};\n')
fc.write('const char Vmod_Varnish_ABI[] = VMOD_ABI_Version;\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") fc.write("\n")
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