diff options
author | Mattes D <github@xoft.cz> | 2017-01-18 10:51:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-18 10:51:17 +0100 |
commit | 0256daa7ca98bab7482581dad39f66d570030874 (patch) | |
tree | de9232cbf239800ea1e7a71cf52086509a9472ea /src/DeadlockDetect.h | |
parent | Updated Github label links (#3543) (diff) | |
parent | DeadlockDetect now lists some tracked CS's stats. (diff) | |
download | cuberite-0256daa7ca98bab7482581dad39f66d570030874.tar cuberite-0256daa7ca98bab7482581dad39f66d570030874.tar.gz cuberite-0256daa7ca98bab7482581dad39f66d570030874.tar.bz2 cuberite-0256daa7ca98bab7482581dad39f66d570030874.tar.lz cuberite-0256daa7ca98bab7482581dad39f66d570030874.tar.xz cuberite-0256daa7ca98bab7482581dad39f66d570030874.tar.zst cuberite-0256daa7ca98bab7482581dad39f66d570030874.zip |
Diffstat (limited to 'src/DeadlockDetect.h')
-rw-r--r-- | src/DeadlockDetect.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/DeadlockDetect.h b/src/DeadlockDetect.h index 39d3f8691..ee6dc3e22 100644 --- a/src/DeadlockDetect.h +++ b/src/DeadlockDetect.h @@ -27,10 +27,20 @@ class cDeadlockDetect : public: cDeadlockDetect(void); + ~cDeadlockDetect(); /** Starts the detection. Hides cIsThread's Start, because we need some initialization */ bool Start(int a_IntervalSec); + /** Adds the critical section for tracking. + Tracked CSs are listed, together with ownership details, when a deadlock is detected. + A tracked CS must be untracked before it is destroyed. + a_Name is an arbitrary name that is listed along with the CS in the output. */ + void TrackCriticalSection(cCriticalSection & a_CS, const AString & a_Name); + + /** Removes the CS from the tracking. */ + void UntrackCriticalSection(cCriticalSection & a_CS); + protected: struct sWorldAge { @@ -44,6 +54,13 @@ protected: /** Maps world name -> sWorldAge */ typedef std::map<AString, sWorldAge> WorldAges; + /** Protects m_TrackedCriticalSections from multithreaded access. */ + cCriticalSection m_CS; + + /** CriticalSections that are tracked (their status output on deadlock). + Protected against multithreaded access by m_CS. */ + std::vector<std::pair<cCriticalSection *, AString>> m_TrackedCriticalSections; + WorldAges m_WorldAges; /** Number of secods for which the ages must be the same for the detection to trigger */ @@ -59,8 +76,13 @@ 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); + + /** Outputs a listing of the tracked CSs, together with their name and state. */ + void ListTrackedCSs(); } ; |