r4882 - trunk/varnish-cache/lib/libvarnishapi

phk at varnish-cache.org phk at varnish-cache.org
Fri Jun 4 11:46:25 CEST 2010


Author: phk
Date: 2010-06-04 11:46:24 +0200 (Fri, 04 Jun 2010)
New Revision: 4882

Modified:
   trunk/varnish-cache/lib/libvarnishapi/vsl.c
   trunk/varnish-cache/lib/libvarnishapi/vsl.h
   trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c
Log:
Move the -n processing up to VSL_Arg() time



Modified: trunk/varnish-cache/lib/libvarnishapi/vsl.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsl.c	2010-06-03 07:57:44 UTC (rev 4881)
+++ trunk/varnish-cache/lib/libvarnishapi/vsl.c	2010-06-04 09:46:24 UTC (rev 4882)
@@ -108,32 +108,25 @@
 {
 	int i;
 	struct shmloghead slh;
-	char *logname;
 
 	if (vd->vsl_lh != NULL)
 		return (0);
 
-	if (vin_n_arg(vd->n_opt, NULL, NULL, &logname)) {
-		fprintf(stderr, "Invalid instance name: %s\n",
-		    strerror(errno));
-		return (1);
-	}
-
-	vd->vsl_fd = open(logname, O_RDONLY);
+	vd->vsl_fd = open(vd->vsl, O_RDONLY);
 	if (vd->vsl_fd < 0) {
 		fprintf(stderr, "Cannot open %s: %s\n",
-		    logname, strerror(errno));
+		    vd->vsl, strerror(errno));
 		return (1);
 	}
 	i = read(vd->vsl_fd, &slh, sizeof slh);
 	if (i != sizeof slh) {
 		fprintf(stderr, "Cannot read %s: %s\n",
-		    logname, strerror(errno));
+		    vd->vsl, strerror(errno));
 		return (1);
 	}
 	if (slh.magic != SHMLOGHEAD_MAGIC) {
 		fprintf(stderr, "Wrong magic number in file %s\n",
-		    logname);
+		    vd->vsl);
 		return (1);
 	}
 
@@ -141,7 +134,7 @@
 	    PROT_READ, MAP_SHARED|MAP_HASSEMAPHORE, vd->vsl_fd, 0);
 	if (vd->vsl_lh == MAP_FAILED) {
 		fprintf(stderr, "Cannot mmap %s: %s\n",
-		    logname, strerror(errno));
+		    vd->vsl, strerror(errno));
 		return (1);
 	}
 	vd->vsl_end = (uint8_t *)vd->vsl_lh + slh.shm_size;

Modified: trunk/varnish-cache/lib/libvarnishapi/vsl.h
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsl.h	2010-06-03 07:57:44 UTC (rev 4881)
+++ trunk/varnish-cache/lib/libvarnishapi/vsl.h	2010-06-04 09:46:24 UTC (rev 4882)
@@ -37,6 +37,7 @@
 	unsigned		magic;
 #define VSL_MAGIC		0x6e3bd69b
 
+	char			*vsl;
 
 	int			vsl_fd;
 	struct shmloghead 	*vsl_lh;

Modified: trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c	2010-06-03 07:57:44 UTC (rev 4881)
+++ trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c	2010-06-04 09:46:24 UTC (rev 4882)
@@ -212,6 +212,11 @@
 		free(vd->n_opt);
 		vd->n_opt = strdup(opt);
 		assert(vd->n_opt != NULL);
+		if (vin_n_arg(vd->n_opt, NULL, NULL, &vd->vsl)) {
+			fprintf(stderr, "Invalid instance name: %s\n",
+			    strerror(errno));
+			return (-1);
+		}
 		return (1);
 	case 'r': return (vsl_r_arg(vd, opt));
 	case 's': return (vsl_s_arg(vd, opt));




More information about the varnish-commit mailing list