From 44f5830503f343021ff99ed4554c7e15b968c377 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Wed, 4 Nov 2015 00:07:29 +0100 Subject: [PATCH] BLocker: Make misuse warning more useful. Also print the locker sem (for manual name lookup) and the involved threads. It was also missing the line terminator which messed up the following output. Also fix a typo in a comment. --- src/kits/support/Locker.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/kits/support/Locker.cpp b/src/kits/support/Locker.cpp index 0d4b672b34..6b42d90a90 100644 --- a/src/kits/support/Locker.cpp +++ b/src/kits/support/Locker.cpp @@ -117,8 +117,12 @@ BLocker::Unlock() // unlock. This is bad practice, but we must allow it for compatibility // reasons. We can at least warn the developer that something is probably // wrong. - if (!IsLocked()) - fprintf(stderr, "Trying to unlock from the wrong thread (#6400)"); + if (!IsLocked()) { + fprintf(stderr, "Unlocking BLocker with sem %" B_PRId32 + " from wrong thread %" B_PRId32 ", current holder %" B_PRId32 + " (see issue #6400).\n", fSemaphoreID, find_thread(NULL), + fLockOwner); + } // Decrement the number of outstanding locks this thread holds // on this BLocker. @@ -135,7 +139,7 @@ BLocker::Unlock() int32 oldBenaphoreCount = atomic_add(&fBenaphoreCount, -1); // If the oldBenaphoreCount is greater than 1, then there is - // at lease one thread waiting for the lock in the case of a + // at least one thread waiting for the lock in the case of a // benaphore. if (oldBenaphoreCount > 1) { // Since there are threads waiting for the lock, it must