fix of asio-debugging build in natpmp. resend_request could be called directly, not only as a handler for an async operation

This commit is contained in:
arvidn 2018-11-08 01:01:12 +01:00 committed by Arvid Norberg
parent e2f8bce539
commit a06a78ee1c
2 changed files with 10 additions and 4 deletions

View File

@ -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);

View File

@ -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;