diff options
author | Mattes D <github@xoft.cz> | 2017-01-17 14:10:02 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2017-01-17 18:35:12 +0100 |
commit | a52de8e8cd67259e328f4a30b12916169406718b (patch) | |
tree | 18e617b9428afa6f4f0e3fa5958c703a275629bb | |
parent | Updated Github label links (#3543) (diff) | |
download | cuberite-a52de8e8cd67259e328f4a30b12916169406718b.tar cuberite-a52de8e8cd67259e328f4a30b12916169406718b.tar.gz cuberite-a52de8e8cd67259e328f4a30b12916169406718b.tar.bz2 cuberite-a52de8e8cd67259e328f4a30b12916169406718b.tar.lz cuberite-a52de8e8cd67259e328f4a30b12916169406718b.tar.xz cuberite-a52de8e8cd67259e328f4a30b12916169406718b.tar.zst cuberite-a52de8e8cd67259e328f4a30b12916169406718b.zip |
-rw-r--r-- | src/Bindings/PluginManager.cpp | 21 | ||||
-rw-r--r-- | src/DeadlockDetect.cpp | 8 | ||||
-rw-r--r-- | src/DeadlockDetect.h | 6 |
3 files changed, 30 insertions, 5 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 19d2e8b4d..276b08ce7 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -601,6 +601,27 @@ bool cPluginManager::CallHookEntityChangedWorld(cEntity & a_Entity, cWorld & a_W bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split, const AString & a_EntireCommand, CommandResult & a_Result) { + // Output the command being executed to log (for troubleshooting deadlocks-in-commands): + auto world = a_Player->GetWorld(); + AString worldName; + Int64 worldAge; + if (world != nullptr) + { + worldName = world->GetName(); + worldAge = world->GetWorldAge(); + } + else + { + worldName = "<no world>"; + worldAge = 0; + } + LOG("Player %s is executing command \"%s\" in world \"%s\" at world age %lld.", + a_Player->GetName().c_str(), + a_EntireCommand.c_str(), + worldName.c_str(), + worldAge + ); + FIND_HOOK(HOOK_EXECUTE_COMMAND); VERIFY_HOOK; diff --git a/src/DeadlockDetect.cpp b/src/DeadlockDetect.cpp index 3141020d0..525dc8118 100644 --- a/src/DeadlockDetect.cpp +++ b/src/DeadlockDetect.cpp @@ -121,7 +121,7 @@ void cDeadlockDetect::CheckWorldAge(const AString & a_WorldName, Int64 a_Age) WorldAge.m_NumCyclesSame += 1; if (WorldAge.m_NumCyclesSame > (m_IntervalSec * 1000) / CYCLE_MILLISECONDS) { - DeadlockDetected(); + DeadlockDetected(a_WorldName, a_Age); } } else @@ -135,9 +135,11 @@ void cDeadlockDetect::CheckWorldAge(const AString & a_WorldName, Int64 a_Age) -void cDeadlockDetect::DeadlockDetected(void) +void cDeadlockDetect::DeadlockDetected(const AString & a_WorldName, Int64 a_WorldAge) { - LOGERROR("Deadlock detected, aborting the server"); + LOGERROR("Deadlock detected: world %s has been stuck at age %lld. Aborting the server.", + a_WorldName.c_str(), static_cast<long long>(a_WorldAge) + ); ASSERT(!"Deadlock detected"); abort(); } diff --git a/src/DeadlockDetect.h b/src/DeadlockDetect.h index 39d3f8691..ee97fd6f7 100644 --- a/src/DeadlockDetect.h +++ b/src/DeadlockDetect.h @@ -59,8 +59,10 @@ protected: /** Checks if the world's age has changed, updates the world's stats; calls DeadlockDetected() if deadlock detected */ void CheckWorldAge(const AString & a_WorldName, Int64 a_Age); - /** Called when a deadlock is detected. Aborts the server. */ - NORETURN void DeadlockDetected(void); + /** Called when a deadlock is detected in a world. Aborts the server. + a_WorldName is the name of the world whose age has triggered the detection. + a_WorldAge is the age (in ticks) in which the world is stuck. */ + NORETURN void DeadlockDetected(const AString & a_WorldName, Int64 a_WorldAge); } ; |