Commit ede6a6dd authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Do pid checks before compat checks.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4802 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 65d4f55c
......@@ -108,7 +108,10 @@ mgt_SHM_Alloc(unsigned size, const char *type, const char *ident)
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 @@ vsl_goodold(int fd, unsigned size, unsigned s2)
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 @@ vsl_goodold(int fd, unsigned size, unsigned s2)
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 @@ vsl_goodold(int fd, unsigned size, unsigned s2)
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);
}
......
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