Qutex: currOwner should use registered sh_ptr to Lockvoker
This ensures that the Lockvoker object we access from currOwner remains valid past the lifetime of the Lockvoker object that gets copied and invoked by boost::asio
This commit is contained in:
+7
-3
@@ -44,7 +44,9 @@ bool Qutex::tryAcquire(
|
||||
{
|
||||
isOwned = true;
|
||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||
currOwner = const_cast<LockerAndInvokerBase*>(&tryingLockvoker);
|
||||
// Use the stored iterator from the LockSet
|
||||
auto it = tryingLockvoker.getLockvokerIteratorForQutex(*this);
|
||||
currOwner = *it;
|
||||
#endif
|
||||
lock.release();
|
||||
return true;
|
||||
@@ -59,7 +61,7 @@ bool Qutex::tryAcquire(
|
||||
{
|
||||
isOwned = true;
|
||||
#ifdef CONFIG_ENABLE_DEBUG_LOCKS
|
||||
currOwner = const_cast<LockerAndInvokerBase*>(&tryingLockvoker);
|
||||
currOwner = queue.front();
|
||||
#endif
|
||||
ret = true;
|
||||
}
|
||||
@@ -96,7 +98,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);
|
||||
// Use the stored iterator from the LockSet
|
||||
auto it = tryingLockvoker.getLockvokerIteratorForQutex(*this);
|
||||
currOwner = *it;
|
||||
#endif
|
||||
lock.release();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user