From: phk Date: Fri, 14 Jul 2006 12:05:28 +0000 (+0000) Subject: More SHM creation polishing X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eedd17d743b6839951e0d7ce23e4b32c404fee52;p=varnish More SHM creation polishing git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@472 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/shmlog.c b/varnish-cache/bin/varnishd/shmlog.c index 6db63317..c42fdd39 100644 --- a/varnish-cache/bin/varnishd/shmlog.c +++ b/varnish-cache/bin/varnishd/shmlog.c @@ -129,6 +129,8 @@ VSL_Init(void) 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 @@ VSL_MgtInit(const char *fn, unsigned size) 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 @@ VSL_MgtInit(const char *fn, unsigned size) fn, strerror(errno)); exit (1); } - memset(&slh, 0, sizeof slh); + memset(&slh, 0, sizeof slh); slh.magic = SHMLOGHEAD_MAGIC; slh.hdrsize = sizeof slh; slh.size = size; diff --git a/varnish-cache/include/shmlog.h b/varnish-cache/include/shmlog.h index 2e61101b..4add0e14 100644 --- a/varnish-cache/include/shmlog.h +++ b/varnish-cache/include/shmlog.h @@ -15,6 +15,8 @@ struct shmloghead { #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.