r1394 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Wed May 9 12:55:33 CEST 2007


Author: phk
Date: 2007-05-09 12:55:33 +0200 (Wed, 09 May 2007)
New Revision: 1394

Modified:
   trunk/varnish-cache/bin/varnishd/mgt_vcc.c
Log:
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.



Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c	2007-05-09 09:45:01 UTC (rev 1393)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c	2007-05-09 10:55:33 UTC (rev 1394)
@@ -33,6 +33,7 @@
 
 #include <sys/types.h>
 
+#include <dlfcn.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -59,7 +60,6 @@
 	int			active;
 };
 
-
 static TAILQ_HEAD(, vclprog) vclhead = TAILQ_HEAD_INITIALIZER(vclhead);
 
 /*--------------------------------------------------------------------*/
@@ -129,6 +129,7 @@
 	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 @@
 		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);




More information about the varnish-commit mailing list