mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
clean up econ sockets on shutdown. Closes #804
This commit is contained in:
parent
10c3e844d7
commit
9349af0085
|
@ -1331,6 +1331,8 @@ int CServer::Run()
|
|||
{
|
||||
if(m_aClients[i].m_State != CClient::STATE_EMPTY)
|
||||
m_NetServer.Drop(i, "Server shutdown");
|
||||
|
||||
m_Econ.Shutdown();
|
||||
}
|
||||
|
||||
GameServer()->OnShutdown();
|
||||
|
|
|
@ -145,3 +145,11 @@ void CEcon::Send(int ClientID, const char *pLine)
|
|||
else if(ClientID >= 0 && ClientID < NET_MAX_CONSOLE_CLIENTS && m_aClients[ClientID].m_State == CClient::STATE_AUTHED)
|
||||
m_NetConsole.Send(ClientID, pLine);
|
||||
}
|
||||
|
||||
void CEcon::Shutdown()
|
||||
{
|
||||
if(!m_Ready)
|
||||
return;
|
||||
|
||||
m_NetConsole.Close();
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
void Init(IConsole *pConsole);
|
||||
void Update();
|
||||
void Send(int ClientID, const char *pLine);
|
||||
void Shutdown();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,9 @@ bool CNetConsole::Open(NETADDR BindAddr, int Flags)
|
|||
{
|
||||
// zero out the whole structure
|
||||
mem_zero(this, sizeof(*this));
|
||||
m_Socket.type = NETTYPE_INVALID;
|
||||
m_Socket.ipv4sock = -1;
|
||||
m_Socket.ipv6sock = -1;
|
||||
|
||||
// open socket
|
||||
m_Socket = net_tcp_create(BindAddr);
|
||||
|
@ -31,7 +34,11 @@ void CNetConsole::SetCallbacks(NETFUNC_NEWCLIENT pfnNewClient, NETFUNC_DELCLIENT
|
|||
|
||||
int CNetConsole::Close()
|
||||
{
|
||||
// TODO: implement me
|
||||
for(int i = 0; i < NET_MAX_CONSOLE_CLIENTS; i++)
|
||||
m_aSlots[i].m_Connection.Disconnect("closing console");
|
||||
|
||||
net_tcp_close(m_Socket);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue