diff -uprN boost_1_55_0.orig/boost/asio/detail/impl/task_io_service.ipp boost_1_55_0.patch/boost/asio/detail/impl/task_io_service.ipp --- boost_1_55_0.orig/boost/asio/detail/impl/task_io_service.ipp 2013-05-20 16:32:20.000000000 +0400 +++ boost_1_55_0.patch/boost/asio/detail/impl/task_io_service.ipp 2015-03-06 21:52:06.000000000 +0400 @@ -77,13 +77,26 @@ struct task_io_service::work_cleanup { lock_->lock(); task_io_service_->op_queue_.push(this_thread_->private_op_queue); + lock_->unlock(); } #endif // defined(BOOST_ASIO_HAS_THREADS) + + // If the last handler put a new work into the empty queue + // we should wake up a thread for it + if(check_new_handlers_) + { + lock_->lock(); + if(!task_io_service_->op_queue_.empty()) + task_io_service_->wake_one_thread_and_unlock(*lock_); + else + lock_->unlock(); + } } task_io_service* task_io_service_; mutex::scoped_lock* lock_; thread_info* this_thread_; + bool check_new_handlers_; }; task_io_service::task_io_service( @@ -377,7 +390,7 @@ std::size_t task_io_service::do_run_one( lock.unlock(); // Ensure the count of outstanding work is decremented on block exit. - work_cleanup on_exit = { this, &lock, &this_thread }; + work_cleanup on_exit = { this, &lock, &this_thread, !more_handlers && !one_thread_ }; (void)on_exit; // Complete the operation. May throw an exception. Deletes the object. diff -uprN boost_1_55_0.orig/boost/asio/detail/posix_event.hpp boost_1_55_0.patch/boost/asio/detail/posix_event.hpp --- boost_1_55_0.orig/boost/asio/detail/posix_event.hpp 2013-05-20 16:32:20.000000000 +0400 +++ boost_1_55_0.patch/boost/asio/detail/posix_event.hpp 2015-03-04 18:03:46.000000000 +0400 @@ -58,8 +58,8 @@ public: { BOOST_ASIO_ASSERT(lock.locked()); signalled_ = true; - lock.unlock(); ::pthread_cond_signal(&cond_); // Ignore EINVAL. + lock.unlock(); } // Reset the event.