removed spaces in template types and more c++11 auto/loop refactor
This commit is contained in:
parent
f2efee4477
commit
6751a1eeb1
|
@ -169,4 +169,3 @@ void bind_converters()
|
||||||
list_to_vector<lt::udp::endpoint>();
|
list_to_vector<lt::udp::endpoint>();
|
||||||
list_to_vector<std::pair<std::string, int>>();
|
list_to_vector<std::pair<std::string, int>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,4 +145,3 @@ visitor<F> allow_threads(F fn)
|
||||||
//}} // namespace libtorrent::python
|
//}} // namespace libtorrent::python
|
||||||
|
|
||||||
#endif // GIL_070107_HPP
|
#endif // GIL_070107_HPP
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,8 @@ namespace {
|
||||||
ret["trackers"] = tracker_list;
|
ret["trackers"] = tracker_list;
|
||||||
|
|
||||||
list nodes_list;
|
list nodes_list;
|
||||||
for (std::vector<std::pair<std::string, int> >::const_iterator i = p.dht_nodes.begin()
|
for (auto const& i : p.dht_nodes)
|
||||||
, end(p.dht_nodes.end()); i != end; ++i)
|
tracker_list.append(boost::python::make_tuple(i.first, i.second));
|
||||||
tracker_list.append(boost::python::make_tuple(i->first, i->second));
|
|
||||||
ret["dht_nodes"] = nodes_list;
|
ret["dht_nodes"] = nodes_list;
|
||||||
ret["info_hash"] = p.info_hash;
|
ret["info_hash"] = p.info_hash;
|
||||||
ret["name"] = p.name;
|
ret["name"] = p.name;
|
||||||
|
@ -83,4 +82,3 @@ void bind_magnet_uri()
|
||||||
def("make_magnet_uri", make_magnet_uri1);
|
def("make_magnet_uri", make_magnet_uri1);
|
||||||
def("parse_magnet_uri", parse_magnet_uri_wrap);
|
def("parse_magnet_uri", parse_magnet_uri_wrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -854,4 +854,3 @@ void bind_session()
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -503,4 +503,3 @@ void bind_torrent_handle()
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -43,12 +43,8 @@ namespace
|
||||||
{
|
{
|
||||||
list result;
|
list result;
|
||||||
|
|
||||||
typedef std::vector<std::pair<std::string, int> > list_type;
|
for (auto const& i : ti.nodes())
|
||||||
|
result.append(boost::python::make_tuple(i.first, i.second));
|
||||||
for (list_type::const_iterator i = ti.nodes().begin(); i != ti.nodes().end(); ++i)
|
|
||||||
{
|
|
||||||
result.append(boost::python::make_tuple(i->first, i->second));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -319,4 +315,3 @@ void bind_torrent_info()
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -159,20 +159,12 @@ int main(int argc, char* argv[])
|
||||||
// print info about torrent
|
// print info about torrent
|
||||||
std::printf("\n\n----- torrent file info -----\n\n"
|
std::printf("\n\n----- torrent file info -----\n\n"
|
||||||
"nodes:\n");
|
"nodes:\n");
|
||||||
|
for (auto const& i : t.nodes())
|
||||||
|
std::printf("%s: %d\n", i.first.c_str(), i.second);
|
||||||
|
|
||||||
typedef std::vector<std::pair<std::string, int> > node_vec;
|
|
||||||
node_vec const& nodes = t.nodes();
|
|
||||||
for (node_vec::const_iterator i = nodes.begin(), end(nodes.end());
|
|
||||||
i != end; ++i)
|
|
||||||
{
|
|
||||||
std::printf("%s: %d\n", i->first.c_str(), i->second);
|
|
||||||
}
|
|
||||||
puts("trackers:\n");
|
puts("trackers:\n");
|
||||||
for (std::vector<announce_entry>::const_iterator i = t.trackers().begin();
|
for (auto const& i : t.trackers())
|
||||||
i != t.trackers().end(); ++i)
|
std::printf("%2d: %s\n", i.tier, i.url.c_str());
|
||||||
{
|
|
||||||
std::printf("%2d: %s\n", i->tier, i->url.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::stringstream ih;
|
std::stringstream ih;
|
||||||
ih << t.info_hash();
|
ih << t.info_hash();
|
||||||
|
@ -226,4 +218,3 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,4 +47,3 @@ namespace libtorrent { namespace aux
|
||||||
} }
|
} }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,15 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "libtorrent/file.hpp"
|
#include "libtorrent/file.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
|
||||||
#include "libtorrent/file_storage.hpp"
|
|
||||||
#include "libtorrent/aux_/time.hpp"
|
#include "libtorrent/aux_/time.hpp"
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
class file_storage;
|
||||||
|
|
||||||
struct pool_file_status
|
struct pool_file_status
|
||||||
{
|
{
|
||||||
// the index of the file this entry refers to into the ``file_storage``
|
// the index of the file this entry refers to into the ``file_storage``
|
||||||
|
@ -136,9 +138,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// maps storage pointer, file index pairs to the
|
// maps storage pointer, file index pairs to the
|
||||||
// lru entry for the file
|
// lru entry for the file
|
||||||
using file_set = std::map<std::pair<void*, int>, lru_file_entry>;
|
std::map<std::pair<void*, int>, lru_file_entry> m_files;
|
||||||
|
|
||||||
file_set m_files;
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
std::vector<std::pair<std::string, void const*>> m_deleted_storages;
|
std::vector<std::pair<std::string, void const*>> m_deleted_storages;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -167,4 +167,3 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TORRENT_HTTP_PARSER_HPP_INCLUDED
|
#endif // TORRENT_HTTP_PARSER_HPP_INCLUDED
|
||||||
|
|
||||||
|
|
|
@ -348,4 +348,3 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,9 @@ private:
|
||||||
std::unordered_multimap<int, observer_ptr> m_transactions;
|
std::unordered_multimap<int, observer_ptr> m_transactions;
|
||||||
|
|
||||||
udp_socket_interface* m_sock;
|
udp_socket_interface* m_sock;
|
||||||
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
dht_logger* m_log;
|
dht_logger* m_log;
|
||||||
|
#endif
|
||||||
dht_settings const& m_settings;
|
dht_settings const& m_settings;
|
||||||
routing_table& m_table;
|
routing_table& m_table;
|
||||||
node_id m_our_id;
|
node_id m_our_id;
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace libtorrent
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct tailqueue_iterator
|
struct tailqueue_iterator
|
||||||
{
|
{
|
||||||
template <typename U> friend struct tailqueue;
|
template <typename U, typename Cond> friend struct tailqueue;
|
||||||
|
|
||||||
T* get() const { return m_current; }
|
T* get() const { return m_current; }
|
||||||
void next() { m_current = m_current->next; }
|
void next() { m_current = m_current->next; }
|
||||||
|
@ -67,8 +67,8 @@ namespace libtorrent
|
||||||
T* m_current;
|
T* m_current;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T, typename Cond = typename std::enable_if<
|
||||||
//#error boost::enable_if< is_base<T, tailqueue_node<T> > >
|
std::is_base_of<tailqueue_node<T>, T>::value>::type>
|
||||||
struct tailqueue
|
struct tailqueue
|
||||||
{
|
{
|
||||||
tailqueue(): m_first(nullptr), m_last(nullptr), m_size(0) {}
|
tailqueue(): m_first(nullptr), m_last(nullptr), m_size(0) {}
|
||||||
|
@ -185,4 +185,3 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TAILQUEUE_HPP
|
#endif // TAILQUEUE_HPP
|
||||||
|
|
||||||
|
|
|
@ -910,12 +910,11 @@ namespace libtorrent
|
||||||
pieces.push_back(std::make_pair(e->storage.get(), int(e->piece)));
|
pieces.push_back(std::make_pair(e->storage.get(), int(e->piece)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<std::pair<piece_manager*, int> >::iterator i = pieces.begin()
|
for (auto const& p : pieces)
|
||||||
, end(pieces.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
// TODO: instead of doing a lookup each time through the loop, save
|
// TODO: instead of doing a lookup each time through the loop, save
|
||||||
// cached_piece_entry pointers with piece_refcount incremented to pin them
|
// cached_piece_entry pointers with piece_refcount incremented to pin them
|
||||||
cached_piece_entry* pe = m_disk_cache.find_piece(i->first, i->second);
|
cached_piece_entry* pe = m_disk_cache.find_piece(p.first, p.second);
|
||||||
if (pe == nullptr) continue;
|
if (pe == nullptr) continue;
|
||||||
|
|
||||||
// another thread may flush this piece while we're looping and
|
// another thread may flush this piece while we're looping and
|
||||||
|
@ -942,10 +941,9 @@ namespace libtorrent
|
||||||
|
|
||||||
// if we still need to flush blocks, start over and flush
|
// if we still need to flush blocks, start over and flush
|
||||||
// everything in LRU order (degrade to lru cache eviction)
|
// everything in LRU order (degrade to lru cache eviction)
|
||||||
for (std::vector<std::pair<piece_manager*, int> >::iterator i = pieces.begin()
|
for (auto const& p : pieces)
|
||||||
, end(pieces.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
cached_piece_entry* pe = m_disk_cache.find_piece(i->first, i->second);
|
cached_piece_entry* pe = m_disk_cache.find_piece(p.first, p.second);
|
||||||
if (pe == nullptr) continue;
|
if (pe == nullptr) continue;
|
||||||
if (pe->num_dirty == 0) continue;
|
if (pe->num_dirty == 0) continue;
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
#include "libtorrent/file_pool.hpp"
|
#include "libtorrent/file_pool.hpp"
|
||||||
#include "libtorrent/error_code.hpp"
|
#include "libtorrent/error_code.hpp"
|
||||||
#include "libtorrent/file_storage.hpp" // for file_entry
|
#include "libtorrent/file_storage.hpp"
|
||||||
#include "libtorrent/aux_/time.hpp"
|
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
@ -141,7 +140,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(is_complete(p));
|
TORRENT_ASSERT(is_complete(p));
|
||||||
TORRENT_ASSERT((m & file::rw_mask) == file::read_only
|
TORRENT_ASSERT((m & file::rw_mask) == file::read_only
|
||||||
|| (m & file::rw_mask) == file::read_write);
|
|| (m & file::rw_mask) == file::read_write);
|
||||||
file_set::iterator i = m_files.find(std::make_pair(st, file_index));
|
auto const i = m_files.find(std::make_pair(st, file_index));
|
||||||
if (i != m_files.end())
|
if (i != m_files.end())
|
||||||
{
|
{
|
||||||
lru_file_entry& e = i->second;
|
lru_file_entry& e = i->second;
|
||||||
|
@ -227,22 +226,21 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_mutex);
|
std::unique_lock<std::mutex> l(m_mutex);
|
||||||
|
|
||||||
auto start = m_files.lower_bound(std::make_pair(st, 0));
|
auto const start = m_files.lower_bound(std::make_pair(st, 0));
|
||||||
auto end = m_files.upper_bound(std::make_pair(st
|
auto const end = m_files.upper_bound(std::make_pair(st
|
||||||
, std::numeric_limits<int>::max()));
|
, std::numeric_limits<int>::max()));
|
||||||
|
|
||||||
for (file_set::const_iterator i = start; i != end; ++i)
|
for (auto i = start; i != end; ++i)
|
||||||
{
|
|
||||||
ret.push_back({i->first.second, i->second.mode, i->second.last_use});
|
ret.push_back({i->first.second, i->second.mode, i->second.last_use});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void file_pool::remove_oldest(std::unique_lock<std::mutex>& l)
|
void file_pool::remove_oldest(std::unique_lock<std::mutex>& l)
|
||||||
{
|
{
|
||||||
file_set::iterator i = std::min_element(m_files.begin(), m_files.end()
|
using value_type = std::map<std::pair<void*, int>, lru_file_entry>::value_type;
|
||||||
, [] (file_set::value_type const& lhs, file_set::value_type const& rhs)
|
auto const i = std::min_element(m_files.begin(), m_files.end()
|
||||||
|
, [] (value_type const& lhs, value_type const& rhs)
|
||||||
{ return lhs.second.last_use < rhs.second.last_use; });
|
{ return lhs.second.last_use < rhs.second.last_use; });
|
||||||
if (i == m_files.end()) return;
|
if (i == m_files.end()) return;
|
||||||
|
|
||||||
|
@ -259,7 +257,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_mutex);
|
std::unique_lock<std::mutex> l(m_mutex);
|
||||||
|
|
||||||
file_set::iterator i = m_files.find(std::make_pair(st, file_index));
|
auto const i = m_files.find(std::make_pair(st, file_index));
|
||||||
if (i == m_files.end()) return;
|
if (i == m_files.end()) return;
|
||||||
|
|
||||||
file_handle file_ptr = i->second.file_ptr;
|
file_handle file_ptr = i->second.file_ptr;
|
||||||
|
@ -278,15 +276,14 @@ namespace libtorrent
|
||||||
|
|
||||||
if (st == nullptr)
|
if (st == nullptr)
|
||||||
{
|
{
|
||||||
file_set tmp;
|
std::map<std::pair<void*, int>, lru_file_entry> tmp;
|
||||||
tmp.swap(m_files);
|
tmp.swap(m_files);
|
||||||
l.unlock();
|
l.unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<file_handle> to_close;
|
std::vector<file_handle> to_close;
|
||||||
for (file_set::iterator i = m_files.begin();
|
for (auto i = m_files.begin(); i != m_files.end();)
|
||||||
i != m_files.end();)
|
|
||||||
{
|
{
|
||||||
if (i->second.key == st)
|
if (i->second.key == st)
|
||||||
{
|
{
|
||||||
|
@ -314,10 +311,9 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_mutex);
|
std::unique_lock<std::mutex> l(m_mutex);
|
||||||
|
|
||||||
for (file_set::const_iterator i = m_files.begin();
|
for (auto const& i : m_files)
|
||||||
i != m_files.end(); ++i)
|
|
||||||
{
|
{
|
||||||
if (i->second.key == st && !i->second.file_ptr.unique())
|
if (i.second.key == st && !i.second.file_ptr.unique())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -340,4 +336,3 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,9 @@ namespace libtorrent { namespace dht
|
||||||
, total_milliseconds((now - match->limit) + seconds(10)) / 1000.0
|
, total_milliseconds((now - match->limit) + seconds(10)) / 1000.0
|
||||||
, match->count);
|
, match->count);
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
|
TORRENT_UNUSED(logger);
|
||||||
|
#endif // TORRENT_DISABLE_LOGGING
|
||||||
// we've received too many messages in less than 10 seconds
|
// we've received too many messages in less than 10 seconds
|
||||||
// from this node. Ignore it until it's silent for 5 minutes
|
// from this node. Ignore it until it's silent for 5 minutes
|
||||||
match->limit = now + seconds(m_block_timeout);
|
match->limit = now + seconds(m_block_timeout);
|
||||||
|
|
|
@ -2952,8 +2952,7 @@ namespace aux {
|
||||||
// remove undead peers that only have this list as their reference keeping them alive
|
// remove undead peers that only have this list as their reference keeping them alive
|
||||||
if (!m_undead_peers.empty())
|
if (!m_undead_peers.empty())
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<peer_connection> >::iterator remove_it
|
auto const remove_it = std::remove_if(m_undead_peers.begin(), m_undead_peers.end()
|
||||||
= std::remove_if(m_undead_peers.begin(), m_undead_peers.end()
|
|
||||||
, std::bind(&std::shared_ptr<peer_connection>::unique, _1));
|
, std::bind(&std::shared_ptr<peer_connection>::unique, _1));
|
||||||
m_undead_peers.erase(remove_it, m_undead_peers.end());
|
m_undead_peers.erase(remove_it, m_undead_peers.end());
|
||||||
if (m_undead_peers.empty())
|
if (m_undead_peers.empty())
|
||||||
|
@ -3296,10 +3295,9 @@ namespace aux {
|
||||||
{
|
{
|
||||||
// if we haven't reached the global max. see if any torrent
|
// if we haven't reached the global max. see if any torrent
|
||||||
// has reached its local limit
|
// has reached its local limit
|
||||||
for (torrent_map::iterator i = m_torrents.begin()
|
for (auto const& pt : m_torrents)
|
||||||
, end(m_torrents.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
std::shared_ptr<torrent> t = i->second;
|
std::shared_ptr<torrent> t = pt.second;
|
||||||
|
|
||||||
// ths disconnect logic is disabled for torrents with
|
// ths disconnect logic is disabled for torrents with
|
||||||
// too low connection limit
|
// too low connection limit
|
||||||
|
@ -3308,11 +3306,10 @@ namespace aux {
|
||||||
|| t->max_connections() < 6)
|
|| t->max_connections() < 6)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int peers_to_disconnect = (std::min)((std::max)(int(t->num_peers()
|
int peers_to_disconnect = (std::min)((std::max)(t->num_peers()
|
||||||
* m_settings.get_int(settings_pack::peer_turnover) / 100), 1)
|
* m_settings.get_int(settings_pack::peer_turnover) / 100, 1)
|
||||||
, t->num_connect_candidates());
|
, t->num_connect_candidates());
|
||||||
t->disconnect_peers(peers_to_disconnect
|
t->disconnect_peers(peers_to_disconnect, errors::optimistic_disconnect);
|
||||||
, error_code(errors::optimistic_disconnect));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4312,8 +4309,7 @@ namespace aux {
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<torrent> >::const_iterator i
|
auto const i = m_uuids.find(uuid);
|
||||||
= m_uuids.find(uuid);
|
|
||||||
if (i != m_uuids.end()) return i->second;
|
if (i != m_uuids.end()) return i->second;
|
||||||
return std::weak_ptr<torrent>();
|
return std::weak_ptr<torrent>();
|
||||||
}
|
}
|
||||||
|
@ -4324,10 +4320,9 @@ namespace aux {
|
||||||
std::string const& collection) const
|
std::string const& collection) const
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<torrent>> ret;
|
std::vector<std::shared_ptr<torrent>> ret;
|
||||||
for (session_impl::torrent_map::const_iterator i = m_torrents.begin()
|
for (auto const& tp : m_torrents)
|
||||||
, end(m_torrents.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
std::shared_ptr<torrent> t = i->second;
|
std::shared_ptr<torrent> t = tp.second;
|
||||||
if (!t) continue;
|
if (!t) continue;
|
||||||
std::vector<std::string> const& c = t->torrent_file().collections();
|
std::vector<std::string> const& c = t->torrent_file().collections();
|
||||||
if (std::find(c.begin(), c.end(), collection) == c.end()) continue;
|
if (std::find(c.begin(), c.end(), collection) == c.end()) continue;
|
||||||
|
@ -4729,11 +4724,8 @@ namespace aux {
|
||||||
// add params.dht_nodes to the DHT, if enabled
|
// add params.dht_nodes to the DHT, if enabled
|
||||||
if (!params.dht_nodes.empty())
|
if (!params.dht_nodes.empty())
|
||||||
{
|
{
|
||||||
for (std::vector<std::pair<std::string, int> >::const_iterator i = params.dht_nodes.begin()
|
for (auto const& n : params.dht_nodes)
|
||||||
, end(params.dht_nodes.end()); i != end; ++i)
|
add_dht_node_name(n);
|
||||||
{
|
|
||||||
add_dht_node_name(*i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4936,14 +4928,12 @@ namespace aux {
|
||||||
// remove from uuid list
|
// remove from uuid list
|
||||||
if (!tptr->uuid().empty())
|
if (!tptr->uuid().empty())
|
||||||
{
|
{
|
||||||
std::map<std::string, std::shared_ptr<torrent> >::iterator j
|
auto const j = m_uuids.find(tptr->uuid());
|
||||||
= m_uuids.find(tptr->uuid());
|
|
||||||
if (j != m_uuids.end()) m_uuids.erase(j);
|
if (j != m_uuids.end()) m_uuids.erase(j);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
torrent_map::iterator i =
|
auto i = m_torrents.find(tptr->torrent_file().info_hash());
|
||||||
m_torrents.find(tptr->torrent_file().info_hash());
|
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// deprecated in 1.2
|
// deprecated in 1.2
|
||||||
|
@ -6746,10 +6736,8 @@ namespace aux {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<std::shared_ptr<peer_connection> >::const_iterator i
|
for (auto const& p : m_undead_peers)
|
||||||
= m_undead_peers.begin(); i != m_undead_peers.end(); ++i)
|
|
||||||
{
|
{
|
||||||
peer_connection* p = i->get();
|
|
||||||
if (p->ignore_unchoke_slots())
|
if (p->ignore_unchoke_slots())
|
||||||
{
|
{
|
||||||
if (!p->is_choked()) ++unchokes_all;
|
if (!p->is_choked()) ++unchokes_all;
|
||||||
|
|
|
@ -198,5 +198,3 @@ void generate_files(libtorrent::torrent_info const& ti, std::string const& path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ void send_dht_request(node& node, char const* msg, udp::endpoint const& ep
|
||||||
|
|
||||||
// If the request is supposed to get a response, by now the node should have
|
// If the request is supposed to get a response, by now the node should have
|
||||||
// invoked the send function and put the response in g_sent_packets
|
// invoked the send function and put the response in g_sent_packets
|
||||||
std::list<std::pair<udp::endpoint, entry> >::iterator i = find_packet(ep);
|
auto const i = find_packet(ep);
|
||||||
if (has_response)
|
if (has_response)
|
||||||
{
|
{
|
||||||
if (i == g_sent_packets.end())
|
if (i == g_sent_packets.end())
|
||||||
|
@ -1977,21 +1977,20 @@ void test_get_peers(address(&rand_addr)())
|
||||||
send_dht_response(t.dht_node, response, next_node
|
send_dht_response(t.dht_node, response, next_node
|
||||||
, msg_args().token("11").port(1234).peers(peers[1]));
|
, msg_args().token("11").port(1234).peers(peers[1]));
|
||||||
|
|
||||||
for (std::list<std::pair<udp::endpoint, entry> >::iterator i = g_sent_packets.begin()
|
for (auto const& p : g_sent_packets)
|
||||||
, end(g_sent_packets.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
// std::printf(" %s:%d: %s\n", i->first.address().to_string(ec).c_str()
|
// std::printf(" %s:%d: %s\n", i->first.address().to_string(ec).c_str()
|
||||||
// , i->first.port(), i->second.to_string().c_str());
|
// , i->first.port(), i->second.to_string().c_str());
|
||||||
TEST_EQUAL(i->second["q"].string(), "announce_peer");
|
TEST_EQUAL(p.second["q"].string(), "announce_peer");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_sent_packets.clear();
|
g_sent_packets.clear();
|
||||||
|
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
for (std::set<tcp::endpoint>::iterator peer = peers[i].begin(); peer != peers[i].end(); ++peer)
|
for (auto const& peer : peers[i])
|
||||||
{
|
{
|
||||||
TEST_CHECK(std::find(g_got_peers.begin(), g_got_peers.end(), *peer) != g_got_peers.end());
|
TEST_CHECK(std::find(g_got_peers.begin(), g_got_peers.end(), peer) != g_got_peers.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_got_peers.clear();
|
g_got_peers.clear();
|
||||||
|
@ -2212,7 +2211,7 @@ TORRENT_TEST(immutable_put)
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
std::list<std::pair<udp::endpoint, entry> >::iterator packet = find_packet(nodes[i].ep());
|
auto const packet = find_packet(nodes[i].ep());
|
||||||
TEST_CHECK(packet != g_sent_packets.end());
|
TEST_CHECK(packet != g_sent_packets.end());
|
||||||
if (packet == g_sent_packets.end()) continue;
|
if (packet == g_sent_packets.end()) continue;
|
||||||
|
|
||||||
|
@ -2241,7 +2240,7 @@ TORRENT_TEST(immutable_put)
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
std::list<std::pair<udp::endpoint, entry> >::iterator packet = find_packet(nodes[i].ep());
|
auto const packet = find_packet(nodes[i].ep());
|
||||||
TEST_CHECK(packet != g_sent_packets.end());
|
TEST_CHECK(packet != g_sent_packets.end());
|
||||||
if (packet == g_sent_packets.end()) continue;
|
if (packet == g_sent_packets.end()) continue;
|
||||||
|
|
||||||
|
@ -2313,7 +2312,7 @@ TORRENT_TEST(mutable_put)
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
std::list<std::pair<udp::endpoint, entry> >::iterator packet = find_packet(nodes[i].ep());
|
auto const packet = find_packet(nodes[i].ep());
|
||||||
TEST_CHECK(packet != g_sent_packets.end());
|
TEST_CHECK(packet != g_sent_packets.end());
|
||||||
if (packet == g_sent_packets.end()) continue;
|
if (packet == g_sent_packets.end()) continue;
|
||||||
|
|
||||||
|
@ -2342,7 +2341,7 @@ TORRENT_TEST(mutable_put)
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
std::list<std::pair<udp::endpoint, entry> >::iterator packet = find_packet(nodes[i].ep());
|
auto const packet = find_packet(nodes[i].ep());
|
||||||
TEST_CHECK(packet != g_sent_packets.end());
|
TEST_CHECK(packet != g_sent_packets.end());
|
||||||
if (packet == g_sent_packets.end()) continue;
|
if (packet == g_sent_packets.end()) continue;
|
||||||
|
|
||||||
|
@ -2428,7 +2427,7 @@ TORRENT_TEST(traversal_done)
|
||||||
// get_item_cb
|
// get_item_cb
|
||||||
if (i == num_test_nodes) i = 0;
|
if (i == num_test_nodes) i = 0;
|
||||||
|
|
||||||
std::list<std::pair<udp::endpoint, entry> >::iterator packet = find_packet(nodes[i].ep());
|
auto const packet = find_packet(nodes[i].ep());
|
||||||
TEST_CHECK(packet != g_sent_packets.end());
|
TEST_CHECK(packet != g_sent_packets.end());
|
||||||
if (packet == g_sent_packets.end()) continue;
|
if (packet == g_sent_packets.end()) continue;
|
||||||
|
|
||||||
|
|
|
@ -297,4 +297,3 @@ TORRENT_TEST(ip_filter)
|
||||||
TEST_CHECK(pf.access(6881) == 0);
|
TEST_CHECK(pf.access(6881) == 0);
|
||||||
TEST_CHECK(pf.access(65535) == 0);
|
TEST_CHECK(pf.access(65535) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,8 +150,7 @@ void mock_peer_connection::disconnect(error_code const& ec
|
||||||
, operation_t op, int error)
|
, operation_t op, int error)
|
||||||
{
|
{
|
||||||
m_torrent.m_p->connection_closed(*this, 0, m_torrent.m_state);
|
m_torrent.m_p->connection_closed(*this, 0, m_torrent.m_state);
|
||||||
std::vector<std::shared_ptr<mock_peer_connection> >::iterator i
|
auto const i = std::find(m_torrent.m_connections.begin(), m_torrent.m_connections.end()
|
||||||
= std::find(m_torrent.m_connections.begin(), m_torrent.m_connections.end()
|
|
||||||
, std::static_pointer_cast<mock_peer_connection>(shared_from_this()));
|
, std::static_pointer_cast<mock_peer_connection>(shared_from_this()));
|
||||||
if (i != m_torrent.m_connections.end()) m_torrent.m_connections.erase(i);
|
if (i != m_torrent.m_connections.end()) m_torrent.m_connections.erase(i);
|
||||||
|
|
||||||
|
@ -161,8 +160,7 @@ void mock_peer_connection::disconnect(error_code const& ec
|
||||||
|
|
||||||
bool has_peer(peer_list const& p, tcp::endpoint const& ep)
|
bool has_peer(peer_list const& p, tcp::endpoint const& ep)
|
||||||
{
|
{
|
||||||
std::pair<peer_list::const_iterator, peer_list::const_iterator> its
|
auto const its = p.find_peers(ep.address());
|
||||||
= p.find_peers(ep.address());
|
|
||||||
return its.first != its.second;
|
return its.first != its.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -939,4 +937,3 @@ TORRENT_TEST(new_peer_size_limit)
|
||||||
// TODO: test connect_to_peer() failing
|
// TODO: test connect_to_peer() failing
|
||||||
// TODO: test connection_closed
|
// TODO: test connection_closed
|
||||||
// TODO: connect candidates recalculation when incrementing failcount
|
// TODO: connect candidates recalculation when incrementing failcount
|
||||||
|
|
||||||
|
|
|
@ -1979,4 +1979,3 @@ TORRENT_TEST(download_filtered_piece)
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: 2 test picking with partial pieces and other peers present so that both backup_pieces and backup_pieces2 are used
|
//TODO: 2 test picking with partial pieces and other peers present so that both backup_pieces and backup_pieces2 are used
|
||||||
|
|
||||||
|
|
|
@ -411,4 +411,3 @@ TORRENT_TEST(rename_file)
|
||||||
|
|
||||||
TEST_EQUAL(info->files().file_path(0), "tmp1");
|
TEST_EQUAL(info->files().file_path(0), "tmp1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue