Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75781 - trunk/boost/thread/pthread
From: vicente.botet_at_[hidden]
Date: 2011-12-03 05:09:12


Author: viboes
Date: 2011-12-03 05:09:11 EST (Sat, 03 Dec 2011)
New Revision: 75781
URL: http://svn.boost.org/trac/boost/changeset/75781

Log:
Thread: 6200 patch to have condition_variable and mutex error better handle EINTR
Text files modified:
   trunk/boost/thread/pthread/condition_variable.hpp | 20 +++++++++++---------
   trunk/boost/thread/pthread/condition_variable_fwd.hpp | 8 ++++++--
   2 files changed, 17 insertions(+), 11 deletions(-)

Modified: trunk/boost/thread/pthread/condition_variable.hpp
==============================================================================
--- trunk/boost/thread/pthread/condition_variable.hpp (original)
+++ trunk/boost/thread/pthread/condition_variable.hpp 2011-12-03 05:09:11 EST (Sat, 03 Dec 2011)
@@ -18,14 +18,14 @@
     {
         void BOOST_THREAD_DECL interruption_point();
     }
-
+
     namespace thread_cv_detail
     {
         template<typename MutexType>
         struct lock_on_exit
         {
             MutexType* m;
-
+
             lock_on_exit():
                 m(0)
             {}
@@ -44,7 +44,7 @@
            }
         };
     }
-
+
     inline void condition_variable::wait(unique_lock<mutex>& m)
     {
         int res=0;
@@ -52,7 +52,9 @@
             thread_cv_detail::lock_on_exit<unique_lock<mutex> > guard;
             detail::interruption_checker check_for_interruption(&internal_mutex,&cond);
             guard.activate(m);
- res=pthread_cond_wait(&cond,&internal_mutex);
+ do {
+ res = pthread_cond_wait(&cond,&internal_mutex);
+ } while (res == EINTR);
         }
         this_thread::interruption_point();
         if(res)
@@ -88,13 +90,13 @@
         boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
         BOOST_VERIFY(!pthread_cond_signal(&cond));
     }
-
+
     inline void condition_variable::notify_all()
     {
         boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
         BOOST_VERIFY(!pthread_cond_broadcast(&cond));
     }
-
+
     class condition_variable_any
     {
         pthread_mutex_t internal_mutex;
@@ -123,7 +125,7 @@
             BOOST_VERIFY(!pthread_mutex_destroy(&internal_mutex));
             BOOST_VERIFY(!pthread_cond_destroy(&cond));
         }
-
+
         template<typename lock_type>
         void wait(lock_type& m)
         {
@@ -146,7 +148,7 @@
         {
             while(!pred()) wait(m);
         }
-
+
         template<typename lock_type>
         bool timed_wait(lock_type& m,boost::system_time const& wait_until)
         {
@@ -209,7 +211,7 @@
             boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
             BOOST_VERIFY(!pthread_cond_signal(&cond));
         }
-
+
         void notify_all()
         {
             boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);

Modified: trunk/boost/thread/pthread/condition_variable_fwd.hpp
==============================================================================
--- trunk/boost/thread/pthread/condition_variable_fwd.hpp (original)
+++ trunk/boost/thread/pthread/condition_variable_fwd.hpp 2011-12-03 05:09:11 EST (Sat, 03 Dec 2011)
@@ -22,7 +22,7 @@
     private:
         pthread_mutex_t internal_mutex;
         pthread_cond_t cond;
-
+
         condition_variable(condition_variable&);
         condition_variable& operator=(condition_variable&);
 
@@ -44,7 +44,11 @@
         ~condition_variable()
         {
             BOOST_VERIFY(!pthread_mutex_destroy(&internal_mutex));
- BOOST_VERIFY(!pthread_cond_destroy(&cond));
+ int ret;
+ do {
+ ret = pthread_cond_destroy(&cond);
+ } while (ret == EINTR);
+ BOOST_VERIFY(!ret);
         }
 
         void wait(unique_lock<mutex>& m);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk