r3081 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Aug 11 17:08:39 CEST 2008


Author: phk
Date: 2008-08-11 17:08:38 +0200 (Mon, 11 Aug 2008)
New Revision: 3081

Modified:
   trunk/varnish-cache/bin/varnishd/mgt_vcc.c
Log:
Make the compile shared object be named $mumble.so to cater for
Solaris tool-chains.

Simplified slightly from submitted patch.

Submitted by:	Theo Schlossnagle


Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c	2008-08-11 10:04:00 UTC (rev 3080)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c	2008-08-11 15:08:38 UTC (rev 3081)
@@ -141,7 +141,8 @@
 	char cmdline[1024];
 	struct vsb cmdsb;
 	char sf[] = "./vcl.########.c";
-	char *of;
+	char of[sizeof sf + 1];
+	char *retval;
 	int p[2], sfd, srclen, status;
 	pid_t pid;
 	void *dlh;
@@ -167,10 +168,11 @@
 	AZ(close(sfd));
 
 	/* Name the output shared library by overwriting the final 'c' */
-	of = strdup(sf);
-	XXXAN(of);
-	assert(of[sizeof sf - 2] == 'c');
-	of[sizeof sf - 2] = 'o';
+	memcpy(of, sf, sizeof sf);
+	assert(sf[sizeof sf - 2] == 'c');
+	of[sizeof sf - 2] = 's';
+	of[sizeof sf - 1] = 'o';
+	of[sizeof sf] = '\0';
 	AN(vsb_new(&cmdsb, cmdline, sizeof cmdline, 0));
 	mgt_make_cc_cmd(&cmdsb, sf, of);
 	vsb_finish(&cmdsb);
@@ -181,7 +183,6 @@
 		vsb_printf(sb, "%s(): pipe() failed: %s",
 		    __func__, strerror(errno));
 		(void)unlink(sf);
-		free(of);
 		return (NULL);
 	}
 	assert(p[0] > STDERR_FILENO);
@@ -192,7 +193,6 @@
 		AZ(close(p[0]));
 		AZ(close(p[1]));
 		(void)unlink(sf);
-		free(of);
 		return (NULL);
 	}
 	if (pid == 0) {
@@ -217,7 +217,6 @@
 		vsb_printf(sb, "%s(): waitpid() failed: %s",
 		    __func__, strerror(errno));
 		(void)unlink(of);
-		free(of);
 		return (NULL);
 	}
 	if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
@@ -229,7 +228,6 @@
 		if (WCOREDUMP(status))
 			vsb_printf(sb, ", core dumped");
 		(void)unlink(of);
-		free(of);
 		return (NULL);
 	}
 
@@ -239,7 +237,6 @@
 		    "%s(): failed to load compiled VCL program:\n  %s",
 		    __func__, dlerror());
 		(void)unlink(of);
-		free(of);
 		return (NULL);
 	}
 
@@ -249,7 +246,9 @@
 	 */
 
 	AZ(dlclose(dlh));
-	return (of);
+	retval = strdup(of);
+	XXXAN(retval);
+	return (retval);
 }
 
 /*--------------------------------------------------------------------*/




More information about the varnish-commit mailing list