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:
Machiavelli
2011-01-13 21:30:37 +01:00
parent 4c15ebe09d
commit bd85914d92
5 changed files with 36 additions and 10 deletions

View File

@@ -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();
}