Qutex: Add currOwner pointer for debugging
We'll use this to detect gridlock-type deadlocks between two requests
This commit is contained in:
+2
-1
@@ -28,7 +28,7 @@ public:
|
||||
Qutex([[maybe_unused]] const std::string &_name)
|
||||
:
|
||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||
name(_name),
|
||||
name(_name), currOwner(nullptr),
|
||||
#endif
|
||||
isOwned(false)
|
||||
{}
|
||||
@@ -92,6 +92,7 @@ public:
|
||||
public:
|
||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||
std::string name;
|
||||
LockerAndInvokerBase* currOwner;
|
||||
#endif
|
||||
SpinLock lock;
|
||||
LockerAndInvokerBase::List queue;
|
||||
|
||||
@@ -43,6 +43,9 @@ bool Qutex::tryAcquire(
|
||||
if (qNItems == 1 || nRearItemsToScan < 1)
|
||||
{
|
||||
isOwned = true;
|
||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||
currOwner = const_cast<LockerAndInvokerBase*>(&tryingLockvoker);
|
||||
#endif
|
||||
lock.release();
|
||||
return true;
|
||||
}
|
||||
@@ -55,6 +58,9 @@ bool Qutex::tryAcquire(
|
||||
if ((*queue.front()) == tryingLockvoker)
|
||||
{
|
||||
isOwned = true;
|
||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||
currOwner = const_cast<LockerAndInvokerBase*>(&tryingLockvoker);
|
||||
#endif
|
||||
ret = true;
|
||||
}
|
||||
else {
|
||||
@@ -89,6 +95,9 @@ bool Qutex::tryAcquire(
|
||||
|
||||
// Not found in rear portion - must be in top X%, so succeed
|
||||
isOwned = true;
|
||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||
currOwner = const_cast<LockerAndInvokerBase*>(&tryingLockvoker);
|
||||
#endif
|
||||
lock.release();
|
||||
return true;
|
||||
}
|
||||
@@ -220,6 +229,9 @@ void Qutex::backoff(
|
||||
}
|
||||
|
||||
isOwned = false;
|
||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||
currOwner = nullptr;
|
||||
#endif
|
||||
LockerAndInvokerBase &newFront = *queue.front();
|
||||
|
||||
lock.release();
|
||||
@@ -280,6 +292,9 @@ void Qutex::release()
|
||||
lock.acquire();
|
||||
|
||||
isOwned = false;
|
||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||
currOwner = nullptr;
|
||||
#endif
|
||||
|
||||
// It's possible for there to be 0 items left in queue after unregistering.
|
||||
if (queue.empty())
|
||||
|
||||
Reference in New Issue
Block a user