From c90f528c4877ab2f0b1c72b6a66221ef112d9edb Mon Sep 17 00:00:00 2001 From: alfred Date: Sun, 13 Aug 2000 01:30:36 +0000 Subject: 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 Reviewed by: deischen --- lib/libkse/thread/thr_mutex.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/libkse/thread/thr_mutex.c') 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 { -- cgit v1.1