Updated to latest kernel versions.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22510 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -820,7 +820,7 @@ user_strlcpy(char *to, const char *from, size_t size)
|
|||||||
// #pragma mark - Private locking functions
|
// #pragma mark - Private locking functions
|
||||||
|
|
||||||
|
|
||||||
int
|
int32
|
||||||
recursive_lock_get_recursion(recursive_lock *lock)
|
recursive_lock_get_recursion(recursive_lock *lock)
|
||||||
{
|
{
|
||||||
thread_id thid = find_thread(NULL);
|
thread_id thid = find_thread(NULL);
|
||||||
@@ -863,38 +863,33 @@ recursive_lock_destroy(recursive_lock *lock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
status_t
|
||||||
recursive_lock_lock(recursive_lock *lock)
|
recursive_lock_lock(recursive_lock *lock)
|
||||||
{
|
{
|
||||||
thread_id thid = find_thread(NULL);
|
thread_id thread = find_thread(NULL);
|
||||||
bool retval = false;
|
|
||||||
|
|
||||||
if (thid != lock->holder) {
|
if (thread != lock->holder) {
|
||||||
acquire_sem(lock->sem);
|
status_t status = acquire_sem(lock->sem);
|
||||||
|
if (status < B_OK)
|
||||||
lock->holder = thid;
|
return status;
|
||||||
retval = true;
|
|
||||||
|
lock->holder = thread;
|
||||||
}
|
}
|
||||||
lock->recursion++;
|
lock->recursion++;
|
||||||
return retval;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
void
|
||||||
recursive_lock_unlock(recursive_lock *lock)
|
recursive_lock_unlock(recursive_lock *lock)
|
||||||
{
|
{
|
||||||
thread_id thid = find_thread(NULL);
|
if (find_thread(NULL) != lock->holder)
|
||||||
bool retval = false;
|
|
||||||
|
|
||||||
if (thid != lock->holder)
|
|
||||||
panic("recursive_lock %p unlocked by non-holder thread!\n", lock);
|
panic("recursive_lock %p unlocked by non-holder thread!\n", lock);
|
||||||
|
|
||||||
if (--lock->recursion == 0) {
|
if (--lock->recursion == 0) {
|
||||||
lock->holder = -1;
|
lock->holder = -1;
|
||||||
release_sem(lock->sem);
|
release_sem_etc(lock->sem, 1, 0/*B_DO_NOT_RESCHEDULE*/);
|
||||||
retval = true;
|
|
||||||
}
|
}
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -934,19 +929,22 @@ mutex_destroy(mutex *mutex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
status_t
|
||||||
mutex_lock(mutex *mutex)
|
mutex_lock(mutex *mutex)
|
||||||
{
|
{
|
||||||
thread_id me = find_thread(NULL);
|
thread_id me = find_thread(NULL);
|
||||||
|
|
||||||
// ToDo: if acquire_sem() fails, we shouldn't panic - but we should definitely
|
// ToDo: if acquire_sem() fails, we shouldn't panic - but we should definitely
|
||||||
// change the mutex API to actually return the status code
|
// change the mutex API to actually return the status code
|
||||||
if (acquire_sem(mutex->sem) == B_OK) {
|
status_t status = acquire_sem(mutex->sem);
|
||||||
if (me == mutex->holder)
|
if (status < B_OK)
|
||||||
panic("mutex_lock failure: mutex %p (sem = 0x%lx) acquired twice by thread 0x%lx\n", mutex, mutex->sem, me);
|
return status;
|
||||||
}
|
|
||||||
|
if (me == mutex->holder)
|
||||||
|
panic("mutex_lock failure: mutex %p (sem = 0x%lx) acquired twice by thread 0x%lx\n", mutex, mutex->sem, me);
|
||||||
|
|
||||||
mutex->holder = me;
|
mutex->holder = me;
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user