summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-11-30 22:14:47 +0100
committermadmaxoft <github@xoft.cz>2013-11-30 22:14:47 +0100
commitbf30528ec4ed53d4c6aef2da0410a04124bbc492 (patch)
treed369ea10c1173cd9a77f740ee07ea869ad6c7e62
parentFixed compiler warnings in IsBiomeNoDownfall(). (diff)
downloadcuberite-bf30528ec4ed53d4c6aef2da0410a04124bbc492.tar
cuberite-bf30528ec4ed53d4c6aef2da0410a04124bbc492.tar.gz
cuberite-bf30528ec4ed53d4c6aef2da0410a04124bbc492.tar.bz2
cuberite-bf30528ec4ed53d4c6aef2da0410a04124bbc492.tar.lz
cuberite-bf30528ec4ed53d4c6aef2da0410a04124bbc492.tar.xz
cuberite-bf30528ec4ed53d4c6aef2da0410a04124bbc492.tar.zst
cuberite-bf30528ec4ed53d4c6aef2da0410a04124bbc492.zip
Diffstat (limited to '')
-rw-r--r--src/DeadlockDetect.cpp6
-rw-r--r--src/DeadlockDetect.h5
-rw-r--r--src/Root.cpp11
3 files changed, 15 insertions, 7 deletions
diff --git a/src/DeadlockDetect.cpp b/src/DeadlockDetect.cpp
index c774c9dce..e699e0c84 100644
--- a/src/DeadlockDetect.cpp
+++ b/src/DeadlockDetect.cpp
@@ -31,8 +31,10 @@ cDeadlockDetect::cDeadlockDetect(void) :
-bool cDeadlockDetect::Start(void)
+bool cDeadlockDetect::Start(int a_IntervalSec)
{
+ m_IntervalSec = a_IntervalSec;
+
// Read the initial world data:
class cFillIn :
public cWorldListCallback
@@ -115,7 +117,7 @@ void cDeadlockDetect::CheckWorldAge(const AString & a_WorldName, Int64 a_Age)
if (itr->second.m_Age == a_Age)
{
itr->second.m_NumCyclesSame += 1;
- if (itr->second.m_NumCyclesSame > NUM_CYCLES_LIMIT)
+ if (itr->second.m_NumCyclesSame > (1000 * m_IntervalSec) / CYCLE_MILLISECONDS)
{
DeadlockDetected();
return;
diff --git a/src/DeadlockDetect.h b/src/DeadlockDetect.h
index 2559c3fff..cb2309169 100644
--- a/src/DeadlockDetect.h
+++ b/src/DeadlockDetect.h
@@ -29,7 +29,7 @@ public:
cDeadlockDetect(void);
/// Starts the detection. Hides cIsThread's Start, because we need some initialization
- bool Start(void);
+ bool Start(int a_IntervalSec);
protected:
struct sWorldAge
@@ -46,6 +46,9 @@ protected:
WorldAges m_WorldAges;
+ /// Number of secods for which the ages must be the same for the detection to trigger
+ int m_IntervalSec;
+
// cIsThread overrides:
virtual void Execute(void) override;
diff --git a/src/Root.cpp b/src/Root.cpp
index 4a6abaf37..f15bfd366 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -165,14 +165,17 @@ void cRoot::Start(void)
LOGD("Starting Authenticator...");
m_Authenticator.Start(IniFile);
- IniFile.WriteFile("settings.ini");
-
LOGD("Starting worlds...");
StartWorlds();
- LOGD("Starting deadlock detector...");
- dd.Start();
+ if (IniFile.GetValueSetB("DeadlockDetect", "Enabled", true))
+ {
+ LOGD("Starting deadlock detector...");
+ dd.Start(IniFile.GetValueSetI("DeadlockDetect", "IntervalSec", 20));
+ }
+ IniFile.WriteFile("settings.ini");
+
LOGD("Finalising startup...");
m_Server->Start();