mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 19:06:49 +01:00
Resolve shutdown crash/leak if MySQL server is not running
Fixes #12734
This commit is contained in:
@@ -87,6 +87,7 @@ bool StartDB();
|
||||
void StopDB();
|
||||
void WorldUpdateLoop();
|
||||
void ClearOnlineAccounts();
|
||||
void ShutdownThreadPool(std::vector<std::thread>& threadPool);
|
||||
variables_map GetConsoleArguments(int argc, char** argv, std::string& cfg_file, std::string& cfg_service);
|
||||
|
||||
/// Launch the Trinity server
|
||||
@@ -179,7 +180,10 @@ extern int main(int argc, char** argv)
|
||||
|
||||
// Start the databases
|
||||
if (!StartDB())
|
||||
{
|
||||
ShutdownThreadPool(threadPool);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Set server offline (not connectable)
|
||||
LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = (flag & ~%u) | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, REALM_FLAG_INVALID, realmID);
|
||||
@@ -236,13 +240,7 @@ extern int main(int argc, char** argv)
|
||||
WorldUpdateLoop();
|
||||
|
||||
// Shutdown starts here
|
||||
|
||||
_ioService.stop();
|
||||
|
||||
for (auto& thread : threadPool)
|
||||
{
|
||||
thread.join();
|
||||
}
|
||||
ShutdownThreadPool(threadPool);
|
||||
|
||||
sScriptMgr->OnShutdown();
|
||||
|
||||
@@ -296,6 +294,16 @@ extern int main(int argc, char** argv)
|
||||
return World::GetExitCode();
|
||||
}
|
||||
|
||||
void ShutdownThreadPool(std::vector<std::thread>& threadPool)
|
||||
{
|
||||
_ioService.stop();
|
||||
|
||||
for (auto& thread : threadPool)
|
||||
{
|
||||
thread.join();
|
||||
}
|
||||
}
|
||||
|
||||
void WorldUpdateLoop()
|
||||
{
|
||||
uint32 realCurrTime = 0;
|
||||
|
||||
Reference in New Issue
Block a user