Ticket #11823: boost_asio_epoll_accept_exception_safety.patch

File boost_asio_epoll_accept_exception_safety.patch, 2.5 KB (added by Sorin Fetche <sorin.fetche@…>, 7 years ago)
  • boost_1_57_0/boost/asio/detail/impl/epoll_reactor.ipp

    Patch to fix exception safety in boost::asio::ip::tcp::acceptor::async_accept when running the epoll reactor.
    
    ----
    
    Steps to recreate the patch:
    1) Original boost sources in the directory: 
           packages\3rdParty\boost\<version>\src\original\boost_<version>\...
    2) Modified sources in:
           packages\3rdParty\boost\<version>\src\patched\boost_<version>\...
    3) Cygwin console, in folder: packages/3rdParty/boost/<version>/src
    4) Patch generated as: 
       diff -Nru original patched > boost_asio_epoll_accept_exception_safety.patch
    5) This note added to the patch file
    
    
    diff -Nru original/boost_1_57_0/boost/asio/detail/impl/epoll_reactor.ipp patched/boost_1_57_0/boost/asio/detail/impl/epoll_reactor.ipp
    old new  
    569569struct epoll_reactor::perform_io_cleanup_on_block_exit
    570570{
    571571  explicit perform_io_cleanup_on_block_exit(epoll_reactor* r)
    572     : reactor_(r), first_op_(0)
     572    : reactor_(r), first_op_(0), compensate_work_finished(false)
    573573  {
    574574  }
    575575
     
    586586      // the fact that the task_io_service will call work_finished() once we
    587587      // return.
    588588    }
    589     else
     589    else if( compensate_work_finished )
    590590    {
    591591      // No user-initiated operations have completed, so we need to compensate
    592592      // for the work_finished() call that the task_io_service will make once
     
    598598  epoll_reactor* reactor_;
    599599  op_queue<operation> ops_;
    600600  operation* first_op_;
     601  bool compensate_work_finished;
    601602};
    602603
    603604epoll_reactor::descriptor_state::descriptor_state()
     
    635636  // be posted for later by the io_cleanup object's destructor.
    636637  io_cleanup.first_op_ = io_cleanup.ops_.front();
    637638  io_cleanup.ops_.pop();
     639  io_cleanup.compensate_work_finished = true;
    638640  return io_cleanup.first_op_;
    639641}
    640642
  • boost_1_57_0/boost/asio/detail/task_io_service_operation.hpp

    diff -Nru original/boost_1_57_0/boost/asio/detail/task_io_service_operation.hpp patched/boost_1_57_0/boost/asio/detail/task_io_service_operation.hpp
    old new  
    4040
    4141  void destroy()
    4242  {
    43     func_(0, this, boost::system::error_code(), 0);
     43    try
     44    {
     45      func_(0, this, boost::system::error_code(), 0);
     46    }
     47    catch(std::exception&)
     48    {
     49    }
    4450  }
    4551
    4652protected: