bug in recursive_mutex

I previously posted about issues when using a recursive_mutex and a condition. after some more inspection, it turns out it is a minor bug in the recursive_mutex implementation (the pthread version). I've included the patch below, which was generated against the 1.31.0 version of boost (but the bug is still in the latest cvs as well). Would be great if someone could integrate this into the latest code, or possibly a bug fix release for 1.31 (this is a major bug for anyone using recursive_mutex with condition). thanks, -james *** boost_1_31_0/libs/thread/src/recursive_mutex.cpp Fri Dec 26 18:22:00 2003 --- boost_1_31_0.jta/libs/thread/src/recursive_mutex.cpp Thu Sep 16 10:01:10 2004 *************** *** 412,417 **** --- 412,418 ---- state.pmutex = &m_mutex; state.count = m_count; + m_count = 0; } recursive_try_mutex::recursive_try_mutex() *************** *** 608,613 **** --- 609,615 ---- state.pmutex = &m_mutex; state.count = m_count; + m_count = 0; } recursive_timed_mutex::recursive_timed_mutex() *************** *** 787,792 **** --- 789,795 ---- state.pmutex = &m_mutex; state.count = m_count; + m_count = 0; } #elif defined(BOOST_HAS_MPTASKS)

James Ahlborn wrote:
I previously posted about issues when using a recursive_mutex and a condition. after some more inspection, it turns out it is a minor bug in the recursive_mutex implementation (the pthread version). I've included the patch below, which was generated against the 1.31.0 version of boost (but the bug is still in the latest cvs as well). Would be great if someone could integrate this into the latest code, or possibly a bug fix release for 1.31 (this is a major bug for anyone using recursive_mutex with condition).
thanks, -james
*** boost_1_31_0/libs/thread/src/recursive_mutex.cpp Fri Dec 26 18:22:00 2003 --- boost_1_31_0.jta/libs/thread/src/recursive_mutex.cpp Thu Sep 16 10:01:10 2004 *************** *** 412,417 **** --- 412,418 ----
state.pmutex = &m_mutex; state.count = m_count; + m_count = 0; }
recursive_try_mutex::recursive_try_mutex() *************** *** 608,613 **** --- 609,615 ----
state.pmutex = &m_mutex; state.count = m_count; + m_count = 0; }
recursive_timed_mutex::recursive_timed_mutex() *************** *** 787,792 **** --- 789,795 ----
state.pmutex = &m_mutex; state.count = m_count; + m_count = 0; } #elif defined(BOOST_HAS_MPTASKS)
I just read your post about the problem a few minutes ago, so I hadn't even had time to look into it myself. I'll take a look at this and apply it as soon as I can if I don't see any problems. Mike

Michael Glassford wrote:
James Ahlborn wrote:
I previously posted about issues when using a recursive_mutex and a condition. after some more inspection, it turns out it is a minor bug in the recursive_mutex implementation (the pthread version). I've included the patch below
[snip patch details]
I just read your post about the problem a few minutes ago, so I hadn't even had time to look into it myself. I'll take a look at this and apply it as soon as I can if I don't see any problems.
Mike
The change looks good to me; I've committed it. Thanks again for tracking it down. Mike

Michael Glassford wrote: ... I suggest you get rid of Javanese wait() and introduce mutex:: swap_lock_count()... so that let James can play Russian roulette. http://lists.boost.org/MailArchives/boost/msg67187.php ([boost] Re: Boost.Threads: Do we need all those mutexes?) regards, alexander.
participants (3)
-
Alexander Terekhov
-
James Ahlborn
-
Michael Glassford