From dfd2660a85e4f0891c63009ee8425b2796586409 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sat, 6 Jan 2018 01:21:59 +0100 Subject: Core/Misc: Added compatibility layer for boost 1.66 and future std:: networking stuff * Based on work done by @dimiandre in PR #21173 Closes #21171 Closes #21173 --- src/server/bnetserver/Main.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/server/bnetserver/Main.cpp') diff --git a/src/server/bnetserver/Main.cpp b/src/server/bnetserver/Main.cpp index caf9326fbd6..05fef45f918 100644 --- a/src/server/bnetserver/Main.cpp +++ b/src/server/bnetserver/Main.cpp @@ -64,12 +64,12 @@ char serviceDescription[] = "TrinityCore Battle.net emulator authentication serv */ int m_ServiceStatus = -1; -void ServiceStatusWatcher(std::weak_ptr serviceStatusWatchTimerRef, std::weak_ptr ioServiceRef, boost::system::error_code const& error); +void ServiceStatusWatcher(std::weak_ptr serviceStatusWatchTimerRef, std::weak_ptr ioContextRef, boost::system::error_code const& error); #endif bool StartDB(); void StopDB(); -void SignalHandler(std::weak_ptr ioServiceRef, boost::system::error_code const& error, int signalNumber); +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); variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, std::string& configService); @@ -153,7 +153,7 @@ int main(int argc, char** argv) std::shared_ptr dbHandle(nullptr, [](void*) { StopDB(); }); - std::shared_ptr ioService = std::make_shared(); + std::shared_ptr ioContext = std::make_shared(); // Start the listening port (acceptor) for auth connections int32 bnport = sConfigMgr->GetIntDefault("BattlenetPort", 1119); @@ -163,7 +163,7 @@ int main(int argc, char** argv) return 1; } - if (!sLoginService.Start(ioService.get())) + if (!sLoginService.Start(ioContext.get())) { TC_LOG_ERROR("server.bnetserver", "Failed to initialize login service"); return 1; @@ -172,13 +172,13 @@ int main(int argc, char** argv) std::shared_ptr sLoginServiceHandle(nullptr, [](void*) { sLoginService.Stop(); }); // Get the list of realms for the server - sRealmList->Initialize(*ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10)); + sRealmList->Initialize(*ioContext, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10)); std::shared_ptr sRealmListHandle(nullptr, [](void*) { sRealmList->Close(); }); std::string bindIp = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0"); - if (!sSessionMgr.StartNetwork(*ioService, bindIp, bnport)) + if (!sSessionMgr.StartNetwork(*ioContext, bindIp, bnport)) { TC_LOG_ERROR("server.bnetserver", "Failed to initialize network"); return 1; @@ -187,23 +187,23 @@ int main(int argc, char** argv) std::shared_ptr sSessionMgrHandle(nullptr, [](void*) { sSessionMgr.StopNetwork(); }); // Set signal handlers - boost::asio::signal_set signals(*ioService, SIGINT, SIGTERM); + boost::asio::signal_set signals(*ioContext, SIGINT, SIGTERM); #if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS signals.add(SIGBREAK); #endif - signals.async_wait(std::bind(&SignalHandler, std::weak_ptr(ioService), std::placeholders::_1, std::placeholders::_2)); + signals.async_wait(std::bind(&SignalHandler, std::weak_ptr(ioContext), std::placeholders::_1, std::placeholders::_2)); // Set process priority according to configuration settings SetProcessPriority("server.bnetserver", sConfigMgr->GetIntDefault(CONFIG_PROCESSOR_AFFINITY, 0), sConfigMgr->GetBoolDefault(CONFIG_HIGH_PRIORITY, false)); // Enabled a timed callback for handling the database keep alive ping int32 dbPingInterval = sConfigMgr->GetIntDefault("MaxPingTime", 30); - std::shared_ptr dbPingTimer = std::make_shared(*ioService); + 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)); int32 banExpiryCheckInterval = sConfigMgr->GetIntDefault("BanExpiryCheckInterval", 60); - std::shared_ptr banExpiryCheckTimer = std::make_shared(*ioService); + 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)); @@ -211,17 +211,17 @@ int main(int argc, char** argv) std::shared_ptr serviceStatusWatchTimer; if (m_ServiceStatus != -1) { - serviceStatusWatchTimer = std::make_shared(*ioService); + serviceStatusWatchTimer = std::make_shared(*ioContext); serviceStatusWatchTimer->expires_from_now(boost::posix_time::seconds(1)); serviceStatusWatchTimer->async_wait(std::bind(&ServiceStatusWatcher, std::weak_ptr(serviceStatusWatchTimer), - std::weak_ptr(ioService), + std::weak_ptr(ioContext), std::placeholders::_1)); } #endif // Start the io service worker loop - ioService->run(); + ioContext->run(); banExpiryCheckTimer->cancel(); dbPingTimer->cancel(); @@ -258,11 +258,11 @@ void StopDB() MySQL::Library_End(); } -void SignalHandler(std::weak_ptr ioServiceRef, boost::system::error_code const& error, int /*signalNumber*/) +void SignalHandler(std::weak_ptr ioContextRef, boost::system::error_code const& error, int /*signalNumber*/) { if (!error) - if (std::shared_ptr ioService = ioServiceRef.lock()) - ioService->stop(); + if (std::shared_ptr ioContext = ioContextRef.lock()) + ioContext->stop(); } void KeepDatabaseAliveHandler(std::weak_ptr dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error) @@ -297,20 +297,20 @@ void BanExpiryHandler(std::weak_ptr banExpiryCheckT } #if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS -void ServiceStatusWatcher(std::weak_ptr serviceStatusWatchTimerRef, std::weak_ptr ioServiceRef, boost::system::error_code const& error) +void ServiceStatusWatcher(std::weak_ptr serviceStatusWatchTimerRef, std::weak_ptr ioContextRef, boost::system::error_code const& error) { if (!error) { - if (std::shared_ptr ioService = ioServiceRef.lock()) + if (std::shared_ptr ioContext = ioContextRef.lock()) { if (m_ServiceStatus == 0) { - ioService->stop(); + ioContext->stop(); } else if (std::shared_ptr serviceStatusWatchTimer = serviceStatusWatchTimerRef.lock()) { serviceStatusWatchTimer->expires_from_now(boost::posix_time::seconds(1)); - serviceStatusWatchTimer->async_wait(std::bind(&ServiceStatusWatcher, serviceStatusWatchTimerRef, ioService, std::placeholders::_1)); + serviceStatusWatchTimer->async_wait(std::bind(&ServiceStatusWatcher, serviceStatusWatchTimerRef, ioContext, std::placeholders::_1)); } } } -- cgit v1.2.3