fix(Core/Database): Gracefully close database workers (#20936)
* Gracefully close database workers * Change init order. Such a silly compiler flag * Fix hang if db connection failed to open
This commit is contained in:
@@ -95,11 +95,6 @@
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
#include <cmath>
|
||||
|
||||
namespace
|
||||
{
|
||||
TaskScheduler playersSaveScheduler;
|
||||
}
|
||||
|
||||
std::atomic_long World::_stopEvent = false;
|
||||
uint8 World::_exitCode = SHUTDOWN_EXIT_CODE;
|
||||
uint32 World::m_worldLoopCounter = 0;
|
||||
@@ -2497,11 +2492,6 @@ void World::Update(uint32 diff)
|
||||
sScriptMgr->OnWorldUpdate(diff);
|
||||
}
|
||||
|
||||
{
|
||||
METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update playersSaveScheduler"));
|
||||
playersSaveScheduler.Update(diff);
|
||||
}
|
||||
|
||||
{
|
||||
METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update metrics"));
|
||||
// Stats logger update
|
||||
@@ -2691,31 +2681,6 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode, const std:
|
||||
_shutdownMask = options;
|
||||
_exitCode = exitcode;
|
||||
|
||||
auto const& playersOnline = GetActiveSessionCount();
|
||||
|
||||
if (time < 5 && playersOnline)
|
||||
{
|
||||
// Set time to 5s for save all players
|
||||
time = 5;
|
||||
}
|
||||
|
||||
playersSaveScheduler.CancelAll();
|
||||
|
||||
if (time >= 5)
|
||||
{
|
||||
playersSaveScheduler.Schedule(Seconds(time - 5), [this](TaskContext /*context*/)
|
||||
{
|
||||
if (!GetActiveSessionCount())
|
||||
{
|
||||
LOG_INFO("server", "> No players online. Skip save before shutdown");
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_INFO("server", "> Save players before shutdown server");
|
||||
ObjectAccessor::SaveAllPlayers();
|
||||
});
|
||||
}
|
||||
|
||||
LOG_WARN("server", "Time left until shutdown/restart: {}", time);
|
||||
|
||||
///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions)
|
||||
|
||||
Reference in New Issue
Block a user