diff --git a/include/libtorrent/udp_socket.hpp b/include/libtorrent/udp_socket.hpp index 6492a17fc..14fefb949 100644 --- a/include/libtorrent/udp_socket.hpp +++ b/include/libtorrent/udp_socket.hpp @@ -170,7 +170,7 @@ namespace libtorrent void on_writable(error_code const& ec, udp::socket* s); void setup_read(udp::socket* s); - void on_read(udp::socket* s); + void on_read(error_code const& ec, udp::socket* s); void on_read_impl(udp::socket* sock, udp::endpoint const& ep , error_code const& e, std::size_t bytes_transferred); void on_name_lookup(error_code const& e, tcp::resolver::iterator i); diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index ee0f32ab9..06fb58276 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -226,7 +226,7 @@ void udp_socket::on_writable(error_code const& ec, udp::socket* s) } // called whenever the socket is readable -void udp_socket::on_read(udp::socket* s) +void udp_socket::on_read(error_code const& ec, udp::socket* s) { #if defined TORRENT_ASIO_DEBUGGING complete_async("udp_socket::on_read"); @@ -248,6 +248,7 @@ void udp_socket::on_read(udp::socket* s) --m_v4_outstanding; } + if (ec == asio::error::operation_aborted) return; if (m_abort) return; CHECK_MAGIC; @@ -430,7 +431,7 @@ void udp_socket::setup_read(udp::socket* s) #endif udp::endpoint ep; s->async_receive_from(asio::null_buffers() - , ep, boost::bind(&udp_socket::on_read, this, s)); + , ep, boost::bind(&udp_socket::on_read, this, _1, s)); } void udp_socket::wrap(udp::endpoint const& ep, char const* p, int len, error_code& ec)