diff --git a/smocore/qutex.cpp b/smocore/qutex.cpp index 3fe5c88..967fe73 100644 --- a/smocore/qutex.cpp +++ b/smocore/qutex.cpp @@ -123,8 +123,25 @@ void Qutex::backoff( ": backoff called on empty queue - this should never happen"); } + /* Check if failedAcquirer is at the front of the queue with + * nRequiredLocks == 1. This should never happen because an + * acquirer at the front of the queue with nRequiredLocks == 1 + * should always succeed. + */ + const LockerAndInvokerBase& oldFront = *queue.front(); + if (oldFront == failedAcquirer && nRequiredLocks == 1) + { + lock.release(); + + throw std::runtime_error( + std::string(__func__) + + ": Failed acquirer is at front of queue with nRequiredLocks==1 - " + "acquirer at front of queue with nRequiredLocks==1 should always " + "succeed."); + } + // Rotate queue members if failedAcquirer is at front of queue - if ((*queue.front()) == failedAcquirer && nQItems > 1) + if (oldFront == failedAcquirer && nQItems > 1) { /** EXPLANATION: * Rotate the top LockSet.size() items in the queue by moving