diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 3095dbd4b..510a0f857 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -313,7 +313,7 @@ namespace libtorrent void dht_get_mutable_item(boost::array key , std::string salt = std::string()); - void dht_put_immutable_item(entry data, sha1_hash target); + void dht_put_immutable_item(entry const& data, sha1_hash target); void dht_put_mutable_item(boost::array key , boost::function& diff --git a/include/libtorrent/kademlia/dht_tracker.hpp b/include/libtorrent/kademlia/dht_tracker.hpp index b32e82ccd..0f2749db3 100644 --- a/include/libtorrent/kademlia/dht_tracker.hpp +++ b/include/libtorrent/kademlia/dht_tracker.hpp @@ -104,14 +104,14 @@ namespace libtorrent { namespace dht // for immutable_item. // the callback function will be called when put operation is done. // the int parameter indicates the success numbers of put operation. - void put_item(entry data + void put_item(entry const& data , boost::function cb); // for mutable_item. // the data_cb will be called when we get authoritative mutable_item, // the cb is same as put immutable_item. void put_item(char const* key - , boost::function cb + , boost::function cb , boost::function data_cb, std::string salt = std::string()); // send an arbitrary DHT request directly to a node diff --git a/include/libtorrent/kademlia/get_item.hpp b/include/libtorrent/kademlia/get_item.hpp index 44ed3980d..00df641c9 100644 --- a/include/libtorrent/kademlia/get_item.hpp +++ b/include/libtorrent/kademlia/get_item.hpp @@ -43,7 +43,7 @@ namespace libtorrent { namespace dht class get_item : public find_data { public: - typedef boost::function data_callback; + typedef boost::function data_callback; void got_data(bdecode_node const& v, char const* pk, diff --git a/include/libtorrent/kademlia/node.hpp b/include/libtorrent/kademlia/node.hpp index 40e1b2cba..ae18994c1 100644 --- a/include/libtorrent/kademlia/node.hpp +++ b/include/libtorrent/kademlia/node.hpp @@ -177,12 +177,12 @@ public: void direct_request(udp::endpoint ep, entry& e , boost::function f); - void get_item(sha1_hash const& target, boost::function f); - void get_item(char const* pk, std::string const& salt, boost::function f); + void get_item(sha1_hash const& target, boost::function f); + void get_item(char const* pk, std::string const& salt, boost::function f); - void put_item(sha1_hash const& target, entry& data, boost::function f); + void put_item(sha1_hash const& target, entry const& data, boost::function f); void put_item(char const* pk, std::string const& salt - , boost::function f + , boost::function f , boost::function data_cb); bool verify_token(std::string const& token, char const* info_hash diff --git a/include/libtorrent/kademlia/put_data.hpp b/include/libtorrent/kademlia/put_data.hpp index 23f65b76b..5330581b5 100644 --- a/include/libtorrent/kademlia/put_data.hpp +++ b/include/libtorrent/kademlia/put_data.hpp @@ -53,7 +53,7 @@ class node; struct put_data: traversal_algorithm { - typedef boost::function put_callback; + typedef boost::function put_callback; put_data(node& node, put_callback const& callback); diff --git a/src/kademlia/dht_tracker.cpp b/src/kademlia/dht_tracker.cpp index b20cc3652..29a511835 100644 --- a/src/kademlia/dht_tracker.cpp +++ b/src/kademlia/dht_tracker.cpp @@ -254,7 +254,7 @@ namespace libtorrent { namespace dht m_dht.get_item(key, salt, cb); } - void dht_tracker::put_item(entry data + void dht_tracker::put_item(entry const& data , boost::function cb) { std::string flat_data; @@ -266,7 +266,7 @@ namespace libtorrent { namespace dht } void dht_tracker::put_item(char const* key - , boost::function cb + , boost::function cb , boost::function data_cb, std::string salt) { m_dht.put_item(key, salt, cb, data_cb); diff --git a/src/kademlia/get_item.cpp b/src/kademlia/get_item.cpp index 25ca0330b..317b9a151 100644 --- a/src/kademlia/get_item.cpp +++ b/src/kademlia/get_item.cpp @@ -119,7 +119,7 @@ get_item::get_item( , nodes_callback const& ncallback) : find_data(dht_node, item_target_id( std::make_pair(salt.c_str(), int(salt.size())), pk) - , ncallback) + , ncallback) , m_data_callback(dcallback) , m_data(pk, salt) , m_immutable(false) diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index cb06b59c6..e4491e058 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -423,7 +423,7 @@ void node::direct_request(udp::endpoint ep, entry& e } void node::get_item(sha1_hash const& target - , boost::function f) + , boost::function f) { #ifndef TORRENT_DISABLE_LOGGING if (m_observer) @@ -441,7 +441,7 @@ void node::get_item(sha1_hash const& target } void node::get_item(char const* pk, std::string const& salt - , boost::function f) + , boost::function f) { #ifndef TORRENT_DISABLE_LOGGING if (m_observer) @@ -462,13 +462,13 @@ namespace { void put(std::vector > const& nodes , boost::intrusive_ptr ta) { - ta->set_targets(nodes); + ta->set_targets(nodes); ta->start(); } -void put_data_cb(item& i, bool auth - , boost::intrusive_ptr ta - , boost::function f) +void put_data_cb(item i, bool auth + , boost::intrusive_ptr ta + , boost::function f) { // call data_callback only when we got authoritative data. if (auth) @@ -480,7 +480,7 @@ void put_data_cb(item& i, bool auth } // namespace -void node::put_item(sha1_hash const& target, entry& data, boost::function f) +void node::put_item(sha1_hash const& target, entry const& data, boost::function f) { #ifndef TORRENT_DISABLE_LOGGING if (m_observer) @@ -505,7 +505,7 @@ void node::put_item(sha1_hash const& target, entry& data, boost::function f + , boost::function f , boost::function data_cb) { #ifndef TORRENT_DISABLE_LOGGING diff --git a/src/kademlia/put_data.cpp b/src/kademlia/put_data.cpp index f23f09673..51e7b4556 100644 --- a/src/kademlia/put_data.cpp +++ b/src/kademlia/put_data.cpp @@ -67,7 +67,6 @@ void put_data::set_targets(std::vector > cons void put_data::done() { - if (m_invoke_count != 0) return; m_done = true; #ifndef TORRENT_DISABLE_LOGGING diff --git a/src/session_impl.cpp b/src/session_impl.cpp index c970c131a..03fd963b5 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -5654,7 +5654,7 @@ retry: alerts.emplace_alert(target, num); } - void on_dht_put_mutable_item(alert_manager& alerts, dht::item& i, int num) + void on_dht_put_mutable_item(alert_manager& alerts, dht::item const& i, int num) { boost::array sig = i.sig(); boost::array pk = i.pk(); @@ -5694,7 +5694,7 @@ retry: } // anonymous namespace - void session_impl::dht_put_immutable_item(entry data, sha1_hash target) + void session_impl::dht_put_immutable_item(entry const& data, sha1_hash target) { if (!m_dht) return; m_dht->put_item(data, boost::bind(&on_dht_put_immutable_item, boost::ref(m_alerts) diff --git a/test/test_dht.cpp b/test/test_dht.cpp index 6a8ce602d..1d5d2d108 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -481,7 +481,7 @@ std::vector g_got_items; dht::item g_put_item; int g_put_count; -void get_mutable_item_cb(dht::item& i, bool a) +void get_mutable_item_cb(dht::item const& i, bool a) { if (!a) return; if (!i.empty()) @@ -498,12 +498,12 @@ void put_mutable_item_data_cb(dht::item& i) g_put_count++; } -void put_mutable_item_cb(dht::item&, int num, int expect) +void put_mutable_item_cb(dht::item const&, int num, int expect) { TEST_EQUAL(num, expect); } -void get_immutable_item_cb(dht::item& i) +void get_immutable_item_cb(dht::item const& i) { if (!i.empty()) g_got_items.push_back(i);