diff --git a/src/natpmp.cpp b/src/natpmp.cpp index 4f642599e..d9ec42beb 100644 --- a/src/natpmp.cpp +++ b/src/natpmp.cpp @@ -58,6 +58,7 @@ natpmp::natpmp(io_service& ios, address const& listen_interface, portmap_callbac , m_refresh_timer(ios) , m_next_refresh(-1) , m_disabled(false) + , m_abort(false) { rebind(listen_interface); } @@ -298,13 +299,18 @@ void natpmp::send_map_request(int i) error_code ec; m_socket.send_to(asio::buffer(buf, 12), m_nat_endpoint, 0, ec); m.map_sent = true; - // linear back-off instead of exponential if (m_abort) { + // when we're shutting down, ignore the + // responses and just remove all mappings + // immediately + m_currently_mapping = -1; + m.action = mapping_t::action_none; try_next_mapping(i); } else { + // 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(bind(&natpmp::resend_request, self(), i, _1));