From 8a05bb865f8402bd40875b2f477f122f38094309 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 16 Oct 2008 21:32:14 +0000 Subject: [PATCH] Added TODO regarding serious locking problem. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28192 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/posix/xsi_message_queue.cpp | 6 +++++- src/system/kernel/posix/xsi_semaphore.cpp | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/posix/xsi_message_queue.cpp b/src/system/kernel/posix/xsi_message_queue.cpp index b8a5da294a..955e169abf 100644 --- a/src/system/kernel/posix/xsi_message_queue.cpp +++ b/src/system/kernel/posix/xsi_message_queue.cpp @@ -127,6 +127,10 @@ public: queueLocker->Unlock(); InterruptsSpinLocker _(gThreadSpinlock); +// TODO: We've got a serious race condition: If BlockAndUnlock() returned due to +// interruption, we will still be queued. A WakeUpThread() at this point will +// call thread_unblock() and might thus screw with our trying to re-lock the +// mutex. return thread_block_locked(thread); } @@ -428,7 +432,7 @@ XsiMessageQueue::Insert(queued_message *message) int32 oldCount = atomic_get(&sXsiMessageCount); if (oldCount >= MAX_XSI_MESSAGE) return true; - // If another thread updates the counter we keep + // If another thread updates the counter we keep // iterating if (atomic_test_and_set(&sXsiMessageCount, oldCount + 1, oldCount) == oldCount) diff --git a/src/system/kernel/posix/xsi_semaphore.cpp b/src/system/kernel/posix/xsi_semaphore.cpp index 2f1114fcf6..4a840f3599 100644 --- a/src/system/kernel/posix/xsi_semaphore.cpp +++ b/src/system/kernel/posix/xsi_semaphore.cpp @@ -144,6 +144,10 @@ public: setLocker->Unlock(); InterruptsSpinLocker _(gThreadSpinlock); +// TODO: We've got a serious race condition: If BlockAndUnlock() returned due to +// interruption, we will still be queued. A WakeUpThread() at this point will +// call thread_unblock() and might thus screw with our trying to re-lock the +// mutex. return thread_block_locked(thread); } @@ -840,8 +844,8 @@ _user_xsi_semctl(int semaphoreID, int semaphoreNumber, int command, } // Lock the semaphore set itself and release both the semaphore - // set hash table lock and the ipc hash table lock _only_ if - // the command it's not IPC_RMID, this prevents undesidered + // set hash table lock and the ipc hash table lock _only_ if + // the command it's not IPC_RMID, this prevents undesidered // situation from happening while (hopefully) improving the // concurrency. MutexLocker setLocker;