From ce1472db1e0ce5130e30533398fb2da6ff50da9b Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Sat, 18 Feb 2023 05:40:51 -0600 Subject: [PATCH] [MySQL] Add keepalives to UCS and Loginserver (#2953) --- loginserver/main.cpp | 7 +++++++ ucs/ucs.cpp | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/loginserver/main.cpp b/loginserver/main.cpp index 43daa4551..af02b878b 100644 --- a/loginserver/main.cpp +++ b/loginserver/main.cpp @@ -288,9 +288,16 @@ int main(int argc, char **argv) LogInfo("[Config] [Security] IsPasswordLoginAllowed [{0}]", server.options.IsPasswordLoginAllowed()); LogInfo("[Config] [Security] IsUpdatingInsecurePasswords [{0}]", server.options.IsUpdatingInsecurePasswords()); + Timer keepalive(INTERSERVER_TIMER); // does auto-reconnect + auto loop_fn = [&](EQ::Timer* t) { Timer::SetCurrentTime(); + if (keepalive.Check()) { + keepalive.Start(); + server.db->ping(); + } + if (!run_server) { EQ::EventLoop::Get().Shutdown(); return; diff --git a/ucs/ucs.cpp b/ucs/ucs.cpp index 79b0bff09..8b365b96d 100644 --- a/ucs/ucs.cpp +++ b/ucs/ucs.cpp @@ -114,7 +114,7 @@ int main() { Timer ChannelListProcessTimer(60000); Timer ClientConnectionPruneTimer(60000); - Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect + Timer keepalive(INTERSERVER_TIMER); // does auto-reconnect LogInfo("Starting EQEmu Universal Chat Server"); @@ -188,6 +188,10 @@ int main() { // crash_test.detach(); auto loop_fn = [&](EQ::Timer* t) { + if (keepalive.Check()) { + keepalive.Start(); + database.ping(); + } Timer::SetCurrentTime();