From fe7730eace5927c3e40f9b80635e74b29e8a299e Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 9 May 2007 10:55:33 +0000 Subject: [PATCH] After compilation of a VCL program, do a test-load into the management process to catch any implementation-discrepancies between symbols used by the compiler and those implemented in the runtime. The situation will happen from time to time and there is no need to issue a panic when we can test sensibly for it. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1394 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/mgt_vcc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/varnish-cache/bin/varnishd/mgt_vcc.c b/varnish-cache/bin/varnishd/mgt_vcc.c index 4602bed2..d5fc8678 100644 --- a/varnish-cache/bin/varnishd/mgt_vcc.c +++ b/varnish-cache/bin/varnishd/mgt_vcc.c @@ -33,6 +33,7 @@ #include +#include #include #include #include @@ -59,7 +60,6 @@ struct vclprog { int active; }; - static TAILQ_HEAD(, vclprog) vclhead = TAILQ_HEAD_INITIALIZER(vclhead); /*--------------------------------------------------------------------*/ @@ -129,6 +129,7 @@ mgt_CallCc(const char *source, struct vsb *sb) FILE *fo, *fs; char *of, *sf, buf[BUFSIZ]; int i, j, sfd; + void *p; /* Create temporary C source file */ sf = strdup("/tmp/vcl.XXXXXXXX"); @@ -201,6 +202,17 @@ mgt_CallCc(const char *source, struct vsb *sb) of = NULL; } + /* Next, try to load the object into the management process */ + p = dlopen(of, RTLD_NOW | RTLD_LOCAL); + if (p == NULL) { + vsb_printf(sb, "Problem loading compiled VCL program:\n\t%s\n", + dlerror()); + unlink(of); + free(of); + of = NULL; + } else + AZ(dlclose(p)); + /* clean up and return */ unlink(sf); free(sf); -- 2.39.5