mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 18:36:31 +01:00
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:
@@ -38,6 +38,7 @@
|
||||
#endif
|
||||
|
||||
bool StartDB();
|
||||
void StopDB();
|
||||
|
||||
bool stopEvent = false; // Setting it to true stops the server
|
||||
|
||||
@@ -235,8 +236,8 @@ extern int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
// Close the Database Pool
|
||||
LoginDatabase.Close();
|
||||
// Close the Database Pool and library
|
||||
StopDB();
|
||||
|
||||
sLog->outString("Halting process...");
|
||||
return 0;
|
||||
@@ -245,6 +246,8 @@ extern int main(int argc, char **argv)
|
||||
// Initialize connection to the database
|
||||
bool StartDB()
|
||||
{
|
||||
MySQL::Library_Init();
|
||||
|
||||
std::string dbstring = sConfig->GetStringDefault("LoginDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
@@ -275,3 +278,9 @@ bool StartDB()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void StopDB()
|
||||
{
|
||||
LoginDatabase.Close();
|
||||
MySQL::Library_End();
|
||||
}
|
||||
Reference in New Issue
Block a user