summaryrefslogtreecommitdiffstats
path: root/src/DeadlockDetect.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/DeadlockDetect.h')
-rw-r--r--src/DeadlockDetect.h26
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();
} ;