Commit 39aa79d5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

More SHM creation polishing


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@472 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 36edd7fc
......@@ -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;
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment