[Network] Prune / disconnect TCP connections gracefully (#4574)

This commit is contained in:
Chris Miles 2025-01-05 23:48:00 -06:00 committed by GitHub
parent fe43d26dd6
commit c44596b38a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 2 additions and 73 deletions

View File

@ -80,6 +80,8 @@ void EQ::Net::TCPConnection::Start() {
}
}
else if (nread == UV_EOF) {
connection->Disconnect();
if (buf->base) {
delete[] buf->base;
}

View File

@ -51,12 +51,6 @@ WorldServer::WorldServer(std::shared_ptr<EQ::Net::ServertalkServerConnection> wo
ServerOP_LSAccountUpdate,
std::bind(&WorldServer::ProcessLSAccountUpdate, this, std::placeholders::_1, std::placeholders::_2)
);
m_keepalive = std::make_unique<EQ::Timer>(
1000,
true,
std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1)
);
}
WorldServer::~WorldServer() = default;
@ -1307,12 +1301,6 @@ const std::string &WorldServer::GetVersion() const
return m_version;
}
void WorldServer::OnKeepAlive(EQ::Timer *t)
{
ServerPacket pack(ServerOP_KeepAlive, 0);
m_connection->SendPacket(&pack);
}
void WorldServer::FormatWorldServerName(char *name, int8 server_list_type)
{
std::string server_long_name = name;

View File

@ -187,13 +187,6 @@ private:
bool m_is_server_logged_in;
bool m_is_server_trusted;
/**
* Keepalive
* @param t
*/
void OnKeepAlive(EQ::Timer *t);
std::unique_ptr<EQ::Timer> m_keepalive;
static void FormatWorldServerName(char *name, int8 server_list_type);
};

View File

@ -595,11 +595,6 @@ bool LoginServer::Connect()
);
}
m_keepalive = std::make_unique<EQ::Timer>(
1000,
true,
std::bind(&LoginServer::OnKeepAlive, this, std::placeholders::_1));
return true;
}
@ -716,8 +711,3 @@ void LoginServer::SendAccountUpdate(ServerPacket *pack)
}
}
void LoginServer::OnKeepAlive(EQ::Timer *t)
{
ServerPacket pack(ServerOP_KeepAlive, 0);
SendPacket(&pack);
}

View File

@ -50,7 +50,6 @@ private:
void ProcessLSRemoteAddr(uint16_t opcode, EQ::Net::Packet &p);
void ProcessLSAccountUpdate(uint16_t opcode, EQ::Net::Packet &p);
void OnKeepAlive(EQ::Timer *t);
std::unique_ptr<EQ::Timer> m_keepalive;
std::unique_ptr<EQ::Net::ServertalkClient> m_client;

View File

@ -22,7 +22,6 @@ void QueryServConnection::AddConnection(std::shared_ptr<EQ::Net::ServertalkServe
connection->OnMessage(ServerOP_QueryServGeneric, std::bind(&QueryServConnection::HandleGenericMessage, this, std::placeholders::_1, std::placeholders::_2));
connection->OnMessage(ServerOP_LFGuildUpdate, std::bind(&QueryServConnection::HandleLFGuildUpdateMessage, this, std::placeholders::_1, std::placeholders::_2));
m_streams.emplace(std::make_pair(connection->GetUUID(), connection));
m_keepalive = std::make_unique<EQ::Timer>(1000, true, std::bind(&QueryServConnection::OnKeepAlive, this, std::placeholders::_1));
}
void QueryServConnection::RemoveConnection(std::shared_ptr<EQ::Net::ServertalkServerConnection> connection)
@ -54,8 +53,3 @@ bool QueryServConnection::SendPacket(ServerPacket* pack)
return true;
}
void QueryServConnection::OnKeepAlive(EQ::Timer *t)
{
ServerPacket pack(ServerOP_KeepAlive, 0);
SendPacket(&pack);
}

View File

@ -15,7 +15,6 @@ public:
void HandleGenericMessage(uint16_t opcode, EQ::Net::Packet &p);
void HandleLFGuildUpdateMessage(uint16_t opcode, EQ::Net::Packet &p);
bool SendPacket(ServerPacket* pack);
void OnKeepAlive(EQ::Timer *t);
private:
std::map<std::string, std::shared_ptr<EQ::Net::ServertalkServerConnection>> m_streams;
std::unique_ptr<EQ::Timer> m_keepalive;

View File

@ -31,8 +31,6 @@ void UCSConnection::SetConnection(std::shared_ptr<EQ::Net::ServertalkServerConne
)
);
}
m_keepalive = std::make_unique<EQ::Timer>(1000, true, std::bind(&UCSConnection::OnKeepAlive, this, std::placeholders::_1));
}
const std::shared_ptr<EQ::Net::ServertalkServerConnection> &UCSConnection::GetConnection() const
@ -92,13 +90,3 @@ void UCSConnection::SendMessage(const char *From, const char *Message)
SendPacket(pack);
safe_delete(pack);
}
void UCSConnection::OnKeepAlive(EQ::Timer *t)
{
if (!connection) {
return;
}
ServerPacket pack(ServerOP_KeepAlive, 0);
connection->SendPacket(&pack);
}

View File

@ -23,11 +23,6 @@ private:
inline std::string GetIP() const { return (connection && connection->Handle()) ? connection->Handle()->RemoteIP() : 0; }
std::shared_ptr<EQ::Net::ServertalkServerConnection> connection;
/**
* Keepalive
*/
std::unique_ptr<EQ::Timer> m_keepalive;
void OnKeepAlive(EQ::Timer *t);
};
#endif /*UCS_H_*/

View File

@ -42,7 +42,6 @@ ZSList::ZSList()
memset(pLockedZones, 0, sizeof(pLockedZones));
m_tick = std::make_unique<EQ::Timer>(5000, true, std::bind(&ZSList::OnTick, this, std::placeholders::_1));
m_keepalive = std::make_unique<EQ::Timer>(1000, true, std::bind(&ZSList::OnKeepAlive, this, std::placeholders::_1));
}
ZSList::~ZSList() {
@ -846,13 +845,6 @@ void ZSList::OnTick(EQ::Timer *t)
web_interface.SendEvent(out);
}
void ZSList::OnKeepAlive(EQ::Timer *t)
{
for (auto &zone : zone_server_list) {
zone->SendKeepAlive();
}
}
const std::list<std::unique_ptr<ZoneServer>> &ZSList::getZoneServerList() const
{
return zone_server_list;

View File

@ -72,7 +72,6 @@ public:
private:
void OnTick(EQ::Timer *t);
void OnKeepAlive(EQ::Timer *t);
uint32 NextID;
uint16 pLockedZones[MaxLockedZones];
uint32 CurGroupID;

View File

@ -91,8 +91,6 @@ void WorldServer::Connect()
});
m_connection->OnMessage(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
m_keepalive = std::make_unique<EQ::Timer>(1000, true, std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1));
}
bool WorldServer::SendPacket(ServerPacket *pack)
@ -4690,12 +4688,6 @@ void WorldServer::RequestTellQueue(const char *who)
return;
}
void WorldServer::OnKeepAlive(EQ::Timer *t)
{
ServerPacket pack(ServerOP_KeepAlive, 0);
SendPacket(&pack);
}
ZoneEventScheduler *WorldServer::GetScheduler() const
{
return m_zone_scheduler;

View File

@ -73,8 +73,6 @@ private:
uint32 cur_groupid;
uint32 last_groupid;
void OnKeepAlive(EQ::Timer *t);
std::unique_ptr<EQ::Net::ServertalkClient> m_connection;
std::unique_ptr<EQ::Timer> m_keepalive;