diff options
author | alfred <alfred@FreeBSD.org> | 2000-08-13 01:30:36 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2000-08-13 01:30:36 +0000 |
commit | c90f528c4877ab2f0b1c72b6a66221ef112d9edb (patch) | |
tree | e211d1aaeae2dc608b5e87ba68cd1750713cbdff /lib/libkse/thread/thr_mutex.c | |
parent | 880b607621269a90e4cec082280fc6088d3f20a6 (diff) | |
download | FreeBSD-src-c90f528c4877ab2f0b1c72b6a66221ef112d9edb.zip FreeBSD-src-c90f528c4877ab2f0b1c72b6a66221ef112d9edb.tar.gz |
Fix an off-by-one error in the recursive mutex handling that made it
prematurely release recursive mutexes.
Test case provided by: Bradley T. Hughes <bhughes@trolltech.com>
Reviewed by: deischen
Diffstat (limited to 'lib/libkse/thread/thr_mutex.c')
-rw-r--r-- | lib/libkse/thread/thr_mutex.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libkse/thread/thr_mutex.c b/lib/libkse/thread/thr_mutex.c index 12fdc8e..b8877f8 100644 --- a/lib/libkse/thread/thr_mutex.c +++ b/lib/libkse/thread/thr_mutex.c @@ -753,7 +753,7 @@ mutex_unlock_common(pthread_mutex_t * mutex, int add_reference) ret = (*mutex)->m_owner == NULL ? EINVAL : EPERM; } else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) && - ((*mutex)->m_data.m_count > 1)) { + ((*mutex)->m_data.m_count > 0)) { /* Decrement the count: */ (*mutex)->m_data.m_count--; } else { @@ -821,7 +821,7 @@ mutex_unlock_common(pthread_mutex_t * mutex, int add_reference) ret = (*mutex)->m_owner == NULL ? EINVAL : EPERM; } else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) && - ((*mutex)->m_data.m_count > 1)) { + ((*mutex)->m_data.m_count > 0)) { /* Decrement the count: */ (*mutex)->m_data.m_count--; } else { @@ -939,7 +939,7 @@ mutex_unlock_common(pthread_mutex_t * mutex, int add_reference) ret = (*mutex)->m_owner == NULL ? EINVAL : EPERM; } else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) && - ((*mutex)->m_data.m_count > 1)) { + ((*mutex)->m_data.m_count > 0)) { /* Decrement the count: */ (*mutex)->m_data.m_count--; } else { |