Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Network] Prune / disconnect TCP connections gracefully #4574

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/net/tcp_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ void EQ::Net::TCPConnection::Start() {
}
}
else if (nread == UV_EOF) {
connection->Disconnect();

if (buf->base) {
delete[] buf->base;
}
Expand Down
12 changes: 0 additions & 12 deletions loginserver/world_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 0 additions & 7 deletions loginserver/world_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,6 @@ class WorldServer {
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);
};

Expand Down
10 changes: 0 additions & 10 deletions world/login_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -716,8 +711,3 @@ void LoginServer::SendAccountUpdate(ServerPacket *pack)
}
}

void LoginServer::OnKeepAlive(EQ::Timer *t)
{
ServerPacket pack(ServerOP_KeepAlive, 0);
SendPacket(&pack);
}
1 change: 0 additions & 1 deletion world/login_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class LoginServer{
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;
Expand Down
6 changes: 0 additions & 6 deletions world/queryserv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -54,8 +53,3 @@ bool QueryServConnection::SendPacket(ServerPacket* pack)
return true;
}

void QueryServConnection::OnKeepAlive(EQ::Timer *t)
{
ServerPacket pack(ServerOP_KeepAlive, 0);
SendPacket(&pack);
}
1 change: 0 additions & 1 deletion world/queryserv.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class QueryServConnection
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;
Expand Down
12 changes: 0 additions & 12 deletions world/ucs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
5 changes: 0 additions & 5 deletions world/ucs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ class UCSConnection
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_*/
8 changes: 0 additions & 8 deletions world/zonelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion world/zonelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class ZSList

private:
void OnTick(EQ::Timer *t);
void OnKeepAlive(EQ::Timer *t);
uint32 NextID;
uint16 pLockedZones[MaxLockedZones];
uint32 CurGroupID;
Expand Down
8 changes: 0 additions & 8 deletions zone/worldserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions zone/worldserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ class WorldServer {
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;

Expand Down