Allow multiple locks to be acquired by detecting corresponding

bit flag, otherwise if a thread acquired a lock, another thread
or the current thread itself can no longer acquire another lock
because thread_mask_set() return whole flag word, this results
bit leaking in the word and misbehavior in later locking and
unlocking.
This commit is contained in:
davidxu 2008-09-16 01:46:11 +00:00
parent 1e7ba9e4d7
commit 612ed6bb13

View File

@ -184,7 +184,7 @@ rtld_lock_t rtld_phdr_lock = &rtld_locks[2];
int
rlock_acquire(rtld_lock_t lock)
{
if (thread_mask_set(lock->mask)) {
if (thread_mask_set(lock->mask) & lock->mask) {
dbg("rlock_acquire: recursed");
return (0);
}
@ -195,7 +195,7 @@ rlock_acquire(rtld_lock_t lock)
int
wlock_acquire(rtld_lock_t lock)
{
if (thread_mask_set(lock->mask)) {
if (thread_mask_set(lock->mask) & lock->mask) {
dbg("wlock_acquire: recursed");
return (0);
}