diff options
Diffstat (limited to 'src/server/worldserver/Master.cpp')
-rw-r--r-- | src/server/worldserver/Master.cpp | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/src/server/worldserver/Master.cpp b/src/server/worldserver/Master.cpp index ce2f442fa8f..ab906cb9b42 100644 --- a/src/server/worldserver/Master.cpp +++ b/src/server/worldserver/Master.cpp @@ -370,9 +370,9 @@ int Master::Run() clearOnlineAccounts(); ///- Wait for delay threads to end - CharacterDatabase.HaltDelayThread(); - WorldDatabase.HaltDelayThread(); - LoginDatabase.HaltDelayThread(); + CharacterDatabase.Close(); + WorldDatabase.Close(); + LoginDatabase.Close(); sLog.outString( "Halting process..." ); @@ -439,8 +439,8 @@ bool Master::_StartDB() { sLog.SetLogDB(false); std::string dbstring; + uint8 num_threads; - ///- Get world database info from configuration file dbstring = sConfig.GetStringDefault("WorldDatabaseInfo", ""); if (dbstring.empty()) { @@ -448,13 +448,20 @@ bool Master::_StartDB() return false; } - ///- Initialise the world database - if( !WorldDatabase.Initialize(dbstring.c_str())) + num_threads = sConfig.GetIntDefault("WorldDatabase.WorkerThreads", 1); + if (num_threads < 1 || num_threads > 32) { - sLog.outError("Cannot connect to world database %s",dbstring.c_str()); + sLog.outError("World database: invalid number of worker threads specified. " + "Please pick a value between 1 and 32."); return false; } + ///- Initialise the world database + if (!WorldDatabase.Open(dbstring, num_threads)) + { + sLog.outError("Cannot connect to world database %s", dbstring.c_str()); + return false; + } ///- Get character database info from configuration file dbstring = sConfig.GetStringDefault("CharacterDatabaseInfo", ""); if (dbstring.empty()) @@ -463,13 +470,20 @@ bool Master::_StartDB() return false; } - ///- Initialise the Character database - if (!CharacterDatabase.Initialize(dbstring.c_str())) + num_threads = sConfig.GetIntDefault("CharacterDatabase.WorkerThreads", 1); + if (num_threads < 1 || num_threads > 32) { - sLog.outError("Cannot connect to Character database %s",dbstring.c_str()); + sLog.outError("Character database: invalid number of worker threads specified. " + "Please pick a value between 1 and 32."); return false; } + ///- Initialise the Character database + if (!CharacterDatabase.Open(dbstring, num_threads)) + { + sLog.outError("Cannot connect to Character database %s", dbstring.c_str()); + return false; + } ///- Get login database info from configuration file dbstring = sConfig.GetStringDefault("LoginDatabaseInfo", ""); if (dbstring.empty()) @@ -478,13 +492,20 @@ bool Master::_StartDB() return false; } - ///- Initialise the login database - if (!LoginDatabase.Initialize(dbstring.c_str())) + num_threads = sConfig.GetIntDefault("LoginDatabase.WorkerThreads", 1); + if (num_threads < 1 || num_threads > 32) { - sLog.outError("Cannot connect to login database %s",dbstring.c_str()); + sLog.outError("Login database: invalid number of worker threads specified. " + "Please pick a value between 1 and 32."); return false; } + ///- Initialise the login database + if (!LoginDatabase.Open(dbstring, num_threads)) + { + sLog.outError("Cannot connect to login database %s", dbstring.c_str()); + return false; + } ///- Get the realm Id from the configuration file realmID = sConfig.GetIntDefault("RealmID", 0); if (!realmID) |