Core/DBLayer: Properly manage mysql library initialization and shutdown in authserver and worldserver. Prevent multiple calls and make it more elegant.
This commit is contained in:
@@ -300,10 +300,7 @@ int Master::Run()
|
||||
///- Clean database before leaving
|
||||
clearOnlineAccounts();
|
||||
|
||||
///- Wait for delay threads to end
|
||||
CharacterDatabase.Close();
|
||||
WorldDatabase.Close();
|
||||
LoginDatabase.Close();
|
||||
_StopDB();
|
||||
|
||||
sLog->outString("Halting process...");
|
||||
|
||||
@@ -368,6 +365,8 @@ int Master::Run()
|
||||
/// Initialize connection to the databases
|
||||
bool Master::_StartDB()
|
||||
{
|
||||
MySQL::Library_Init();
|
||||
|
||||
sLog->SetLogDB(false);
|
||||
std::string dbstring;
|
||||
uint8 async_threads, synch_threads;
|
||||
@@ -471,6 +470,15 @@ bool Master::_StartDB()
|
||||
return true;
|
||||
}
|
||||
|
||||
void Master::_StopDB()
|
||||
{
|
||||
CharacterDatabase.Close();
|
||||
WorldDatabase.Close();
|
||||
LoginDatabase.Close();
|
||||
|
||||
MySQL::Library_End();
|
||||
}
|
||||
|
||||
/// Clear 'online' status for all accounts with characters in this realm
|
||||
void Master::clearOnlineAccounts()
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@ class Master
|
||||
|
||||
private:
|
||||
bool _StartDB();
|
||||
void _StopDB();
|
||||
|
||||
void clearOnlineAccounts();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user