Skip to content

Commit

Permalink
Check return values of pthread_* calls with BOOST_VERIFY, per #8904.
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Dec 11, 2013
1 parent a41b81f commit 4c8a558
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions include/boost/smart_ptr/detail/atomic_count_pthreads.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
//

#include <boost/assert.hpp>
#include <pthread.h>

//
Expand All @@ -37,12 +38,12 @@ class atomic_count

scoped_lock(pthread_mutex_t & m): m_(m)
{
pthread_mutex_lock(&m_);
BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
}

~scoped_lock()
{
pthread_mutex_unlock(&m_);
BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
}

private:
Expand All @@ -54,12 +55,12 @@ class atomic_count

explicit atomic_count(long v): value_(v)
{
pthread_mutex_init(&mutex_, 0);
BOOST_VERIFY( pthread_mutex_init( &mutex_, 0 ) == 0 );
}

~atomic_count()
{
pthread_mutex_destroy(&mutex_);
BOOST_VERIFY( pthread_mutex_destroy( &mutex_ ) == 0 );
}

long operator++()
Expand Down

0 comments on commit 4c8a558

Please sign in to comment.