aboutsummaryrefslogtreecommitdiff
path: root/src/server/worldserver/Main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/worldserver/Main.cpp')
-rw-r--r--src/server/worldserver/Main.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp
index 1f270b3abcb..69b226a319a 100644
--- a/src/server/worldserver/Main.cpp
+++ b/src/server/worldserver/Main.cpp
@@ -475,6 +475,11 @@ void WorldUpdateLoop()
uint32 realCurrTime = 0;
uint32 realPrevTime = getMSTime();
+ uint32 maxCoreStuckTime = uint32(sConfigMgr->GetIntDefault("MaxCoreStuckTime", 60)) * 1000;
+ uint32 halfMaxCoreStuckTime = maxCoreStuckTime / 2;
+ if (!halfMaxCoreStuckTime)
+ halfMaxCoreStuckTime = std::numeric_limits<uint32>::max();
+
LoginDatabase.WarnAboutSyncQueries(true);
CharacterDatabase.WarnAboutSyncQueries(true);
WorldDatabase.WarnAboutSyncQueries(true);
@@ -488,8 +493,11 @@ void WorldUpdateLoop()
uint32 diff = getMSTimeDiff(realPrevTime, realCurrTime);
if (diff < minUpdateDiff)
{
+ uint32 sleepTime = minUpdateDiff - diff;
+ if (sleepTime >= halfMaxCoreStuckTime)
+ TC_LOG_ERROR("server.worldserver", "WorldUpdateLoop() waiting for %u ms with MaxCoreStuckTime set to %u ms", sleepTime, maxCoreStuckTime);
// sleep until enough time passes that we can update all timers
- std::this_thread::sleep_for(Milliseconds(minUpdateDiff - diff));
+ std::this_thread::sleep_for(Milliseconds(sleepTime));
continue;
}
@@ -531,10 +539,14 @@ void FreezeDetector::Handler(std::weak_ptr<FreezeDetector> freezeDetectorRef, bo
freezeDetector->_worldLoopCounter = worldLoopCounter;
}
// possible freeze
- else if (getMSTimeDiff(freezeDetector->_lastChangeMsTime, curtime) > freezeDetector->_maxCoreStuckTimeInMs)
+ else
{
- TC_LOG_ERROR("server.worldserver", "World Thread hangs, kicking out server!");
- ABORT();
+ uint32 msTimeDiff = getMSTimeDiff(freezeDetector->_lastChangeMsTime, curtime);
+ if (msTimeDiff > freezeDetector->_maxCoreStuckTimeInMs)
+ {
+ TC_LOG_ERROR("server.worldserver", "World Thread hangs for %u ms, forcing a crash!", msTimeDiff);
+ ABORT_MSG("World Thread hangs for %u ms, forcing a crash!", msTimeDiff);
+ }
}
freezeDetector->_timer.expires_from_now(boost::posix_time::seconds(1));