From 35fa3832e83a634bff217d7220c481b5b0f0cb9e Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Fri, 17 Jan 2014 00:01:16 -0200 Subject: [PATCH] bugfix. this was a tough one. because the observer was already dequeued from m_transactions, we need to properly terminate it in some way. usually we go through the end of the function, where reply() does done(). however there are some error cases where function may returns sooner. this might be unlikely to occur in original upstream code (missing 'r' key, missing 'id'), but with IP enforcing it is not so uncommon. hopefully this will fix #32. --- libtorrent/src/kademlia/rpc_manager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libtorrent/src/kademlia/rpc_manager.cpp b/libtorrent/src/kademlia/rpc_manager.cpp index 5557b8bc..b55453ab 100644 --- a/libtorrent/src/kademlia/rpc_manager.cpp +++ b/libtorrent/src/kademlia/rpc_manager.cpp @@ -326,6 +326,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id) entry e; incoming_error(e, "missing 'r' key"); m_sock->send_packet(e, m.addr, 0); + o->timeout(); return false; } @@ -335,6 +336,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id) entry e; incoming_error(e, "missing 'id' key"); m_sock->send_packet(e, m.addr, 0); + o->timeout(); return false; } @@ -348,6 +350,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id) m_observer->set_external_address(address_v4(b) , m.addr.address()); // [MF] enforced: no valid response is sent along with "ip". + o->timeout(); return false; } #if TORRENT_USE_IPV6 @@ -360,6 +363,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id) m_observer->set_external_address(address_v6(b) , m.addr.address()); // [MF] enforced: no valid response is sent along with "ip". + o->timeout(); return false; } #endif @@ -505,10 +509,7 @@ observer::~observer() // reported back to the traversal_algorithm as // well. If it wasn't sent, it cannot have been // reported back - /* [MF] this assert seems too strict. Some usages of rpc_manager::invoke, for - * example, don't test the return value (false) which indicates that packet was not sent. TORRENT_ASSERT(m_was_sent == bool(flags & flag_done) || m_was_abandoned); - */ TORRENT_ASSERT(!m_in_constructor); #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS TORRENT_ASSERT(m_in_use);