Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84482 - trunk/boost/asio/detail/impl
From: chris_at_[hidden]
Date: 2013-05-25 07:35:11


Author: chris_kohlhoff
Date: 2013-05-25 07:35:10 EDT (Sat, 25 May 2013)
New Revision: 84482
URL: http://svn.boost.org/trac/boost/changeset/84482

Log:
Fix potential deadlock in signal_set implementation.
Text files modified:
   trunk/boost/asio/detail/impl/signal_set_service.ipp | 35 +++++++++++++++++++++++++----------
   1 files changed, 25 insertions(+), 10 deletions(-)

Modified: trunk/boost/asio/detail/impl/signal_set_service.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/signal_set_service.ipp (original)
+++ trunk/boost/asio/detail/impl/signal_set_service.ipp 2013-05-25 07:35:10 EDT (Sat, 25 May 2013)
@@ -162,14 +162,22 @@
   switch (fork_ev)
   {
   case boost::asio::io_service::fork_prepare:
- reactor_.deregister_internal_descriptor(
- state->read_descriptor_, reactor_data_);
- state->fork_prepared_ = true;
+ {
+ int read_descriptor = state->read_descriptor_;
+ state->fork_prepared_ = true;
+ lock.unlock();
+ reactor_.deregister_internal_descriptor(read_descriptor, reactor_data_);
+ }
     break;
   case boost::asio::io_service::fork_parent:
- state->fork_prepared_ = false;
- reactor_.register_internal_descriptor(reactor::read_op,
- state->read_descriptor_, reactor_data_, new pipe_read_op);
+ if (state->fork_prepared_)
+ {
+ int read_descriptor = state->read_descriptor_;
+ state->fork_prepared_ = false;
+ lock.unlock();
+ reactor_.register_internal_descriptor(reactor::read_op,
+ read_descriptor, reactor_data_, new pipe_read_op);
+ }
     break;
   case boost::asio::io_service::fork_child:
     if (state->fork_prepared_)
@@ -177,10 +185,12 @@
       boost::asio::detail::signal_blocker blocker;
       close_descriptors();
       open_descriptors();
+ int read_descriptor = state->read_descriptor_;
       state->fork_prepared_ = false;
+ lock.unlock();
+ reactor_.register_internal_descriptor(reactor::read_op,
+ read_descriptor, reactor_data_, new pipe_read_op);
     }
- reactor_.register_internal_descriptor(reactor::read_op,
- state->read_descriptor_, reactor_data_, new pipe_read_op);
     break;
   default:
     break;
@@ -481,8 +491,10 @@
 
 #if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
   // Register for pipe readiness notifications.
+ int read_descriptor = state->read_descriptor_;
+ lock.unlock();
   service->reactor_.register_internal_descriptor(reactor::read_op,
- state->read_descriptor_, service->reactor_data_, new pipe_read_op);
+ read_descriptor, service->reactor_data_, new pipe_read_op);
 #endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
 }
 
@@ -495,8 +507,11 @@
   {
 #if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
     // Disable the pipe readiness notifications.
+ int read_descriptor = state->read_descriptor_;
+ lock.unlock();
     service->reactor_.deregister_descriptor(
- state->read_descriptor_, service->reactor_data_, false);
+ read_descriptor, service->reactor_data_, false);
+ lock.lock();
 #endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
 
     // Remove service from linked list of all services.


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