r174 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Tue Jun 13 15:10:09 CEST 2006


Author: phk
Date: 2006-06-13 15:10:09 +0200 (Tue, 13 Jun 2006)
New Revision: 174

Modified:
   trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Clone the stevedore before calling its init function and be more precise
about any optional arguments.


Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c	2006-06-13 08:05:33 UTC (rev 173)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c	2006-06-13 13:10:09 UTC (rev 174)
@@ -309,22 +309,27 @@
 static void
 setup_storage(const char *sflag)
 {
-	const char *p;
+	const char *p, *q;
+	struct stevedore *stp;
 
-	p = strchr(sflag, ',');
+	q = p = strchr(sflag, ',');
 	if (p == NULL)
-		p = strchr(sflag, '\0');
+		q = p = strchr(sflag, '\0');
+	else
+		q++;
 	if (!cmp_storage(&sma_stevedore, sflag, p)) {
-		heritage.stevedore = &sma_stevedore;
+		stp = &sma_stevedore;
 	} else if (!cmp_storage(&smf_stevedore, sflag, p)) {
-		heritage.stevedore = &smf_stevedore;
+		stp = &smf_stevedore;
 	} else {
 		fprintf(stderr, "Unknown storage method \"%*.*s\"\n",
 			p - sflag, p - sflag, sflag);
 		exit (2);
 	}
-	if (heritage.stevedore->init != NULL)
-		heritage.stevedore->init(heritage.stevedore, p);
+	heritage.stevedore = malloc(sizeof *heritage.stevedore);
+	*heritage.stevedore = *stp;
+	if (stp->init != NULL)
+		stp->init(heritage.stevedore, q);
 }
 
 /*--------------------------------------------------------------------*/




More information about the varnish-commit mailing list