Commit 3826496b authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Lasse Karstensen

Don't rename the VSM file into place until we have started the

child process during startup.

Fixes #1407
parent 234c2ef5
......@@ -107,6 +107,7 @@ void mgt_SHM_Init(void);
void mgt_SHM_static_alloc(const void *, ssize_t size,
const char *class, const char *type, const char *ident);
void mgt_SHM_Create(void);
void mgt_SHM_Commit(void);
void mgt_SHM_Destroy(int keep);
void mgt_SHM_Size_Adjust(void);
......
......@@ -570,6 +570,7 @@ mgt_reap_child(void)
mgt_SHM_Destroy(0);
}
mgt_SHM_Create();
mgt_SHM_Commit();
if (child_state == CH_RUNNING)
child_state = CH_DIED;
......@@ -752,13 +753,15 @@ MGT_Run(void)
REPORT0(LOG_ERR, "No VCL loaded yet");
else if (!d_flag) {
mgt_launch_child(NULL);
if (child_state == CH_STOPPED) {
if (child_state != CH_RUNNING) {
// XXX correct? or 0?
exit_status = 2;
return;
}
}
mgt_SHM_Commit();
i = vev_schedule(mgt_evb);
if (i != 0)
REPORT(LOG_ERR, "vev_schedule() = %d", i);
......
......@@ -246,17 +246,28 @@ mgt_SHM_Create(void)
AN(VSC_C_mgt);
*VSC_C_mgt = static_VSC_C_mgt;
#ifdef __OpenBSD__
/* Commit changes, for OS's without coherent VM/buf */
AZ(msync(p, getpagesize(), MS_SYNC));
#endif
}
/*--------------------------------------------------------------------
* Commit the VSM
*/
void
mgt_SHM_Commit(void)
{
char fnbuf[64];
bprintf(fnbuf, "%s.%jd", VSM_FILENAME, (intmax_t)getpid());
if (rename(fnbuf, VSM_FILENAME)) {
fprintf(stderr, "Rename failed %s -> %s: %s\n",
fnbuf, VSM_FILENAME, strerror(errno));
(void)unlink(fnbuf);
exit(1);
}
#ifdef __OpenBSD__
/* Commit changes, for OS's without coherent VM/buf */
AZ(msync(p, getpagesize(), MS_SYNC));
#endif
}
/*--------------------------------------------------------------------
......
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