r4802 - trunk/varnish-cache/bin/varnishd

phk at varnish-cache.org phk at varnish-cache.org
Mon May 17 14:30:54 CEST 2010


Author: phk
Date: 2010-05-17 14:30:54 +0200 (Mon, 17 May 2010)
New Revision: 4802

Modified:
   trunk/varnish-cache/bin/varnishd/mgt_shmem.c
Log:
Do pid checks before compat checks.



Modified: trunk/varnish-cache/bin/varnishd/mgt_shmem.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_shmem.c	2010-05-17 10:24:12 UTC (rev 4801)
+++ trunk/varnish-cache/bin/varnishd/mgt_shmem.c	2010-05-17 12:30:54 UTC (rev 4802)
@@ -108,7 +108,10 @@
 	return (NULL);
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Try to reuse an existing shmem file, but try to not disturb another
+ * varnishd using the file.
+ */
 
 static int
 vsl_goodold(int fd, unsigned size, unsigned s2)
@@ -119,9 +122,7 @@
 
 	AZ(fstat(fd, &st));
 	if (!S_ISREG(st.st_mode))
-		ARGV_ERR("\t-l ...: Not a file\n");
-	if (st.st_size != size)
-		return (0);
+		ARGV_ERR("\tshmlog: Not a file\n");
 
 	memset(&slh, 0, sizeof slh);	/* XXX: for flexelint */
 	i = read(fd, &slh, sizeof slh);
@@ -131,8 +132,6 @@
 		return (0);
 	if (slh.hdrsize != sizeof slh)
 		return (0);
-	if (slh.start != s2)
-		return (0);
 
 	if (slh.master_pid != 0 && !kill(slh.master_pid, 0)) {
 		fprintf(stderr,
@@ -151,6 +150,15 @@
 		fprintf(stderr, "(We assume that process is busy dying.)\n");
 		return (0);
 	}
+
+	/* Sanity checks */
+
+	if (slh.start != s2)
+		return (0);
+
+	if (st.st_size != size)
+		return (0);
+
 	return (1);
 }
 




More information about the varnish-commit mailing list