forked from premiere/premiere-libtorrent
asserts in dht
This commit is contained in:
parent
a16d592ff4
commit
99eed299cd
|
@ -56,9 +56,16 @@ struct observer : boost::noncopyable
|
||||||
: sent(time_now())
|
: sent(time_now())
|
||||||
, pool_allocator(p)
|
, pool_allocator(p)
|
||||||
, m_refs(0)
|
, m_refs(0)
|
||||||
{}
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
m_in_constructor = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~observer() {}
|
virtual ~observer()
|
||||||
|
{
|
||||||
|
TORRENT_ASSERT(!m_in_constructor);
|
||||||
|
}
|
||||||
|
|
||||||
// these two callbacks lets the observer add
|
// these two callbacks lets the observer add
|
||||||
// information to the message before it's sent
|
// information to the message before it's sent
|
||||||
|
@ -79,6 +86,9 @@ struct observer : boost::noncopyable
|
||||||
|
|
||||||
udp::endpoint target_addr;
|
udp::endpoint target_addr;
|
||||||
ptime sent;
|
ptime sent;
|
||||||
|
#ifndef NDEBUG
|
||||||
|
bool m_in_constructor;
|
||||||
|
#endif
|
||||||
private:
|
private:
|
||||||
boost::pool<>& pool_allocator;
|
boost::pool<>& pool_allocator;
|
||||||
// reference counter for intrusive_ptr
|
// reference counter for intrusive_ptr
|
||||||
|
|
|
@ -102,6 +102,9 @@ void closest_nodes::invoke(node_id const& id, udp::endpoint addr)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(closest_nodes_observer));
|
TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(closest_nodes_observer));
|
||||||
observer_ptr o(new (m_rpc.allocator().malloc()) closest_nodes_observer(this, id, m_target));
|
observer_ptr o(new (m_rpc.allocator().malloc()) closest_nodes_observer(this, id, m_target));
|
||||||
|
#ifndef NDEBUG
|
||||||
|
o->m_in_constructor = false;
|
||||||
|
#endif
|
||||||
m_rpc.invoke(messages::find_node, addr, o);
|
m_rpc.invoke(messages::find_node, addr, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,9 @@ void find_data::invoke(node_id const& id, asio::ip::udp::endpoint addr)
|
||||||
|
|
||||||
TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(find_data_observer));
|
TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(find_data_observer));
|
||||||
observer_ptr o(new (m_rpc.allocator().malloc()) find_data_observer(this, id, m_target));
|
observer_ptr o(new (m_rpc.allocator().malloc()) find_data_observer(this, id, m_target));
|
||||||
|
#ifndef NDEBUG
|
||||||
|
o->m_in_constructor = false;
|
||||||
|
#endif
|
||||||
m_rpc.invoke(messages::get_peers, addr, o);
|
m_rpc.invoke(messages::get_peers, addr, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,8 +273,11 @@ namespace
|
||||||
for (std::vector<node_entry>::const_iterator i = v.begin()
|
for (std::vector<node_entry>::const_iterator i = v.begin()
|
||||||
, end(v.end()); i != end; ++i)
|
, end(v.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
rpc.invoke(messages::get_peers, i->addr, observer_ptr(
|
observer_ptr o(new (rpc.allocator().malloc()) get_peers_observer(ih, listen_port, rpc, f));
|
||||||
new (rpc.allocator().malloc()) get_peers_observer(ih, listen_port, rpc, f)));
|
#ifndef NDEBUG
|
||||||
|
o->m_in_constructor = false;
|
||||||
|
#endif
|
||||||
|
rpc.invoke(messages::get_peers, i->addr, o);
|
||||||
nodes = true;
|
nodes = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,6 +293,9 @@ void node_impl::add_node(udp::endpoint node)
|
||||||
// ping the node, and if we get a reply, it
|
// ping the node, and if we get a reply, it
|
||||||
// will be added to the routing table
|
// will be added to the routing table
|
||||||
observer_ptr o(new (m_rpc.allocator().malloc()) null_observer(m_rpc.allocator()));
|
observer_ptr o(new (m_rpc.allocator().malloc()) null_observer(m_rpc.allocator()));
|
||||||
|
#ifndef NDEBUG
|
||||||
|
o->m_in_constructor = false;
|
||||||
|
#endif
|
||||||
m_rpc.invoke(messages::ping, node, o);
|
m_rpc.invoke(messages::ping, node, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,9 @@ void refresh::invoke(node_id const& nid, udp::endpoint addr)
|
||||||
TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(refresh_observer));
|
TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(refresh_observer));
|
||||||
observer_ptr o(new (m_rpc.allocator().malloc()) refresh_observer(
|
observer_ptr o(new (m_rpc.allocator().malloc()) refresh_observer(
|
||||||
this, nid, m_target));
|
this, nid, m_target));
|
||||||
|
#ifndef NDEBUG
|
||||||
|
o->m_in_constructor = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_rpc.invoke(messages::find_node, addr, o);
|
m_rpc.invoke(messages::find_node, addr, o);
|
||||||
}
|
}
|
||||||
|
@ -158,6 +161,9 @@ void refresh::invoke_pings_or_finish(bool prevent_request)
|
||||||
TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(ping_observer));
|
TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(ping_observer));
|
||||||
observer_ptr o(new (m_rpc.allocator().malloc()) ping_observer(
|
observer_ptr o(new (m_rpc.allocator().malloc()) ping_observer(
|
||||||
this, node.id));
|
this, node.id));
|
||||||
|
#ifndef NDEBUG
|
||||||
|
o->m_in_constructor = false;
|
||||||
|
#endif
|
||||||
m_rpc.invoke(messages::ping, node.addr, o);
|
m_rpc.invoke(messages::ping, node.addr, o);
|
||||||
++m_active_pings;
|
++m_active_pings;
|
||||||
++m_leftover_nodes_iterator;
|
++m_leftover_nodes_iterator;
|
||||||
|
|
|
@ -438,6 +438,9 @@ void rpc_manager::reply_with_ping(msg& m)
|
||||||
|
|
||||||
TORRENT_ASSERT(allocation_size() >= sizeof(null_observer));
|
TORRENT_ASSERT(allocation_size() >= sizeof(null_observer));
|
||||||
observer_ptr o(new (allocator().malloc()) null_observer(allocator()));
|
observer_ptr o(new (allocator().malloc()) null_observer(allocator()));
|
||||||
|
#ifndef NDEBUG
|
||||||
|
o->m_in_constructor = false;
|
||||||
|
#endif
|
||||||
TORRENT_ASSERT(!m_transactions[m_next_transaction_id]);
|
TORRENT_ASSERT(!m_transactions[m_next_transaction_id]);
|
||||||
o->sent = time_now();
|
o->sent = time_now();
|
||||||
o->target_addr = m.addr;
|
o->target_addr = m.addr;
|
||||||
|
|
Loading…
Reference in New Issue