diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 6b8847f5d..1d0024374 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -1193,7 +1193,9 @@ namespace aux { aux::handler_storage m_tick_handler_storage; // abort may not fail and cannot allocate memory -#ifdef _M_AMD64 +#if defined BOOST_ASIO_ENABLE_HANDLER_TRACKING + aux::handler_storage<100> m_abort_handler_storage; +#elif defined _M_AMD64 aux::handler_storage<88> m_abort_handler_storage; #else aux::handler_storage<56> m_abort_handler_storage; diff --git a/src/kademlia/dht_tracker.cpp b/src/kademlia/dht_tracker.cpp index 66da30465..7eec91007 100644 --- a/src/kademlia/dht_tracker.cpp +++ b/src/kademlia/dht_tracker.cpp @@ -146,6 +146,7 @@ namespace libtorrent { namespace dht { if (m_running && n.second) { + ADD_OUTSTANDING_ASYNC("dht_tracker::connection_timeout"); error_code ec; n.first->second.connection_timer.expires_from_now(seconds(1), ec); n.first->second.connection_timer.async_wait( @@ -170,10 +171,13 @@ namespace libtorrent { namespace dht { { m_running = true; error_code ec; + + ADD_OUTSTANDING_ASYNC("dht_tracker::refresh_key"); refresh_key(ec); for (auto& n : m_nodes) { + ADD_OUTSTANDING_ASYNC("dht_tracker::connection_timeout"); n.second.connection_timer.expires_from_now(seconds(1), ec); n.second.connection_timer.async_wait( std::bind(&dht_tracker::connection_timeout, self(), n.first, _1)); @@ -183,6 +187,7 @@ namespace libtorrent { namespace dht { n.second.dht.bootstrap(concat(m_state.nodes, m_state.nodes6), f); } + ADD_OUTSTANDING_ASYNC("dht_tracker::refresh_timeout"); m_refresh_timer.expires_from_now(seconds(5), ec); m_refresh_timer.async_wait(std::bind(&dht_tracker::refresh_timeout, self(), _1)); @@ -242,6 +247,7 @@ namespace libtorrent { namespace dht { void dht_tracker::connection_timeout(aux::listen_socket_handle const& s, error_code const& e) { + COMPLETE_ASYNC("dht_tracker::connection_timeout"); if (e || !m_running) return; auto const it = m_nodes.find(s); @@ -254,11 +260,13 @@ namespace libtorrent { namespace dht { error_code ec; deadline_timer& timer = n.connection_timer; timer.expires_from_now(d, ec); + ADD_OUTSTANDING_ASYNC("dht_tracker::connection_timeout"); timer.async_wait(std::bind(&dht_tracker::connection_timeout, self(), s, _1)); } void dht_tracker::refresh_timeout(error_code const& e) { + COMPLETE_ASYNC("dht_tracker::refresh_timeout"); if (e || !m_running) return; for (auto& n : m_nodes) @@ -270,14 +278,17 @@ namespace libtorrent { namespace dht { error_code ec; m_refresh_timer.expires_from_now(seconds(5), ec); + ADD_OUTSTANDING_ASYNC("dht_tracker::refresh_timeout"); m_refresh_timer.async_wait( std::bind(&dht_tracker::refresh_timeout, self(), _1)); } void dht_tracker::refresh_key(error_code const& e) { + COMPLETE_ASYNC("dht_tracker::refresh_key"); if (e || !m_running) return; + ADD_OUTSTANDING_ASYNC("dht_tracker::refresh_key"); error_code ec; m_key_refresh_timer.expires_from_now(key_refresh, ec); m_key_refresh_timer.async_wait(std::bind(&dht_tracker::refresh_key, self(), _1)); diff --git a/test/test_direct_dht.cpp b/test/test_direct_dht.cpp index e2d2b48e4..53a72c303 100644 --- a/test/test_direct_dht.cpp +++ b/test/test_direct_dht.cpp @@ -91,6 +91,8 @@ dht_direct_response_alert* get_direct_response(lt::session& ses) TORRENT_TEST(direct_dht_request) { #if !defined TORRENT_DISABLE_EXTENSIONS && !defined TORRENT_DISABLE_DHT + + std::vector abort; settings_pack sp; sp.set_bool(settings_pack::enable_lsd, false); sp.set_bool(settings_pack::enable_natpmp, false); @@ -137,5 +139,8 @@ TORRENT_TEST(direct_dht_request) TEST_EQUAL(ra->response().type(), bdecode_node::none_t); TEST_EQUAL(ra->userdata, reinterpret_cast(123456)); } + + abort.emplace_back(responder.abort()); + abort.emplace_back(requester.abort()); #endif // #if !defined TORRENT_DISABLE_EXTENSIONS && !defined TORRENT_DISABLE_DHT }