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:
2025-09-29 14:37:16 -04:00
parent 462247d743
commit 2a60fdd9df
7 changed files with 22 additions and 16 deletions
+7 -3
View File
@@ -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;