mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-05 16:39:08 +01:00
Core/NetworkIO: Use reactor style sending on linux to reduce locking overhead
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
#include "CliRunnable.h"
|
||||
#include "SystemConfig.h"
|
||||
#include "WorldSocket.h"
|
||||
#include "WorldSocketMgr.h"
|
||||
|
||||
using namespace boost::program_options;
|
||||
|
||||
@@ -82,7 +83,7 @@ uint32 realmID; ///< Id of the realm
|
||||
|
||||
void SignalHandler(const boost::system::error_code& error, int signalNumber);
|
||||
void FreezeDetectorHandler(const boost::system::error_code& error);
|
||||
AsyncAcceptor<RASession>* StartRaSocketAcceptor(boost::asio::io_service& ioService);
|
||||
AsyncAcceptor* StartRaSocketAcceptor(boost::asio::io_service& ioService);
|
||||
bool StartDB();
|
||||
void StopDB();
|
||||
void WorldUpdateLoop();
|
||||
@@ -203,7 +204,7 @@ extern int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
// Start the Remote Access port (acceptor) if enabled
|
||||
AsyncAcceptor<RASession>* raAcceptor = nullptr;
|
||||
AsyncAcceptor* raAcceptor = nullptr;
|
||||
if (sConfigMgr->GetBoolDefault("Ra.Enable", false))
|
||||
raAcceptor = StartRaSocketAcceptor(_ioService);
|
||||
|
||||
@@ -217,11 +218,8 @@ extern int main(int argc, char** argv)
|
||||
// Launch the worldserver listener socket
|
||||
uint16 worldPort = uint16(sWorld->getIntConfig(CONFIG_PORT_WORLD));
|
||||
std::string worldListener = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
|
||||
bool tcpNoDelay = sConfigMgr->GetBoolDefault("Network.TcpNodelay", true);
|
||||
|
||||
AsyncAcceptor<WorldSocket> worldAcceptor(_ioService, worldListener, worldPort, tcpNoDelay);
|
||||
|
||||
sScriptMgr->OnNetworkStart();
|
||||
sWorldSocketMgr.StartNetwork(_ioService, worldListener, worldPort);
|
||||
|
||||
// Set server online (allow connecting now)
|
||||
LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag & ~%u, population = 0 WHERE id = '%u'", REALM_FLAG_INVALID, realmID);
|
||||
@@ -252,6 +250,8 @@ extern int main(int argc, char** argv)
|
||||
// unload battleground templates before different singletons destroyed
|
||||
sBattlegroundMgr->DeleteAllBattlegrounds();
|
||||
|
||||
sWorldSocketMgr.StopNetwork();
|
||||
|
||||
sInstanceSaveMgr->Unload();
|
||||
sMapMgr->UnloadAll(); // unload all grids (including locked in memory)
|
||||
sObjectAccessor->UnloadAll(); // unload 'i_player2corpse' storage and remove from world
|
||||
@@ -379,12 +379,14 @@ void FreezeDetectorHandler(const boost::system::error_code& error)
|
||||
}
|
||||
}
|
||||
|
||||
AsyncAcceptor<RASession>* StartRaSocketAcceptor(boost::asio::io_service& ioService)
|
||||
AsyncAcceptor* StartRaSocketAcceptor(boost::asio::io_service& ioService)
|
||||
{
|
||||
uint16 raPort = uint16(sConfigMgr->GetIntDefault("Ra.Port", 3443));
|
||||
std::string raListener = sConfigMgr->GetStringDefault("Ra.IP", "0.0.0.0");
|
||||
|
||||
return new AsyncAcceptor<RASession>(ioService, raListener, raPort);
|
||||
AsyncAcceptor* acceptor = new AsyncAcceptor(ioService, raListener, raPort);
|
||||
acceptor->AsyncAccept<RASession>();
|
||||
return acceptor;
|
||||
}
|
||||
|
||||
/// Initialize connection to the databases
|
||||
|
||||
Reference in New Issue
Block a user