From a06a78ee1ceb75f15bf466a9ef294fa6d5adca8b Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 8 Nov 2018 01:01:12 +0100 Subject: [PATCH] fix of asio-debugging build in natpmp. resend_request could be called directly, not only as a handler for an async operation --- include/libtorrent/natpmp.hpp | 3 ++- src/natpmp.cpp | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/libtorrent/natpmp.hpp b/include/libtorrent/natpmp.hpp index 296c96ac8..bd7d4bf17 100644 --- a/include/libtorrent/natpmp.hpp +++ b/include/libtorrent/natpmp.hpp @@ -104,7 +104,8 @@ private: void update_mapping(port_mapping_t i); void send_map_request(port_mapping_t i); void send_get_ip_address_request(); - void resend_request(port_mapping_t i, error_code const& e); + void on_resend_request(port_mapping_t i, error_code const& e); + void resend_request(port_mapping_t); void on_reply(error_code const& e , std::size_t bytes_transferred); void try_next_mapping(port_mapping_t i); diff --git a/src/natpmp.cpp b/src/natpmp.cpp index 2d2ceee14..d17866715 100644 --- a/src/natpmp.cpp +++ b/src/natpmp.cpp @@ -583,15 +583,20 @@ void natpmp::send_map_request(port_mapping_t const i) // linear back-off instead of exponential ++m_retry_count; m_send_timer.expires_from_now(milliseconds(250 * m_retry_count), ec); - m_send_timer.async_wait(std::bind(&natpmp::resend_request, self(), i, _1)); + m_send_timer.async_wait(std::bind(&natpmp::on_resend_request, self(), i, _1)); } } -void natpmp::resend_request(port_mapping_t const i, error_code const& e) +void natpmp::on_resend_request(port_mapping_t const i, error_code const& e) { TORRENT_ASSERT(is_single_thread()); COMPLETE_ASYNC("natpmp::resend_request"); if (e) return; + resend_request(i); +} + +void natpmp::resend_request(port_mapping_t const i) +{ if (m_currently_mapping != i) return; // if we're shutting down, don't retry, just move on @@ -696,7 +701,7 @@ void natpmp::on_reply(error_code const& e if (m_version == version_pcp && !is_v6(m_socket.local_endpoint())) { m_version = version_natpmp; - resend_request(m_currently_mapping, error_code()); + resend_request(m_currently_mapping); send_get_ip_address_request(); } return;