]> err.no Git - varnish/commitdiff
After compilation of a VCL program, do a test-load into the management
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 9 May 2007 10:55:33 +0000 (10:55 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 9 May 2007 10:55:33 +0000 (10:55 +0000)
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

index 4602bed246201e567aa2ec3145091fe8582086c0..d5fc867819dad7d103d2ae5b3113691de9e3dfd0 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <sys/types.h>
 
+#include <dlfcn.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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);