forked from premiere/premiere-libtorrent
fix in DHT counters, alert types test, typos, formatting (#1747)
fix in DHT counters, alert types test, typos, formatting
This commit is contained in:
parent
23edbfbee8
commit
ee4d82d166
|
@ -396,7 +396,7 @@ namespace libtorrent
|
|||
|
||||
void dht_live_nodes(sha1_hash const& nid);
|
||||
|
||||
void dht_direct_request(udp::endpoint ep, entry& e
|
||||
void dht_direct_request(udp::endpoint const& ep, entry& e
|
||||
, void* userdata = nullptr);
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
|
|
|
@ -455,7 +455,7 @@ namespace libtorrent
|
|||
// with the response (if any) and the userdata pointer passed in here.
|
||||
// Since this alert is a response to an explicit call, it will always be
|
||||
// posted, regardless of the alert mask.
|
||||
void dht_direct_request(udp::endpoint ep, entry const& e, void* userdata = nullptr);
|
||||
void dht_direct_request(udp::endpoint const& ep, entry const& e, void* userdata = nullptr);
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
// deprecated in 0.15
|
||||
|
|
|
@ -31,15 +31,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
#include <libtorrent/config.hpp>
|
||||
#include <libtorrent/hasher.hpp>
|
||||
#include <libtorrent/bdecode.hpp>
|
||||
#include <libtorrent/kademlia/get_item.hpp>
|
||||
#include <libtorrent/kademlia/node.hpp>
|
||||
#include <libtorrent/kademlia/dht_observer.hpp>
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
#include <libtorrent/bencode.hpp>
|
||||
#endif
|
||||
#include <libtorrent/performance_counters.hpp>
|
||||
|
||||
namespace libtorrent { namespace dht
|
||||
{
|
||||
|
@ -91,7 +87,7 @@ void get_item::got_data(bdecode_node const& v,
|
|||
|
||||
// for get_item, we should call callback when we get data,
|
||||
// even if the date is not authoritative, we can update later.
|
||||
// so caller can get response ASAP without waitting transaction
|
||||
// so caller can get response ASAP without waiting transaction
|
||||
// time-out (15 seconds).
|
||||
// for put_item, the callback function will do nothing
|
||||
// if the data is non-authoritative.
|
||||
|
@ -146,6 +142,8 @@ bool get_item::invoke(observer_ptr o)
|
|||
e["q"] = "get";
|
||||
a["target"] = target().to_string();
|
||||
|
||||
m_node.stats_counters().inc_stats_counter(counters::dht_get_out);
|
||||
|
||||
return m_node.m_rpc.invoke(e, o->target_ep(), o);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <libtorrent/kademlia/dht_observer.hpp>
|
||||
#include <libtorrent/kademlia/node.hpp>
|
||||
#include <libtorrent/io.hpp>
|
||||
#include <libtorrent/performance_counters.hpp>
|
||||
|
||||
namespace libtorrent { namespace dht
|
||||
{
|
||||
|
@ -85,8 +86,8 @@ bool put_data::invoke(observer_ptr o)
|
|||
{
|
||||
if (m_done) return false;
|
||||
|
||||
// TODO: what if o is not an isntance of put_data_observer? This need to be
|
||||
// redesigned for better type saftey.
|
||||
// TODO: what if o is not an instance of put_data_observer? This need to be
|
||||
// redesigned for better type safety.
|
||||
put_data_observer* po = static_cast<put_data_observer*>(o.get());
|
||||
|
||||
entry e;
|
||||
|
@ -106,6 +107,8 @@ bool put_data::invoke(observer_ptr o)
|
|||
}
|
||||
}
|
||||
|
||||
m_node.stats_counters().inc_stats_counter(counters::dht_put_out);
|
||||
|
||||
return m_node.m_rpc.invoke(e, o->target_ep(), o);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace libtorrent
|
|||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
(m_impl->*f)(a...);
|
||||
(m_impl->*f)(std::forward<Args>(a)...);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (system_error const& e) {
|
||||
m_impl->alerts().emplace_alert<session_error_alert>(e.code(), e.what());
|
||||
|
@ -86,7 +86,7 @@ namespace libtorrent
|
|||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
(m_impl->*f)(a...);
|
||||
(m_impl->*f)(std::forward<Args>(a)...);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (...) {
|
||||
ex = std::current_exception();
|
||||
|
@ -115,7 +115,7 @@ namespace libtorrent
|
|||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try {
|
||||
#endif
|
||||
r = (m_impl->*f)(a...);
|
||||
r = (m_impl->*f)(std::forward<Args>(a)...);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch (...) {
|
||||
ex = std::current_exception();
|
||||
|
@ -610,7 +610,7 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
void session_handle::dht_direct_request(udp::endpoint ep, entry const& e, void* userdata)
|
||||
void session_handle::dht_direct_request(udp::endpoint const& ep, entry const& e, void* userdata)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
entry copy = e;
|
||||
|
|
|
@ -5838,7 +5838,7 @@ namespace aux {
|
|||
m_alerts.emplace_alert<dht_live_nodes_alert>(nid, nodes);
|
||||
}
|
||||
|
||||
void session_impl::dht_direct_request(udp::endpoint ep, entry& e, void* userdata)
|
||||
void session_impl::dht_direct_request(udp::endpoint const& ep, entry& e, void* userdata)
|
||||
{
|
||||
if (!m_dht) return;
|
||||
m_dht->direct_request(ep, e, std::bind(&on_direct_response, std::ref(m_alerts), userdata, _1));
|
||||
|
|
|
@ -39,6 +39,21 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
using namespace libtorrent;
|
||||
|
||||
TORRENT_TEST(alerts_types)
|
||||
{
|
||||
#define TEST_ALERT_TYPE(name, seq, prio) \
|
||||
TEST_EQUAL(name::priority, prio); \
|
||||
TEST_EQUAL(name::alert_type, seq);
|
||||
|
||||
TEST_ALERT_TYPE(dht_get_peers_reply_alert, 87, 0);
|
||||
TEST_ALERT_TYPE(session_error_alert, 90, 0);
|
||||
TEST_ALERT_TYPE(dht_live_nodes_alert, 91, 0);
|
||||
|
||||
#undef TEST_ALERT_TYPE
|
||||
|
||||
TEST_EQUAL(num_alert_types, 92);
|
||||
}
|
||||
|
||||
TORRENT_TEST(dht_get_peers_reply_alert)
|
||||
{
|
||||
alert_manager mgr(1, dht_get_peers_reply_alert::static_category);
|
||||
|
|
|
@ -195,7 +195,7 @@ TORRENT_TEST(test_assign2)
|
|||
bitfield test1;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
memset(&b[i], 0xff, 5);
|
||||
std::memset(&b[i], 0xff, 5);
|
||||
b[i + 5] = char(0xc0);
|
||||
test1.assign(&b[i], 32 + 8 + 2);
|
||||
print_bitfield(test1);
|
||||
|
|
|
@ -2437,7 +2437,7 @@ TORRENT_TEST(traversal_done)
|
|||
std::array<node_entry, 9> nodes = build_nodes(target);
|
||||
|
||||
// invert the ith most significant byte so that the test nodes are
|
||||
// progressivly closer to the target item
|
||||
// progressively closer to the target item
|
||||
for (int i = 0; i < num_test_nodes; ++i)
|
||||
nodes[i].id[i] = ~nodes[i].id[i];
|
||||
|
||||
|
|
Loading…
Reference in New Issue