clean up econ sockets on shutdown. Closes #804

This commit is contained in:
oy 2011-07-31 02:20:46 +02:00
parent 10c3e844d7
commit 9349af0085
4 changed files with 19 additions and 1 deletions

View file

@ -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();

View file

@ -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();
}

View file

@ -38,6 +38,7 @@ public:
void Init(IConsole *pConsole);
void Update();
void Send(int ClientID, const char *pLine);
void Shutdown();
};
#endif

View file

@ -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;
}