mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fix race condition. Closes #2004
This commit is contained in:
parent
7a3ebd5948
commit
40dc9692aa
|
@ -71,6 +71,7 @@ public:
|
|||
STATE_ONLINE,
|
||||
STATE_DEMOPLAYBACK,
|
||||
STATE_QUITING,
|
||||
STATE_RESTARTING
|
||||
};
|
||||
|
||||
//
|
||||
|
|
|
@ -548,7 +548,7 @@ int *CClient::GetDirectInput(int Tick)
|
|||
// ------ state handling -----
|
||||
void CClient::SetState(int s)
|
||||
{
|
||||
if(m_State == IClient::STATE_QUITING)
|
||||
if(m_State >= IClient::STATE_QUITING)
|
||||
return;
|
||||
|
||||
int Old = m_State;
|
||||
|
@ -1016,9 +1016,7 @@ void CClient::DebugRender()
|
|||
|
||||
void CClient::Restart()
|
||||
{
|
||||
char aBuf[512];
|
||||
shell_execute(Storage()->GetBinaryPath(PLAT_CLIENT_EXEC, aBuf, sizeof aBuf));
|
||||
Quit();
|
||||
SetState(IClient::STATE_RESTARTING);
|
||||
}
|
||||
|
||||
void CClient::Quit()
|
||||
|
@ -2360,7 +2358,7 @@ void CClient::PumpNetwork()
|
|||
if(State() != IClient::STATE_DEMOPLAYBACK)
|
||||
{
|
||||
// check for errors
|
||||
if(State() != IClient::STATE_OFFLINE && State() != IClient::STATE_QUITING && m_NetClient[CLIENT_MAIN].State() == NETSTATE_OFFLINE)
|
||||
if(State() != IClient::STATE_OFFLINE && State() < IClient::STATE_QUITING && m_NetClient[CLIENT_MAIN].State() == NETSTATE_OFFLINE)
|
||||
{
|
||||
SetState(IClient::STATE_OFFLINE);
|
||||
Disconnect();
|
||||
|
@ -3053,7 +3051,7 @@ void CClient::Run()
|
|||
AutoCSV_Cleanup();
|
||||
|
||||
// check conditions
|
||||
if(State() == IClient::STATE_QUITING)
|
||||
if(State() >= IClient::STATE_QUITING)
|
||||
break;
|
||||
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
|
@ -3962,10 +3960,18 @@ int main(int argc, const char **argv) // ignore_convention
|
|||
// write down the config and quit
|
||||
pConfig->Save();
|
||||
|
||||
delete pKernel;
|
||||
bool Restarting = pClient->State() == CClient::STATE_RESTARTING;
|
||||
|
||||
pClient->~CClient();
|
||||
free(pClient);
|
||||
|
||||
if(Restarting)
|
||||
{
|
||||
char aBuf[512];
|
||||
shell_execute(pStorage->GetBinaryPath(PLAT_CLIENT_EXEC, aBuf, sizeof aBuf));
|
||||
}
|
||||
|
||||
delete pKernel;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue