mutex_lock() will no longer panic() if acquire_sem() failed and the mutex
holder did not change (required for booting properly). Also added a ToDo comment about a required mutex API change in order to be able to return a status that indicates failure. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10639 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -138,10 +138,13 @@ mutex_lock(mutex *mutex)
|
||||
if (!kernel_startup && !are_interrupts_enabled())
|
||||
panic("mutex_lock: called with interrupts disabled for mutex %p, sem %#lx\n", mutex, mutex->sem);
|
||||
|
||||
if (me == mutex->holder)
|
||||
panic("mutex_lock failure: mutex %p (sem = 0x%lx) acquired twice by thread 0x%lx\n", mutex, mutex->sem, me);
|
||||
// ToDo: if acquire_sem() fails, we shouldn't panic - but we should definitely
|
||||
// change the mutex API to actually return the status code
|
||||
if (acquire_sem(mutex->sem) == B_OK) {
|
||||
if (me == mutex->holder)
|
||||
panic("mutex_lock failure: mutex %p (sem = 0x%lx) acquired twice by thread 0x%lx\n", mutex, mutex->sem, me);
|
||||
}
|
||||
|
||||
acquire_sem(mutex->sem);
|
||||
mutex->holder = me;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user