From 3b8598f01d5cbad8006be34604ea64406191b828 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Mon, 16 Dec 2024 21:44:48 +0100 Subject: [PATCH 1/2] c1 --- src/common/Asio/IoContext.h | 4 +- .../Asio/{DeadlineTimer.h => SteadyTimer.h} | 21 +++++----- src/common/Metric/Metric.cpp | 14 ++++--- src/common/Metric/Metric.h | 6 +-- src/server/apps/authserver/Main.cpp | 40 ++++++++++++------- src/server/apps/worldserver/Main.cpp | 12 ++++-- src/server/shared/Network/NetworkThread.h | 8 ++-- src/server/shared/Realms/RealmList.cpp | 8 ++-- src/server/shared/Realms/RealmList.h | 18 ++++++--- 9 files changed, 80 insertions(+), 51 deletions(-) rename src/common/Asio/{DeadlineTimer.h => SteadyTimer.h} (66%) diff --git a/src/common/Asio/IoContext.h b/src/common/Asio/IoContext.h index 46dfa8516fec60..e62327cc38cb37 100644 --- a/src/common/Asio/IoContext.h +++ b/src/common/Asio/IoContext.h @@ -52,9 +52,9 @@ namespace Acore::Asio } template - inline decltype(auto) get_io_context(T&& ioObject) + inline boost::asio::io_context& get_io_context(T&& ioObject) { - return ioObject.get_executor().context(); + return static_cast(ioObject.get_executor().context()); } } diff --git a/src/common/Asio/DeadlineTimer.h b/src/common/Asio/SteadyTimer.h similarity index 66% rename from src/common/Asio/DeadlineTimer.h rename to src/common/Asio/SteadyTimer.h index 09e377e6d4594f..e2d0b874db886f 100644 --- a/src/common/Asio/DeadlineTimer.h +++ b/src/common/Asio/SteadyTimer.h @@ -15,20 +15,23 @@ * with this program. If not, see . */ -#ifndef DeadlineTimer_h__ -#define DeadlineTimer_h__ - -#include +#ifndef steadytimer_h +#define steadytimer_h +/* +#include +#include -#define DeadlineTimerBase boost::asio::basic_deadline_timer, boost::asio::io_context::executor_type> +#define SteadyTimerBase boost::asio::steady_timer namespace Acore::Asio { - class DeadlineTimer : public DeadlineTimerBase + class SteadyTimer : public SteadyTimerBase { public: - using DeadlineTimerBase::basic_deadline_timer; + // Using the constructor of steady_timer + using SteadyTimerBase::steady_timer; }; -} +}*/ + +#endif // steadytimer_h -#endif // DeadlineTimer_h__ diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp index 8a2ecabd82695f..6298473d4ad594 100644 --- a/src/common/Metric/Metric.cpp +++ b/src/common/Metric/Metric.cpp @@ -17,7 +17,7 @@ #include "Metric.h" #include "Config.h" -#include "DeadlineTimer.h" +#include "SteadyTimer.h" #include "Log.h" #include "Strand.h" #include "Tokenize.h" @@ -42,8 +42,8 @@ void Metric::Initialize(std::string const& realmName, Acore::Asio::IoContext& io { _dataStream = std::make_unique(); _realmName = FormatInfluxDBTagValue(realmName); - _batchTimer = std::make_unique(ioContext); - _overallStatusTimer = std::make_unique(ioContext); + _batchTimer = std::make_unique(ioContext); + _overallStatusTimer = std::make_unique(ioContext); _overallStatusLogger = overallStatusLogger; LoadFromConfigs(); } @@ -247,7 +247,9 @@ void Metric::ScheduleSend() { if (_enabled) { - _batchTimer->expires_from_now(boost::posix_time::seconds(_updateInterval)); + // Calculate the expiration time + auto expirationTime = std::chrono::steady_clock::now() + std::chrono::seconds(_updateInterval); + _batchTimer->expires_at(expirationTime); _batchTimer->async_wait(std::bind(&Metric::SendBatch, this)); } else @@ -280,7 +282,9 @@ void Metric::ScheduleOverallStatusLog() { if (_enabled) { - _overallStatusTimer->expires_from_now(boost::posix_time::seconds(_overallStatusTimerInterval)); + // Calculate the expiration time _overallStatusTimerInterval from now + auto expirationTime = std::chrono::steady_clock::now() + std::chrono::seconds(_overallStatusTimerInterval); + _overallStatusTimer->expires_at(expirationTime); _overallStatusTimer->async_wait([this](const boost::system::error_code&) { _overallStatusTimerTriggered = true; diff --git a/src/common/Metric/Metric.h b/src/common/Metric/Metric.h index eca14f52c8cc53..9982ca2aa0da54 100644 --- a/src/common/Metric/Metric.h +++ b/src/common/Metric/Metric.h @@ -30,7 +30,7 @@ namespace Acore::Asio { class IoContext; - class DeadlineTimer; + class SteadyTimer; } enum MetricDataType @@ -62,8 +62,8 @@ class AC_COMMON_API Metric std::iostream& GetDataStream() { return *_dataStream; } std::unique_ptr _dataStream; MPSCQueue _queuedData; - std::unique_ptr _batchTimer; - std::unique_ptr _overallStatusTimer; + std::unique_ptr _batchTimer; + std::unique_ptr _overallStatusTimer; int32 _updateInterval = 0; int32 _overallStatusTimerInterval = 0; bool _enabled = false; diff --git a/src/server/apps/authserver/Main.cpp b/src/server/apps/authserver/Main.cpp index dd07cf0ae989f1..417ad2899dc4e4 100644 --- a/src/server/apps/authserver/Main.cpp +++ b/src/server/apps/authserver/Main.cpp @@ -29,7 +29,7 @@ #include "Config.h" #include "DatabaseEnv.h" #include "DatabaseLoader.h" -#include "DeadlineTimer.h" +#include "SteadyTimer.h" #include "IPLocation.h" #include "IoContext.h" #include "Log.h" @@ -60,8 +60,8 @@ namespace fs = std::filesystem; bool StartDB(); void StopDB(); void SignalHandler(std::weak_ptr ioContextRef, boost::system::error_code const& error, int signalNumber); -void KeepDatabaseAliveHandler(std::weak_ptr dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error); -void BanExpiryHandler(std::weak_ptr banExpiryCheckTimerRef, int32 banExpiryCheckInterval, boost::system::error_code const& error); +void KeepDatabaseAliveHandler(std::weak_ptr dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error); +void BanExpiryHandler(std::weak_ptr banExpiryCheckTimerRef, int32 banExpiryCheckInterval, boost::system::error_code const& error); variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile); /// Launch the auth server @@ -178,14 +178,20 @@ int main(int argc, char** argv) // Enabled a timed callback for handling the database keep alive ping int32 dbPingInterval = sConfigMgr->GetOption("MaxPingTime", 30); - std::shared_ptr dbPingTimer = std::make_shared(*ioContext); - dbPingTimer->expires_from_now(boost::posix_time::minutes(dbPingInterval)); - dbPingTimer->async_wait(std::bind(&KeepDatabaseAliveHandler, std::weak_ptr(dbPingTimer), dbPingInterval, std::placeholders::_1)); + std::shared_ptr dbPingTimer = std::make_shared(*ioContext); + + // Calculate the expiration time + auto expirationTime = std::chrono::steady_clock::now() + std::chrono::seconds(dbPingInterval); + dbPingTimer->expires_at(expirationTime); + dbPingTimer->async_wait(std::bind(&KeepDatabaseAliveHandler, std::weak_ptr(dbPingTimer), dbPingInterval, std::placeholders::_1)); int32 banExpiryCheckInterval = sConfigMgr->GetOption("BanExpiryCheckInterval", 60); - std::shared_ptr banExpiryCheckTimer = std::make_shared(*ioContext); - banExpiryCheckTimer->expires_from_now(boost::posix_time::seconds(banExpiryCheckInterval)); - banExpiryCheckTimer->async_wait(std::bind(&BanExpiryHandler, std::weak_ptr(banExpiryCheckTimer), banExpiryCheckInterval, std::placeholders::_1)); + std::shared_ptr banExpiryCheckTimer = std::make_shared(*ioContext); + + // Calculate the expiration time + auto expirationTimeBanExpiry = std::chrono::steady_clock::now() + std::chrono::seconds(banExpiryCheckInterval); + banExpiryCheckTimer->expires_at(expirationTimeBanExpiry); + banExpiryCheckTimer->async_wait(std::bind(&BanExpiryHandler, std::weak_ptr(banExpiryCheckTimer), banExpiryCheckInterval, std::placeholders::_1)); // Start the io service worker loop ioContext->run(); @@ -238,31 +244,35 @@ void SignalHandler(std::weak_ptr ioContextRef, boost::sy } } -void KeepDatabaseAliveHandler(std::weak_ptr dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error) +void KeepDatabaseAliveHandler(std::weak_ptr dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error) { if (!error) { - if (std::shared_ptr dbPingTimer = dbPingTimerRef.lock()) + if (std::shared_ptr dbPingTimer = dbPingTimerRef.lock()) { LOG_INFO("server.authserver", "Ping MySQL to keep connection alive"); LoginDatabase.KeepAlive(); - dbPingTimer->expires_from_now(boost::posix_time::minutes(dbPingInterval)); + // Calculate the expiration time + auto expirationTime = std::chrono::steady_clock::now() + std::chrono::seconds(dbPingInterval); + dbPingTimer->expires_at(expirationTime); dbPingTimer->async_wait(std::bind(&KeepDatabaseAliveHandler, dbPingTimerRef, dbPingInterval, std::placeholders::_1)); } } } -void BanExpiryHandler(std::weak_ptr banExpiryCheckTimerRef, int32 banExpiryCheckInterval, boost::system::error_code const& error) +void BanExpiryHandler(std::weak_ptr banExpiryCheckTimerRef, int32 banExpiryCheckInterval, boost::system::error_code const& error) { if (!error) { - if (std::shared_ptr banExpiryCheckTimer = banExpiryCheckTimerRef.lock()) + if (std::shared_ptr banExpiryCheckTimer = banExpiryCheckTimerRef.lock()) { LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS)); LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPIRED_ACCOUNT_BANS)); - banExpiryCheckTimer->expires_from_now(boost::posix_time::seconds(banExpiryCheckInterval)); + // Calculate the expiration time + auto expirationTime = std::chrono::steady_clock::now() + std::chrono::seconds(banExpiryCheckInterval); + banExpiryCheckTimer->expires_at(expirationTime); banExpiryCheckTimer->async_wait(std::bind(&BanExpiryHandler, banExpiryCheckTimerRef, banExpiryCheckInterval, std::placeholders::_1)); } } diff --git a/src/server/apps/worldserver/Main.cpp b/src/server/apps/worldserver/Main.cpp index 01d182623dedb5..bb8f1576f577f7 100644 --- a/src/server/apps/worldserver/Main.cpp +++ b/src/server/apps/worldserver/Main.cpp @@ -31,7 +31,7 @@ #include "Config.h" #include "DatabaseEnv.h" #include "DatabaseLoader.h" -#include "DeadlineTimer.h" +#include "SteadyTimer.h" #include "GitRevision.h" #include "IoContext.h" #include "MapMgr.h" @@ -92,14 +92,16 @@ class FreezeDetector static void Start(std::shared_ptr const& freezeDetector) { - freezeDetector->_timer.expires_from_now(boost::posix_time::seconds(5)); + // Calculate the expiration time 5seconds from now + auto expirationTime = std::chrono::steady_clock::now() + std::chrono::seconds(5); + freezeDetector->_timer.expires_at(expirationTime); freezeDetector->_timer.async_wait(std::bind(&FreezeDetector::Handler, std::weak_ptr(freezeDetector), std::placeholders::_1)); } static void Handler(std::weak_ptr freezeDetectorRef, boost::system::error_code const& error); private: - Acore::Asio::DeadlineTimer _timer; + Acore::Asio::SteadyTimer _timer; uint32 _worldLoopCounter; uint32 _lastChangeMsTime; uint32 _maxCoreStuckTimeInMs; @@ -642,7 +644,9 @@ void FreezeDetector::Handler(std::weak_ptr freezeDetectorRef, bo } } - freezeDetector->_timer.expires_from_now(boost::posix_time::seconds(1)); + // Calculate the expiration time + auto expirationTime = std::chrono::steady_clock::now() + std::chrono::seconds(1); + freezeDetector->_timer.expires_at(expirationTime); freezeDetector->_timer.async_wait(std::bind(&FreezeDetector::Handler, freezeDetectorRef, std::placeholders::_1)); } } diff --git a/src/server/shared/Network/NetworkThread.h b/src/server/shared/Network/NetworkThread.h index aca77faab05a3f..1e4f7f72a0add5 100644 --- a/src/server/shared/Network/NetworkThread.h +++ b/src/server/shared/Network/NetworkThread.h @@ -18,7 +18,7 @@ #ifndef NetworkThread_h__ #define NetworkThread_h__ -#include "DeadlineTimer.h" +#include "SteadyTimer.h" #include "Define.h" #include "Errors.h" #include "IoContext.h" @@ -179,7 +179,7 @@ class NetworkThread { LOG_DEBUG("misc", "Network Thread Starting"); - _updateTimer.expires_from_now(boost::posix_time::milliseconds(1)); + _updateTimer.expires_at(std::chrono::steady_clock::now()); _updateTimer.async_wait([this](boost::system::error_code const&) { Update(); }); _ioContext.run(); @@ -193,7 +193,7 @@ class NetworkThread if (_stopped) return; - _updateTimer.expires_from_now(boost::posix_time::milliseconds(1)); + _updateTimer.expires_at(std::chrono::steady_clock::now()); _updateTimer.async_wait([this](boost::system::error_code const&) { Update(); }); AddNewSockets(); @@ -230,7 +230,7 @@ class NetworkThread Acore::Asio::IoContext _ioContext; tcp::socket _acceptSocket; - Acore::Asio::DeadlineTimer _updateTimer; + Acore::Asio::SteadyTimer _updateTimer; bool _proxyHeaderReadingEnabled; }; diff --git a/src/server/shared/Realms/RealmList.cpp b/src/server/shared/Realms/RealmList.cpp index 5576cb26247f20..f1e3729a3a175b 100644 --- a/src/server/shared/Realms/RealmList.cpp +++ b/src/server/shared/Realms/RealmList.cpp @@ -17,7 +17,7 @@ #include "RealmList.h" #include "DatabaseEnv.h" -#include "DeadlineTimer.h" +#include "SteadyTimer.h" #include "Log.h" #include "Resolver.h" #include "QueryResult.h" @@ -37,7 +37,7 @@ RealmList* RealmList::Instance() void RealmList::Initialize(Acore::Asio::IoContext& ioContext, uint32 updateInterval) { _updateInterval = updateInterval; - _updateTimer = std::make_unique(ioContext); + _updateTimer = std::make_unique(ioContext); _resolver = std::make_unique(ioContext); LoadBuildInfo(); @@ -228,7 +228,9 @@ void RealmList::UpdateRealms(boost::system::error_code const& error) if (_updateInterval) { - _updateTimer->expires_from_now(boost::posix_time::seconds(_updateInterval)); + // Calculate the expiration time _updateInterval from now + auto expiration_time = std::chrono::steady_clock::now() + std::chrono::seconds(_updateInterval); + _updateTimer->expires_at(expiration_time); _updateTimer->async_wait([this](boost::system::error_code const& errorCode){ UpdateRealms(errorCode); }); } } diff --git a/src/server/shared/Realms/RealmList.h b/src/server/shared/Realms/RealmList.h index 76456c3e34806e..d02205f388fe37 100644 --- a/src/server/shared/Realms/RealmList.h +++ b/src/server/shared/Realms/RealmList.h @@ -25,6 +25,17 @@ #include // NOTE: this import is NEEDED (even though some IDEs report it as unused) #include +namespace Acore::Asio +{ + class IoContext; + class SteadyTimer; +} + +namespace boost::system +{ + class error_code; +} + struct RealmBuildInfo { uint32 Build; @@ -36,11 +47,6 @@ struct RealmBuildInfo std::array MacHash; }; -namespace boost::system -{ - class error_code; -} - /// Storage object for the list of realms on the server class AC_SHARED_API RealmList { @@ -70,7 +76,7 @@ class AC_SHARED_API RealmList std::vector _builds; RealmMap _realms; uint32 _updateInterval{0}; - std::unique_ptr _updateTimer; + std::unique_ptr _updateTimer; std::unique_ptr _resolver; }; From d9bca2bad213936eb0a2abc653cf0c20843181c1 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Mon, 16 Dec 2024 21:59:35 +0100 Subject: [PATCH 2/2] utilize boost::asio::steady_timer --- src/common/Asio/IoContext.h | 1 - src/common/Asio/SteadyTimer.h | 37 ----------------------- src/common/Metric/Metric.cpp | 5 ++- src/common/Metric/Metric.h | 6 ++-- src/server/apps/authserver/Main.cpp | 21 ++++++------- src/server/apps/worldserver/Main.cpp | 3 +- src/server/shared/Network/NetworkThread.h | 6 ++-- src/server/shared/Realms/RealmList.cpp | 3 +- src/server/shared/Realms/RealmList.h | 4 +-- 9 files changed, 22 insertions(+), 64 deletions(-) delete mode 100644 src/common/Asio/SteadyTimer.h diff --git a/src/common/Asio/IoContext.h b/src/common/Asio/IoContext.h index e62327cc38cb37..fa85c67155867f 100644 --- a/src/common/Asio/IoContext.h +++ b/src/common/Asio/IoContext.h @@ -19,7 +19,6 @@ #define IoContext_h__ #include - #include #include #define IoContextBaseNamespace boost::asio diff --git a/src/common/Asio/SteadyTimer.h b/src/common/Asio/SteadyTimer.h deleted file mode 100644 index e2d0b874db886f..00000000000000 --- a/src/common/Asio/SteadyTimer.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by the - * Free Software Foundation; either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef steadytimer_h -#define steadytimer_h -/* -#include -#include - -#define SteadyTimerBase boost::asio::steady_timer - -namespace Acore::Asio -{ - class SteadyTimer : public SteadyTimerBase - { - public: - // Using the constructor of steady_timer - using SteadyTimerBase::steady_timer; - }; -}*/ - -#endif // steadytimer_h - diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp index 6298473d4ad594..a6cd4b1f276ea8 100644 --- a/src/common/Metric/Metric.cpp +++ b/src/common/Metric/Metric.cpp @@ -17,7 +17,6 @@ #include "Metric.h" #include "Config.h" -#include "SteadyTimer.h" #include "Log.h" #include "Strand.h" #include "Tokenize.h" @@ -42,8 +41,8 @@ void Metric::Initialize(std::string const& realmName, Acore::Asio::IoContext& io { _dataStream = std::make_unique(); _realmName = FormatInfluxDBTagValue(realmName); - _batchTimer = std::make_unique(ioContext); - _overallStatusTimer = std::make_unique(ioContext); + _batchTimer = std::make_unique(ioContext); + _overallStatusTimer = std::make_unique(ioContext); _overallStatusLogger = overallStatusLogger; LoadFromConfigs(); } diff --git a/src/common/Metric/Metric.h b/src/common/Metric/Metric.h index 9982ca2aa0da54..729d2f7fc5a170 100644 --- a/src/common/Metric/Metric.h +++ b/src/common/Metric/Metric.h @@ -21,6 +21,7 @@ #include "Define.h" #include "Duration.h" #include "MPSCQueue.h" +#include #include #include // NOTE: this import is NEEDED (even though some IDEs report it as unused) #include @@ -30,7 +31,6 @@ namespace Acore::Asio { class IoContext; - class SteadyTimer; } enum MetricDataType @@ -62,8 +62,8 @@ class AC_COMMON_API Metric std::iostream& GetDataStream() { return *_dataStream; } std::unique_ptr _dataStream; MPSCQueue _queuedData; - std::unique_ptr _batchTimer; - std::unique_ptr _overallStatusTimer; + std::unique_ptr _batchTimer; + std::unique_ptr _overallStatusTimer; int32 _updateInterval = 0; int32 _overallStatusTimerInterval = 0; bool _enabled = false; diff --git a/src/server/apps/authserver/Main.cpp b/src/server/apps/authserver/Main.cpp index 417ad2899dc4e4..6030d9114220ae 100644 --- a/src/server/apps/authserver/Main.cpp +++ b/src/server/apps/authserver/Main.cpp @@ -29,7 +29,6 @@ #include "Config.h" #include "DatabaseEnv.h" #include "DatabaseLoader.h" -#include "SteadyTimer.h" #include "IPLocation.h" #include "IoContext.h" #include "Log.h" @@ -60,8 +59,8 @@ namespace fs = std::filesystem; bool StartDB(); void StopDB(); void SignalHandler(std::weak_ptr ioContextRef, boost::system::error_code const& error, int signalNumber); -void KeepDatabaseAliveHandler(std::weak_ptr dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error); -void BanExpiryHandler(std::weak_ptr banExpiryCheckTimerRef, int32 banExpiryCheckInterval, boost::system::error_code const& error); +void KeepDatabaseAliveHandler(std::weak_ptr dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error); +void BanExpiryHandler(std::weak_ptr banExpiryCheckTimerRef, int32 banExpiryCheckInterval, boost::system::error_code const& error); variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile); /// Launch the auth server @@ -178,20 +177,20 @@ int main(int argc, char** argv) // Enabled a timed callback for handling the database keep alive ping int32 dbPingInterval = sConfigMgr->GetOption("MaxPingTime", 30); - std::shared_ptr dbPingTimer = std::make_shared(*ioContext); + std::shared_ptr dbPingTimer = std::make_shared(*ioContext); // Calculate the expiration time auto expirationTime = std::chrono::steady_clock::now() + std::chrono::seconds(dbPingInterval); dbPingTimer->expires_at(expirationTime); - dbPingTimer->async_wait(std::bind(&KeepDatabaseAliveHandler, std::weak_ptr(dbPingTimer), dbPingInterval, std::placeholders::_1)); + dbPingTimer->async_wait(std::bind(&KeepDatabaseAliveHandler, std::weak_ptr(dbPingTimer), dbPingInterval, std::placeholders::_1)); int32 banExpiryCheckInterval = sConfigMgr->GetOption("BanExpiryCheckInterval", 60); - std::shared_ptr banExpiryCheckTimer = std::make_shared(*ioContext); + std::shared_ptr banExpiryCheckTimer = std::make_shared(*ioContext); // Calculate the expiration time auto expirationTimeBanExpiry = std::chrono::steady_clock::now() + std::chrono::seconds(banExpiryCheckInterval); banExpiryCheckTimer->expires_at(expirationTimeBanExpiry); - banExpiryCheckTimer->async_wait(std::bind(&BanExpiryHandler, std::weak_ptr(banExpiryCheckTimer), banExpiryCheckInterval, std::placeholders::_1)); + banExpiryCheckTimer->async_wait(std::bind(&BanExpiryHandler, std::weak_ptr(banExpiryCheckTimer), banExpiryCheckInterval, std::placeholders::_1)); // Start the io service worker loop ioContext->run(); @@ -244,11 +243,11 @@ void SignalHandler(std::weak_ptr ioContextRef, boost::sy } } -void KeepDatabaseAliveHandler(std::weak_ptr dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error) +void KeepDatabaseAliveHandler(std::weak_ptr dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error) { if (!error) { - if (std::shared_ptr dbPingTimer = dbPingTimerRef.lock()) + if (std::shared_ptr dbPingTimer = dbPingTimerRef.lock()) { LOG_INFO("server.authserver", "Ping MySQL to keep connection alive"); LoginDatabase.KeepAlive(); @@ -261,11 +260,11 @@ void KeepDatabaseAliveHandler(std::weak_ptr dbPingTime } } -void BanExpiryHandler(std::weak_ptr banExpiryCheckTimerRef, int32 banExpiryCheckInterval, boost::system::error_code const& error) +void BanExpiryHandler(std::weak_ptr banExpiryCheckTimerRef, int32 banExpiryCheckInterval, boost::system::error_code const& error) { if (!error) { - if (std::shared_ptr banExpiryCheckTimer = banExpiryCheckTimerRef.lock()) + if (std::shared_ptr banExpiryCheckTimer = banExpiryCheckTimerRef.lock()) { LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS)); LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPIRED_ACCOUNT_BANS)); diff --git a/src/server/apps/worldserver/Main.cpp b/src/server/apps/worldserver/Main.cpp index bb8f1576f577f7..05d860c5b24042 100644 --- a/src/server/apps/worldserver/Main.cpp +++ b/src/server/apps/worldserver/Main.cpp @@ -31,7 +31,6 @@ #include "Config.h" #include "DatabaseEnv.h" #include "DatabaseLoader.h" -#include "SteadyTimer.h" #include "GitRevision.h" #include "IoContext.h" #include "MapMgr.h" @@ -101,7 +100,7 @@ class FreezeDetector static void Handler(std::weak_ptr freezeDetectorRef, boost::system::error_code const& error); private: - Acore::Asio::SteadyTimer _timer; + boost::asio::steady_timer _timer; uint32 _worldLoopCounter; uint32 _lastChangeMsTime; uint32 _maxCoreStuckTimeInMs; diff --git a/src/server/shared/Network/NetworkThread.h b/src/server/shared/Network/NetworkThread.h index 1e4f7f72a0add5..b280c16d4f0f9d 100644 --- a/src/server/shared/Network/NetworkThread.h +++ b/src/server/shared/Network/NetworkThread.h @@ -18,14 +18,14 @@ #ifndef NetworkThread_h__ #define NetworkThread_h__ -#include "SteadyTimer.h" #include "Define.h" #include "Errors.h" #include "IoContext.h" #include "Log.h" #include "Socket.h" -#include #include +#include +#include #include #include #include @@ -230,7 +230,7 @@ class NetworkThread Acore::Asio::IoContext _ioContext; tcp::socket _acceptSocket; - Acore::Asio::SteadyTimer _updateTimer; + boost::asio::steady_timer _updateTimer; bool _proxyHeaderReadingEnabled; }; diff --git a/src/server/shared/Realms/RealmList.cpp b/src/server/shared/Realms/RealmList.cpp index f1e3729a3a175b..a1c258edd3d3e1 100644 --- a/src/server/shared/Realms/RealmList.cpp +++ b/src/server/shared/Realms/RealmList.cpp @@ -17,7 +17,6 @@ #include "RealmList.h" #include "DatabaseEnv.h" -#include "SteadyTimer.h" #include "Log.h" #include "Resolver.h" #include "QueryResult.h" @@ -37,7 +36,7 @@ RealmList* RealmList::Instance() void RealmList::Initialize(Acore::Asio::IoContext& ioContext, uint32 updateInterval) { _updateInterval = updateInterval; - _updateTimer = std::make_unique(ioContext); + _updateTimer = std::make_unique(ioContext); _resolver = std::make_unique(ioContext); LoadBuildInfo(); diff --git a/src/server/shared/Realms/RealmList.h b/src/server/shared/Realms/RealmList.h index d02205f388fe37..9d8912ad2ce461 100644 --- a/src/server/shared/Realms/RealmList.h +++ b/src/server/shared/Realms/RealmList.h @@ -20,6 +20,7 @@ #include "Define.h" #include "Realm.h" +#include #include #include #include // NOTE: this import is NEEDED (even though some IDEs report it as unused) @@ -28,7 +29,6 @@ namespace Acore::Asio { class IoContext; - class SteadyTimer; } namespace boost::system @@ -76,7 +76,7 @@ class AC_SHARED_API RealmList std::vector _builds; RealmMap _realms; uint32 _updateInterval{0}; - std::unique_ptr _updateTimer; + std::unique_ptr _updateTimer; std::unique_ptr _resolver; };