Fixed a potential deadlock ( http://forum.mc-server.org/showthread.php?tid=374 )
git-svn-id: http://mc-server.googlecode.com/svn/trunk@369 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
e4043be593
commit
0df305e226
@ -353,31 +353,36 @@ bool cServer::Tick(float a_Dt)
|
|||||||
|
|
||||||
cRoot::Get()->TickWorlds( a_Dt ); // TODO - Maybe give all worlds their own thread?
|
cRoot::Get()->TickWorlds( a_Dt ); // TODO - Maybe give all worlds their own thread?
|
||||||
|
|
||||||
|
cClientHandleList RemoveClients;
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CSClients);
|
cCSLock Lock(m_CSClients);
|
||||||
for (cClientHandleList::iterator itr = m_Clients.begin(); itr != m_Clients.end();)
|
for (cClientHandleList::iterator itr = m_Clients.begin(); itr != m_Clients.end();)
|
||||||
{
|
{
|
||||||
if ((*itr)->IsDestroyed())
|
if ((*itr)->IsDestroyed())
|
||||||
{
|
{
|
||||||
cClientHandle* RemoveMe = *itr;
|
RemoveClients.push_back(*itr); // Remove the client later, when CS is not held, to avoid deadlock ( http://forum.mc-server.org/showthread.php?tid=374 )
|
||||||
itr = m_Clients.erase(itr);
|
itr = m_Clients.erase(itr);
|
||||||
delete RemoveMe;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
(*itr)->Tick(a_Dt);
|
(*itr)->Tick(a_Dt);
|
||||||
++itr;
|
++itr;
|
||||||
}
|
} // for itr - m_Clients[]
|
||||||
}
|
}
|
||||||
|
for (cClientHandleList::iterator itr = RemoveClients.begin(); itr != RemoveClients.end(); ++itr)
|
||||||
|
{
|
||||||
|
delete *itr;
|
||||||
|
} // for itr - RemoveClients[]
|
||||||
|
|
||||||
cRoot::Get()->GetPluginManager()->Tick( a_Dt );
|
cRoot::Get()->GetPluginManager()->Tick( a_Dt );
|
||||||
|
|
||||||
if( !m_bRestarting )
|
if( !m_bRestarting )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_bRestarting = false;
|
m_bRestarting = false;
|
||||||
m_pState->RestartEvent.Set();
|
m_pState->RestartEvent.Set();
|
||||||
LOG("<<<<>>>>SIGNALLED SEMAPHORE");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user