diff options
Diffstat (limited to 'src/server/bnetserver')
-rw-r--r-- | src/server/bnetserver/Main.cpp | 31 | ||||
-rw-r--r-- | src/server/bnetserver/Realms/RealmList.cpp | 1 | ||||
-rw-r--r-- | src/server/bnetserver/Server/SessionManager.h | 2 |
3 files changed, 22 insertions, 12 deletions
diff --git a/src/server/bnetserver/Main.cpp b/src/server/bnetserver/Main.cpp index 678e24c4682..6299ae802a7 100644 --- a/src/server/bnetserver/Main.cpp +++ b/src/server/bnetserver/Main.cpp @@ -57,8 +57,8 @@ void SignalHandler(const boost::system::error_code& error, int signalNumber); void KeepDatabaseAliveHandler(const boost::system::error_code& error); variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile); -boost::asio::io_service _ioService; -boost::asio::deadline_timer _dbPingTimer(_ioService); +std::unique_ptr<boost::asio::io_service> _ioService; +std::unique_ptr<boost::asio::deadline_timer> _dbPingTimer; uint32 _dbPingInterval; LoginDatabaseWorkerPool LoginDatabase; @@ -109,8 +109,10 @@ int main(int argc, char** argv) sIpcContext->Initialize(); + _ioService.reset(new boost::asio::io_service()); + // Get the list of realms for the server - sRealmList->Initialize(_ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10), worldListenPort); + sRealmList->Initialize(*_ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10), worldListenPort); // Start the listening port (acceptor) for auth connections int32 bnport = sConfigMgr->GetIntDefault("BattlenetPort", 1119); @@ -123,10 +125,10 @@ int main(int argc, char** argv) std::string bindIp = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0"); - sSessionMgr.StartNetwork(_ioService, bindIp, bnport); + sSessionMgr.StartNetwork(*_ioService, bindIp, bnport); // Set signal handlers - boost::asio::signal_set signals(_ioService, SIGINT, SIGTERM); + boost::asio::signal_set signals(*_ioService, SIGINT, SIGTERM); #if PLATFORM == PLATFORM_WINDOWS signals.add(SIGBREAK); #endif @@ -137,14 +139,19 @@ int main(int argc, char** argv) // Enabled a timed callback for handling the database keep alive ping _dbPingInterval = sConfigMgr->GetIntDefault("MaxPingTime", 30); - _dbPingTimer.expires_from_now(boost::posix_time::minutes(_dbPingInterval)); - _dbPingTimer.async_wait(KeepDatabaseAliveHandler); + _dbPingTimer.reset(new boost::asio::deadline_timer(*_ioService)); + _dbPingTimer->expires_from_now(boost::posix_time::minutes(_dbPingInterval)); + _dbPingTimer->async_wait(KeepDatabaseAliveHandler); sComponentMgr->Load(); sModuleMgr->Load(); // Start the io service worker loop - _ioService.run(); + _ioService->run(); + + _dbPingTimer->cancel(); + + sSessionMgr.StopNetwork(); sIpcContext->Close(); @@ -153,6 +160,8 @@ int main(int argc, char** argv) // Close the Database Pool and library StopDB(); + _ioService.reset(); + TC_LOG_INFO("server.bnetserver", "Halting process..."); return 0; } @@ -186,7 +195,7 @@ void StopDB() void SignalHandler(const boost::system::error_code& error, int /*signalNumber*/) { if (!error) - _ioService.stop(); + _ioService->stop(); } void KeepDatabaseAliveHandler(const boost::system::error_code& error) @@ -196,8 +205,8 @@ void KeepDatabaseAliveHandler(const boost::system::error_code& error) TC_LOG_INFO("server.bnetserver", "Ping MySQL to keep connection alive"); LoginDatabase.KeepAlive(); - _dbPingTimer.expires_from_now(boost::posix_time::minutes(_dbPingInterval)); - _dbPingTimer.async_wait(KeepDatabaseAliveHandler); + _dbPingTimer->expires_from_now(boost::posix_time::minutes(_dbPingInterval)); + _dbPingTimer->async_wait(KeepDatabaseAliveHandler); } } diff --git a/src/server/bnetserver/Realms/RealmList.cpp b/src/server/bnetserver/Realms/RealmList.cpp index 0f1a2df807e..fe4bfe3425e 100644 --- a/src/server/bnetserver/Realms/RealmList.cpp +++ b/src/server/bnetserver/Realms/RealmList.cpp @@ -52,6 +52,7 @@ void RealmList::Initialize(boost::asio::io_service& ioService, uint32 updateInte void RealmList::Close() { _worldListener->End(); + _updateTimer->cancel(); } template<typename FieldType> diff --git a/src/server/bnetserver/Server/SessionManager.h b/src/server/bnetserver/Server/SessionManager.h index 5f95616bf74..3ede9eb0ff6 100644 --- a/src/server/bnetserver/Server/SessionManager.h +++ b/src/server/bnetserver/Server/SessionManager.h @@ -40,7 +40,7 @@ namespace Battlenet #pragma pack(pop) - class SessionManager : SocketMgr<Session> + class SessionManager : public SocketMgr<Session> { typedef SocketMgr<Session> BaseSocketMgr; typedef std::map<SessionInfo, Session*> SessionMap; |