Locking: Add contin tracing to detect deadlocks
We added the code to trace all the contins linked to a particular Lockvoker, into SerializedAsyncContinuation. This basically ensures that we'll almost never deal with a deadlock. So cool.
This commit is contained in:
@@ -38,7 +38,6 @@ public:
|
||||
std::shared_ptr<AsynchronousContinuation<OriginalCbFnT>>
|
||||
lifetimePreservingConveyance);
|
||||
|
||||
|
||||
/** EXPLANATION:
|
||||
* When an exception is thrown in a an async callee, which pertains to an
|
||||
* error in the data given by the caller, we ought not to throw the
|
||||
@@ -67,6 +66,11 @@ public:
|
||||
{ std::rethrow_exception(exception); }
|
||||
}
|
||||
|
||||
// Implement the virtual method from AsynchronousContinuationChainLink
|
||||
virtual std::shared_ptr<AsynchronousContinuationChainLink>
|
||||
getCallersContinuation() override
|
||||
{ return originalCallback.callerContinuation; }
|
||||
|
||||
public:
|
||||
Callback<OriginalCbFnT> originalCallback;
|
||||
std::exception_ptr exception;
|
||||
|
||||
@@ -18,6 +18,9 @@ class AsynchronousContinuationChainLink
|
||||
{
|
||||
public:
|
||||
virtual ~AsynchronousContinuationChainLink() = default;
|
||||
|
||||
virtual std::shared_ptr<AsynchronousContinuationChainLink>
|
||||
getCallersContinuation() = 0;
|
||||
};
|
||||
|
||||
} // namespace smo
|
||||
|
||||
@@ -100,7 +100,14 @@ public:
|
||||
{ return; }
|
||||
|
||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||
handleLikelyDeadlock(*firstFailedQutexPtr);
|
||||
Qutex &firstFailedQutex = *firstFailedQutexPtr;
|
||||
bool isDeadlock = traceContinuationHistoryForDeadlockOn(
|
||||
firstFailedQutex);
|
||||
|
||||
if (!isDeadlock)
|
||||
{ return; }
|
||||
|
||||
handleDeadlock(firstFailedQutex);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -186,12 +193,13 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||
bool traceContinuationHistoryForDeadlockOn(Qutex &firstFailedQutex);
|
||||
/**
|
||||
* @brief Handle a likely deadlock situation by logging debug information
|
||||
* @param firstFailedQutex The first qutex that failed acquisition
|
||||
*/
|
||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||
void handleLikelyDeadlock(Qutex& firstFailedQutex);
|
||||
void handleDeadlock(Qutex& firstFailedQutex);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user