Browse Source

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.
miguelfreitas
Miguel Freitas 11 years ago
parent
commit
35fa3832e8
  1. 7
      libtorrent/src/kademlia/rpc_manager.cpp

7
libtorrent/src/kademlia/rpc_manager.cpp

@ -326,6 +326,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id) @@ -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) @@ -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) @@ -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) @@ -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() @@ -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);

Loading…
Cancel
Save