r472 - in trunk/varnish-cache: bin/varnishd include

phk at projects.linpro.no phk at projects.linpro.no
Fri Jul 14 14:05:28 CEST 2006


Author: phk
Date: 2006-07-14 14:05:28 +0200 (Fri, 14 Jul 2006)
New Revision: 472

Modified:
   trunk/varnish-cache/bin/varnishd/shmlog.c
   trunk/varnish-cache/include/shmlog.h
Log:
More SHM creation polishing


Modified: trunk/varnish-cache/bin/varnishd/shmlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/shmlog.c	2006-07-14 11:44:28 UTC (rev 471)
+++ trunk/varnish-cache/bin/varnishd/shmlog.c	2006-07-14 12:05:28 UTC (rev 472)
@@ -129,6 +129,8 @@
 	    heritage.vsl_fd, 0);
 	assert(loghead != MAP_FAILED);
 
+	assert(loghead->magic == SHMLOGHEAD_MAGIC);
+	assert(loghead->hdrsize == sizeof *loghead);
 	/* XXX check sanity of loghead */
 	logstart = (unsigned char *)loghead + loghead->start;
 	AZ(pthread_mutex_init(&vsl_mutex, NULL));
@@ -151,8 +153,10 @@
 	    slh.hdrsize != sizeof slh) {
 		/* XXX more checks */
 
-		if (heritage.vsl_fd >= 0);
+		fprintf(stderr, "Creating new SHMFILE\n");
+		if (heritage.vsl_fd >= 0); {
 			close(heritage.vsl_fd);
+		}
 		unlink(fn);
 		heritage.vsl_fd = open(fn, O_RDWR | O_CREAT, 0644);
 		if (heritage.vsl_fd < 0) {
@@ -160,8 +164,8 @@
 			    fn, strerror(errno));
 			exit (1);
 		}
+
 		memset(&slh, 0, sizeof slh);
-
 		slh.magic = SHMLOGHEAD_MAGIC;
 		slh.hdrsize = sizeof slh;
 		slh.size = size;

Modified: trunk/varnish-cache/include/shmlog.h
===================================================================
--- trunk/varnish-cache/include/shmlog.h	2006-07-14 11:44:28 UTC (rev 471)
+++ trunk/varnish-cache/include/shmlog.h	2006-07-14 12:05:28 UTC (rev 472)
@@ -15,6 +15,8 @@
 #define SHMLOGHEAD_MAGIC	4185512498U	/* From /dev/random */
 	unsigned		magic;
 
+	unsigned		hdrsize;
+
 	/*
 	 * Byte offset into the file where the fifolog starts
  	 * This allows the header to expand later.




More information about the varnish-commit mailing list