avoid incorrect assert in the DHT

This commit is contained in:
Arvid Norberg 2012-06-24 22:53:15 +00:00
parent 84d1498122
commit 60f501ca5d
3 changed files with 11 additions and 2 deletions

View File

@ -81,6 +81,7 @@ struct observer : boost::noncopyable
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
m_in_constructor = true; m_in_constructor = true;
m_was_sent = false; m_was_sent = false;
m_was_abandoned = false;
#endif #endif
set_target(ep); set_target(ep);
} }
@ -165,6 +166,7 @@ public:
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
bool m_in_constructor:1; bool m_in_constructor:1;
bool m_was_sent:1; bool m_was_sent:1;
bool m_was_abandoned:1;
#endif #endif
}; };

View File

@ -487,7 +487,7 @@ observer::~observer()
// reported back to the traversal_algorithm as // reported back to the traversal_algorithm as
// well. If it wasn't sent, it cannot have been // well. If it wasn't sent, it cannot have been
// reported back // reported back
TORRENT_ASSERT(m_was_sent == bool(flags & flag_done)); TORRENT_ASSERT(m_was_sent == bool(flags & flag_done) || m_was_abandoned);
TORRENT_ASSERT(!m_in_constructor); TORRENT_ASSERT(!m_in_constructor);
} }

View File

@ -156,7 +156,14 @@ void traversal_algorithm::add_entry(node_id const& id, udp::endpoint addr, unsig
i = m_results.insert(i, o); i = m_results.insert(i, o);
} }
if (m_results.size() > 100) m_results.resize(100); if (m_results.size() > 100)
{
#ifdef TORRENT_DEBUG
for (int i = 100; i < m_results.size(); ++i)
m_results[i]->m_was_abandoned = true;
#endif
m_results.resize(100);
}
} }
void traversal_algorithm::start() void traversal_algorithm::start()