merged dht fix from RC_0_16
This commit is contained in:
parent
89cbe57b93
commit
89d5582560
|
@ -436,11 +436,11 @@ bool routing_table::add_node(node_entry e)
|
|||
// the routing table
|
||||
// pinged means that we have sent a message to the IP, port and received
|
||||
// a response with a correct transaction ID, i.e. it is verified to not
|
||||
// be the result of a poioned routing table
|
||||
// be the result of a poisoned routing table
|
||||
|
||||
node_entry* existing = 0;
|
||||
table_t::iterator existing_bucket;
|
||||
if (!e.pinged() || (existing = find_node(e.ep(), &existing_bucket)) == 0)
|
||||
node_entry* existing = find_node(e.ep(), &existing_bucket);
|
||||
if (!e.pinged() || existing == 0)
|
||||
{
|
||||
// the new node is not pinged, or it's not an existing node
|
||||
// we should ignore it, unless we allow duplicate IPs in our
|
||||
|
@ -454,46 +454,44 @@ bool routing_table::add_node(node_entry e)
|
|||
return ret;
|
||||
}
|
||||
}
|
||||
if (e.pinged() && existing)
|
||||
{
|
||||
// if the node ID is the same, just update the failcount
|
||||
// and be done with it
|
||||
if (existing->id == e.id)
|
||||
TORRENT_ASSERT(e.pinged() && existing);
|
||||
// if the node ID is the same, just update the failcount
|
||||
// and be done with it
|
||||
if (existing->id == e.id)
|
||||
{
|
||||
existing->timeout_count = 0;
|
||||
existing->update_rtt(e.rtt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// delete the current entry before we instert the new one
|
||||
bucket_t& b = existing_bucket->live_nodes;
|
||||
bucket_t& rb = existing_bucket->replacements;
|
||||
|
||||
bucket_t::iterator i = std::find_if(b.begin(), b.end()
|
||||
, boost::bind(&node_entry::ep, _1) == e.ep());
|
||||
if (i != b.end())
|
||||
{
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_LOG(table) << "node ID changed, deleting old entry: "
|
||||
<< i->id << " " << i->addr();
|
||||
#endif
|
||||
b.erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
i = std::find_if(rb.begin(), rb.end()
|
||||
, boost::bind(&node_entry::ep, _1) == e.ep());
|
||||
|
||||
// this must hold because existing != NULL
|
||||
TORRENT_ASSERT(i != rb.end());
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_LOG(table) << "node ID changed, deleting old entry: "
|
||||
<< i->id << " " << i->addr();
|
||||
#endif
|
||||
rb.erase(i);
|
||||
}
|
||||
m_ips.erase(e.addr().to_v4().to_bytes());
|
||||
existing->timeout_count = 0;
|
||||
existing->update_rtt(e.rtt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// delete the current entry before we instert the new one
|
||||
bucket_t& b = existing_bucket->live_nodes;
|
||||
bucket_t& rb = existing_bucket->replacements;
|
||||
|
||||
bucket_t::iterator i = std::find_if(b.begin(), b.end()
|
||||
, boost::bind(&node_entry::ep, _1) == e.ep());
|
||||
if (i != b.end())
|
||||
{
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_LOG(table) << "node ID changed, deleting old entry: "
|
||||
<< i->id << " " << i->addr();
|
||||
#endif
|
||||
b.erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
i = std::find_if(rb.begin(), rb.end()
|
||||
, boost::bind(&node_entry::ep, _1) == e.ep());
|
||||
|
||||
// this must hold because existing != NULL
|
||||
TORRENT_ASSERT(i != rb.end());
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_LOG(table) << "node ID changed, deleting old entry: "
|
||||
<< i->id << " " << i->addr();
|
||||
#endif
|
||||
rb.erase(i);
|
||||
}
|
||||
m_ips.erase(e.addr().to_v4().to_bytes());
|
||||
}
|
||||
|
||||
table_t::iterator i = find_bucket(e.id);
|
||||
|
|
Loading…
Reference in New Issue