From 1be2b6dc1a4c470b0e0dfd51f5d51c36af1dce8b Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 17 Nov 2013 23:06:51 +0000 Subject: [PATCH] some errors cause asio to throw exceptions instead of returning the error in the passed in error_code&. catch the one in udp_socket --- src/udp_socket.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index cf61f6516..a6aee814e 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #if BOOST_VERSION < 103500 #include #else @@ -471,8 +472,16 @@ void udp_socket::setup_read(udp::socket* s) add_outstanding_async("udp_socket::on_read"); #endif udp::endpoint ep; - s->async_receive_from(asio::null_buffers() - , ep, boost::bind(&udp_socket::on_read, this, _1, s)); + TORRENT_TRY + { + s->async_receive_from(asio::null_buffers() + , ep, boost::bind(&udp_socket::on_read, this, _1, s)); + } + TORRENT_CATCH(boost::system::system_error& e) + { + get_io_service().post(boost::bind(&udp_socket::on_read + , this, e.code(), s)); + } } void udp_socket::wrap(udp::endpoint const& ep, char const* p, int len, error_code& ec)