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
|
|
569 | 569 | struct epoll_reactor::perform_io_cleanup_on_block_exit |
570 | 570 | { |
571 | 571 | 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) |
573 | 573 | { |
574 | 574 | } |
575 | 575 | |
… |
… |
|
586 | 586 | // the fact that the task_io_service will call work_finished() once we |
587 | 587 | // return. |
588 | 588 | } |
589 | | else |
| 589 | else if( compensate_work_finished ) |
590 | 590 | { |
591 | 591 | // No user-initiated operations have completed, so we need to compensate |
592 | 592 | // for the work_finished() call that the task_io_service will make once |
… |
… |
|
598 | 598 | epoll_reactor* reactor_; |
599 | 599 | op_queue<operation> ops_; |
600 | 600 | operation* first_op_; |
| 601 | bool compensate_work_finished; |
601 | 602 | }; |
602 | 603 | |
603 | 604 | epoll_reactor::descriptor_state::descriptor_state() |
… |
… |
|
635 | 636 | // be posted for later by the io_cleanup object's destructor. |
636 | 637 | io_cleanup.first_op_ = io_cleanup.ops_.front(); |
637 | 638 | io_cleanup.ops_.pop(); |
| 639 | io_cleanup.compensate_work_finished = true; |
638 | 640 | return io_cleanup.first_op_; |
639 | 641 | } |
640 | 642 | |
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
|
|
40 | 40 | |
41 | 41 | void destroy() |
42 | 42 | { |
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 | } |
44 | 50 | } |
45 | 51 | |
46 | 52 | protected: |