fixed natpmp (broken in [3023])

This commit is contained in:
Arvid Norberg 2008-12-19 19:27:58 +00:00
parent 2c03c44a59
commit 41b2be779e
1 changed files with 7 additions and 1 deletions

View File

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