resolved a shm suspend/resume bug on windows

develop
Petr Mrázek 2010-02-11 05:10:23 +00:00
parent 2b430ea432
commit 7fcc4d5e22
1 changed files with 11 additions and 2 deletions

@ -374,15 +374,18 @@ bool SHMProcess::suspend()
{ {
if(!d->attached) if(!d->attached)
{ {
cerr << "couldn't suspend, not attached" << endl;
return false; return false;
} }
if(d->suspended) if(d->suspended)
{ {
cerr << "couldn't suspend, already suspended" << endl;
return true; return true;
} }
((shm_cmd *)d->my_shm)->pingpong = DFPP_SUSPEND; ((shm_cmd *)d->my_shm)->pingpong = DFPP_SUSPEND;
if(!d->waitWhile(DFPP_SUSPEND)) if(!d->waitWhile(DFPP_SUSPEND))
{ {
cerr << "couldn't suspend, DF not responding to commands" << endl;
return false; return false;
} }
d->suspended = true; d->suspended = true;
@ -419,9 +422,15 @@ bool SHMProcess::forceresume()
bool SHMProcess::resume() bool SHMProcess::resume()
{ {
if(!d->attached) if(!d->attached)
{
cerr << "couldn't resume because of no attachment" << endl;
return false; return false;
}
if(!d->suspended) if(!d->suspended)
{
cerr << "couldn't resume because of not being suspended" << endl;
return true; return true;
}
((shm_cmd *)d->my_shm)->pingpong = DFPP_RUNNING; ((shm_cmd *)d->my_shm)->pingpong = DFPP_RUNNING;
d->suspended = false; d->suspended = false;
return true; return true;
@ -471,9 +480,9 @@ bool SHMProcess::attach()
} }
// we close the handle right here so we don't have to keep track of it // we close the handle right here so we don't have to keep track of it
CloseHandle(shmHandle); CloseHandle(shmHandle);
suspend();
g_pProcess = this;
d->attached = true; d->attached = true;
suspend();
g_pProcess = this;
return true; return true;
} }