From 74272e4c46e34c4e772054baf6c0345a3a395cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 10 Jan 2005 07:46:48 +0000 Subject: [PATCH] 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 --- src/kernel/core/lock.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/kernel/core/lock.c b/src/kernel/core/lock.c index 3973529905..b76559b28e 100644 --- a/src/kernel/core/lock.c +++ b/src/kernel/core/lock.c @@ -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; }