relevance 3 | ../test/test_primitives.cpp:202 | move this out to a test_enum_net test |
move this out to a test_enum_net test../test/test_primitives.cpp:202
+ if (supports_ipv6())
+ {
+ // make sure the assumption we use in policy's peer list hold
+ std::multimap<address, int> peers;
+ std::multimap<address, int>::iterator i;
+ peers.insert(std::make_pair(address::from_string("::1", ec), 0));
+ peers.insert(std::make_pair(address::from_string("::2", ec), 3));
+ peers.insert(std::make_pair(address::from_string("::3", ec), 5));
+ i = peers.find(address::from_string("::2", ec));
+ TEST_CHECK(i != peers.end());
+ if (i != peers.end())
+ {
+ TEST_CHECK(i->first == address::from_string("::2", ec));
+ TEST_CHECK(i->second == 3);
+ }
+ }
+
+ // test network functions
+
+ TEST_CHECK(is_local(address::from_string("192.168.0.1", ec)));
+ TEST_CHECK(is_local(address::from_string("10.1.1.56", ec)));
+ TEST_CHECK(!is_local(address::from_string("14.14.251.63", ec)));
+ TEST_CHECK(is_loopback(address::from_string("127.0.0.1", ec)));
+#if TORRENT_USE_IPV6
+ if (supports_ipv6())
+ {
+ TEST_CHECK(is_loopback(address::from_string("::1", ec)));
+ TEST_CHECK(is_any(address_v6::any()));
+ }
+#endif
+ TEST_CHECK(is_any(address_v4::any()));
+ TEST_CHECK(!is_any(address::from_string("31.53.21.64", ec)));
+
+ TEST_CHECK(match_addr_mask(
+ address::from_string("10.0.1.176", ec),
+ address::from_string("10.0.1.176", ec),
+ address::from_string("255.255.255.0", ec)));
+
+ TEST_CHECK(match_addr_mask(
+ address::from_string("10.0.1.3", ec),
+ address::from_string("10.0.3.3", ec),
+ address::from_string("255.255.0.0", ec)));
+
+ TEST_CHECK(!match_addr_mask(
+ address::from_string("10.0.1.3", ec),
+ address::from_string("10.1.3.3", ec),
+ address::from_string("255.255.0.0", ec)));
+
+ // CIDR distance test
+ sha1_hash h1 = to_hash("0123456789abcdef01232456789abcdef0123456");
+ | ||
relevance 3 | ../src/file.cpp:484 | find out what error code is reported when the filesystem does not support hard links. |
find out what error code is reported when the filesystem
+does not support hard links.../src/file.cpp:484 {
#ifdef TORRENT_WINDOWS
#if TORRENT_USE_WSTRING
@@ -69,28 +120,113 @@ does not support hard links.../src/file.cpp:481relevance 3 | ../src/upnp.cpp:72 | listen_interface is not used. It's meant to bind the broadcast socket |
|
listen_interface is not used. It's meant to bind the broadcast socket../src/upnp.cpp:72#include <asio/ip/multicast.hpp>
-#else
-#include <boost/asio/ip/host_name.hpp>
-#include <boost/asio/ip/multicast.hpp>
-#endif
-#include <cstdlib>
+ | ||
relevance 3 | ../src/session_impl.cpp:3600 | also deduct force started checking torrents from checking_limit also deduct started inactive torrents from hard_limit |
also deduct force started checking torrents from checking_limit
+also deduct started inactive torrents from hard_limit../src/session_impl.cpp:3600 if (hard_limit == -1)
+ hard_limit = (std::numeric_limits<int>::max)();
+ if (dht_limit == -1)
+ dht_limit = (std::numeric_limits<int>::max)();
+ if (lsd_limit == -1)
+ lsd_limit = (std::numeric_limits<int>::max)();
+ if (tracker_limit == -1)
+ tracker_limit = (std::numeric_limits<int>::max)();
-namespace libtorrent {
+ // deduct "force started" torrents from the hard_limit
+ // we don't have explicit access to the number of force started torrents,
+ // but we know how many started downloading and seeding torrents we have.
+ // if we subtract all non-force started torrents from the total, we get
+ // the number of force started.
+ hard_limit -= m_stats_counters[counters::num_downloading_torrents] -
+ downloaders.size();
+ hard_limit -= m_stats_counters[counters::num_seeding_torrents]
+ + m_stats_counters[counters::num_upload_only_torrents] -
+ seeds.size();
-namespace upnp_errors
-{
- boost::system::error_code make_error_code(error_code_enum e)
+
+ // if hard_limit is <= 0, all torrents in these lists should be paused.
+ // The order is not relevant
+ if (hard_limit > 0)
+ {
+ // we only need to sort the first n torrents here, where n is the number
+ // of checking torrents we allow. The rest of the list is still used to
+ // make sure the remaining torrents are paused, but their order is not
+ // relevant
+ std::partial_sort(checking.begin(), checking.begin() +
+ (std::min)(checking_limit, int(checking.size())), checking.end()
+ , boost::bind(&torrent::sequence_number, _1) < boost::bind(&torrent::sequence_number, _2));
+
+ std::partial_sort(downloaders.begin(), downloaders.begin() +
+ (std::min)(hard_limit, int(downloaders.size())), downloaders.end()
+ , boost::bind(&torrent::sequence_number, _1) < boost::bind(&torrent::sequence_number, _2));
+
+ std::partial_sort(seeds.begin(), seeds.begin() +
+ (std::min)(hard_limit, int(seeds.size())), seeds.end()
+ , boost::bind(&torrent::seed_rank, _1, boost::ref(m_settings))
+ > boost::bind(&torrent::seed_rank, _2, boost::ref(m_settings)));
+ }
+
+ auto_manage_checking_torrents(checking, checking_limit);
+
+ if (settings().get_bool(settings_pack::auto_manage_prefer_seeds))
+ {
+ auto_manage_torrents(seeds, dht_limit, tracker_limit, lsd_limit
+ , hard_limit, num_seeds);
+ auto_manage_torrents(downloaders, dht_limit, tracker_limit, lsd_limit
+ , hard_limit, num_downloaders);
+ | ||
relevance 3 | ../src/settings_pack.cpp:62 | write a unit test for settings_pack |
write a unit test for settings_pack../src/settings_pack.cpp:62namespace {
+
+ template <class T>
+ bool compare_first(std::pair<boost::uint16_t, T> const& lhs
+ , std::pair<boost::uint16_t, T> const& rhs)
{
- return error_code(e, get_upnp_category());
+ return lhs.first < rhs.first;
}
-} // upnp_errors namespace
+ template <class T>
+ void insort_replace(std::vector<std::pair<boost::uint16_t, T> >& c, std::pair<boost::uint16_t, T> const& v)
+ {
+ typedef std::vector<std::pair<boost::uint16_t, T> > container_t;
+ typename container_t::iterator i = std::lower_bound(c.begin(), c.end(), v
+ , &compare_first<T>);
+ if (i != c.end() && i->first == v.first) i->second = v.second;
+ else c.insert(i, v);
+ }
+}
-static error_code ec;
+namespace libtorrent
+ {
+ struct str_setting_entry_t
+ {
+ // the name of this setting. used for serialization and deserialization
+ char const* name;
+ // if present, this function is called when the setting is changed
+ void (aux::session_impl::*fun)();
+ char const *default_value;
+#ifndef TORRENT_NO_DEPRECATE
+ // offset into session_settings, used to map
+ // settings to the deprecated settings struct
+ int offset;
+#endif
+ };
-upnp::upnp(io_service& ios
- , address const& listen_interface, std::string const& user_agent
+ struct int_setting_entry_t
+ {
+ // the name of this setting. used for serialization and deserialization
+ char const* name;
+ // if present, this function is called when the setting is changed
+ void (aux::session_impl::*fun)();
+ int default_value;
+#ifndef TORRENT_NO_DEPRECATE
+ // offset into session_settings, used to map
+ // settings to the deprecated settings struct
+ int offset;
+#endif
+ };
+
+ struct bool_setting_entry_t
+ | ||
relevance 3 | ../src/upnp.cpp:88 | listen_interface is not used. It's meant to bind the broadcast socket. it would probably have to be changed to a vector of interfaces to bind to though, since the broadcast socket opens one socket per local interface by default |
listen_interface is not used. It's meant to bind the broadcast
+socket. it would probably have to be changed to a vector of interfaces to
+bind to though, since the broadcast socket opens one socket per local
+interface by default../src/upnp.cpp:88 , address const& listen_interface, std::string const& user_agent
, portmap_callback_t const& cb, log_callback_t const& lcb
, bool ignore_nonrouters)
: m_user_agent(user_agent)
@@ -109,7 +245,9 @@ static error_code ec;
, m_last_if_update(min_time())
{
TORRENT_ASSERT(cb);
-}
+
+ TORRENT_UNUSED(listen_interface);
+ }
void upnp::start(void* state)
{
@@ -120,60 +258,26 @@ void upnp::start(void* state)
if (state)
{
upnp_state_t* s = (upnp_state_t*)state;
- | ||
relevance 3 | ../src/kademlia/dht_tracker.cpp:521 | it would be nice to not have to decode this if logging is not enabled. Maybe there could be a separate log function for incoming and outgoing packets. |
it would be nice to not have to decode this if logging
-is not enabled. Maybe there could be a separate log function for
-incoming and outgoing packets.../src/kademlia/dht_tracker.cpp:521
- bool dht_tracker::has_quota()
- {
- return m_sock.has_quota();
+ m_devices.swap(s->devices);
+ m_mappings.swap(s->mappings);
+ delete s;
}
- bool dht_tracker::send_packet(libtorrent::entry& e, udp::endpoint const& addr, int send_flags)
- {
- using libtorrent::bencode;
- using libtorrent::entry;
+ m_mappings.reserve(10);
+}
- static char const version_str[] = {'L', 'T'
- , LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR};
- e["v"] = std::string(version_str, version_str + 4);
+void* upnp::drain_state()
+{
+ upnp_state_t* s = new upnp_state_t;
+ s->mappings.swap(m_mappings);
- m_send_buf.clear();
- bencode(std::back_inserter(m_send_buf), e);
- error_code ec;
-
-#ifdef TORRENT_DHT_VERBOSE_LOGGING
- bdecode_node print;
- int ret = bdecode(&m_send_buf[0], &m_send_buf[0] + m_send_buf.size(), print, ec);
- TORRENT_ASSERT(ret == 0);
- std::string outgoing_message = print_entry(print, true);
-#endif
-
- if (m_sock.send(addr, &m_send_buf[0], (int)m_send_buf.size(), ec, send_flags))
- {
- if (ec)
- {
- m_counters.inc_stats_counter(counters::dht_messages_out_dropped);
-#ifdef TORRENT_DHT_VERBOSE_LOGGING
- m_log->log(dht_logger::tracker, "==> %s DROPPED (%s) %s"
- , print_endpoint(addr).c_str(), ec.message().c_str()
- , outgoing_message.c_str());
-#endif
- return false;
- }
-
- m_counters.inc_stats_counter(counters::dht_bytes_out, m_send_buf.size());
- // account for IP and UDP overhead
- m_counters.inc_stats_counter(counters::sent_ip_overhead_bytes
- , addr.address().is_v6() ? 48 : 28);
- m_counters.inc_stats_counter(counters::dht_messages_out);
-#ifdef TORRENT_DHT_VERBOSE_LOGGING
- m_log->log(dht_logger::tracker, "==> %s %s"
- , print_endpoint(addr).c_str()
- , outgoing_message.c_str());
-#endif
- return true;
- }
- | ||
relevance 3 | ../src/kademlia/get_item.cpp:202 | it would be nice to not have to spend so much time rendering the bencoded dict if logging is disabled |
it would be nice to not have to spend so much time rendering
+ for (std::set<rootdevice>::iterator i = m_devices.begin()
+ , end(m_devices.end()); i != end; ++i)
+ i->upnp_connection.reset();
+ s->devices.swap(m_devices);
+ return s;
+}
+ | ||
relevance 3 | ../src/kademlia/get_item.cpp:202 | it would be nice to not have to spend so much time rendering the bencoded dict if logging is disabled |
it would be nice to not have to spend so much time rendering
the bencoded dict if logging is disabled../src/kademlia/get_item.cpp:202 bencode(std::back_inserter(buffer), m_data.value());
TORRENT_ASSERT(m_target == hasher(&buffer[0], buffer.size()).final());
}
@@ -193,10 +297,10 @@ the bencoded dict if logging is disabled../src/kademlia/get_item.cpp:20
// as the v argument
void get_item::put(std::vector<std::pair<node_entry, std::string> > const& v)
{
-#ifdef TORRENT_DHT_VERBOSE_LOGGING
- get_node().observer()->log(dht_logger::traversal, "[%p] sending put [ v: \"%s\" seq: %" PRId64 " nodes: %d ]"
- , this, m_data.value().to_string().c_str()
- , (m_data.is_mutable() ? m_data.seq() : -1)
+#ifndef TORRENT_DISABLE_LOGGING
+ get_node().observer()->log(dht_logger::traversal, "[%p] sending put "
+ "[ seq: %" PRId64 " nodes: %d ]"
+ , this, (m_data.is_mutable() ? m_data.seq() : -1)
, int(v.size()));
#endif
@@ -208,7 +312,7 @@ void get_item::put(std::vector<std::pair<node_entry, std::string> >
for (std::vector<std::pair<node_entry, std::string> >::const_iterator i = v.begin()
, end(v.end()); i != end; ++i)
{
-#ifdef TORRENT_DHT_VERBOSE_LOGGING
+#ifndef TORRENT_DISABLE_LOGGING
get_node().observer()->log(dht_logger::traversal, "[%p] put-distance: %d"
, this, 160 - distance_exp(m_target, i->first.id));
#endif
@@ -216,7 +320,7 @@ void get_item::put(std::vector<std::pair<node_entry, std::string> >
void* ptr = m_node.m_rpc.allocate_observer();
if (ptr == 0) return;
- | ||
relevance 3 | ../src/kademlia/get_item.cpp:226 | we don't support CAS errors here! we need a custom observer |
we don't support CAS errors here! we need a custom observer../src/kademlia/get_item.cpp:226 , (m_data.is_mutable() ? m_data.seq() : -1)
+ | ||
relevance 3 | ../src/kademlia/get_item.cpp:226 | we don't support CAS errors here! we need a custom observer |
we don't support CAS errors here! we need a custom observer../src/kademlia/get_item.cpp:226 , this, (m_data.is_mutable() ? m_data.seq() : -1)
, int(v.size()));
#endif
@@ -228,7 +332,7 @@ void get_item::put(std::vector<std::pair<node_entry, std::string> >
for (std::vector<std::pair<node_entry, std::string> >::const_iterator i = v.begin()
, end(v.end()); i != end; ++i)
{
-#ifdef TORRENT_DHT_VERBOSE_LOGGING
+#ifndef TORRENT_DISABLE_LOGGING
get_node().observer()->log(dht_logger::traversal, "[%p] put-distance: %d"
, this, 160 - distance_exp(m_target, i->first.id));
#endif
@@ -267,8 +371,59 @@ void get_item_observer::reply(msg const& m)
boost::uint64_t seq = 0;
bdecode_node r = m.message.dict_find_dict("r");
- | ||
relevance 3 | ../src/kademlia/traversal_algorithm.cpp:357 | it would be nice to not have to perform this loop if logging is disabled |
it would be nice to not have to perform this loop if
-logging is disabled../src/kademlia/traversal_algorithm.cpp:357 ++m_timeouts;
+ | ||
relevance 3 | ../src/kademlia/rpc_manager.cpp:84 | move this into it's own .cpp file |
move this into it's own .cpp file../src/kademlia/rpc_manager.cpp:84
+void intrusive_ptr_add_ref(observer const* o)
+{
+ TORRENT_ASSERT(o != 0);
+ TORRENT_ASSERT(o->m_refs < 0xffff);
+ ++o->m_refs;
+}
+
+void intrusive_ptr_release(observer const* o)
+{
+ TORRENT_ASSERT(o != 0);
+ TORRENT_ASSERT(o->m_refs > 0);
+ if (--o->m_refs == 0)
+ {
+ boost::intrusive_ptr<traversal_algorithm> ta = o->algorithm();
+ (const_cast<observer*>(o))->~observer();
+ ta->free_observer(const_cast<observer*>(o));
+ }
+}
+
+dht_observer* observer::get_observer() const
+ {
+ return m_algorithm->get_node().observer();
+}
+
+void observer::set_target(udp::endpoint const& ep)
+{
+ m_sent = clock_type::now();
+
+ m_port = ep.port();
+#if TORRENT_USE_IPV6
+ if (ep.address().is_v6())
+ {
+ flags |= flag_ipv6_address;
+ m_addr.v6 = ep.address().to_v6().to_bytes();
+ }
+ else
+#endif
+ {
+ flags &= ~flag_ipv6_address;
+ m_addr.v4 = ep.address().to_v4().to_bytes();
+ }
+}
+
+address observer::target_addr() const
+{
+#if TORRENT_USE_IPV6
+ if (flags & flag_ipv6_address)
+ return address_v6(m_addr.v6);
+ else
+#endif
+ | ||
relevance 3 | ../src/kademlia/traversal_algorithm.cpp:376 | it would be nice to not have to perform this loop if logging is disabled |
it would be nice to not have to perform this loop if
+logging is disabled../src/kademlia/traversal_algorithm.cpp:376 ++m_timeouts;
TORRENT_ASSERT(m_invoke_count > 0);
--m_invoke_count;
}
@@ -284,7 +439,7 @@ logging is disabled../src/kademlia/traversal_algorithm.cpp:357 , end(m_results.end()); i != end && results_target > 0; ++i)
{
boost::intrusive_ptr<observer> o = *i;
- if (o->flags & observer::flag_alive)
+ if ((o->flags & observer::flag_alive) && get_node().observer())
{
TORRENT_ASSERT(o->flags & observer::flag_queried);
char hex_id[41];
@@ -308,18 +463,197 @@ void traversal_algorithm::done()
}
}
- get_node().observer()->log(dht_logger::traversal
- , "[%p] COMPLETED distance: %d type: %s"
- , this, closest_target, name());
+ if (get_node().observer())
+ {
+ get_node().observer()->log(dht_logger::traversal
+ , "[%p] COMPLETED distance: %d type: %s"
+ , this, closest_target, name());
+ }
#endif
// delete all our references to the observer objects so
// they will in turn release the traversal algorithm
m_results.clear();
}
+ | ||
relevance 3 | ../include/libtorrent/peer_connection.hpp:1245 | factor this out into its own header and use it for UDP socket and maybe second_timer as well |
factor this out into its own header and use it for UDP socket
+and maybe second_timer as well../include/libtorrent/peer_connection.hpp:1245 bool m_need_interest_update:1;
-bool traversal_algorithm::add_requests()
+ // set to true if this peer has metadata, and false
+ // otherwise.
+ bool m_has_metadata:1;
+
+ // this is set to true if this peer was accepted exceeding
+ // the connection limit. It means it has to disconnect
+ // itself, or some other peer, as soon as it's completed
+ // the handshake. We need to wait for the handshake in
+ // order to know which torrent it belongs to, to know which
+ // other peers to compare it to.
+ bool m_exceeded_limit:1;
+
+ // this is slow-start at the bittorrent layer. It affects how we increase
+ // desired queue size (i.e. the number of outstanding requests we keep).
+ // While the underlying transport protocol is in slow-start, the number of
+ // outstanding requests need to increase at the same pace to keep up.
+ bool m_slow_start:1;
+
+ template <class Handler, std::size_t Size>
+ struct allocating_handler
+ {
+ | ||
relevance 3 | ../include/libtorrent/peer_connection.hpp:1250 | if move semantics is supported, move the handler into this wrapper |
if move semantics is supported, move the handler into this
+wrapper../include/libtorrent/peer_connection.hpp:1250 // otherwise.
+ bool m_has_metadata:1;
+
+ // this is set to true if this peer was accepted exceeding
+ // the connection limit. It means it has to disconnect
+ // itself, or some other peer, as soon as it's completed
+ // the handshake. We need to wait for the handshake in
+ // order to know which torrent it belongs to, to know which
+ // other peers to compare it to.
+ bool m_exceeded_limit:1;
+
+ // this is slow-start at the bittorrent layer. It affects how we increase
+ // desired queue size (i.e. the number of outstanding requests we keep).
+ // While the underlying transport protocol is in slow-start, the number of
+ // outstanding requests need to increase at the same pace to keep up.
+ bool m_slow_start:1;
+
+ template <class Handler, std::size_t Size>
+ struct allocating_handler
+ {
+ allocating_handler(
+ Handler const& h, handler_storage<Size>& s)
+ : handler(h)
+ , storage(s)
+ {}
+
+#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
+ template <class... A>
+ void operator()(A&&... a) const
+ {
+ handler(std::forward<A>(a)...);
+ }
+#else
+ template <class A0>
+ void operator()(A0 const& a0) const
+ {
+ handler(a0);
+ }
+
+ template <class A0, class A1>
+ void operator()(A0 const& a0, A1 const& a1) const
+ {
+ handler(a0, a1);
+ }
+
+ template <class A0, class A1, class A2>
+ void operator()(A0 const& a0, A1 const& a1, A2 const& a2) const
+ {
+ handler(a0, a1, a2);
+ }
+#endif
+ | ||
relevance 3 | ../include/libtorrent/torrent.hpp:1365 | factor out the links (as well as update_list() to a separate class that torrent can inherit) |
factor out the links (as well as update_list() to a separate
+class that torrent can inherit)../include/libtorrent/torrent.hpp:1365
+ // this was the last time _we_ saw a seed in this swarm
+ time_t m_last_seen_complete;
+
+ // this is the time last any of our peers saw a seed
+ // in this swarm
+ time_t m_swarm_last_seen_complete;
+
+ // keep a copy if the info-hash here, so it can be accessed from multiple
+ // threads, and be cheap to access from the client
+ sha1_hash m_info_hash;
+
+ public:
+ // these are the lists this torrent belongs to. For more
+ // details about each list, see session_impl.hpp. Each list
+ // represents a group this torrent belongs to and makes it
+ // efficient to enumerate only torrents belonging to a specific
+ // group. Such as torrents that want peer connections or want
+ // to be ticked etc.
+
+ link m_links[aux::session_interface::num_torrent_lists];
+
+ private:
+
+ // m_num_verified = m_verified.count()
+ boost::uint32_t m_num_verified;
+
+ // this timestamp is kept in session-time, to
+ // make it fit in 16 bits
+ boost::uint16_t m_last_saved_resume;
+
+ // if this torrent is running, this was the time
+ // when it was started. This is used to have a
+ // bias towards keeping seeding torrents that
+ // recently was started, to avoid oscillation
+ // this is specified at a second granularity
+ // in session-time. see session_impl for details.
+ // the reference point is stepped forward every 4
+ // hours to keep the timestamps fit in 16 bits
+ boost::uint16_t m_started;
+
+ // if we're a seed, this is the session time
+ // timestamp of when we became one
+ boost::uint16_t m_became_seed;
+
+ // if we're finished, this is the session time
+ // timestamp of when we finished
+ boost::uint16_t m_became_finished;
+
+ // when checking, this is the first piece we have not
+ // issued a hash job for
+ | ||
relevance 2 | ../test/test_piece_picker.cpp:277 | split this up into smaller tests (where we print_title) |
split this up into smaller tests (where we print_title)../test/test_piece_picker.cpp:277 std::vector<piece_block> picked;
+ counters pc;
+ p->pick_pieces(string2vec(availability), picked
+ , num_blocks, prefer_contiguous_blocks, peer_struct
+ , options, suggested_pieces, 20, pc);
+ print_pick(picked);
+ TEST_CHECK(verify_pick(p, picked));
+ return picked;
+}
+
+int test_pick(boost::shared_ptr<piece_picker> const& p
+ , int options = piece_picker::rarest_first)
{
- | ||
relevance 2 | ../src/alert.cpp:1444 | the salt here is allocated on the heap. It would be nice to allocate in in the stack_allocator |
the salt here is allocated on the heap. It would be nice to
+ const std::vector<int> empty_vector;
+ std::vector<piece_block> picked = pick_pieces(p, "*******", 1, 0, 0
+ , options, empty_vector);
+ if (picked.empty()) return -1;
+ return picked[0].piece_index;
+}
+
+TORRENT_TEST(piece_picker)
+ {
+ tcp::endpoint endp;
+ piece_picker::downloading_piece st;
+#if TORRENT_USE_ASSERTS
+ tmp0.in_use = true;
+ tmp1.in_use = true;
+ tmp2.in_use = true;
+ tmp3.in_use = true;
+ tmp4.in_use = true;
+ tmp5.in_use = true;
+ tmp6.in_use = true;
+ tmp7.in_use = true;
+ tmp8.in_use = true;
+ tmp9.in_use = true;
+ peer_struct.in_use = true;
+#endif
+ tmp_peer = &tmp1;
+ std::vector<piece_block> picked;
+ boost::shared_ptr<piece_picker> p;
+ const int options = piece_picker::rarest_first;
+ std::pair<int, int> dc;
+ counters pc;
+
+ print_title("test piece_block");
+
+ TEST_CHECK(piece_block(0, 0) != piece_block(0, 1));
+ TEST_CHECK(piece_block(0, 0) != piece_block(1, 0));
+ TEST_CHECK(!(piece_block(0, 0) != piece_block(0, 0)));
+
+ TEST_CHECK(!(piece_block(0, 0) == piece_block(0, 1)));
+ | ||
relevance 2 | ../src/alert.cpp:1444 | the salt here is allocated on the heap. It would be nice to allocate in in the stack_allocator |
the salt here is allocated on the heap. It would be nice to
allocate in in the stack_allocator../src/alert.cpp:1444 , operation_names[op]
, error.value()
, convert_from_native(error.message()).c_str());
@@ -330,7 +664,7 @@ allocate in in the stack_allocator../src/alert.cpp:1444../src/alert.cpp:1444
| ||
relevance 2 | ../src/alert_manager.cpp:97 | keep a count of the number of threads waiting. Only if it's > 0 notify them |
keep a count of the number of threads waiting. Only if it's
-> 0 notify them../src/alert_manager.cpp:97 for (ses_extension_list_t::iterator i = m_ses_extensions.begin()
- , end(m_ses_extensions.end()); i != end; ++i)
- {
- (*i)->on_alert(a);
- }
-#endif
+ | ||
relevance 2 | ../src/alert_manager.cpp:90 | keep a count of the number of threads waiting. Only if it's > 0 notify them |
keep a count of the number of threads waiting. Only if it's
+> 0 notify them../src/alert_manager.cpp:90
+ return NULL;
+ }
+
+ void alert_manager::maybe_notify(alert* a, mutex::scoped_lock& lock)
+ {
if (a->type() == save_resume_data_failed_alert::alert_type
|| a->type() == save_resume_data_alert::alert_type)
++m_num_queued_resume;
@@ -394,6 +728,18 @@ allocate in in the stack_allocator../src/alert.cpp:1444 m_condition.notify_all();
}
+ else
+ {
+ lock.unlock();
+ }
+
+#ifndef TORRENT_DISABLE_EXTENSIONS
+ for (ses_extension_list_t::iterator i = m_ses_extensions.begin()
+ , end(m_ses_extensions.end()); i != end; ++i)
+ {
+ (*i)->on_alert(a);
+ }
+#endif
}
#ifndef TORRENT_NO_DEPRECATE
@@ -411,22 +757,10 @@ allocate in in the stack_allocator../src/alert.cpp:1444 | ||
relevance 2 | ../src/block_cache.cpp:1690 | turn these return values into enums returns -1: block not in cache -2: out of memory |
turn these return values into enums
+ | ||
relevance 2 | ../src/block_cache.cpp:1691 | turn these return values into enums returns -1: block not in cache -2: out of memory |
turn these return values into enums
returns
-1: block not in cache
--2: out of memory../src/block_cache.cpp:1690 {
+-2: out of memory../src/block_cache.cpp:1691 {
TORRENT_PIECE_ASSERT(!p.blocks[k].dirty, &p);
TORRENT_PIECE_ASSERT(!p.blocks[k].pending, &p);
TORRENT_PIECE_ASSERT(p.blocks[k].refcount == 0, &p);
@@ -453,7 +787,7 @@ returns
INVARIANT_CHECK;
TORRENT_UNUSED(expect_no_fail);
- TORRENT_PIECE_ASSERT(j->buffer == 0, pe);
+ TORRENT_PIECE_ASSERT(j->buffer.disk_block == 0, pe);
TORRENT_PIECE_ASSERT(pe->in_use, pe);
// copy from the cache and update the last use timestamp
@@ -465,7 +799,7 @@ returns
TORRENT_PIECE_ASSERT(size <= block_size(), pe);
const int start_block = block;
-#ifdef TORRENT_DEBUG
+#if TORRENT_USE_ASSERTS
int piece_size = j->storage->files()->piece_size(j->piece);
int blocks_in_piece = (piece_size + block_size() - 1) / block_size();
TORRENT_PIECE_ASSERT(start_block < blocks_in_piece, pe);
@@ -475,9 +809,9 @@ returns
// the cache, and we're not currently reading it in either
// since it's not pending
- if (inc_block_refcount(pe, start_block, ref_reading) == false)
+ if (inc_block_refcount(pe, start_block, ref_reading) == false)
{
- | ||
relevance 2 | ../src/escape_string.cpp:209 | this should probably be moved into string_util.cpp |
this should probably be moved into string_util.cpp../src/escape_string.cpp:209 }
+ | ||
relevance 2 | ../src/escape_string.cpp:209 | this should probably be moved into string_util.cpp |
this should probably be moved into string_util.cpp../src/escape_string.cpp:209 }
return false;
}
@@ -528,7 +862,7 @@ returns
snprintf(msg, sizeof(msg), "%s://%s%s%s%s%s%s", protocol.c_str(), auth.c_str()
, auth.empty()?"":"@", host.c_str()
, port == -1 ? "" : ":"
- | ||
relevance 2 | ../src/file.cpp:505 | test this on a FAT volume to see what error we get! |
test this on a FAT volume to see what error we get!../src/file.cpp:505 // if the filesystem does not support it.
+ | ||
relevance 2 | ../src/file.cpp:508 | test this on a FAT volume to see what error we get! |
test this on a FAT volume to see what error we get!../src/file.cpp:508 // if the filesystem does not support it.
ec.assign(GetLastError(), system_category());
return;
@@ -579,8 +913,8 @@ returns
create_directory(new_path, ec);
if (ec) return;
for (directory i(old_path, ec); !i.done(); i.next(ec))
- | ||
relevance 2 | ../src/http_tracker_connection.cpp:379 | returning a bool here is redundant. Instead this function should return the peer_entry |
returning a bool here is redundant. Instead this function should
-return the peer_entry../src/http_tracker_connection.cpp:379 {
+ | ||
relevance 2 | ../src/http_tracker_connection.cpp:383 | returning a bool here is redundant. Instead this function should return the peer_entry |
returning a bool here is redundant. Instead this function should
+return the peer_entry../src/http_tracker_connection.cpp:383 {
std::list<address> ip_list;
if (m_tracker_connection)
{
@@ -631,10 +965,10 @@ return the peer_entry../src/http_tracker_connection.cpp:379 | ||
relevance 2 | ../src/peer_connection.cpp:2336 | this should probably be based on time instead of number of request messages. For a very high throughput connection, 300 may be a legitimate number of requests to have in flight when getting choked |
this should probably be based on time instead of number
+ | ||
relevance 2 | ../src/peer_connection.cpp:2340 | this should probably be based on time instead of number of request messages. For a very high throughput connection, 300 may be a legitimate number of requests to have in flight when getting choked |
this should probably be based on time instead of number
of request messages. For a very high throughput connection, 300
may be a legitimate number of requests to have in flight when
-getting choked../src/peer_connection.cpp:2336 , "piece: %d s: %d l: %d invalid request"
+getting choked../src/peer_connection.cpp:2340 , "piece: %d s: %d l: %d invalid request"
, r.piece , r.start , r.length);
#endif
@@ -685,11 +1019,11 @@ getting choked../src/peer_connection.cpp:2336relevance 2 | ../src/peer_connection.cpp:3043 | since we throw away the queue entry once we issue the disk job, this may happen. Instead, we should keep the queue entry around, mark it as having been requested from disk and once the disk job comes back, discard it if it has been cancelled. Maybe even be able to cancel disk jobs? |
|
since we throw away the queue entry once we issue
+ | ||
relevance 2 | ../src/peer_connection.cpp:3051 | since we throw away the queue entry once we issue the disk job, this may happen. Instead, we should keep the queue entry around, mark it as having been requested from disk and once the disk job comes back, discard it if it has been cancelled. Maybe even be able to cancel disk jobs? |
since we throw away the queue entry once we issue
the disk job, this may happen. Instead, we should keep the
queue entry around, mark it as having been requested from
disk and once the disk job comes back, discard it if it has
-been cancelled. Maybe even be able to cancel disk jobs?../src/peer_connection.cpp:3043
+been cancelled. Maybe even be able to cancel disk jobs?../src/peer_connection.cpp:3051
std::vector<peer_request>::iterator i
= std::find(m_requests.begin(), m_requests.end(), r);
@@ -740,10 +1074,10 @@ been cancelled. Maybe even be able to cancel disk jobs?../src/peer_conn
void peer_connection::incoming_have_all()
{
TORRENT_ASSERT(is_single_thread());
- | ||
relevance 2 | ../src/peer_connection.cpp:4693 | use a deadline_timer for timeouts. Don't rely on second_tick()! Hook this up to connect timeout as well. This would improve performance because of less work in second_tick(), and might let use remove ticking entirely eventually |
use a deadline_timer for timeouts. Don't rely on second_tick()!
+ | ||
relevance 2 | ../src/peer_connection.cpp:4709 | use a deadline_timer for timeouts. Don't rely on second_tick()! Hook this up to connect timeout as well. This would improve performance because of less work in second_tick(), and might let use remove ticking entirely eventually |
use a deadline_timer for timeouts. Don't rely on second_tick()!
Hook this up to connect timeout as well. This would improve performance
because of less work in second_tick(), and might let use remove ticking
-entirely eventually../src/peer_connection.cpp:4693 connect_timeout += 20;
+entirely eventually../src/peer_connection.cpp:4709 connect_timeout += 20;
#endif
if (d > seconds(connect_timeout)
@@ -775,10 +1109,14 @@ entirely eventually../src/peer_connection.cpp:4693../src/peer_connection.cpp:4693relevance 2 | ../src/peer_list.cpp:495 | it would be nice if there was a way to iterate over these torrent_peer objects in the order they are allocated in the pool instead. It would probably be more efficient |
|
it would be nice if there was a way to iterate over these
+ | ||
relevance 2 | ../src/peer_list.cpp:495 | it would be nice if there was a way to iterate over these torrent_peer objects in the order they are allocated in the pool instead. It would probably be more efficient |
it would be nice if there was a way to iterate over these
torrent_peer objects in the order they are allocated in the pool
instead. It would probably be more efficient../src/peer_list.cpp:495 , int session_time, torrent_state* state)
{
@@ -847,7 +1181,7 @@ instead. It would probably be more efficient../src/peer_list.cpp:495 | ||
relevance 2 | ../src/piece_picker.cpp:1996 | make the 2048 limit configurable |
make the 2048 limit configurable../src/piece_picker.cpp:1996 // only one of rarest_first or sequential can be set
+ | ||
relevance 2 | ../src/piece_picker.cpp:1974 | make the 2048 limit configurable |
make the 2048 limit configurable../src/piece_picker.cpp:1974 // only one of rarest_first or sequential can be set
void piece_picker::pick_pieces(bitfield const& pieces
, std::vector<piece_block>& interesting_blocks, int num_blocks
@@ -896,10 +1230,10 @@ instead. It would probably be more efficient../src/peer_list.cpp:495 | ||
relevance 2 | ../src/piece_picker.cpp:2605 | the first_block returned here is the largest free range, not the first-fit range, which would be better |
the first_block returned here is the largest free range, not
-the first-fit range, which would be better../src/piece_picker.cpp:2605 , end(m_block_info.end()); i != end; ++i)
+ | ||
relevance 2 | ../src/piece_picker.cpp:2583 | the first_block returned here is the largest free range, not the first-fit range, which would be better |
the first_block returned here is the largest free range, not
+the first-fit range, which would be better../src/piece_picker.cpp:2583 , end(m_block_info.end()); i != end; ++i)
{
TORRENT_ASSERT(i->peer == 0 || static_cast<torrent_peer*>(i->peer)->in_use);
}
@@ -950,11 +1284,11 @@ the first-fit range, which would be better../src/piece_picker.cpp:2605<
exclusive = false;
if (info.state == piece_picker::block_info::state_requested
&& info.peer != 0)
- | ||
relevance 2 | ../src/piece_picker.cpp:3390 | it would be nice if this could be folded into lock_piece() the main distinction is that this also maintains the m_num_passed counter and the passed_hash_check member Is there ever a case where we call write filed without also locking the piece? Perhaps write_failed() should imply locking it. |
it would be nice if this could be folded into lock_piece()
+ | ||
relevance 2 | ../src/piece_picker.cpp:3367 | it would be nice if this could be folded into lock_piece() the main distinction is that this also maintains the m_num_passed counter and the passed_hash_check member Is there ever a case where we call write filed without also locking the piece? Perhaps write_failed() should imply locking it. |
it would be nice if this could be folded into lock_piece()
the main distinction is that this also maintains the m_num_passed
counter and the passed_hash_check member
Is there ever a case where we call write filed without also locking
-the piece? Perhaps write_failed() should imply locking it.../src/piece_picker.cpp:3390 int state = m_piece_map[piece].download_queue();
+the piece? Perhaps write_failed() should imply locking it.../src/piece_picker.cpp:3367 int state = m_piece_map[piece].download_queue();
if (state == piece_pos::piece_open) return;
std::vector<downloading_piece>::iterator i = find_dl_piece(state, piece);
if (i == m_downloads[state].end()) return;
@@ -1005,14 +1339,14 @@ the piece? Perhaps write_failed() should imply locking it.../src/piece_
if (info.state == block_info::state_finished) return;
if (info.state == block_info::state_writing) --i->writing;
- | ||
relevance 2 | ../src/session_impl.cpp:214 | find a better place for this function |
find a better place for this function../src/session_impl.cpp:214 *j.vec, j.peer->make_write_handler(boost::bind(
+ | ||
relevance 2 | ../src/session_impl.cpp:218 | find a better place for this function |
find a better place for this function../src/session_impl.cpp:218 *j.vec, j.peer->make_write_handler(boost::bind(
&peer_connection::on_send_data, j.peer, _1, _2)));
}
else
{
if (j.recv_buf)
{
- j.peer->get_socket()->async_read_some(asio::buffer(j.recv_buf, j.buf_size)
+ j.peer->get_socket()->async_read_some(boost::asio::buffer(j.recv_buf, j.buf_size)
, j.peer->make_read_handler(boost::bind(
&peer_connection::on_receive_data, j.peer, _1, _2)));
}
@@ -1025,7 +1359,7 @@ the piece? Perhaps write_failed() should imply locking it.../src/piece_
}
}
-proxy_settings::proxy_settings(aux::session_settings const& sett)
+ proxy_settings::proxy_settings(settings_pack const& sett)
{
hostname = sett.get_str(settings_pack::proxy_hostname);
username = sett.get_str(settings_pack::proxy_username);
@@ -1037,6 +1371,18 @@ the piece? Perhaps write_failed() should imply locking it. ../src/piece_
settings_pack::proxy_peer_connections);
}
+proxy_settings::proxy_settings(aux::session_settings const& sett)
+{
+ hostname = sett.get_str(settings_pack::proxy_hostname);
+ username = sett.get_str(settings_pack::proxy_username);
+ password = sett.get_str(settings_pack::proxy_password);
+ type = sett.get_int(settings_pack::proxy_type);
+ port = sett.get_int(settings_pack::proxy_port);
+ proxy_hostnames = sett.get_bool(settings_pack::proxy_hostnames);
+ proxy_peer_connections = sett.get_bool(
+ settings_pack::proxy_peer_connections);
+}
+
namespace aux {
void session_impl::init_peer_class_filter(bool unlimited_local)
@@ -1044,28 +1390,68 @@ namespace aux {
// set the default peer_class_filter to use the local peer class
// for peers on local networks
boost::uint32_t lfilter = 1 << m_local_peer_class;
- boost::uint32_t gfilter = 1 << m_global_class;
+ | ||
relevance 2 | ../src/session_impl.cpp:464 | is there a reason not to move all of this into init()? and just post it to the io_service? |
is there a reason not to move all of this into init()? and just
+post it to the io_service?../src/session_impl.cpp:464 m_posting_torrent_updates = false;
+#endif
+ m_udp_socket.set_rate_limit(m_settings.get_int(settings_pack::dht_upload_rate_limit));
- struct class_mapping
- {
- char const* first;
- char const* last;
- boost::uint32_t filter;
- };
+ m_udp_socket.subscribe(&m_utp_socket_manager);
+ m_udp_socket.subscribe(this);
+ m_udp_socket.subscribe(&m_tracker_manager);
- static const class_mapping v4_classes[] =
- {
- // everything
- | ||
relevance 2 | ../src/session_impl.cpp:821 | if the DHT is enabled, it should probably be restarted here. maybe it should even be deferred to not be started until the client has had a chance to pass in the dht state |
if the DHT is enabled, it should probably be restarted here.
+#ifdef TORRENT_USE_OPENSSL
+ m_ssl_udp_socket.subscribe(&m_ssl_utp_socket_manager);
+ m_ssl_udp_socket.subscribe(this);
+#endif
+
+ error_code ec;
+ m_listen_interface = tcp::endpoint(address_v4::any(), 0);
+ TORRENT_ASSERT_VAL(!ec, ec);
+ }
+
+ // This function is called by the creating thread, not in the message loop's
+ // / io_service thread.
+ void session_impl::start_session(settings_pack const& pack)
+ {
+ m_alerts.set_alert_mask(pack.get_int(settings_pack::alert_mask));
+
+#ifndef TORRENT_DISABLE_LOGGING
+ session_log("start session");
+#endif
+
+ error_code ec;
+#ifdef TORRENT_USE_OPENSSL
+ m_ssl_ctx.set_verify_mode(boost::asio::ssl::context::verify_none, ec);
+#if BOOST_VERSION >= 104700
+#if OPENSSL_VERSION_NUMBER >= 0x90812f
+ SSL_CTX_set_tlsext_servername_callback(m_ssl_ctx.native_handle(), servername_callback);
+ SSL_CTX_set_tlsext_servername_arg(m_ssl_ctx.native_handle(), this);
+#endif // OPENSSL_VERSION_NUMBER
+#endif // BOOST_VERSION
+#endif
+
+#ifndef TORRENT_DISABLE_DHT
+ m_next_dht_torrent = m_torrents.begin();
+#endif
+ m_next_lsd_torrent = m_torrents.begin();
+ m_tcp_mapping[0] = -1;
+ m_tcp_mapping[1] = -1;
+ m_udp_mapping[0] = -1;
+ m_udp_mapping[1] = -1;
+#ifdef TORRENT_USE_OPENSSL
+ m_ssl_tcp_mapping[0] = -1;
+ m_ssl_tcp_mapping[1] = -1;
+ m_ssl_udp_mapping[0] = -1;
+ | ||
relevance 2 | ../src/session_impl.cpp:835 | if the DHT is enabled, it should probably be restarted here. maybe it should even be deferred to not be started until the client has had a chance to pass in the dht state |
if the DHT is enabled, it should probably be restarted here.
maybe it should even be deferred to not be started until the client
-has had a chance to pass in the dht state../src/session_impl.cpp:821 if (val) m_settings.set_int(settings_pack::allowed_enc_level, val.int_value());
+has had a chance to pass in the dht state../src/session_impl.cpp:835 if (val) m_settings.set_int(settings_pack::allowed_enc_level, val.int_value());
}
#endif
-
+
settings = e->dict_find_dict("settings");
if (settings)
{
- settings_pack* pack = load_pack_from_dict(settings);
+ boost::shared_ptr<settings_pack> pack = load_pack_from_dict(settings);
apply_settings_pack(pack);
}
@@ -1109,10 +1495,10 @@ has had a chance to pass in the dht state../src/session_impl.cpp:821 | ||
relevance 2 | ../src/session_impl.cpp:1817 | the udp socket(s) should be using the same generic mechanism and not be restricted to a single one we should open a one listen socket for each entry in the listen_interfaces list |
the udp socket(s) should be using the same generic
+ | ||
relevance 2 | ../src/session_impl.cpp:1884 | the udp socket(s) should be using the same generic mechanism and not be restricted to a single one we should open a one listen socket for each entry in the listen_interfaces list |
the udp socket(s) should be using the same generic
mechanism and not be restricted to a single one
we should open a one listen socket for each entry in the
-listen_interfaces list../src/session_impl.cpp:1817 }
+listen_interfaces list../src/session_impl.cpp:1884 }
#endif // TORRENT_USE_OPENSSL
}
#endif // TORRENT_USE_IPV6
@@ -1138,7 +1524,7 @@ listen_interfaces list../src/session_impl.cpp:1817../src/session_impl.cpp:1817relevance 2 | ../src/session_impl.cpp:1919 | use bind_to_device in udp_socket |
|
use bind_to_device in udp_socket../src/session_impl.cpp:1919 if (m_listen_port_retries > 0)
+ | ||
relevance 2 | ../src/session_impl.cpp:1976 | use bind_to_device in udp_socket |
use bind_to_device in udp_socket../src/session_impl.cpp:1976 if (listen_port_retries > 0)
{
m_listen_interface.port(m_listen_interface.port() + 1);
- --m_listen_port_retries;
+ --listen_port_retries;
goto retry;
}
if (m_alerts.should_post<listen_failed_alert>())
@@ -1208,7 +1594,7 @@ listen_interfaces list../src/session_impl.cpp:1817relevance 2 | ../src/session_impl.cpp:1945 | use bind_to_device in udp_socket |
|
use bind_to_device in udp_socket../src/session_impl.cpp:1945 , print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
+ | ||
relevance 2 | ../src/session_impl.cpp:2002 | use bind_to_device in udp_socket |
use bind_to_device in udp_socket../src/session_impl.cpp:2002 , print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
#endif
if (m_alerts.should_post<listen_failed_alert>())
{
@@ -1235,10 +1621,10 @@ listen_interfaces list../src/session_impl.cpp:1817../src/session_impl.cpp:1817relevance 2 | ../src/session_impl.cpp:3391 | make a list for torrents that want to be announced on the DHT so we don't have to loop over all torrents, just to find the ones that want to announce |
|
make a list for torrents that want to be announced on the DHT so we
-don't have to loop over all torrents, just to find the ones that want to announce../src/session_impl.cpp:3391 if (!m_dht_torrents.empty())
+ | ||
relevance 2 | ../src/session_impl.cpp:3446 | make a list for torrents that want to be announced on the DHT so we don't have to loop over all torrents, just to find the ones that want to announce |
make a list for torrents that want to be announced on the DHT so we
+don't have to loop over all torrents, just to find the ones that want to announce../src/session_impl.cpp:3446 if (!m_dht_torrents.empty())
{
boost::shared_ptr<torrent> t;
do
{
- t = m_dht_torrents.front().lock();
+ t = m_dht_torrents.front().lock();
m_dht_torrents.pop_front();
} while (!t && !m_dht_torrents.empty());
@@ -1283,7 +1669,7 @@ don't have to loop over all torrents, just to find the ones that want to announc
++m_next_dht_torrent;
if (m_next_dht_torrent == m_torrents.end())
m_next_dht_torrent = m_torrents.begin();
- }
+ }
#endif
void session_impl::on_lsd_announce(error_code const& e)
@@ -1311,7 +1697,7 @@ don't have to loop over all torrents, just to find the ones that want to announc
if (m_torrents.empty()) return;
if (m_next_lsd_torrent == m_torrents.end())
- | ||
relevance 2 | ../src/storage.cpp:921 | is this risky? The upper layer will assume we have the whole file. Perhaps we should verify that at least the size of the file is correct |
is this risky? The upper layer will assume we have the
+ | ||
relevance 2 | ../src/storage.cpp:921 | is this risky? The upper layer will assume we have the whole file. Perhaps we should verify that at least the size of the file is correct |
is this risky? The upper layer will assume we have the
whole file. Perhaps we should verify that at least the size
of the file is correct../src/storage.cpp:921 if (links)
{
@@ -1364,39 +1750,40 @@ of the file is correct../src/storage.cpp:921relevance 2 | ../src/torrent.cpp:726 | post alert |
|
post alert../src/torrent.cpp:726 state_updated();
+ | ||
relevance 2 | ../src/torrent.cpp:667 | post alert |
post alert../src/torrent.cpp:667
+ state_updated();
set_state(torrent_status::downloading);
- m_override_resume_data = true;
init();
}
#endif // if 0
- void torrent::leave_seed_mode(bool seed)
+ void torrent::leave_seed_mode(bool skip_checking)
{
if (!m_seed_mode) return;
- if (!seed)
+ if (!skip_checking)
{
// this means the user promised we had all the
// files, but it turned out we didn't. This is
// an error.
-
+
#ifndef TORRENT_DISABLE_LOGGING
debug_log("*** FAILED SEED MODE, rechecking");
#endif
}
#ifndef TORRENT_DISABLE_LOGGING
- debug_log("*** LEAVING SEED MODE (%s)", seed ? "as seed" : "as non-seed");
+ debug_log("*** LEAVING SEED MODE (%s)"
+ , skip_checking ? "as seed" : "as non-seed");
#endif
m_seed_mode = false;
// seed is false if we turned out not
// to be a seed after all
- if (!seed)
+ if (!skip_checking)
{
m_have_all = false;
set_state(torrent_status::downloading);
@@ -1414,9 +1801,60 @@ of the file is correct ../src/storage.cpp:921relevance 2 | ../src/torrent.cpp:4807 | abort lookups this torrent has made via the session host resolver interface |
|
abort lookups this torrent has made via the
-session host resolver interface../src/torrent.cpp:4807 // files belonging to the torrents
+ | ||
relevance 2 | ../src/torrent.cpp:3317 | this looks suspicious. Figure out why it makes sense to use the first IP in this list and leave a comment here |
this looks suspicious. Figure out why it makes sense to use the
+first IP in this list and leave a comment here../src/torrent.cpp:3317 m_incomplete = incomplete;
+ m_downloaded = downloaded;
+
+ update_auto_sequential();
+
+ // these numbers are cached in the resume data
+ m_need_save_resume_data = true;
+ }
+
+ void torrent::tracker_response(
+ tracker_request const& r
+ , address const& tracker_ip // this is the IP we connected to
+ , std::list<address> const& tracker_ips // these are all the IPs it resolved to
+ , struct tracker_response const& resp)
+ {
+ TORRENT_ASSERT(is_single_thread());
+
+ INVARIANT_CHECK;
+ TORRENT_ASSERT(r.kind == tracker_request::announce_request);
+
+ if (resp.external_ip != address() && !tracker_ips.empty())
+ m_ses.set_external_address(resp.external_ip
+ , aux::session_interface::source_tracker
+ , *tracker_ips.begin());
+
+ time_point now = aux::time_now();
+
+ int interval = resp.interval;
+ if (interval < settings().get_int(settings_pack::min_announce_interval))
+ interval = settings().get_int(settings_pack::min_announce_interval);
+
+ announce_entry* ae = find_tracker(r);
+ if (ae)
+ {
+ if (resp.incomplete >= 0) ae->scrape_incomplete = resp.incomplete;
+ if (resp.complete >= 0) ae->scrape_complete = resp.complete;
+ if (resp.downloaded >= 0) ae->scrape_downloaded = resp.downloaded;
+ if (!ae->start_sent && r.event == tracker_request::started)
+ ae->start_sent = true;
+ if (!ae->complete_sent && r.event == tracker_request::completed)
+ ae->complete_sent = true;
+ ae->verified = true;
+ ae->updating = false;
+ ae->fails = 0;
+ ae->next_announce = now + seconds(interval);
+ ae->min_announce = now + seconds(resp.min_interval);
+ int tracker_index = ae - &m_trackers[0];
+ m_last_working_tracker = prioritize_tracker(tracker_index);
+
+ if ((!resp.trackerid.empty()) && (ae->trackerid != resp.trackerid))
+ {
+ | ||
relevance 2 | ../src/torrent.cpp:4822 | abort lookups this torrent has made via the session host resolver interface |
abort lookups this torrent has made via the
+session host resolver interface../src/torrent.cpp:4822 // files belonging to the torrents
disconnect_all(errors::torrent_aborted, op_bittorrent);
// post a message to the main thread to destruct
@@ -1433,7 +1871,7 @@ session host resolver interface../src/torrent.cpp:4807
@@ -1445,6 +1883,7 @@ session host resolver interface../src/torrent.cpp:4807 | ||
relevance 2 | ../src/torrent.cpp:4951 | the tracker login feature should probably be deprecated |
the tracker login feature should probably be deprecated../src/torrent.cpp:4951 if (alerts().should_post<file_renamed_alert>())
- alerts().emplace_alert<file_renamed_alert>(get_handle(), j->buffer, j->piece);
- m_torrent_file->rename_file(j->piece, j->buffer);
+ | ||
relevance 2 | ../src/torrent.cpp:4968 | the tracker login feature should probably be deprecated |
the tracker login feature should probably be deprecated../src/torrent.cpp:4968 alerts().emplace_alert<file_renamed_alert>(get_handle()
+ , j->buffer.string, j->piece);
+ m_torrent_file->rename_file(j->piece, j->buffer.string);
}
else
{
@@ -1518,7 +1956,9 @@ session host resolver interface../src/torrent.cpp:4807relevance 2 | ../src/torrent.cpp:7808 | if peer is a really good peer, maybe we shouldn't disconnect it |
|
if peer is a really good peer, maybe we shouldn't disconnect it../src/torrent.cpp:7808#ifndef TORRENT_DISABLE_LOGGING
+ | ||
relevance 2 | ../src/torrent.cpp:7897 | if peer is a really good peer, maybe we shouldn't disconnect it perhaps this logic should be disabled if we have too many idle peers (with some definition of idle) |
if peer is a really good peer, maybe we shouldn't disconnect it
+perhaps this logic should be disabled if we have too many idle peers
+(with some definition of idle)../src/torrent.cpp:7897#ifndef TORRENT_DISABLE_LOGGING
debug_log("incoming peer (%d)", int(m_connections.size()));
#endif
@@ -1540,11 +1980,25 @@ session host resolver interface../src/torrent.cpp:4807 if (peer && peer->peer_rank() < p->peer_rank())
{
+#ifndef TORRENT_DISABLE_LOGGING
+ debug_log("CLOSING CONNECTION \"%s\" peer list full (low peer rank) "
+ "connections: %d limit: %d"
+ , print_endpoint(peer->remote()).c_str()
+ , int(m_connections.size())
+ , m_max_connections);
+#endif
peer->disconnect(errors::too_many_connections, op_bittorrent);
p->peer_disconnected_other();
}
else
{
+#ifndef TORRENT_DISABLE_LOGGING
+ debug_log("CLOSING CONNECTION \"%s\" peer list full (low peer rank) "
+ "connections: %d limit: %d"
+ , print_endpoint(p->remote()).c_str()
+ , int(m_connections.size())
+ , m_max_connections);
+#endif
p->disconnect(errors::too_many_connections, op_bittorrent);
// we have to do this here because from the peer's point of
// it wasn't really attached to the torrent, but we do need
@@ -1555,21 +2009,58 @@ session host resolver interface../src/torrent.cpp:4807relevance 2 | ../src/torrent.cpp:9834 | if residual is not used, remove it |
|
if residual is not used, remove it../src/torrent.cpp:9834 }
- if (m_share_mode)
- recalc_share_mode();
-
- return true;
+ int torrent::finished_time() const
+ {
+ return m_finished_time + ((!is_finished() || is_paused()) ? 0
+ : (m_ses.session_time() - m_became_finished));
}
- bool torrent::want_tick() const
+ int torrent::active_time() const
{
- if (m_abort) return false;
+ return m_active_time + (is_paused() ? 0
+ : m_ses.session_time() - m_started);
+ }
- if (!m_connections.empty()) return true;
- | ||
relevance 2 | ../src/tracker_manager.cpp:200 | some of these arguments could probably be moved to the tracker request itself. like the ip_filter and settings |
some of these arguments could probably be moved to the
+ int torrent::seeding_time() const
+ {
+ return m_seeding_time + ((!is_seed() || is_paused()) ? 0
+ : m_ses.session_time() - m_became_seed);
+ }
+
+ void torrent::second_tick(int tick_interval_ms, int /* residual */)
+ {
+ TORRENT_ASSERT(want_tick());
+ TORRENT_ASSERT(is_single_thread());
+ INVARIANT_CHECK;
+
+ boost::weak_ptr<torrent> self(shared_from_this());
+
+#ifndef TORRENT_DISABLE_EXTENSIONS
+ for (extension_list_t::iterator i = m_extensions.begin()
+ , end(m_extensions.end()); i != end; ++i)
+ {
+ TORRENT_TRY {
+ (*i)->tick();
+ } TORRENT_CATCH (std::exception&) {}
+ }
+
+ if (m_abort) return;
+#endif
+
+ // if we're in upload only mode and we're auto-managed
+ // leave upload mode every 10 minutes hoping that the error
+ // condition has been fixed
+ if (m_upload_mode && m_auto_managed
+ && int(m_ses.session_time() - m_upload_mode_time)
+ >= settings().get_int(settings_pack::optimistic_disk_retry))
+ {
+ set_upload_mode(false);
+ }
+
+ if (m_storage_tick > 0 && is_loaded())
+ | ||
relevance 2 | ../src/tracker_manager.cpp:200 | some of these arguments could probably be moved to the tracker request itself. like the ip_filter and settings |
some of these arguments could probably be moved to the
tracker request itself. like the ip_filter and settings../src/tracker_manager.cpp:200 , interval == 0 ? min_interval : interval);
close();
}
@@ -1593,14 +2084,12 @@ tracker request itself. like the ip_filter and settings../src/tracker_m
tracker_manager::tracker_manager(class udp_socket& sock
, counters& stats_counters
, resolver_interface& resolver
- , struct ip_filter& ipf
, aux::session_settings const& sett
#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
, aux::session_logger& ses
#endif
)
- : m_ip_filter(ipf)
- , m_udp_socket(sock)
+ : m_udp_socket(sock)
, m_host_resolver(resolver)
, m_settings(sett)
, m_stats_counters(stats_counters)
@@ -1621,7 +2110,62 @@ tracker request itself. like the ip_filter and settings../src/tracker_m
TORRENT_ASSERT(m_ses.is_single_thread());
m_stats_counters.inc_stats_counter(counters::sent_tracker_bytes, bytes);
}
- | ||
relevance 2 | ../src/udp_tracker_connection.cpp:83 | support authentication here. tracker_req().auth |
support authentication here. tracker_req().auth../src/udp_tracker_connection.cpp:83 udp_tracker_connection::m_connection_cache;
+
+ void tracker_manager::received_bytes(int bytes)
+ | ||
relevance 2 | ../src/udp_socket.cpp:734 | the udp_socket should really just be a single socket, and the session should support having more than one, just like with TCP sockets for now, just make bind failures non-fatal |
the udp_socket should really just be a single socket, and the
+session should support having more than one, just like with TCP sockets
+for now, just make bind failures non-fatal../src/udp_socket.cpp:734 }
+
+ if (m_ipv4_sock.is_open()) m_ipv4_sock.close(ec);
+#if TORRENT_USE_IPV6
+ if (m_ipv6_sock.is_open()) m_ipv6_sock.close(ec);
+#endif
+
+ if (ep.address().is_v4())
+ {
+ m_ipv4_sock.open(udp::v4(), ec);
+ if (ec) return;
+ m_ipv4_sock.bind(ep, ec);
+ if (ec) return;
+ udp::socket::non_blocking_io ioc(true);
+ m_ipv4_sock.io_control(ioc, ec);
+ if (ec) return;
+ setup_read(&m_ipv4_sock);
+ }
+
+#if TORRENT_USE_IPV6
+ if (supports_ipv6() && (ep.address().is_v6() || is_any(ep.address())))
+ {
+ udp::endpoint ep6 = ep;
+ if (is_any(ep.address())) ep6.address(address_v6::any());
+ m_ipv6_sock.open(udp::v6(), ec);
+ if (ec) return;
+#ifdef IPV6_V6ONLY
+ m_ipv6_sock.set_option(v6only(true), ec);
+ ec.clear();
+#endif
+ m_ipv6_sock.bind(ep6, ec);
+ if (ec != error_code(boost::system::errc::address_not_available
+ , boost::system::generic_category()))
+ {
+ if (ec) return;
+ udp::socket::non_blocking_io ioc(true);
+ m_ipv6_sock.io_control(ioc, ec);
+ if (ec) return;
+ setup_read(&m_ipv6_sock);
+ }
+ else
+ {
+ ec.clear();
+ }
+ }
+#endif
+#if TORRENT_USE_ASSERTS
+ m_started = true;
+#endif
+ m_bind_port = ep.port();
+}
+ | ||
relevance 2 | ../src/udp_tracker_connection.cpp:83 | support authentication here. tracker_req().auth |
support authentication here. tracker_req().auth../src/udp_tracker_connection.cpp:83 udp_tracker_connection::m_connection_cache;
mutex udp_tracker_connection::m_cache_mutex;
@@ -1672,9 +2216,9 @@ tracker request itself. like the ip_filter and settings../src/tracker_m
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("udp_tracker_connection::name_lookup");
#endif
- | ||
relevance 2 | ../src/ut_metadata.cpp:120 | if we were to initialize m_metadata_size lazily instead, we would probably be more efficient initialize m_metadata_size |
if we were to initialize m_metadata_size lazily instead,
+ | ||
relevance 2 | ../src/ut_metadata.cpp:122 | if we were to initialize m_metadata_size lazily instead, we would probably be more efficient initialize m_metadata_size |
if we were to initialize m_metadata_size lazily instead,
we would probably be more efficient
-initialize m_metadata_size../src/ut_metadata.cpp:120 metadata();
+initialize m_metadata_size../src/ut_metadata.cpp:122 metadata();
}
bool need_loaded()
@@ -1698,8 +2242,8 @@ initialize m_metadata_size../src/ut_metadata.cpp:120 | ||
relevance 2 | ../src/utp_stream.cpp:351 | it would be nice if not everything would have to be public here |
it would be nice if not everything would have to be public here../src/utp_stream.cpp:351 void incoming(boost::uint8_t const* buf, int size, packet* p, time_point now);
+ | ||
relevance 2 | ../src/utp_socket_manager.cpp:259 | we may want to take ec into account here. possibly close connections quicker |
we may want to take ec into account here. possibly close
+connections quicker../src/utp_socket_manager.cpp:259 error_code ec;
+ m_interfaces = enum_net_interfaces(m_sock.get_io_service(), ec);
+ if (ec) return socket_ep;
+ }
+
+ for (std::vector<ip_interface>::iterator i = m_interfaces.begin()
+ , end(m_interfaces.end()); i != end; ++i)
+ {
+ if (i->interface_address.is_v4() != remote.is_v4())
+ continue;
+
+ if (strcmp(best->name, i->name) == 0)
+ return tcp::endpoint(i->interface_address, socket_ep.port());
+ }
+ return socket_ep;
+ }
+
+ bool utp_socket_manager::incoming_packet(error_code const& ec, udp::endpoint const& ep
+ , char const* p, int size)
+ {
+ TORRENT_UNUSED(ec);
+ // UTP_LOGV("incoming packet size:%d\n", size);
+
+ if (size < int(sizeof(utp_header))) return false;
+
+ utp_header const* ph = (utp_header*)p;
+
+// UTP_LOGV("incoming packet version:%d\n", int(ph->get_version()));
+
+ if (ph->get_version() != 1) return false;
+
+ const time_point receive_time = clock_type::now();
+
+ // parse out connection ID and look for existing
+ // connections. If found, forward to the utp_stream.
+ boost::uint16_t id = ph->connection_id;
+
+ // first test to see if it's the same socket as last time
+ // in most cases it is
+ if (m_last_socket
+ && utp_match(m_last_socket, ep, id))
+ {
+ return utp_incoming_packet(m_last_socket, p, size, ep, receive_time);
+ }
+
+ std::pair<socket_map_t::iterator, socket_map_t::iterator> r =
+ m_utp_sockets.equal_range(id);
+
+ for (; r.first != r.second; ++r.first)
+ {
+ if (!utp_match(r.first->second, ep, id)) continue;
+ | ||
relevance 2 | ../src/utp_stream.cpp:353 | it would be nice if not everything would have to be public here |
it would be nice if not everything would have to be public here../src/utp_stream.cpp:353 void incoming(boost::uint8_t const* buf, int size, packet* p, time_point now);
void do_ledbat(int acked_bytes, int delay, int in_flight);
int packet_timeout() const;
bool test_socket_state();
@@ -1776,9 +2372,9 @@ private:
{
iovec_t(void* b, size_t l): buf(b), len(l) {}
void* buf;
- | ||
relevance 2 | ../src/web_peer_connection.cpp:632 | just make this peer not have the pieces associated with the file we just requested. Only when it doesn't have any of the file do the following |
just make this peer not have the pieces
+ | ||
relevance 2 | ../src/web_peer_connection.cpp:622 | just make this peer not have the pieces associated with the file we just requested. Only when it doesn't have any of the file do the following |
just make this peer not have the pieces
associated with the file we just requested. Only
-when it doesn't have any of the file do the following../src/web_peer_connection.cpp:632 ++m_num_responses;
+when it doesn't have any of the file do the following../src/web_peer_connection.cpp:622 ++m_num_responses;
if (m_parser.connection_close())
{
@@ -1829,13 +2425,13 @@ when it doesn't have any of the file do the following../src/web_peer_co
{
// we should not try this server again.
t->remove_web_seed(this, errors::missing_location, op_bittorrent, 2);
- | ||
relevance 2 | ../src/web_peer_connection.cpp:691 | create a mapping of file-index to redirection URLs. Use that to form URLs instead. Support to reconnect to a new server without destructing this peer_connection |
create a mapping of file-index to redirection URLs. Use that to form
+ | ||
relevance 2 | ../src/web_peer_connection.cpp:681 | create a mapping of file-index to redirection URLs. Use that to form URLs instead. Support to reconnect to a new server without destructing this peer_connection |
create a mapping of file-index to redirection URLs. Use that to form
URLs instead. Support to reconnect to a new server without destructing this
-peer_connection../src/web_peer_connection.cpp:691 == dl_target);
+peer_connection../src/web_peer_connection.cpp:681 == dl_target);
#endif
return;
}
-
+
bool single_file_request = false;
if (!m_path.empty() && m_path[m_path.size() - 1] != '/')
single_file_request = true;
@@ -1882,7 +2478,7 @@ peer_connection../src/web_peer_connection.cpp:691relevance 2 | ../src/kademlia/node.cpp:71 | make this configurable in dht_settings |
|
make this configurable in dht_settings../src/kademlia/node.cpp:71#include "libtorrent/random.hpp"
+ | ||
relevance 2 | ../src/kademlia/node.cpp:71 | make this configurable in dht_settings |
make this configurable in dht_settings../src/kademlia/node.cpp:71#include "libtorrent/random.hpp"
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/alert_types.hpp" // for dht_lookup
#include "libtorrent/performance_counters.hpp" // for counters
@@ -1933,8 +2529,8 @@ node_id calculate_node_id(node_id const& nid, dht_observer* observer)
}
} // anonymous namespace
- | ||
relevance 2 | ../src/kademlia/node.cpp:503 | it would be nice to have a bias towards node-id prefixes that are missing in the bucket |
it would be nice to have a bias towards node-id prefixes that
-are missing in the bucket../src/kademlia/node.cpp:503 // this shouldn't happen
+ | ||
relevance 2 | ../src/kademlia/node.cpp:535 | it would be nice to have a bias towards node-id prefixes that are missing in the bucket |
it would be nice to have a bias towards node-id prefixes that
+are missing in the bucket../src/kademlia/node.cpp:535 // this shouldn't happen
TORRENT_ASSERT(m_id != ne->id);
if (ne->id == m_id) return;
@@ -1958,7 +2554,7 @@ void node::send_single_refresh(udp::endpoint const& ep, int bucket
node_id target = generate_secret_id() & ~mask;
target |= m_id & mask;
- // create a dummy traversal_algorithm
+ // create a dummy traversal_algorithm
// this is unfortunately necessary for the observer
// to free itself from the pool when it's being released
boost::intrusive_ptr<traversal_algorithm> algo(
@@ -1985,7 +2581,7 @@ void node::send_single_refresh(udp::endpoint const& ep, int bucket
time_duration node::connection_timeout()
{
time_duration d = m_rpc.tick();
- | ||
relevance 2 | ../src/kademlia/node.cpp:593 | use the non deprecated function instead of this one |
use the non deprecated function instead of this one../src/kademlia/node.cpp:593 return d;
+ | ||
relevance 2 | ../src/kademlia/node.cpp:625 | use the non deprecated function instead of this one |
use the non deprecated function instead of this one../src/kademlia/node.cpp:625 return d;
}
void node::status(std::vector<dht_routing_bucket>& table
@@ -2036,7 +2632,7 @@ void node::lookup_peers(sha1_hash const& info_hash, entry& reply
torrent_entry const& v = i->second;
if (!v.name.empty()) reply["n"] = v.name;
- | ||
relevance 2 | ../src/kademlia/node.cpp:926 | find_node should write directly to the response entry |
find_node should write directly to the response entry../src/kademlia/node.cpp:926 , int(reply["values"].list().size()));
+ | ||
relevance 2 | ../src/kademlia/node.cpp:958 | find_node should write directly to the response entry |
find_node should write directly to the response entry../src/kademlia/node.cpp:958 , int(reply["values"].list().size()));
}
#endif
}
@@ -2087,7 +2683,7 @@ void node::lookup_peers(sha1_hash const& info_hash, entry& reply
port = m.addr.port();
if (port < 0 || port >= 65536)
- | ||
relevance 2 | ../src/kademlia/routing_table.cpp:116 | use the non deprecated function instead of this one |
use the non deprecated function instead of this one../src/kademlia/routing_table.cpp:116
+ | ||
relevance 2 | ../src/kademlia/routing_table.cpp:116 | use the non deprecated function instead of this one |
use the non deprecated function instead of this one../src/kademlia/routing_table.cpp:116
static const int size_exceptions[] = {16, 8, 4, 2};
if (bucket < int(sizeof(size_exceptions)/sizeof(size_exceptions[0])))
return m_bucket_size * size_exceptions[bucket];
@@ -2138,7 +2734,7 @@ boost::tuple<int, int, int> routing_table::size() const
nodes += i->live_nodes.size();
for (bucket_t::const_iterator k = i->live_nodes.begin()
, end(i->live_nodes.end()); k != end; ++k)
- | ||
relevance 2 | ../src/kademlia/routing_table.cpp:955 | move the lowest priority nodes to the replacement bucket |
move the lowest priority nodes to the replacement bucket../src/kademlia/routing_table.cpp:955 bucket_t& b = m_buckets[bucket_index].live_nodes;
+ | ||
relevance 2 | ../src/kademlia/routing_table.cpp:955 | move the lowest priority nodes to the replacement bucket |
move the lowest priority nodes to the replacement bucket../src/kademlia/routing_table.cpp:955 bucket_t& b = m_buckets[bucket_index].live_nodes;
bucket_t& rb = m_buckets[bucket_index].replacements;
// move any node whose (160 - distane_exp(m_id, id)) >= (i - m_buckets.begin())
@@ -2189,7 +2785,7 @@ boost::tuple<int, int, int> routing_table::size() const
else
new_replacement_bucket.push_back(*j);
}
- | ||
relevance 2 | ../include/libtorrent/alert_types.hpp:1428 | should the alert baseclass have this object instead? |
should the alert baseclass have this object instead?../include/libtorrent/alert_types.hpp:1428 {
+ | ||
relevance 2 | ../include/libtorrent/alert_types.hpp:1415 | should the alert baseclass have this object instead? |
should the alert baseclass have this object instead?../include/libtorrent/alert_types.hpp:1415 {
// internal
portmap_log_alert(aux::stack_allocator& alloc, int t, const char* m);
@@ -2240,7 +2836,7 @@ boost::tuple<int, int, int> routing_table::size() const
#endif
// If the error happend to a specific file, this returns the path to it.
- | ||
relevance 2 | ../include/libtorrent/build_config.hpp:40 | instead of using a dummy function to cause link errors when incompatible build configurations are used, make the namespace name depend on the configuration, and have a using declaration in the headers to pull it into libtorrent. |
instead of using a dummy function to cause link errors when
+ | ||
relevance 2 | ../include/libtorrent/build_config.hpp:40 | instead of using a dummy function to cause link errors when incompatible build configurations are used, make the namespace name depend on the configuration, and have a using declaration in the headers to pull it into libtorrent. |
instead of using a dummy function to cause link errors when
incompatible build configurations are used, make the namespace name
depend on the configuration, and have a using declaration in the headers
to pull it into libtorrent.../include/libtorrent/build_config.hpp:40AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -2283,8 +2879,8 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
- | ||
relevance 2 | ../include/libtorrent/enum_net.hpp:143 | this could be done more efficiently by just looking up the interface with the given name, maybe even with if_nametoindex() |
this could be done more efficiently by just looking up
-the interface with the given name, maybe even with if_nametoindex()../include/libtorrent/enum_net.hpp:143
+ | ||
relevance 2 | ../include/libtorrent/enum_net.hpp:142 | this could be done more efficiently by just looking up the interface with the given name, maybe even with if_nametoindex() |
this could be done more efficiently by just looking up
+the interface with the given name, maybe even with if_nametoindex()../include/libtorrent/enum_net.hpp:142
address ip = address::from_string(device_name, ec);
if (!ec)
{
@@ -2335,7 +2931,7 @@ the interface with the given name, maybe even with if_nametoindex()../i
// returns true if the given device exists
TORRENT_EXTRA_EXPORT bool has_interface(char const* name, io_service& ios
- | ||
relevance 2 | ../include/libtorrent/heterogeneous_queue.hpp:56 | add emplace_back() version |
add emplace_back() version../include/libtorrent/heterogeneous_queue.hpp:56#include <vector>
+ | ||
relevance 2 | ../include/libtorrent/heterogeneous_queue.hpp:56 | add emplace_back() version |
add emplace_back() version../include/libtorrent/heterogeneous_queue.hpp:56#include <vector>
#include <boost/cstdint.hpp>
#include <boost/utility/enable_if.hpp>
@@ -2386,8 +2982,59 @@ namespace libtorrent {
void get_pointers(std::vector<T*>& out)
{
- | ||
relevance 2 | ../include/libtorrent/piece_picker.hpp:600 | having 8 priority levels is probably excessive. It should probably be changed to 3 levels + dont-download |
having 8 priority levels is probably excessive. It should
-probably be changed to 3 levels + dont-download../include/libtorrent/piece_picker.hpp:600 // the number of peers that has this piece
+ | ||
relevance 2 | ../include/libtorrent/peer_connection.hpp:1122 | rename this target queue size |
rename this target queue size../include/libtorrent/peer_connection.hpp:1122
+ // the number of bytes send to the disk-io
+ // thread that hasn't yet been completely written.
+ int m_outstanding_writing_bytes;
+
+ // max transfer rates seen on this peer
+ int m_download_rate_peak;
+ int m_upload_rate_peak;
+
+ // when using the BitTyrant choker, this is our
+ // estimated reciprocation rate. i.e. the rate
+ // we need to send to this peer for it to unchoke
+ // us
+ int m_est_reciprocation_rate;
+
+ // stop sending data after this many bytes, INT_MAX = inf
+ int m_send_barrier;
+
+ // the number of request we should queue up
+ // at the remote end.
+ boost::uint16_t m_desired_queue_size;
+
+#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
+ // in case the session settings is set
+ // to resolve countries, this is set to
+ // the two character country code this
+ // peer resides in.
+ char m_country[2];
+#endif
+
+ // if set to non-zero, this peer will always prefer
+ // to request entire n pieces, rather than blocks.
+ // where n is the value of this variable.
+ // if it is 0, the download rate limit setting
+ // will be used to determine if whole pieces
+ // are preferred.
+ boost::uint8_t m_prefer_contiguous_blocks;
+
+ // this is the number of times this peer has had
+ // a request rejected because of a disk I/O failure.
+ // once this reaches a certain threshold, the
+ // peer is disconnected in order to avoid infinite
+ // loops of consistent failures
+ boost::uint8_t m_disk_read_failures;
+
+ // this is used in seed mode whenever we trigger a hash check
+ // for a piece, before we read it. It's used to throttle
+ // the hash checks to just a few per peer at a time.
+ boost::uint8_t m_outstanding_piece_verification:3;
+
+ // is true if it was we that connected to the peer
+ | ||
relevance 2 | ../include/libtorrent/piece_picker.hpp:598 | having 8 priority levels is probably excessive. It should probably be changed to 3 levels + dont-download |
having 8 priority levels is probably excessive. It should
+probably be changed to 3 levels + dont-download../include/libtorrent/piece_picker.hpp:598 // the number of peers that has this piece
// (availability)
#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE
boost::uint32_t peer_count : 9;
@@ -2438,7 +3085,7 @@ probably be changed to 3 levels + dont-download../include/libtorrent/pi
#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE
we_have_index = 0x3ffff,
#else
- | ||
relevance 2 | ../include/libtorrent/proxy_base.hpp:259 | use the resolver interface that has a built-in cache |
use the resolver interface that has a built-in cache../include/libtorrent/proxy_base.hpp:259 return m_sock.lowest_layer();
+ | ||
relevance 2 | ../include/libtorrent/proxy_base.hpp:259 | use the resolver interface that has a built-in cache |
use the resolver interface that has a built-in cache../include/libtorrent/proxy_base.hpp:259 return m_sock.lowest_layer();
}
next_layer_type& next_layer()
@@ -2447,12 +3094,12 @@ probably be changed to 3 levels + dont-download../include/libtorrent/pi
}
bool is_open() const { return m_sock.is_open(); }
-
+
protected:
bool handle_error(error_code const& e, boost::shared_ptr<handler_type> const& h);
- stream_socket m_sock;
+ tcp::socket m_sock;
std::string m_hostname;
int m_port;
@@ -2465,78 +3112,25 @@ protected:
#endif
- | ||
relevance 2 | ../include/libtorrent/session.hpp:198 | the two second constructors here should probably be deprecated in favor of the more generic one that just takes a settings_pack and a string |
the two second constructors here should probably
-be deprecated in favor of the more generic one that just
-takes a settings_pack and a string../include/libtorrent/session.hpp:198 // nat-pmp) and default plugins (ut_metadata, ut_pex and smart_ban). The
- // default is to start those features. If you do not want them to start,
- // pass 0 as the flags parameter.
- //
- // The ``alert_mask`` is the same mask that you would send to
- // set_alert_mask().
+ | ||
relevance 2 | ../include/libtorrent/session_handle.hpp:72 | the ip filter should probably be saved here too |
the ip filter should probably be saved here too../include/libtorrent/session_handle.hpp:72 struct plugin;
+ struct torrent_plugin;
+ class torrent;
+ struct ip_filter;
+ class port_filter;
+ class alert;
- session(settings_pack const& pack
- , int flags = start_default_features | add_default_plugins)
- {
- TORRENT_CFG();
- start(flags, pack);
- }
- session(fingerprint const& print = fingerprint("LT"
- , LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)
- , int flags = start_default_features | add_default_plugins
- , boost::uint32_t alert_mask = alert::error_notification)
- {
- TORRENT_CFG();
- settings_pack pack;
- pack.set_int(settings_pack::alert_mask, alert_mask);
- pack.set_str(settings_pack::peer_fingerprint, print.to_string());
- if ((flags & start_default_features) == 0)
- {
- pack.set_bool(settings_pack::enable_upnp, false);
- pack.set_bool(settings_pack::enable_natpmp, false);
- pack.set_bool(settings_pack::enable_lsd, false);
- pack.set_bool(settings_pack::enable_dht, false);
- }
+#ifndef TORRENT_NO_DEPRECATE
+ struct session_status;
+#endif
- start(flags, pack);
- }
- session(fingerprint const& print
- , std::pair<int, int> listen_port_range
- , char const* listen_interface = "0.0.0.0"
- , int flags = start_default_features | add_default_plugins
- , int alert_mask = alert::error_notification)
- {
- TORRENT_CFG();
- TORRENT_ASSERT(listen_port_range.first > 0);
- TORRENT_ASSERT(listen_port_range.first <= listen_port_range.second);
+ typedef boost::function<void(sha1_hash const&, std::vector<char>&
+ , error_code&)> user_load_function_t;
- settings_pack pack;
- pack.set_int(settings_pack::alert_mask, alert_mask);
- pack.set_int(settings_pack::max_retry_port_bind, listen_port_range.second - listen_port_range.first);
- pack.set_str(settings_pack::peer_fingerprint, print.to_string());
- char if_string[100];
- snprintf(if_string, sizeof(if_string), "%s:%d", listen_interface, listen_port_range.first);
- pack.set_str(settings_pack::listen_interfaces, if_string);
-
- if ((flags & start_default_features) == 0)
- | ||
relevance 2 | ../include/libtorrent/session.hpp:249 | the ip filter should probably be saved here too |
the ip filter should probably be saved here too../include/libtorrent/session.hpp:249 pack.set_str(settings_pack::listen_interfaces, if_string);
-
- if ((flags & start_default_features) == 0)
- {
- pack.set_bool(settings_pack::enable_upnp, false);
- pack.set_bool(settings_pack::enable_natpmp, false);
- pack.set_bool(settings_pack::enable_lsd, false);
- pack.set_bool(settings_pack::enable_dht, false);
- }
- start(flags, pack);
- }
-
- // The destructor of session will notify all trackers that our torrents
- // have been shut down. If some trackers are down, they will time out.
- // All this before the destructor of session returns. So, it's advised
- // that any kind of interface (such as windows) are closed before
- // destructing the session object. Because it can take a few second for
- // it to finish. The timeout can be set with apply_settings().
- ~session();
+ struct TORRENT_EXPORT session_handle
+ {
+ session_handle(aux::session_impl* impl)
+ : m_impl(impl)
+ {}
// flags that determines which aspects of the session should be
@@ -2569,10 +3163,10 @@ takes a settings_pack and a string../include/libtorrent/session.hpp:198
save_peer_proxy = save_proxy,
save_web_proxy = save_proxy,
save_tracker_proxy = save_proxy
- | ||
relevance 2 | ../include/libtorrent/session_settings.hpp:55 | this type is only used internally now. move it to an internal header and make this type properly deprecated. |
this type is only used internally now. move it to an internal
-header and make this type properly deprecated.../include/libtorrent/session_settings.hpp:55
-#include "libtorrent/version.hpp"
+ | ||
relevance 2 | ../include/libtorrent/session_settings.hpp:56 | this type is only used internally now. move it to an internal header and make this type properly deprecated. |
this type is only used internally now. move it to an internal
+header and make this type properly deprecated.../include/libtorrent/session_settings.hpp:56#include "libtorrent/version.hpp"
#include "libtorrent/config.hpp"
+#include "libtorrent/settings_pack.hpp"
#include <boost/cstdint.hpp>
#include <string>
@@ -2604,6 +3198,7 @@ namespace libtorrent
// construct the proxy_settings object from the settings
// this constructor is implemented in session_impl.cpp
+ proxy_settings(settings_pack const& sett);
proxy_settings(aux::session_settings const& sett);
// the name or IP of the proxy server. ``port`` is the port number the
@@ -2620,9 +3215,8 @@ namespace libtorrent
// the type of proxy to use. Assign one of these to the
// proxy_settings::type field.
enum proxy_type
- {
- | ||
relevance 2 | ../include/libtorrent/socket_type.hpp:321 | it would be nice to use aligned_storage here when building on c++11 |
it would be nice to use aligned_storage here when
-building on c++11../include/libtorrent/socket_type.hpp:321 sizeof(stream_socket)
+ | ||
relevance 2 | ../include/libtorrent/socket_type.hpp:324 | it would be nice to use aligned_storage here when building on c++11 |
it would be nice to use aligned_storage here when
+building on c++11../include/libtorrent/socket_type.hpp:324 sizeof(tcp::socket)
, sizeof(socks5_stream)
, sizeof(http_stream)
, sizeof(utp_stream)
@@ -2632,7 +3226,7 @@ building on c++11../include/libtorrent/socket_type.hpp:321../include/libtorrent/socket_type.hpp:321
| ||
relevance 2 | ../include/libtorrent/socks5_stream.hpp:135 | add async_connect() that takes a hostname and port as well |
add async_connect() that takes a hostname and port as well../include/libtorrent/socks5_stream.hpp:135 if (m_dst_name.size() > 255)
+ | ||
relevance 2 | ../include/libtorrent/socks5_stream.hpp:135 | add async_connect() that takes a hostname and port as well |
add async_connect() that takes a hostname and port as well../include/libtorrent/socks5_stream.hpp:135 if (m_dst_name.size() > 255)
m_dst_name.resize(255);
}
@@ -2718,7 +3312,7 @@ building on c++11../include/libtorrent/socket_type.hpp:321 | ||
relevance 2 | ../include/libtorrent/tracker_manager.hpp:276 | this class probably doesn't need to have virtual functions. |
this class probably doesn't need to have virtual functions.../include/libtorrent/tracker_manager.hpp:276 int m_completion_timeout;
+ | ||
relevance 2 | ../include/libtorrent/tracker_manager.hpp:278 | this class probably doesn't need to have virtual functions. |
this class probably doesn't need to have virtual functions.../include/libtorrent/tracker_manager.hpp:278 int m_completion_timeout;
typedef mutex mutex_t;
mutable mutex_t m_mutex;
@@ -2732,7 +3326,7 @@ building on c++11../include/libtorrent/socket_type.hpp:321../include/libtorrent/socket_type.hpp:321
| ||
relevance 2 | ../include/libtorrent/kademlia/observer.hpp:133 | make this private and unconditional |
make this private and unconditional../include/libtorrent/kademlia/observer.hpp:133 node_id const& id() const { return m_id; }
+ | ||
relevance 2 | ../include/libtorrent/aux_/session_impl.hpp:1125 | the throttling of saving resume data could probably be factored out into a separate class |
the throttling of saving resume data could probably be
+factored out into a separate class../include/libtorrent/aux_/session_impl.hpp:1125 // each second tick the timer takes a little
+ // bit longer than one second to trigger. The
+ // extra time it took is accumulated into this
+ // counter. Every time it exceeds 1000, torrents
+ // will tick their timers 2 seconds instead of one.
+ // this keeps the timers more accurate over time
+ // as a kind of "leap second" to adjust for the
+ // accumulated error
+ boost::uint16_t m_tick_residual;
- void set_transaction_id(boost::uint16_t tid)
- { m_transaction_id = tid; }
+#ifndef TORRENT_DISABLE_LOGGING
+ virtual void session_log(char const* fmt, ...) const TORRENT_FORMAT(2,3);
+ virtual void session_vlog(char const* fmt, va_list& va) const TORRENT_FORMAT(2,0);
- boost::uint16_t transaction_id() const
- { return m_transaction_id; }
-
- enum {
- flag_queried = 1,
- flag_initial = 2,
- flag_no_id = 4,
- flag_short_timeout = 8,
- flag_failed = 16,
- flag_ipv6_address = 32,
- flag_alive = 64,
- flag_done = 128
- };
-
-#ifndef TORRENT_DHT_VERBOSE_LOGGING
-protected:
- #endif
-
- void done();
-
- time_point m_sent;
-
- const boost::intrusive_ptr<traversal_algorithm> m_algorithm;
-
- node_id m_id;
-
- TORRENT_UNION addr_t
- {
-#if TORRENT_USE_IPV6
- address_v6::bytes_type v6;
+ // this list of tracker loggers serves as tracker_callbacks when
+ // shutting down. This list is just here to keep them alive during
+ // whe shutting down process
+ std::list<boost::shared_ptr<tracker_logger> > m_tracker_loggers;
#endif
- address_v4::bytes_type v4;
- } m_addr;
- // reference counter for intrusive_ptr
- mutable boost::uint16_t m_refs;
+ void queue_async_resume_data(boost::shared_ptr<torrent> const& t);
+ void done_async_resume();
+ void async_resume_dispatched();
- boost::uint16_t m_port;
+ // state for keeping track of external IPs
+ external_ip m_external_ip;
- // the transaction ID for this call
- boost::uint16_t m_transaction_id;
-public:
- unsigned char flags;
+#ifndef TORRENT_DISABLE_EXTENSIONS
+ // this is a list to allow extensions to potentially remove themselves.
+ typedef std::list<boost::shared_ptr<plugin> > ses_extension_list_t;
+ ses_extension_list_t m_ses_extensions;
+#endif
-#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
- bool m_in_constructor:1;
- | ||
relevance 2 | ../include/libtorrent/aux_/session_interface.hpp:138 | the IP voting mechanism should be factored out to its own class, not part of the session |
the IP voting mechanism should be factored out
-to its own class, not part of the session../include/libtorrent/aux_/session_interface.hpp:138#if TORRENT_USE_ASSERTS
+ // if this function is set, it indicates that torrents are allowed
+ // to be unloaded. If it isn't, torrents will never be unloaded
+ user_load_function_t m_user_load_torrent;
+
+ // this is true whenever we have posted a deferred-disk job
+ // it means we don't need to post another one
+ bool m_deferred_submit_disk_jobs;
+
+ // this is set to true when a torrent auto-manage
+ // event is triggered, and reset whenever the message
+ // is delivered and the auto-manage is executed.
+ // there should never be more than a single pending auto-manage
+ // message in-flight at any given time.
+ bool m_pending_auto_manage;
+
+ // this is also set to true when triggering an auto-manage
+ // of the torrents. However, if the normal auto-manage
+ // timer comes along and executes the auto-management,
+ | ||
relevance 2 | ../include/libtorrent/aux_/session_interface.hpp:137 | the IP voting mechanism should be factored out to its own class, not part of the session |
the IP voting mechanism should be factored out
+to its own class, not part of the session../include/libtorrent/aux_/session_interface.hpp:137#if TORRENT_USE_ASSERTS
virtual bool is_single_thread() const = 0;
virtual bool has_peer(peer_connection const* p) const = 0;
virtual bool any_torrent_has_peer(peer_connection const* p) const = 0;
@@ -2864,7 +3459,7 @@ to its own class, not part of the session../include/libtorrent/aux_/ses
typedef boost::function<void(error_code const&, std::vector<address> const&)>
callback_t;
- | ||
relevance 2 | ../include/libtorrent/aux_/session_interface.hpp:163 | remove this. There's already get_resolver() |
remove this. There's already get_resolver()../include/libtorrent/aux_/session_interface.hpp:163 source_peer = 2,
+ | ||
relevance 2 | ../include/libtorrent/aux_/session_interface.hpp:162 | remove this. There's already get_resolver() |
remove this. There's already get_resolver()../include/libtorrent/aux_/session_interface.hpp:162 source_peer = 2,
source_tracker = 4,
source_router = 8
};
@@ -2897,9 +3492,9 @@ to its own class, not part of the session../include/libtorrent/aux_/ses
virtual void remove_torrent(torrent_handle const& h, int options = 0) = 0;
virtual void remove_torrent_impl(boost::shared_ptr<torrent> tptr, int options) = 0;
- // ip and port filter
- virtual ip_filter& get_ip_filter() = 0;
+ // port filter
virtual port_filter const& get_port_filter() const = 0;
+ virtual void ban_ip(address addr) = 0;
virtual boost::int64_t session_time() const = 0;
@@ -2915,9 +3510,9 @@ to its own class, not part of the session../include/libtorrent/aux_/ses
virtual boost::shared_ptr<torrent> delay_load_torrent(sha1_hash const& info_hash
, peer_connection* pc) = 0;
virtual void insert_torrent(sha1_hash const& ih, boost::shared_ptr<torrent> const& t
- | ||
relevance 2 | ../include/libtorrent/aux_/session_interface.hpp:218 | factor out the thread pool for socket jobs into a separate class used to (potentially) issue socket write calls onto multiple threads |
factor out the thread pool for socket jobs into a separate
+ | ||
relevance 2 | ../include/libtorrent/aux_/session_interface.hpp:217 | factor out the thread pool for socket jobs into a separate class used to (potentially) issue socket write calls onto multiple threads |
factor out the thread pool for socket jobs into a separate
class
-used to (potentially) issue socket write calls onto multiple threads../include/libtorrent/aux_/session_interface.hpp:218 virtual int num_torrents() const = 0;
+used to (potentially) issue socket write calls onto multiple threads../include/libtorrent/aux_/session_interface.hpp:217 virtual int num_torrents() const = 0;
virtual peer_id const& get_peer_id() const = 0;
@@ -2958,26 +3553,26 @@ used to (potentially) issue socket write calls onto multiple threads../
std::string const& collection) const = 0;
#endif
- | ||
relevance 1 | ../src/disk_io_thread.cpp:206 | it would be nice to have the number of threads be set dynamically |
it would be nice to have the number of threads be set dynamically../src/disk_io_thread.cpp:206 std::pair<block_cache::iterator, block_cache::iterator> pieces
- = m_disk_cache.all_pieces();
- TORRENT_ASSERT(pieces.first == pieces.second);
-#endif
-
-#ifdef TORRENT_DISK_STATS
- if (g_access_log)
- {
- FILE* f = g_access_log;
- g_access_log = NULL;
- fclose(f);
- }
-#endif
-
+ | ||
relevance 1 | ../src/disk_io_thread.cpp:219 | it would be nice to have the number of threads be set dynamically |
it would be nice to have the number of threads be set dynamically../src/disk_io_thread.cpp:219
TORRENT_ASSERT(m_magic == 0x1337);
#if TORRENT_USE_ASSERTS
m_magic = 0xdead;
#endif
}
+ void disk_io_thread::abort(bool wait)
+ {
+ m_abort = true;
+ if (m_num_threads == 0)
+ {
+ abort_jobs();
+ }
+ else
+ {
+ set_num_threads(0, wait);
+ }
+ }
+
void disk_io_thread::set_num_threads(int i, bool wait)
{
TORRENT_ASSERT(m_magic == 0x1337);
@@ -2990,26 +3585,26 @@ used to (potentially) issue socket write calls onto multiple threads../
int thread_id = (++m_num_threads) - 1;
thread_type_t type = generic_thread;
+ // this keeps the io_service::run() call blocked from returning.
+ // When shutting down, it's possible that the event queue is drained
+ // before the disk_io_thread has posted its last callback. When this
+ // happens, the io_service will have a pending callback from the
+ // disk_io_thread, but the event loop is not running. this means
+ // that the event is destructed after the disk_io_thread. If the
+ // event refers to a disk buffer it will try to free it, but the
+ // buffer pool won't exist anymore, and crash. This prevents that.
+ boost::shared_ptr<io_service::work> work =
+ boost::make_shared<io_service::work>(boost::ref(m_ios));
+
// the magic number 3 is also used in add_job()
// every 4:th thread is a hasher thread
if ((thread_id & 0x3) == 3) type = hasher_thread;
m_threads.push_back(boost::shared_ptr<thread>(
- new thread(boost::bind(&disk_io_thread::thread_fun, this, thread_id, type))));
+ new thread(boost::bind(&disk_io_thread::thread_fun, this
+ , thread_id, type, work))));
}
}
- else
- {
- while (m_num_threads > i) { --m_num_threads; }
- mutex::scoped_lock l(m_job_mutex);
- m_job_cond.notify_all();
- m_hash_job_cond.notify_all();
- l.unlock();
- if (wait) for (int i = m_num_threads; i < m_threads.size(); ++i) m_threads[i]->join();
- // this will detach the threads
- m_threads.resize(m_num_threads);
- }
- }
- | ||
relevance 1 | ../src/http_seed_connection.cpp:123 | in chunked encoding mode, this assert won't hold. the chunk headers should be subtracted from the receive_buffer_size |
in chunked encoding mode, this assert won't hold.
+ | ||
relevance 1 | ../src/http_seed_connection.cpp:123 | in chunked encoding mode, this assert won't hold. the chunk headers should be subtracted from the receive_buffer_size |
in chunked encoding mode, this assert won't hold.
the chunk headers should be subtracted from the receive_buffer_size../src/http_seed_connection.cpp:123 boost::optional<piece_block_progress>
http_seed_connection::downloading_piece_progress() const
{
@@ -3061,8 +3656,8 @@ the chunk headers should be subtracted from the receive_buffer_size../s
std::string request;
request.reserve(400);
- | ||
relevance 1 | ../src/session_impl.cpp:5223 | report the proper address of the router as the source IP of this understanding of our external address, instead of the empty address |
report the proper address of the router as the source IP of
-this understanding of our external address, instead of the empty address../src/session_impl.cpp:5223 void session_impl::on_port_mapping(int mapping, address const& ip, int port
+ | ||
relevance 1 | ../src/session_impl.cpp:5225 | report the proper address of the router as the source IP of this understanding of our external address, instead of the empty address |
report the proper address of the router as the source IP of
+this understanding of our external address, instead of the empty address../src/session_impl.cpp:5225 void session_impl::on_port_mapping(int mapping, address const& ip, int port
, error_code const& ec, int map_transport)
{
TORRENT_ASSERT(is_single_thread());
@@ -3113,9 +3708,9 @@ this understanding of our external address, instead of the empty address | ||
relevance 1 | ../src/session_impl.cpp:6506 | we only need to do this if our global IPv4 address has changed since the DHT (currently) only supports IPv4. Since restarting the DHT is kind of expensive, it would be nice to not do it unnecessarily |
we only need to do this if our global IPv4 address has changed
+ | ||
relevance 1 | ../src/session_impl.cpp:6529 | we only need to do this if our global IPv4 address has changed since the DHT (currently) only supports IPv4. Since restarting the DHT is kind of expensive, it would be nice to not do it unnecessarily |
we only need to do this if our global IPv4 address has changed
since the DHT (currently) only supports IPv4. Since restarting the DHT
-is kind of expensive, it would be nice to not do it unnecessarily../src/session_impl.cpp:6506#endif
+is kind of expensive, it would be nice to not do it unnecessarily../src/session_impl.cpp:6529#endif
if (!m_external_ip.cast_vote(ip, source_type, source)) return;
@@ -3166,16 +3761,16 @@ is kind of expensive, it would be nice to not do it unnecessarily../src
, boost::function<void(char*)> const& handler)
{
return m_disk_thread.async_allocate_disk_buffer(category, handler);
- | ||
relevance 1 | ../src/torrent.cpp:1168 | make this depend on the error and on the filesystem the files are being downloaded to. If the error is no_space_left_on_device and the filesystem doesn't support sparse files, only zero the priorities of the pieces that are at the tails of all files, leaving everything up to the highest written piece in each file |
make this depend on the error and on the filesystem the
+ | ||
relevance 1 | ../src/torrent.cpp:1224 | make this depend on the error and on the filesystem the files are being downloaded to. If the error is no_space_left_on_device and the filesystem doesn't support sparse files, only zero the priorities of the pieces that are at the tails of all files, leaving everything up to the highest written piece in each file |
make this depend on the error and on the filesystem the
files are being downloaded to. If the error is no_space_left_on_device
and the filesystem doesn't support sparse files, only zero the priorities
of the pieces that are at the tails of all files, leaving everything
-up to the highest written piece in each file../src/torrent.cpp:1168 alerts().emplace_alert<file_error_alert>(j->error.ec
+up to the highest written piece in each file../src/torrent.cpp:1224
+ // notify the user of the error
+ if (alerts().should_post<file_error_alert>())
+ alerts().emplace_alert<file_error_alert>(j->error.ec
, resolve_filename(j->error.file), j->error.operation_str(), get_handle());
- // put the torrent in an error-state
- set_error(j->error.ec, j->error.file);
-
// if a write operation failed, and future writes are likely to
// fail, while reads may succeed, just set the torrent to upload mode
// if we make an incorrect assumption here, it's not the end of the
@@ -3194,6 +3789,9 @@ up to the highest written piece in each file../src/torrent.cpp:1168 return;
}
+ // put the torrent in an error-state
+ set_error(j->error.ec, j->error.file);
+
// if the error appears to be more serious than a full disk, just pause the torrent
pause();
}
@@ -3218,11 +3816,8 @@ up to the highest written piece in each file../src/torrent.cpp:1168 | ||
relevance 1 | ../src/torrent.cpp:6956 | save the send_stats state instead of throwing them away it may pose an issue when downgrading though |
save the send_stats state instead of throwing them away
-it may pose an issue when downgrading though../src/torrent.cpp:6956 for (int k = 0; k < bits; ++k)
+ | ||
relevance 1 | ../src/torrent.cpp:7026 | save the send_stats state instead of throwing them away it may pose an issue when downgrading though |
save the send_stats state instead of throwing them away
+it may pose an issue when downgrading though../src/torrent.cpp:7026 for (int k = 0; k < bits; ++k)
v |= (info[j*8+k].state == piece_picker::block_info::state_finished)
? (1 << k) : 0;
bitmask.append(1, v);
@@ -3273,9 +3868,10 @@ it may pose an issue when downgrading though../src/torrent.cpp:6956 | ||
relevance 1 | ../src/torrent.cpp:8057 | should disconnect all peers that have the pieces we have not just seeds. It would be pretty expensive to check all pieces for all peers though |
should disconnect all peers that have the pieces we have
+ | ||
relevance 1 | ../src/torrent.cpp:8231 | should disconnect all peers that have the pieces we have not just seeds. It would be pretty expensive to check all pieces for all peers though |
should disconnect all peers that have the pieces we have
not just seeds. It would be pretty expensive to check all pieces
-for all peers though../src/torrent.cpp:8057 set_state(torrent_status::finished);
+for all peers though../src/torrent.cpp:8231
+ set_state(torrent_status::finished);
set_queue_position(-1);
m_became_finished = m_ses.session_time();
@@ -3286,7 +3882,6 @@ for all peers though../src/torrent.cpp:8057 | ||
relevance 1 | ../include/libtorrent/ip_voter.hpp:124 | instead, have one instance per possible subnet, global IPv4, global IPv6, loopback, 192.168.x.x, 10.x.x.x, etc. |
instead, have one instance per possible subnet, global IPv4, global IPv6, loopback, 192.168.x.x, 10.x.x.x, etc.../include/libtorrent/ip_voter.hpp:124 // away all the votes and started from scratch, in case
+ | ||
relevance 1 | ../include/libtorrent/ip_voter.hpp:124 | instead, have one instance per possible subnet, global IPv4, global IPv6, loopback, 192.168.x.x, 10.x.x.x, etc. |
instead, have one instance per possible subnet, global IPv4, global IPv6, loopback, 192.168.x.x, 10.x.x.x, etc.../include/libtorrent/ip_voter.hpp:124 // away all the votes and started from scratch, in case
// our IP has changed
time_point m_last_rotate;
};
@@ -3353,7 +3948,7 @@ for all peers though../src/torrent.cpp:8057relevance 1 | ../include/libtorrent/web_peer_connection.hpp:120 | if we make this be a disk_buffer_holder instead we would save a copy sometimes use allocate_disk_receive_buffer and release_disk_receive_buffer |
|
if we make this be a disk_buffer_holder instead
+ | ||
relevance 1 | ../include/libtorrent/web_peer_connection.hpp:120 | if we make this be a disk_buffer_holder instead we would save a copy sometimes use allocate_disk_receive_buffer and release_disk_receive_buffer |
if we make this be a disk_buffer_holder instead
we would save a copy sometimes
use allocate_disk_receive_buffer and release_disk_receive_buffer../include/libtorrent/web_peer_connection.hpp:120
// returns the block currently being
@@ -3406,7 +4001,7 @@ use allocate_disk_receive_buffer and release_disk_receive_buffer../incl
};
}
- | ||
relevance 0 | ../test/test_block_cache.cpp:469 | test try_evict_blocks |
test try_evict_blocks../test/test_block_cache.cpp:469 | ||
relevance 0 | ../test/test_block_cache.cpp:470 | test evicting volatile pieces, to see them be removed |
test evicting volatile pieces, to see them be removed../test/test_block_cache.cpp:470 | ||
relevance 0 | ../test/test_block_cache.cpp:471 | test evicting dirty pieces |
test evicting dirty pieces../test/test_block_cache.cpp:471 | ||
relevance 0 | ../test/test_block_cache.cpp:472 | test free_piece |
test free_piece../test/test_block_cache.cpp:472 | ||
relevance 0 | ../test/test_block_cache.cpp:473 | test abort_dirty |
test abort_dirty../test/test_block_cache.cpp:473 | ||
relevance 0 | ../test/test_block_cache.cpp:474 | test unaligned reads |
test unaligned reads../test/test_block_cache.cpp:474 // it's supposed to be a cache hit
+ | ||
relevance 0 | ../test/test_block_cache.cpp:469 | test try_evict_blocks |
test try_evict_blocks../test/test_block_cache.cpp:469 | ||
relevance 0 | ../test/test_block_cache.cpp:470 | test evicting volatile pieces, to see them be removed |
test evicting volatile pieces, to see them be removed../test/test_block_cache.cpp:470 | ||
relevance 0 | ../test/test_block_cache.cpp:471 | test evicting dirty pieces |
test evicting dirty pieces../test/test_block_cache.cpp:471 | ||
relevance 0 | ../test/test_block_cache.cpp:472 | test free_piece |
test free_piece../test/test_block_cache.cpp:472 | ||
relevance 0 | ../test/test_block_cache.cpp:473 | test abort_dirty |
test abort_dirty../test/test_block_cache.cpp:473 | ||
relevance 0 | ../test/test_block_cache.cpp:474 | test unaligned reads |
test unaligned reads../test/test_block_cache.cpp:474 // it's supposed to be a cache hit
TEST_CHECK(ret >= 0);
// return the reference to the buffer we just read
RETURN_BUFFER;
@@ -3415,7 +4010,7 @@ use allocate_disk_receive_buffer and release_disk_receive_buffer../incl
bc.clear(jobs);
}
-int test_main()
+TORRENT_TEST(block_cache)
{
test_write();
test_flush();
@@ -3426,12 +4021,31 @@ int test_main()
test_iovec();
test_unaligned_read();
- return 0;
- }
+}
+
+ | ||
relevance 0 | ../test/test_bloom_filter.cpp:130 | test size() |
test size()../test/test_bloom_filter.cpp:130 | ||
relevance 0 | ../test/test_bloom_filter.cpp:131 | test clear() |
test clear()../test/test_bloom_filter.cpp:131 TEST_EQUAL(memcmp(bits_out.c_str(), bits, 4), 0);
- | ||
relevance 0 | ../test/test_dht.cpp:439 | test obfuscated_get_peers |
test obfuscated_get_peers../test/test_dht.cpp:439 return false;
+ sha1_hash k( "\x01\x00\x02\x00 ");
+ TEST_CHECK(!filter.find(k));
+ filter.set(k);
+ TEST_CHECK(filter.find(k));
+
+ boost::uint8_t compare[4] = { 0x16, 0xff, 0x55, 0xaa};
+
+ bits_out = filter.to_string();
+ TEST_EQUAL(memcmp(compare, bits_out.c_str(), 4), 0);
}
+TORRENT_TEST(bloom_filter)
+{
+ test_set_and_get();
+ test_set_bits();
+ test_count_zeroes();
+ test_to_from_string();
+
+}
+
+ | ||
relevance 0 | ../test/test_dht.cpp:441 | test obfuscated_get_peers |
test obfuscated_get_peers../test/test_dht.cpp:441
struct obs : dht::dht_observer
{
virtual void set_external_address(address const& addr
@@ -3446,10 +4060,12 @@ struct obs : dht::dht_observer
virtual void outgoing_get_peers(sha1_hash const& target
, sha1_hash const& sent_target, udp::endpoint const& ep) TORRENT_OVERRIDE {}
virtual void announce(sha1_hash const& ih, address const& addr, int port) TORRENT_OVERRIDE {}
- virtual void log(dht_logger::dht_module_t l, char const* fmt, ...) TORRENT_OVERRIDE {}
+ virtual void log(dht_logger::module_t l, char const* fmt, ...) TORRENT_OVERRIDE {}
+ virtual void log_packet(message_direction_t dir, char const* pkt, int len
+ , udp::endpoint node) TORRENT_OVERRIDE {}
};
-int test_main()
+ TORRENT_TEST(dht)
{
dht_settings sett;
sett.max_torrents = 4;
@@ -3480,60 +4096,72 @@ struct obs : dht::dht_observer
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
ret = dht::verify_message(response, pong_desc, parsed, 4, error_string
, sizeof(error_string));
- | ||
relevance 0 | ../test/test_file_storage.cpp:210 | test file_storage::optimize too |
test file_storage::optimize too../test/test_file_storage.cpp:210 | ||
relevance 0 | ../test/test_file_storage.cpp:211 | test map_block |
test map_block../test/test_file_storage.cpp:211 | ||
relevance 0 | ../test/test_file_storage.cpp:212 | test piece_size(int piece) |
test piece_size(int piece)../test/test_file_storage.cpp:212 | ||
relevance 0 | ../test/test_file_storage.cpp:213 | test file_index_at_offset |
test file_index_at_offset../test/test_file_storage.cpp:213 | ||
relevance 0 | ../test/test_file_storage.cpp:214 | test file attributes |
test file attributes../test/test_file_storage.cpp:214 | ||
relevance 0 | ../test/test_file_storage.cpp:215 | test symlinks |
test symlinks../test/test_file_storage.cpp:215 | ||
relevance 0 | ../test/test_file_storage.cpp:216 | test pad_files |
test pad_files../test/test_file_storage.cpp:216 | ||
relevance 0 | ../test/test_file_storage.cpp:217 | test reorder_file (make sure internal_file_entry::swap() is used) |
test reorder_file (make sure internal_file_entry::swap() is used)../test/test_file_storage.cpp:217 TEST_EQUAL(rq.piece, 7);
- TEST_EQUAL(rq.start, 298);
- TEST_EQUAL(rq.length, 841);
- }
+ | ||
relevance 0 | ../test/test_fast_extension.cpp:801 | test sending invalid requests (out of bound piece index, offsets and sizes) |
test sending invalid requests (out of bound piece index, offsets and
+sizes)../test/test_fast_extension.cpp:801
+ entry ut_metadata_msg = read_ut_metadata_msg(s, recv_buffer
+ , sizeof(recv_buffer));
- {
- // test file_path_hash and path_hash. Make sure we can detect a path
- // whose name collides with
- file_storage fs;
- fs.set_piece_length(512);
- fs.add_file(combine_path("temp_storage", "Foo"), 17);
- fs.add_file(combine_path("temp_storage", "foo"), 612);
+ // the first response should be "dont-have"
+ TEST_EQUAL(ut_metadata_msg["msg_type"].integer(), 2);
+ TEST_EQUAL(ut_metadata_msg["piece"].integer(), 1);
- fprintf(stderr, "path: %s\n", fs.file_path(0).c_str());
- fprintf(stderr, "file: %s\n", fs.file_path(1).c_str());
- boost::uint32_t file_hash0 = fs.file_path_hash(0, "a");
- boost::uint32_t file_hash1 = fs.file_path_hash(1, "a");
- TEST_EQUAL(file_hash0, file_hash1);
- }
+ ut_metadata_msg = read_ut_metadata_msg(s, recv_buffer
+ , sizeof(recv_buffer));
-
- return 0;
+ // the second response should be the payload
+ TEST_EQUAL(ut_metadata_msg["msg_type"].integer(), 1);
+ TEST_EQUAL(ut_metadata_msg["piece"].integer(), 0);
+
+ print_session_log(*ses);
}
- | ||
relevance 0 | ../test/test_metadata_extension.cpp:93 | it would be nice to test reversing which session is making the connection as well |
it would be nice to test reversing
-which session is making the connection as well../test/test_metadata_extension.cpp:93 , int timeout)
+#endif // TORRENT_DISABLE_EXTENSIONS
+
+
+ | ||
relevance 0 | ../test/test_file_progress.cpp:109 | test the update function too |
test the update function too../test/test_file_progress.cpp:109 for (int idx = 0; idx < fs.num_pieces(); ++idx)
+ {
+ piece_picker picker;
+ picker.init(4, fs.total_size() % 4, fs.num_pieces());
+ picker.we_have(idx);
+
+ std::vector<boost::int64_t> vec;
+ aux::file_progress fp;
+
+ fp.init(picker, fs);
+ fp.export_progress(vec);
+
+ boost::uint64_t sum = 0;
+ for (int i = 0; i < vec.size(); ++i)
+ sum += vec[i];
+
+ TEST_EQUAL(int(sum), fs.piece_size(idx));
+ }
+}
+
+
+ | ||
relevance 0 | ../test/test_file_storage.cpp:214 | test file_storage::optimize |
test file_storage::optimize../test/test_file_storage.cpp:214 | ||
relevance 0 | ../test/test_file_storage.cpp:215 | test map_block |
test map_block../test/test_file_storage.cpp:215 | ||
relevance 0 | ../test/test_file_storage.cpp:216 | test piece_size(int piece) |
test piece_size(int piece)../test/test_file_storage.cpp:216 | ||
relevance 0 | ../test/test_file_storage.cpp:217 | test file_index_at_offset |
test file_index_at_offset../test/test_file_storage.cpp:217 | ||
relevance 0 | ../test/test_file_storage.cpp:218 | test file attributes |
test file attributes../test/test_file_storage.cpp:218 | ||
relevance 0 | ../test/test_file_storage.cpp:219 | test symlinks |
test symlinks../test/test_file_storage.cpp:219 | ||
relevance 0 | ../test/test_file_storage.cpp:220 | test pad_files |
test pad_files../test/test_file_storage.cpp:220 | ||
relevance 0 | ../test/test_file_storage.cpp:221 | test reorder_file (make sure internal_file_entry::swap() is used) |
test reorder_file (make sure internal_file_entry::swap() is used)../test/test_file_storage.cpp:221 TEST_EQUAL(rq.start, 298);
+ TEST_EQUAL(rq.length, 841);
+}
+
+TORRENT_TEST(file_path_hash)
{
- using namespace libtorrent;
- namespace lt = libtorrent;
+ // test file_path_hash and path_hash. Make sure we can detect a path
+ // whose name collides with
+ file_storage fs;
+ fs.set_piece_length(512);
+ fs.add_file(combine_path("temp_storage", "Foo"), 17);
+ fs.add_file(combine_path("temp_storage", "foo"), 612);
- fprintf(stderr, "\n==== test transfer: timeout=%d %s%s%s%s%s%s ====\n\n"
- , timeout
- , (flags & clear_files) ? "clear-files " : ""
- , (flags & disconnect) ? "disconnect " : ""
- , (flags & full_encryption) ? "encryption " : ""
- , (flags & reverse) ? "reverse " : ""
- , (flags & utp) ? "utp " : ""
- , (flags & upload_only) ? "upload_only " : "");
+ fprintf(stderr, "path: %s\n", fs.file_path(0).c_str());
+ fprintf(stderr, "file: %s\n", fs.file_path(1).c_str());
+ boost::uint32_t file_hash0 = fs.file_path_hash(0, "a");
+ boost::uint32_t file_hash1 = fs.file_path_hash(1, "a");
+ TEST_EQUAL(file_hash0, file_hash1);
+}
- // these are declared before the session objects
- // so that they are destructed last. This enables
- // the sessions to destruct in parallel
- session_proxy p1;
- session_proxy p2;
-
- lt::session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48100, 49000), "0.0.0.0", 0);
- lt::session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49100, 50000), "0.0.0.0", 0);
- ses1.add_extension(constructor);
- ses2.add_extension(constructor);
- torrent_handle tor1;
- torrent_handle tor2;
-
- settings_pack pack;
- pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_forced);
+
+ | ||
relevance 0 | ../test/test_metadata_extension.cpp:114 | it would be nice to test reversing which session is making the connection as well |
it would be nice to test reversing
+which session is making the connection as well../test/test_metadata_extension.cpp:114 pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_forced);
pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_forced);
pack.set_bool(settings_pack::prefer_rc4, flags & full_encryption);
@@ -3553,85 +4181,59 @@ which session is making the connection as well../test/test_metadata_ext
pack.set_bool(settings_pack::enable_outgoing_tcp, true);
}
- ses1.apply_settings(pack);
- ses2.apply_settings(pack);
+ pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48100");
+ lt::session ses1(pack);
+ pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:49100");
+ lt::session ses2(pack);
+ ses1.add_extension(constructor);
+ ses2.add_extension(constructor);
+ torrent_handle tor1;
+ torrent_handle tor2;
- | ||
relevance 0 | ../test/test_peer_list.cpp:921 | test erasing peers |
test erasing peers../test/test_peer_list.cpp:921 | ||
relevance 0 | ../test/test_peer_list.cpp:922 | test update_peer_port with allow_multiple_connections_per_ip and without |
test update_peer_port with allow_multiple_connections_per_ip and without../test/test_peer_list.cpp:922 | ||
relevance 0 | ../test/test_peer_list.cpp:923 | test add i2p peers |
test add i2p peers../test/test_peer_list.cpp:923 | ||
relevance 0 | ../test/test_peer_list.cpp:924 | test allow_i2p_mixed |
test allow_i2p_mixed../test/test_peer_list.cpp:924 | ||
relevance 0 | ../test/test_peer_list.cpp:925 | test insert_peer failing with all error conditions |
test insert_peer failing with all error conditions../test/test_peer_list.cpp:925 | ||
relevance 0 | ../test/test_peer_list.cpp:926 | test IPv6 |
test IPv6../test/test_peer_list.cpp:926 | ||
relevance 0 | ../test/test_peer_list.cpp:927 | test connect_to_peer() failing |
test connect_to_peer() failing../test/test_peer_list.cpp:927 | ||
relevance 0 | ../test/test_peer_list.cpp:928 | test connection_closed |
test connection_closed../test/test_peer_list.cpp:928 | ||
relevance 0 | ../test/test_peer_list.cpp:929 | connect candidates recalculation when incrementing failcount |
connect candidates recalculation when incrementing failcount../test/test_peer_list.cpp:929 torrent_peer* peer4 = add_peer(p, st, ep("10.0.0.4", 8080));
- TEST_CHECK(peer4);
- TEST_EQUAL(p.num_peers(), 4);
- torrent_peer* peer5 = add_peer(p, st, ep("10.0.0.5", 8080));
- TEST_CHECK(peer5);
- TEST_EQUAL(p.num_peers(), 5);
- torrent_peer* peer6 = p.add_peer(ep("10.0.0.6", 8080), 0, 0, &st);
- TEST_CHECK(peer6 == NULL);
- TEST_EQUAL(p.num_peers(), 5);
+ lt::session* downloader = &ses2;
+ lt::session* seed = &ses1;
- // one of the connection should have been removed
- TEST_EQUAL(has_peer(p, ep("10.0.0.1", 8080))
- + has_peer(p, ep("10.0.0.2", 8080))
- + has_peer(p, ep("10.0.0.3", 8080))
- + has_peer(p, ep("10.0.0.4", 8080))
- + has_peer(p, ep("10.0.0.5", 8080))
- + has_peer(p, ep("10.0.0.6", 8080))
- , 5);
+ boost::tie(tor1, tor2, ignore) = setup_transfer(seed, downloader, NULL
+ , flags & clear_files, true, false, "_meta");
+
+ if (flags & upload_only)
+ {
+ tor2.set_upload_mode(true);
}
-
- return 0;
+ if (flags & reverse)
+ {
+ error_code ec;
+ int port = seed->listen_port();
+ fprintf(stderr, "%s: downloader: connecting peer port: %d\n"
+ , time_now_string(), port);
+ tor2.connect_peer(tcp::endpoint(address::from_string("127.0.0.1", ec)
+ , port));
+ }
+ else
+ {
+ | ||
relevance 0 | ../test/test_peer_list.cpp:944 | test erasing peers |
test erasing peers../test/test_peer_list.cpp:944 | ||
relevance 0 | ../test/test_peer_list.cpp:945 | test update_peer_port with allow_multiple_connections_per_ip and without |
test update_peer_port with allow_multiple_connections_per_ip and without../test/test_peer_list.cpp:945 | ||
relevance 0 | ../test/test_peer_list.cpp:946 | test add i2p peers |
test add i2p peers../test/test_peer_list.cpp:946 | ||
relevance 0 | ../test/test_peer_list.cpp:947 | test allow_i2p_mixed |
test allow_i2p_mixed../test/test_peer_list.cpp:947 | ||
relevance 0 | ../test/test_peer_list.cpp:948 | test insert_peer failing with all error conditions |
test insert_peer failing with all error conditions../test/test_peer_list.cpp:948 | ||
relevance 0 | ../test/test_peer_list.cpp:949 | test IPv6 |
test IPv6../test/test_peer_list.cpp:949 | ||
relevance 0 | ../test/test_peer_list.cpp:950 | test connect_to_peer() failing |
test connect_to_peer() failing../test/test_peer_list.cpp:950 | ||
relevance 0 | ../test/test_peer_list.cpp:951 | test connection_closed |
test connection_closed../test/test_peer_list.cpp:951 | ||
relevance 0 | ../test/test_peer_list.cpp:952 | connect candidates recalculation when incrementing failcount |
connect candidates recalculation when incrementing failcount../test/test_peer_list.cpp:952 torrent_peer* peer4 = add_peer(p, st, ep("10.0.0.4", 8080));
+ TEST_CHECK(peer4);
+ TEST_EQUAL(p.num_peers(), 4);
+ torrent_peer* peer5 = add_peer(p, st, ep("10.0.0.5", 8080));
+ TEST_CHECK(peer5);
+ TEST_EQUAL(p.num_peers(), 5);
+ torrent_peer* peer6 = p.add_peer(ep("10.0.0.6", 8080), 0, 0, &st);
+ TEST_CHECK(peer6 == NULL);
+ TEST_EQUAL(p.num_peers(), 5);
+
+ // one of the connection should have been removed
+ TEST_EQUAL(has_peer(p, ep("10.0.0.1", 8080))
+ + has_peer(p, ep("10.0.0.2", 8080))
+ + has_peer(p, ep("10.0.0.3", 8080))
+ + has_peer(p, ep("10.0.0.4", 8080))
+ + has_peer(p, ep("10.0.0.5", 8080))
+ + has_peer(p, ep("10.0.0.6", 8080))
+ , 5);
}
- | ||
relevance 0 | ../test/test_primitives.cpp:212 | test the case where we have > 120 samples (and have the base delay actually be updated) |
test the case where we have > 120 samples (and have the base delay actually be updated)../test/test_primitives.cpp:212 | ||
relevance 0 | ../test/test_primitives.cpp:213 | test the case where a sample is lower than the history entry but not lower than the base |
test the case where a sample is lower than the history entry but not lower than the base../test/test_primitives.cpp:213 TEST_CHECK(!filter.find(k3));
- TEST_CHECK(filter.find(k4));
-
- // test timestamp_history
- {
- timestamp_history h;
- TEST_EQUAL(h.add_sample(0x32, false), 0);
- TEST_EQUAL(h.base(), 0x32);
- TEST_EQUAL(h.add_sample(0x33, false), 0x1);
- TEST_EQUAL(h.base(), 0x32);
- TEST_EQUAL(h.add_sample(0x3433, false), 0x3401);
- TEST_EQUAL(h.base(), 0x32);
- TEST_EQUAL(h.add_sample(0x30, false), 0);
- TEST_EQUAL(h.base(), 0x30);
-
- // test that wrapping of the timestamp is properly handled
- h.add_sample(0xfffffff3, false);
- TEST_EQUAL(h.base(), 0xfffffff3);
-
-
- }
-
- // test error codes
- TEST_CHECK(error_code(errors::http_error).message() == "HTTP error");
- TEST_CHECK(error_code(errors::missing_file_sizes).message() == "missing or invalid 'file sizes' entry");
- TEST_CHECK(error_code(errors::unsupported_protocol_version).message() == "unsupported protocol version");
- TEST_CHECK(error_code(errors::no_i2p_router).message() == "no i2p router is set up");
- TEST_CHECK(error_code(errors::http_parse_error).message() == "Invalid HTTP header");
- TEST_CHECK(error_code(errors::error_code_max).message() == "Unknown error");
-
- TEST_CHECK(error_code(errors::unauthorized, get_http_category()).message() == "401 Unauthorized");
- TEST_CHECK(error_code(errors::service_unavailable, get_http_category()).message() == "503 Service Unavailable");
-
- // test snprintf
-
- char msg[10];
- snprintf(msg, sizeof(msg), "too %s format string", "long");
- TEST_CHECK(strcmp(msg, "too long ") == 0);
-
- std::string path;
- sanitize_append_path_element(path, "a...", 4);
- TEST_EQUAL(path, "a");
-
- path.clear();
- sanitize_append_path_element(path, "a ", 4);
- TEST_EQUAL(path, "a");
-
- path.clear();
- sanitize_append_path_element(path, "a...b", 5);
- TEST_EQUAL(path, "a...b");
-
- | ||
relevance 0 | ../test/test_resolve_links.cpp:80 | test files with different piece size (negative test) |
test files with different piece size (negative test)../test/test_resolve_links.cpp:80 { "test2", "test1_pad_files", 0},
+
+ | ||
relevance 0 | ../test/test_resolve_links.cpp:80 | test files with different piece size (negative test) |
test files with different piece size (negative test)../test/test_resolve_links.cpp:80 { "test2", "test1_pad_files", 0},
{ "test3", "test1_pad_files", 0},
{ "test2", "test1_single", 0},
@@ -3653,7 +4255,7 @@ which session is making the connection as well../test/test_metadata_ext
};
- | ||
relevance 0 | ../test/test_resolve_links.cpp:83 | it would be nice to test resolving of more than just 2 files as well. like 3 single file torrents merged into one, resolving all 3 files. |
it would be nice to test resolving of more than just 2 files as well.
+ | ||
relevance 0 | ../test/test_resolve_links.cpp:83 | it would be nice to test resolving of more than just 2 files as well. like 3 single file torrents merged into one, resolving all 3 files. |
it would be nice to test resolving of more than just 2 files as well.
like 3 single file torrents merged into one, resolving all 3 files.../test/test_resolve_links.cpp:83 { "test2", "test1_single", 0},
// these are all padded. The first small file will accidentally also
@@ -3675,7 +4277,7 @@ like 3 single file torrents merged into one, resolving all 3 files.../t
};
- int test_main()
+TORRENT_TEST(resolve_links)
{
#ifndef TORRENT_DISABLE_MUTABLE_TORRENTS
@@ -3705,11 +4307,106 @@ like 3 single file torrents merged into one, resolving all 3 files.../t
// some debug output in case the test fails
if (num_matches > e.expected_matches)
- | ||
relevance 0 | ../test/test_resume.cpp:340 | test all other resume flags here too. This would require returning more than just the torrent_status from test_resume_flags. Also http seeds and trackers for instance |
test all other resume flags here too. This would require returning
+ | ||
relevance 0 | ../test/test_resume.cpp:230 | test what happens when loading a resume file with both piece priorities and file priorities (file prio should take presedence) |
test what happens when loading a resume file with both piece priorities
+and file priorities (file prio should take presedence)../test/test_resume.cpp:230 fprintf(stderr, "%s\n", ra->resume_data->to_string().c_str());
+ entry::string_type prios = (*ra->resume_data)["piece_priority"].string();
+ TEST_EQUAL(prios.size(), ti->num_pieces());
+ TEST_EQUAL(prios[0], '\0');
+ TEST_EQUAL(prios[1], '\x04');
+ TEST_EQUAL(prios[ti->num_pieces()-1], '\0');
+
+ bencode(std::back_inserter(p.resume_data), *ra->resume_data);
+ }
+
+ ses.remove_torrent(h);
+
+ // now, make sure the piece priorities are loaded correctly
+ h = ses.add_torrent(p);
+
+ TEST_EQUAL(h.piece_priority(0), 0);
+ TEST_EQUAL(h.piece_priority(1), 4);
+ TEST_EQUAL(h.piece_priority(ti->num_pieces()-1), 0);
+}
+
+
+ | ||
relevance 0 | ../test/test_resume.cpp:233 | make sure a resume file only ever contain file priorities OR piece priorities. Never both. |
make sure a resume file only ever contain file priorities OR piece
+priorities. Never both.../test/test_resume.cpp:233 entry::string_type prios = (*ra->resume_data)["piece_priority"].string();
+ TEST_EQUAL(prios.size(), ti->num_pieces());
+ TEST_EQUAL(prios[0], '\0');
+ TEST_EQUAL(prios[1], '\x04');
+ TEST_EQUAL(prios[ti->num_pieces()-1], '\0');
+
+ bencode(std::back_inserter(p.resume_data), *ra->resume_data);
+ }
+
+ ses.remove_torrent(h);
+
+ // now, make sure the piece priorities are loaded correctly
+ h = ses.add_torrent(p);
+
+ TEST_EQUAL(h.piece_priority(0), 0);
+ TEST_EQUAL(h.piece_priority(1), 4);
+ TEST_EQUAL(h.piece_priority(ti->num_pieces()-1), 0);
+}
+
+
+
+ | ||
relevance 0 | ../test/test_resume.cpp:236 | generally save |
generally save../test/test_resume.cpp:236 TEST_EQUAL(prios.size(), ti->num_pieces());
+ TEST_EQUAL(prios[0], '\0');
+ TEST_EQUAL(prios[1], '\x04');
+ TEST_EQUAL(prios[ti->num_pieces()-1], '\0');
+
+ bencode(std::back_inserter(p.resume_data), *ra->resume_data);
+ }
+
+ ses.remove_torrent(h);
+
+ // now, make sure the piece priorities are loaded correctly
+ h = ses.add_torrent(p);
+
+ TEST_EQUAL(h.piece_priority(0), 0);
+ TEST_EQUAL(h.piece_priority(1), 4);
+ TEST_EQUAL(h.piece_priority(ti->num_pieces()-1), 0);
+}
+
+
+
+
+ TORRENT_TEST(file_priorities_default)
+{
+ libtorrent::session ses;
+ std::vector<int> file_priorities = test_resume_flags(ses, 0, "", "").file_priorities();
+
+ TEST_EQUAL(file_priorities.size(), 3);
+ TEST_EQUAL(file_priorities[0], 4);
+ TEST_EQUAL(file_priorities[1], 4);
+ TEST_EQUAL(file_priorities[2], 4);
+}
+
+TORRENT_TEST(file_priorities_resume_seed_mode)
+{
+ // in share mode file priorities should always be 0
+ libtorrent::session ses;
+ std::vector<int> file_priorities = test_resume_flags(ses,
+ add_torrent_params::flag_share_mode, "", "123").file_priorities();
+
+ TEST_EQUAL(file_priorities.size(), 3);
+ TEST_EQUAL(file_priorities[0], 0);
+ TEST_EQUAL(file_priorities[1], 0);
+ TEST_EQUAL(file_priorities[2], 0);
+}
+
+TORRENT_TEST(file_priorities_seed_mode)
+{
+ // in share mode file priorities should always be 0
+ libtorrent::session ses;
+ std::vector<int> file_priorities = test_resume_flags(ses,
+ add_torrent_params::flag_share_mode, "123", "").file_priorities();
+ | ||
relevance 0 | ../test/test_resume.cpp:648 | test all other resume flags here too. This would require returning more than just the torrent_status from test_resume_flags. Also http seeds and trackers for instance |
test all other resume flags here too. This would require returning
more than just the torrent_status from test_resume_flags. Also http seeds
-and trackers for instance../test/test_resume.cpp:340 // resume data overrides the paused flag
- fprintf(stderr, "flags: paused\n");
- s = test_resume_flags(add_torrent_params::flag_paused);
+and trackers for instance../test/test_resume.cpp:648 libtorrent::session ses;
+ // resume data overrides the paused flag
+ torrent_status s = test_resume_flags(ses, add_torrent_params::flag_paused).status();
default_tests(s);
#ifdef TORRENT_WINDOWS
TEST_EQUAL(s.save_path, "c:\\add_torrent_params save_path");
@@ -3727,11 +4424,10 @@ and trackers for instance../test/test_resume.cpp:340 return 0;
-}
+}
+
-
- | ||
relevance 0 | ../test/test_ssl.cpp:378 | test using a signed certificate with the wrong info-hash in DN |
test using a signed certificate with the wrong info-hash in DN../test/test_ssl.cpp:378 // in verifying peers
+ | ||
relevance 0 | ../test/test_ssl.cpp:378 | test using a signed certificate with the wrong info-hash in DN |
test using a signed certificate with the wrong info-hash in DN../test/test_ssl.cpp:378 // in verifying peers
ctx.set_verify_mode(context::verify_none, ec);
if (ec)
{
@@ -3782,7 +4478,7 @@ and trackers for instance../test/test_resume.cpp:340 | ||
relevance 0 | ../test/test_ssl.cpp:476 | also test using a hash that refers to a valid torrent but that differs from the SNI hash |
also test using a hash that refers to a valid torrent
+ | ||
relevance 0 | ../test/test_ssl.cpp:476 | also test using a hash that refers to a valid torrent but that differs from the SNI hash |
also test using a hash that refers to a valid torrent
but that differs from the SNI hash../test/test_ssl.cpp:476 print_alerts(ses1, "ses1", true, true, true, &on_alert);
if (ec)
{
@@ -3795,7 +4491,7 @@ but that differs from the SNI hash../test/test_ssl.cpp:476../test/test_ssl.cpp:476../test/test_ssl.cpp:476../test/test_ssl.cpp:476
| ||
relevance 0 | ../test/test_torrent.cpp:133 | wait for an alert rather than just waiting 10 seconds. This is kind of silly |
wait for an alert rather than just waiting 10 seconds. This is kind of silly../test/test_torrent.cpp:133 TEST_EQUAL(h.file_priorities().size(), info->num_files());
+ | ||
relevance 0 | ../test/test_timestamp_history.cpp:54 | test the case where we have > 120 samples (and have the base delay actually be updated) |
test the case where we have > 120 samples (and have the base delay actually be updated)../test/test_timestamp_history.cpp:54 | ||
relevance 0 | ../test/test_timestamp_history.cpp:55 | test the case where a sample is lower than the history entry but not lower than the base |
test the case where a sample is lower than the history entry but not lower than the base../test/test_timestamp_history.cpp:55#include "libtorrent/timestamp_history.hpp"
+
+TORRENT_TEST(timestamp_history)
+{
+ using namespace libtorrent;
+
+ timestamp_history h;
+ TEST_EQUAL(h.add_sample(0x32, false), 0);
+ TEST_EQUAL(h.base(), 0x32);
+ TEST_EQUAL(h.add_sample(0x33, false), 0x1);
+ TEST_EQUAL(h.base(), 0x32);
+ TEST_EQUAL(h.add_sample(0x3433, false), 0x3401);
+ TEST_EQUAL(h.base(), 0x32);
+ TEST_EQUAL(h.add_sample(0x30, false), 0);
+ TEST_EQUAL(h.base(), 0x30);
+
+ // test that wrapping of the timestamp is properly handled
+ h.add_sample(0xfffffff3, false);
+ TEST_EQUAL(h.base(), 0xfffffff3);
+
+}
+
+ | ||
relevance 0 | ../test/test_torrent.cpp:135 | wait for an alert rather than just waiting 10 seconds. This is kind of silly |
wait for an alert rather than just waiting 10 seconds. This is kind of silly../test/test_torrent.cpp:135 TEST_EQUAL(h.file_priorities().size(), info->num_files());
TEST_EQUAL(h.file_priorities()[0], 0);
if (info->num_files() > 1)
TEST_EQUAL(h.file_priorities()[1], 0);
@@ -3875,7 +4593,7 @@ but that differs from the SNI hash../test/test_ssl.cpp:476 | ||
relevance 0 | ../test/test_torrent_info.cpp:160 | test remap_files |
test remap_files../test/test_torrent_info.cpp:160 | ||
relevance 0 | ../test/test_torrent_info.cpp:161 | merkle torrents. specifically torrent_info::add_merkle_nodes and torrent with "root hash" |
merkle torrents. specifically torrent_info::add_merkle_nodes and torrent with "root hash"../test/test_torrent_info.cpp:161 | ||
relevance 0 | ../test/test_torrent_info.cpp:162 | torrent with 'p' (padfile) attribute |
torrent with 'p' (padfile) attribute../test/test_torrent_info.cpp:162 | ||
relevance 0 | ../test/test_torrent_info.cpp:163 | torrent with 'h' (hidden) attribute |
torrent with 'h' (hidden) attribute../test/test_torrent_info.cpp:163 | ||
relevance 0 | ../test/test_torrent_info.cpp:164 | torrent with 'x' (executable) attribute |
torrent with 'x' (executable) attribute../test/test_torrent_info.cpp:164 | ||
relevance 0 | ../test/test_torrent_info.cpp:165 | torrent with 'l' (symlink) attribute |
torrent with 'l' (symlink) attribute../test/test_torrent_info.cpp:165 | ||
relevance 0 | ../test/test_torrent_info.cpp:166 | creating a merkle torrent (torrent_info::build_merkle_list) |
creating a merkle torrent (torrent_info::build_merkle_list)../test/test_torrent_info.cpp:166 | ||
relevance 0 | ../test/test_torrent_info.cpp:167 | torrent with multiple trackers in multiple tiers, making sure we shuffle them (how do you test shuffling?, load it multiple times and make sure it's in different order at least once) |
torrent with multiple trackers in multiple tiers, making sure we shuffle them (how do you test shuffling?, load it multiple times and make sure it's in different order at least once)../test/test_torrent_info.cpp:167 | ||
relevance 0 | ../test/test_torrent_info.cpp:168 | sanitize_append_path_element with all kinds of UTF-8 sequences, including invalid ones |
sanitize_append_path_element with all kinds of UTF-8 sequences, including invalid ones../test/test_torrent_info.cpp:168 | ||
relevance 0 | ../test/test_torrent_info.cpp:169 | torrents with a missing name |
torrents with a missing name../test/test_torrent_info.cpp:169 | ||
relevance 0 | ../test/test_torrent_info.cpp:170 | torrents with a zero-length name |
torrents with a zero-length name../test/test_torrent_info.cpp:170 | ||
relevance 0 | ../test/test_torrent_info.cpp:171 | torrents with a merkle tree and add_merkle_nodes |
torrents with a merkle tree and add_merkle_nodes../test/test_torrent_info.cpp:171 | ||
relevance 0 | ../test/test_torrent_info.cpp:172 | torrent with a non-dictionary info-section |
torrent with a non-dictionary info-section../test/test_torrent_info.cpp:172 | ||
relevance 0 | ../test/test_torrent_info.cpp:173 | torrents with DHT nodes |
torrents with DHT nodes../test/test_torrent_info.cpp:173 | ||
relevance 0 | ../test/test_torrent_info.cpp:174 | torrent with url-list as a single string |
torrent with url-list as a single string../test/test_torrent_info.cpp:174 | ||
relevance 0 | ../test/test_torrent_info.cpp:175 | torrent with http seed as a single string |
torrent with http seed as a single string../test/test_torrent_info.cpp:175 | ||
relevance 0 | ../test/test_torrent_info.cpp:176 | torrent with a comment |
torrent with a comment../test/test_torrent_info.cpp:176 | ||
relevance 0 | ../test/test_torrent_info.cpp:177 | torrent with an SSL cert |
torrent with an SSL cert../test/test_torrent_info.cpp:177 | ||
relevance 0 | ../test/test_torrent_info.cpp:178 | torrent with attributes (executable and hidden) |
torrent with attributes (executable and hidden)../test/test_torrent_info.cpp:178 | ||
relevance 0 | ../test/test_torrent_info.cpp:179 | torrent_info::add_tracker |
torrent_info::add_tracker../test/test_torrent_info.cpp:179 | ||
relevance 0 | ../test/test_torrent_info.cpp:180 | torrent_info::add_url_seed |
torrent_info::add_url_seed../test/test_torrent_info.cpp:180 | ||
relevance 0 | ../test/test_torrent_info.cpp:181 | torrent_info::add_http_seed |
torrent_info::add_http_seed../test/test_torrent_info.cpp:181 | ||
relevance 0 | ../test/test_torrent_info.cpp:182 | torrent_info::unload |
torrent_info::unload../test/test_torrent_info.cpp:182 | ||
relevance 0 | ../test/test_torrent_info.cpp:183 | torrent_info constructor that takes an invalid bencoded buffer |
torrent_info constructor that takes an invalid bencoded buffer../test/test_torrent_info.cpp:183 | ||
relevance 0 | ../test/test_torrent_info.cpp:184 | verify_encoding with a string that triggers character replacement |
verify_encoding with a string that triggers character replacement../test/test_torrent_info.cpp:184 { "invalid_info.torrent", errors::torrent_missing_info },
+ | ||
relevance 0 | ../test/test_torrent_info.cpp:155 | test remap_files |
test remap_files../test/test_torrent_info.cpp:155 | ||
relevance 0 | ../test/test_torrent_info.cpp:156 | merkle torrents. specifically torrent_info::add_merkle_nodes and torrent with "root hash" |
merkle torrents. specifically torrent_info::add_merkle_nodes and torrent with "root hash"../test/test_torrent_info.cpp:156 | ||
relevance 0 | ../test/test_torrent_info.cpp:157 | torrent with 'p' (padfile) attribute |
torrent with 'p' (padfile) attribute../test/test_torrent_info.cpp:157 | ||
relevance 0 | ../test/test_torrent_info.cpp:158 | torrent with 'h' (hidden) attribute |
torrent with 'h' (hidden) attribute../test/test_torrent_info.cpp:158 | ||
relevance 0 | ../test/test_torrent_info.cpp:159 | torrent with 'x' (executable) attribute |
torrent with 'x' (executable) attribute../test/test_torrent_info.cpp:159 | ||
relevance 0 | ../test/test_torrent_info.cpp:160 | torrent with 'l' (symlink) attribute |
torrent with 'l' (symlink) attribute../test/test_torrent_info.cpp:160 | ||
relevance 0 | ../test/test_torrent_info.cpp:161 | creating a merkle torrent (torrent_info::build_merkle_list) |
creating a merkle torrent (torrent_info::build_merkle_list)../test/test_torrent_info.cpp:161 | ||
relevance 0 | ../test/test_torrent_info.cpp:162 | torrent with multiple trackers in multiple tiers, making sure we shuffle them (how do you test shuffling?, load it multiple times and make sure it's in different order at least once) |
torrent with multiple trackers in multiple tiers, making sure we shuffle them (how do you test shuffling?, load it multiple times and make sure it's in different order at least once)../test/test_torrent_info.cpp:162 | ||
relevance 0 | ../test/test_torrent_info.cpp:163 | sanitize_append_path_element with all kinds of UTF-8 sequences, including invalid ones |
sanitize_append_path_element with all kinds of UTF-8 sequences, including invalid ones../test/test_torrent_info.cpp:163 | ||
relevance 0 | ../test/test_torrent_info.cpp:164 | torrents with a missing name |
torrents with a missing name../test/test_torrent_info.cpp:164 | ||
relevance 0 | ../test/test_torrent_info.cpp:165 | torrents with a zero-length name |
torrents with a zero-length name../test/test_torrent_info.cpp:165 | ||
relevance 0 | ../test/test_torrent_info.cpp:166 | torrents with a merkle tree and add_merkle_nodes |
torrents with a merkle tree and add_merkle_nodes../test/test_torrent_info.cpp:166 | ||
relevance 0 | ../test/test_torrent_info.cpp:167 | torrent with a non-dictionary info-section |
torrent with a non-dictionary info-section../test/test_torrent_info.cpp:167 | ||
relevance 0 | ../test/test_torrent_info.cpp:168 | torrents with DHT nodes |
torrents with DHT nodes../test/test_torrent_info.cpp:168 | ||
relevance 0 | ../test/test_torrent_info.cpp:169 | torrent with url-list as a single string |
torrent with url-list as a single string../test/test_torrent_info.cpp:169 | ||
relevance 0 | ../test/test_torrent_info.cpp:170 | torrent with http seed as a single string |
torrent with http seed as a single string../test/test_torrent_info.cpp:170 | ||
relevance 0 | ../test/test_torrent_info.cpp:171 | torrent with a comment |
torrent with a comment../test/test_torrent_info.cpp:171 | ||
relevance 0 | ../test/test_torrent_info.cpp:172 | torrent with an SSL cert |
torrent with an SSL cert../test/test_torrent_info.cpp:172 | ||
relevance 0 | ../test/test_torrent_info.cpp:173 | torrent with attributes (executable and hidden) |
torrent with attributes (executable and hidden)../test/test_torrent_info.cpp:173 | ||
relevance 0 | ../test/test_torrent_info.cpp:174 | torrent_info::add_tracker |
torrent_info::add_tracker../test/test_torrent_info.cpp:174 | ||
relevance 0 | ../test/test_torrent_info.cpp:175 | torrent_info::add_url_seed |
torrent_info::add_url_seed../test/test_torrent_info.cpp:175 | ||
relevance 0 | ../test/test_torrent_info.cpp:176 | torrent_info::add_http_seed |
torrent_info::add_http_seed../test/test_torrent_info.cpp:176 | ||
relevance 0 | ../test/test_torrent_info.cpp:177 | torrent_info::unload |
torrent_info::unload../test/test_torrent_info.cpp:177 | ||
relevance 0 | ../test/test_torrent_info.cpp:178 | torrent_info constructor that takes an invalid bencoded buffer |
torrent_info constructor that takes an invalid bencoded buffer../test/test_torrent_info.cpp:178 | ||
relevance 0 | ../test/test_torrent_info.cpp:179 | verify_encoding with a string that triggers character replacement |
verify_encoding with a string that triggers character replacement../test/test_torrent_info.cpp:179test_failing_torrent_t test_error_torrents[] =
+{
+ { "missing_piece_len.torrent", errors::torrent_missing_piece_length },
+ { "invalid_piece_len.torrent", errors::torrent_missing_piece_length },
+ { "negative_piece_len.torrent", errors::torrent_missing_piece_length },
+ { "no_name.torrent", errors::torrent_missing_name },
+ { "invalid_name.torrent", errors::torrent_missing_name },
+ { "invalid_info.torrent", errors::torrent_missing_info },
{ "string.torrent", errors::torrent_is_no_dict },
{ "negative_size.torrent", errors::torrent_invalid_length },
{ "negative_file_size.torrent", errors::torrent_invalid_length },
@@ -3898,18 +4623,9 @@ int test_main()
{ "invalid_file_size.torrent", errors::torrent_invalid_length },
};
-namespace libtorrent
-{
- // defined in torrent_info.cpp
- TORRENT_EXPORT bool verify_encoding(std::string& target, bool path = true);
- TORRENT_EXTRA_EXPORT void sanitize_append_path_element(std::string& p, char const* element, int len);
-}
-
- int test_torrent_parse()
+TORRENT_TEST(sanitize_path)
{
- error_code ec;
-
// test sanitize_append_path_element
std::string path;
@@ -3936,64 +4652,66 @@ namespace libtorrent
"abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_"
"abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_"
"abcdefghi_abcdefghi_abcdefghi_abcdefghi_/"
- | ||
relevance 0 | ../test/test_tracker.cpp:252 | test parse peers6 |
test parse peers6../test/test_tracker.cpp:252 | ||
relevance 0 | ../test/test_tracker.cpp:253 | test parse tracker-id |
test parse tracker-id../test/test_tracker.cpp:253 | ||
relevance 0 | ../test/test_tracker.cpp:254 | test parse failure-reason |
test parse failure-reason../test/test_tracker.cpp:254 | ||
relevance 0 | ../test/test_tracker.cpp:255 | test all failure paths, including invalid bencoding not a dictionary no files entry in scrape response no info-hash entry in scrape response malformed peers in peer list of dictionaries uneven number of bytes in peers and peers6 string responses |
test all failure paths, including
+ "abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_"
+ "abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_abcdefghi_"
+ | ||
relevance 0 | ../test/test_tracker.cpp:47 | test scrape requests |
test scrape requests../test/test_tracker.cpp:47 | ||
relevance 0 | ../test/test_tracker.cpp:48 | test parse peers6 |
test parse peers6../test/test_tracker.cpp:48 | ||
relevance 0 | ../test/test_tracker.cpp:49 | test parse tracker-id |
test parse tracker-id../test/test_tracker.cpp:49 | ||
relevance 0 | ../test/test_tracker.cpp:50 | test parse failure-reason |
test parse failure-reason../test/test_tracker.cpp:50 | ||
relevance 0 | ../test/test_tracker.cpp:51 | test all failure paths, including invalid bencoding not a dictionary no files entry in scrape response no info-hash entry in scrape response malformed peers in peer list of dictionaries uneven number of bytes in peers and peers6 string responses |
test all failure paths, including
invalid bencoding
not a dictionary
no files entry in scrape response
no info-hash entry in scrape response
malformed peers in peer list of dictionaries
-uneven number of bytes in peers and peers6 string responses../test/test_tracker.cpp:255 peer_entry result = extract_peer("d7:peer id20:abababababababababab2:ip4:abcde"
- , error_code(errors::invalid_tracker_response, get_libtorrent_category()), false);
+uneven number of bytes in peers and peers6 string responses../test/test_tracker.cpp:51CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+#include "test.hpp"
+#include "setup_transfer.hpp"
+#include "udp_tracker.hpp"
+#include "libtorrent/alert.hpp"
+#include "libtorrent/session.hpp"
+#include "libtorrent/error_code.hpp"
+#include "libtorrent/tracker_manager.hpp"
+#include "libtorrent/http_tracker_connection.hpp" // for parse_tracker_response
+
+#include <fstream>
+
+using namespace libtorrent;
+namespace lt = libtorrent;
+
+
+ TORRENT_TEST(parse_hostname_peers)
+{
+ char const response[] = "d5:peersld7:peer id20:aaaaaaaaaaaaaaaaaaaa2:ip13:test_hostname4:porti1000eed7:peer id20:bbbbabaababababababa2:ip12:another_host4:porti1001eeee";
+ error_code ec;
+ tracker_response resp = parse_tracker_response(response, sizeof(response) - 1
+ , ec, false, sha1_hash());
+
+ TEST_EQUAL(ec, error_code());
+ TEST_EQUAL(resp.peers.size(), 2);
+ if (resp.peers.size() == 2)
+ {
+ peer_entry const& e0 = resp.peers[0];
+ peer_entry const& e1 = resp.peers[1];
+ TEST_EQUAL(e0.hostname, "test_hostname");
+ TEST_EQUAL(e0.port, 1000);
+ TEST_EQUAL(e0.pid, peer_id("aaaaaaaaaaaaaaaaaaaa"));
+
+ TEST_EQUAL(e1.hostname, "another_host");
+ TEST_EQUAL(e1.port, 1001);
+ TEST_EQUAL(e1.pid, peer_id("bbbbabaababababababa"));
}
}
-int test_main()
+TORRENT_TEST(parse_peers4)
{
- test_extract_peer();
- test_parse_hostname_peers();
- test_parse_peers4();
- test_parse_interval();
- test_parse_warning();
- test_parse_failure_reason();
- test_parse_scrape_response();
- test_parse_scrape_response_with_zero();
- test_parse_external_ip();
-#if TORRENT_USE_IPV6
- test_parse_external_ip6();
-#endif
-
-
- int http_port = start_web_server();
- int udp_port = start_udp_tracker();
-
- int prev_udp_announces = num_udp_announces();
-
- int const alert_mask = alert::all_categories
- & ~alert::progress_notification
- & ~alert::stats_notification;
-
- lt::session* s = new lt::session(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48875, 49800), "0.0.0.0", 0, alert_mask);
-
- settings_pack pack;
-#ifndef TORRENT_NO_DEPRECATE
- pack.set_int(settings_pack::half_open_limit, 1);
-#endif
- pack.set_bool(settings_pack::announce_to_all_trackers, true);
- pack.set_bool(settings_pack::announce_to_all_tiers, true);
- s->apply_settings(pack);
-
+ char const response[] = "d5:peers12:\x01\x02\x03\x04\x30\x10"
+ "\x09\x08\x07\x06\x20\x10" "e";
error_code ec;
- remove_all("tmp1_tracker", ec);
- create_directory("tmp1_tracker", ec);
- std::ofstream file(combine_path("tmp1_tracker", "temporary").c_str());
- boost::shared_ptr<torrent_info> t = ::create_torrent(&file, 16 * 1024, 13, false);
- file.close();
-
- char tracker_url[200];
- snprintf(tracker_url, sizeof(tracker_url), "http://127.0.0.1:%d/announce", http_port);
- t->add_tracker(tracker_url, 0);
-
- | ||
relevance 0 | ../test/test_transfer.cpp:291 | factor out the disk-full test into its own unit test |
factor out the disk-full test into its own unit test../test/test_transfer.cpp:291 print_alerts(ses1, "ses1", true, true, true, &on_alert);
+ tracker_response resp = parse_tracker_response(response, sizeof(response) - 1
+ , ec, false, sha1_hash());
+ | ||
relevance 0 | ../test/test_transfer.cpp:297 | factor out the disk-full test into its own unit test |
factor out the disk-full test into its own unit test../test/test_transfer.cpp:297 print_alerts(ses1, "ses1", true, true, true, &on_alert);
print_alerts(ses2, "ses2", true, true, true, &on_alert);
if (i % 10 == 0)
@@ -4029,6 +4747,9 @@ int test_main()
print_alerts(ses1, "ses1", true, true, true, &on_alert);
print_alerts(ses2, "ses2", true, true, true, &on_alert);
+ std::string err = tor2.status().error;
+ fprintf(stderr, "error: \"%s\"\n", err.c_str());
+ TEST_CHECK(err.empty());
tor2.set_upload_mode(false);
// at this point we probably disconnected the seed
@@ -4041,10 +4762,7 @@ int test_main()
TEST_CHECK(tor2.status().is_finished == false);
fprintf(stderr, "disconnects: %d\n", peer_disconnects);
TEST_CHECK(peer_disconnects >= 2);
- fprintf(stderr, "%s: discovered disk full mode. Raise limit and disable upload-mode\n", time_now_string());
- peer_disconnects = 0;
- continue;
- | ||
relevance 0 | ../test/test_upnp.cpp:100 | store the log and verify that some key messages are there |
store the log and verify that some key messages are there../test/test_upnp.cpp:100 "USN:uuid:000f-66d6-7296000099dc::upnp:rootdevice\r\n"
+ | ||
relevance 0 | ../test/test_upnp.cpp:108 | store the log and verify that some key messages are there |
store the log and verify that some key messages are there../test/test_upnp.cpp:108 "USN:uuid:000f-66d6-7296000099dc::upnp:rootdevice\r\n"
"Location: http://127.0.0.1:%d/upnp.xml\r\n"
"Server: Custom/1.0 UPnP/1.0 Proc/Ver\r\n"
"EXT:\r\n"
@@ -4085,17 +4803,17 @@ void callback(int mapping, address const& ip, int port, error_code const&
<< ", error: \"" << err.message() << "\"\n";
}
-int run_upnp_test(char const* root_filename, char const* router_model, char const* control_name)
+void run_upnp_test(char const* root_filename, char const* router_model, char const* control_name, int igd_version)
{
libtorrent::io_service ios;
-
+
g_port = start_web_server();
std::vector<char> buf;
error_code ec;
load_file(root_filename, buf, ec);
buf.push_back(0);
- | ||
relevance 0 | ../test/web_seed_suite.cpp:366 | file hashes don't work with the new torrent creator reading async |
file hashes don't work with the new torrent creator reading async../test/web_seed_suite.cpp:366 // corrupt the files now, so that the web seed will be banned
+ | ||
relevance 0 | ../test/web_seed_suite.cpp:369 | file hashes don't work with the new torrent creator reading async |
file hashes don't work with the new torrent creator reading async../test/web_seed_suite.cpp:369 // corrupt the files now, so that the web seed will be banned
if (test_url_seed)
{
create_random_files(combine_path(save_path, "torrent_dir"), file_sizes, sizeof(file_sizes)/sizeof(file_sizes[0]));
@@ -4133,20 +4851,20 @@ int run_upnp_test(char const* root_filename, char const* router_model, char cons
}
*/
{
+ const int mask = alert::all_categories
+ & ~(alert::progress_notification
+ | alert::performance_warning
+ | alert::stats_notification);
+
settings_pack pack;
pack.set_int(settings_pack::max_queued_disk_bytes, 256 * 1024);
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:51000");
pack.set_int(settings_pack::max_retry_port_bind, 1000);
- pack.set_int(settings_pack::alert_mask, ~(alert::progress_notification | alert::stats_notification));
+ pack.set_int(settings_pack::alert_mask, mask);
pack.set_bool(settings_pack::enable_lsd, false);
pack.set_bool(settings_pack::enable_natpmp, false);
pack.set_bool(settings_pack::enable_upnp, false);
- pack.set_bool(settings_pack::enable_dht, false);
- libtorrent::session ses(pack, 0);
-
- test_transfer(ses, torrent_file, proxy, port, protocol, test_url_seed
- , chunked_encoding, test_ban, keepalive);
- | ||
relevance 0 | ../src/block_cache.cpp:959 | it's somewhat expensive to iterate over this linked list. Presumably because of the random access of memory. It would be nice if pieces with no evictable blocks weren't in this list |
it's somewhat expensive
+ | ||
relevance 0 | ../src/block_cache.cpp:959 | it's somewhat expensive to iterate over this linked list. Presumably because of the random access of memory. It would be nice if pieces with no evictable blocks weren't in this list |
it's somewhat expensive
to iterate over this linked list. Presumably because of the random
access of memory. It would be nice if pieces with no evictable blocks
weren't in this list../src/block_cache.cpp:959 }
@@ -4200,7 +4918,7 @@ weren't in this list../src/block_cache.cpp:959relevance 0 | ../src/block_cache.cpp:1023 | this should probably only be done every n:th time |
|
this should probably only be done every n:th time../src/block_cache.cpp:1023 }
+ | ||
relevance 0 | ../src/block_cache.cpp:1023 | this should probably only be done every n:th time |
this should probably only be done every n:th time../src/block_cache.cpp:1023 }
if (pe->ok_to_evict())
{
@@ -4251,17 +4969,17 @@ weren't in this list../src/block_cache.cpp:959relevance 0 | ../src/block_cache.cpp:1775 | create a holder for refcounts that automatically decrement |
|
create a holder for refcounts that automatically decrement../src/block_cache.cpp:1775 }
+ | ||
relevance 0 | ../src/block_cache.cpp:1778 | create a holder for refcounts that automatically decrement |
create a holder for refcounts that automatically decrement../src/block_cache.cpp:1778 }
- j->buffer = allocate_buffer("send buffer");
- if (j->buffer == 0) return -2;
+ j->buffer.disk_block = allocate_buffer("send buffer");
+ if (j->buffer.disk_block == 0) return -2;
while (size > 0)
{
TORRENT_PIECE_ASSERT(pe->blocks[block].buf, pe);
int to_copy = (std::min)(block_size()
- block_offset, size);
- std::memcpy(j->buffer + buffer_offset
+ std::memcpy(j->buffer.disk_block + buffer_offset
, pe->blocks[block].buf + block_offset
, to_copy);
size -= to_copy;
@@ -4302,7 +5020,7 @@ bool block_cache::maybe_free_piece(cached_piece_entry* pe)
boost::shared_ptr<piece_manager> s = pe->storage;
- | ||
relevance 0 | ../src/bt_peer_connection.cpp:676 | this could be optimized using knuth morris pratt |
this could be optimized using knuth morris pratt../src/bt_peer_connection.cpp:676 }
+ | ||
relevance 0 | ../src/bt_peer_connection.cpp:679 | this could be optimized using knuth morris pratt |
this could be optimized using knuth morris pratt../src/bt_peer_connection.cpp:679 }
m_rc4->set_incoming_key(&remote_key[0], 20);
m_rc4->set_outgoing_key(&local_key[0], 20);
@@ -4329,31 +5047,31 @@ bool block_cache::maybe_free_piece(cached_piece_entry* pe)
return i;
}
-// // Partial sync
-// for (int i = 0; i < target_size; ++i)
-// {
-// // first is iterator in src[] at which mismatch occurs
-// // second is iterator in target[] at which mismatch occurs
-// std::pair<const char*, const char*> ret;
-// int src_sync_size;
-// if (i > traverse_limit) // partial sync test
-// {
-// ret = std::mismatch(src, src + src_size - (i - traverse_limit), &target[i]);
-// src_sync_size = ret.first - src;
-// if (src_sync_size == (src_size - (i - traverse_limit)))
-// return i;
-// }
-// else // complete sync test
-// {
-// ret = std::mismatch(src, src + src_size, &target[i]);
-// src_sync_size = ret.first - src;
-// if (src_sync_size == src_size)
-// return i;
-// }
-// }
+ // Partial sync
+// for (int i = 0; i < target_size; ++i)
+// {
+// // first is iterator in src[] at which mismatch occurs
+// // second is iterator in target[] at which mismatch occurs
+// std::pair<const char*, const char*> ret;
+// int src_sync_size;
+// if (i > traverse_limit) // partial sync test
+// {
+// ret = std::mismatch(src, src + src_size - (i - traverse_limit), &target[i]);
+// src_sync_size = ret.first - src;
+// if (src_sync_size == (src_size - (i - traverse_limit)))
+// return i;
+// }
+// else // complete sync test
+// {
+// ret = std::mismatch(src, src + src_size, &target[i]);
+// src_sync_size = ret.first - src;
+// if (src_sync_size == src_size)
+// return i;
+// }
+// }
- // no complete sync
- | ||
relevance 0 | ../src/bt_peer_connection.cpp:2245 | if we're finished, send upload_only message |
if we're finished, send upload_only message../src/bt_peer_connection.cpp:2245 }
+ // no complete sync
+ | ||
relevance 0 | ../src/bt_peer_connection.cpp:2249 | if we're finished, send upload_only message |
if we're finished, send upload_only message../src/bt_peer_connection.cpp:2249 }
peer_log(peer_log_alert::outgoing_message, "BITFIELD"
, "%s", bitfield_string.c_str());
#endif
@@ -4404,7 +5122,7 @@ bool block_cache::maybe_free_piece(cached_piece_entry* pe)
? m_settings.get_str(settings_pack::user_agent)
: m_settings.get_str(settings_pack::handshake_client_version);
}
- | ||
relevance 0 | ../src/choker.cpp:336 | optimize this using partial_sort or something. We don't need to sort the entire list |
optimize this using partial_sort or something. We don't need
+ | ||
relevance 0 | ../src/choker.cpp:336 | optimize this using partial_sort or something. We don't need to sort the entire list |
optimize this using partial_sort or something. We don't need
to sort the entire list../src/choker.cpp:336 return upload_slots;
}
@@ -4425,8 +5143,8 @@ to sort the entire list../src/choker.cpp:336
- | ||
relevance 0 | ../src/choker.cpp:339 | make the comparison function a free function and move it into this cpp file |
make the comparison function a free function and move it
+
+ | ||
relevance 0 | ../src/choker.cpp:339 | make the comparison function a free function and move it into this cpp file |
make the comparison function a free function and move it
into this cpp file../src/choker.cpp:339 }
// ==== rate-based ====
@@ -4446,11 +5164,11 @@ into this cpp file../src/choker.cpp:339 std::sort(peers.begin(), peers.end()
, boost::bind(&upload_rate_compare, _1, _2));
- | ||
relevance 0 | ../src/choker.cpp:344 | make configurable |
make configurable../src/choker.cpp:344 //
+ | ||
relevance 0 | ../src/choker.cpp:344 | make configurable |
make configurable../src/choker.cpp:344 //
// The rate based unchoker looks at our upload rate to peers, and find
// a balance between number of upload slots and the rate we achieve. The
// intention is to not spread upload bandwidth too thin, but also to not
@@ -4466,7 +5184,7 @@ into this cpp file../src/choker.cpp:339 | ||
relevance 0 | ../src/choker.cpp:358 | make configurable |
make configurable../src/choker.cpp:358 // it purely based on the current state of our peers.
+ | ||
relevance 0 | ../src/choker.cpp:358 | make configurable |
make configurable../src/choker.cpp:358 // it purely based on the current state of our peers.
upload_slots = 0;
-
+
std::sort(peers.begin(), peers.end()
, boost::bind(&upload_rate_compare, _1, _2));
@@ -4512,7 +5230,7 @@ into this cpp file../src/choker.cpp:339 | ||
relevance 0 | ../src/create_torrent.cpp:284 | this should probably be optional |
this should probably be optional../src/create_torrent.cpp:284 boost::shared_ptr<char> dummy;
- counters cnt;
+ | ||
relevance 0 | ../src/create_torrent.cpp:285 | this should probably be optional |
this should probably be optional../src/create_torrent.cpp:285 counters cnt;
disk_io_thread disk_thread(ios, cnt, 0);
+ disk_thread.set_num_threads(1);
storage_params params;
params.files = &t.files();
@@ -4585,7 +5303,7 @@ into this cpp file../src/choker.cpp:339relevance 0 | ../src/disk_buffer_pool.cpp:319 | perhaps we should sort the buffers here? |
|
perhaps we should sort the buffers here?../src/disk_buffer_pool.cpp:319 mutex::scoped_lock l(m_pool_mutex);
+ | ||
relevance 0 | ../src/disk_buffer_pool.cpp:319 | perhaps we should sort the buffers here? |
perhaps we should sort the buffers here?../src/disk_buffer_pool.cpp:319 mutex::scoped_lock l(m_pool_mutex);
for (int i = 0; i < iov_len; ++i)
{
iov[i].iov_base = allocate_buffer_impl(l, "pending read");
@@ -4636,8 +5354,8 @@ into this cpp file../src/choker.cpp:339relevance 0 | ../src/disk_io_thread.cpp:857 | it would be nice to optimize this by having the cache pieces also ordered by |
|
it would be nice to optimize this by having the cache
-pieces also ordered by../src/disk_io_thread.cpp:857 // from disk_io_thread::do_delete, which is a fence job and should
+ | ||
relevance 0 | ../src/disk_io_thread.cpp:884 | it would be nice to optimize this by having the cache pieces also ordered by |
it would be nice to optimize this by having the cache
+pieces also ordered by../src/disk_io_thread.cpp:884 // from disk_io_thread::do_delete, which is a fence job and should
// have any other jobs active, i.e. there should not be any references
// keeping pieces or blocks alive
if ((flags & flush_delete_cache) && (flags & flush_expect_clear))
@@ -4688,8 +5406,8 @@ pieces also ordered by../src/disk_io_thread.cpp:857relevance 0 | ../src/disk_io_thread.cpp:900 | instead of doing a lookup each time through the loop, save cached_piece_entry pointers with piece_refcount incremented to pin them |
|
instead of doing a lookup each time through the loop, save
-cached_piece_entry pointers with piece_refcount incremented to pin them../src/disk_io_thread.cpp:900 // this is why we pass in 1 as cont_block to the flushing functions
+ | ||
relevance 0 | ../src/disk_io_thread.cpp:927 | instead of doing a lookup each time through the loop, save cached_piece_entry pointers with piece_refcount incremented to pin them |
instead of doing a lookup each time through the loop, save
+cached_piece_entry pointers with piece_refcount incremented to pin them../src/disk_io_thread.cpp:927 // this is why we pass in 1 as cont_block to the flushing functions
void disk_io_thread::try_flush_write_blocks(int num, tailqueue& completed_jobs
, mutex::scoped_lock& l)
{
@@ -4740,10 +5458,10 @@ cached_piece_entry pointers with piece_refcount incremented to pin them
cached_piece_entry* pe = m_disk_cache.find_piece(i->first, i->second);
if (pe == NULL) continue;
if (pe->num_dirty == 0) continue;
- | ||
relevance 0 | ../src/disk_io_thread.cpp:1079 | instead of doing this. pass in the settings to each storage_interface call. Each disk thread could hold its most recent understanding of the settings in a shared_ptr, and update it every time it wakes up from a job. That way each access to the settings won't require a mutex to be held. |
instead of doing this. pass in the settings to each storage_interface
+ | ||
relevance 0 | ../src/disk_io_thread.cpp:1106 | instead of doing this. pass in the settings to each storage_interface call. Each disk thread could hold its most recent understanding of the settings in a shared_ptr, and update it every time it wakes up from a job. That way each access to the settings won't require a mutex to be held. |
instead of doing this. pass in the settings to each storage_interface
call. Each disk thread could hold its most recent understanding of the settings
in a shared_ptr, and update it every time it wakes up from a job. That way
-each access to the settings won't require a mutex to be held.../src/disk_io_thread.cpp:1079 {
+each access to the settings won't require a mutex to be held.../src/disk_io_thread.cpp:1106 {
INVARIANT_CHECK;
TORRENT_ASSERT(j->next == 0);
TORRENT_ASSERT((j->flags & disk_io_job::in_progress) || !j->storage);
@@ -4787,9 +5505,9 @@ each access to the settings won't require a mutex to be held.../src/dis
// our quanta in case there aren't any other
// jobs to run in between
- | ||
relevance 0 | ../src/disk_io_thread.cpp:1107 | a potentially more efficient solution would be to have a special queue for retry jobs, that's only ever run when a job completes, in any thread. It would only work if counters::num_running_disk_jobs > 0 |
a potentially more efficient solution would be to have a special
+ | ||
relevance 0 | ../src/disk_io_thread.cpp:1134 | a potentially more efficient solution would be to have a special queue for retry jobs, that's only ever run when a job completes, in any thread. It would only work if counters::num_running_disk_jobs > 0 |
a potentially more efficient solution would be to have a special
queue for retry jobs, that's only ever run when a job completes, in
-any thread. It would only work if counters::num_running_disk_jobs > 0../src/disk_io_thread.cpp:1107
+any thread. It would only work if counters::num_running_disk_jobs > 0../src/disk_io_thread.cpp:1134
time_point start_time = clock_type::now();
m_stats_counters.inc_stats_counter(counters::num_running_disk_jobs, 1);
@@ -4820,7 +5538,7 @@ any thread. It would only work if counters::num_running_disk_jobs > 0..
}
#if TORRENT_USE_ASSERT
- | ||
relevance 0 | ../src/disk_io_thread.cpp:1121 | it should clear the hash state even when there's an error, right? |
it should clear the hash state even when there's an error, right?../src/disk_io_thread.cpp:1121 m_stats_counters.inc_stats_counter(counters::num_running_disk_jobs, -1);
+ | ||
relevance 0 | ../src/disk_io_thread.cpp:1148 | it should clear the hash state even when there's an error, right? |
it should clear the hash state even when there's an error, right?../src/disk_io_thread.cpp:1148 m_stats_counters.inc_stats_counter(counters::num_running_disk_jobs, -1);
if (ret == retry_job)
{
@@ -4864,15 +5582,15 @@ any thread. It would only work if counters::num_running_disk_jobs > 0..
int disk_io_thread::do_uncached_read(disk_io_job* j)
{
- j->buffer = m_disk_cache.allocate_buffer("send buffer");
- if (j->buffer == 0)
+ j->buffer.disk_block = m_disk_cache.allocate_buffer("send buffer");
+ if (j->buffer.disk_block == 0)
{
j->error.ec = error::no_memory;
j->error.operation = storage_error::alloc_cache_piece;
return -1;
}
- | ||
relevance 0 | ../src/disk_io_thread.cpp:1819 | maybe the tailqueue_iterator should contain a pointer-pointer instead and have an unlink function |
maybe the tailqueue_iterator should contain a pointer-pointer
-instead and have an unlink function../src/disk_io_thread.cpp:1819 j->callback = handler;
+ | ||
relevance 0 | ../src/disk_io_thread.cpp:1849 | maybe the tailqueue_iterator should contain a pointer-pointer instead and have an unlink function |
maybe the tailqueue_iterator should contain a pointer-pointer
+instead and have an unlink function../src/disk_io_thread.cpp:1849 j->callback = handler;
add_fence_job(storage, j);
}
@@ -4923,8 +5641,8 @@ instead and have an unlink function../src/disk_io_thread.cpp:1819<
if (completed_jobs.size())
add_completed_jobs(completed_jobs);
- | ||
relevance 0 | ../src/disk_io_thread.cpp:2081 | this is potentially very expensive. One way to solve it would be to have a fence for just this one piece. |
this is potentially very expensive. One way to solve
-it would be to have a fence for just this one piece.../src/disk_io_thread.cpp:2081 }
+ | ||
relevance 0 | ../src/disk_io_thread.cpp:2111 | this is potentially very expensive. One way to solve it would be to have a fence for just this one piece. |
this is potentially very expensive. One way to solve
+it would be to have a fence for just this one piece.../src/disk_io_thread.cpp:2111 }
void disk_io_thread::async_clear_piece(piece_manager* storage, int index
, boost::function<void(disk_io_job const*)> const& handler)
@@ -4947,7 +5665,7 @@ it would be to have a fence for just this one piece.../src/disk_io_thre
add_fence_job(storage, j);
}
- void disk_io_thread::clear_piece(piece_manager* storage, int index)
+ void disk_io_thread::clear_piece(piece_manager* storage, int index)
{
mutex::scoped_lock l(m_cache_mutex);
@@ -4967,6 +5685,7 @@ it would be to have a fence for just this one piece.../src/disk_io_thre
tailqueue jobs;
bool ok = m_disk_cache.evict_piece(pe, jobs);
TORRENT_PIECE_ASSERT(ok, pe);
+ TORRENT_UNUSED(ok);
fail_jobs(storage_error(boost::asio::error::operation_aborted), jobs);
}
@@ -4974,8 +5693,7 @@ it would be to have a fence for just this one piece.../src/disk_io_thre
{
if (!pe->hash) return;
if (pe->hashing) return;
-
- | ||
relevance 0 | ../src/disk_io_thread.cpp:2342 | we should probably just hang the job on the piece and make sure the hasher gets kicked |
we should probably just hang the job on the piece and make sure the hasher gets kicked../src/disk_io_thread.cpp:2342 if (pe == NULL)
+ | ||
relevance 0 | ../src/disk_io_thread.cpp:2373 | we should probably just hang the job on the piece and make sure the hasher gets kicked |
we should probably just hang the job on the piece and make sure the hasher gets kicked../src/disk_io_thread.cpp:2373 if (pe == NULL)
{
int cache_state = (j->flags & disk_io_job::volatile_read)
? cached_piece_entry::volatile_read_lru
@@ -5026,8 +5744,8 @@ it would be to have a fence for just this one piece.../src/disk_io_thre
TORRENT_PIECE_ASSERT(ph->offset % block_size == 0, pe);
for (int i = ph->offset / block_size; i < blocks_in_piece; ++i)
{
- | ||
relevance 0 | ../src/disk_io_thread.cpp:2409 | introduce a holder class that automatically increments and decrements the piece_refcount |
introduce a holder class that automatically increments
-and decrements the piece_refcount../src/disk_io_thread.cpp:2409 {
+ | ||
relevance 0 | ../src/disk_io_thread.cpp:2440 | introduce a holder class that automatically increments and decrements the piece_refcount |
introduce a holder class that automatically increments
+and decrements the piece_refcount../src/disk_io_thread.cpp:2440 {
file::iovec_t iov;
iov.iov_len = (std::min)(block_size, piece_size - ph->offset);
@@ -5078,8 +5796,8 @@ and decrements the piece_refcount../src/disk_io_thread.cpp:2409 | ||
relevance 0 | ../src/disk_io_thread.cpp:2655 | it would be nice to not have to lock the mutex every turn through this loop |
it would be nice to not have to lock the mutex every
-turn through this loop../src/disk_io_thread.cpp:2655 j->error.ec = error::no_memory;
+ | ||
relevance 0 | ../src/disk_io_thread.cpp:2688 | it would be nice to not have to lock the mutex every turn through this loop |
it would be nice to not have to lock the mutex every
+turn through this loop../src/disk_io_thread.cpp:2688 j->error.ec = error::no_memory;
j->error.operation = storage_error::alloc_cache_piece;
return -1;
}
@@ -5130,7 +5848,58 @@ turn through this loop../src/disk_io_thread.cpp:2655relevance 0 | ../src/http_tracker_connection.cpp:184 | support this somehow |
|
support this somehow../src/http_tracker_connection.cpp:184 url += escape_string(id.c_str(), id.length());
+ | ||
relevance 0 | ../src/file_progress.cpp:136 | it would be nice to not depend on alert_manager here |
it would be nice to not depend on alert_manager here../src/file_progress.cpp:136 , alert_manager* alerts, torrent_handle const& h)
+ {
+ if (m_file_progress.empty())
+ return;
+
+ const int piece_size = fs.piece_length();
+ boost::int64_t off = boost::int64_t(index) * piece_size;
+ int file_index = fs.file_index_at_offset(off);
+ int size = fs.piece_size(index);
+ for (; size > 0; ++file_index)
+ {
+ boost::int64_t file_offset = off - fs.file_offset(file_index);
+ TORRENT_ASSERT(file_index != fs.num_files());
+ TORRENT_ASSERT(file_offset <= fs.file_size(file_index));
+ int add = (std::min)(fs.file_size(file_index) - file_offset, (boost::int64_t)size);
+ m_file_progress[file_index] += add;
+
+ TORRENT_ASSERT(m_file_progress[file_index]
+ <= fs.file_size(file_index));
+
+ if (m_file_progress[file_index] >= fs.file_size(file_index) && alerts)
+ {
+ if (!fs.pad_file_at(file_index))
+ {
+ if (alerts->should_post<file_completed_alert>())
+ {
+ // this file just completed, post alert
+ alerts->emplace_alert<file_completed_alert>(h, file_index);
+ }
+ }
+ }
+ size -= add;
+ off += add;
+ TORRENT_ASSERT(size >= 0);
+ }
+ }
+
+#if TORRENT_USE_INVARIANT_CHECKS
+ void file_progress::check_invariant(file_storage const& fs) const
+ {
+ if (!m_file_progress.empty())
+ {
+ for (std::vector<boost::uint64_t>::const_iterator i = m_file_progress.begin()
+ , end(m_file_progress.end()); i != end; ++i)
+ {
+ int index = i - m_file_progress.begin();
+ TORRENT_ASSERT(*i <= fs.file_size(index));
+ }
+ }
+ }
+#endif
+ | ||
relevance 0 | ../src/http_tracker_connection.cpp:185 | support this somehow |
support this somehow../src/http_tracker_connection.cpp:185 url += escape_string(id.c_str(), id.length());
}
#if TORRENT_USE_I2P
@@ -5181,8 +5950,8 @@ turn through this loop../src/disk_io_thread.cpp:2655relevance 0 | ../src/metadata_transfer.cpp:356 | this is not safe. The torrent could be unloaded while we're still sending the metadata |
|
this is not safe. The torrent could be unloaded while
-we're still sending the metadata../src/metadata_transfer.cpp:356 = req_to_offset(req, (int)m_tp.metadata().left());
+ | ||
relevance 0 | ../src/metadata_transfer.cpp:358 | this is not safe. The torrent could be unloaded while we're still sending the metadata |
this is not safe. The torrent could be unloaded while
+we're still sending the metadata../src/metadata_transfer.cpp:358 = req_to_offset(req, (int)m_tp.metadata().left());
char msg[15];
char* ptr = msg;
@@ -5233,10 +6002,10 @@ we're still sending the metadata../src/metadata_transfer.cpp:356 | ||
relevance 0 | ../src/packet_buffer.cpp:176 | use compare_less_wrap for this comparison as well |
use compare_less_wrap for this comparison as well../src/packet_buffer.cpp:176 while (new_size < size)
- new_size <<= 1;
-
- void** new_storage = (void**)malloc(sizeof(void*) * new_size);
+ | ||
relevance 0 | ../src/packet_buffer.cpp:180 | use compare_less_wrap for this comparison as well |
use compare_less_wrap for this comparison as well../src/packet_buffer.cpp:180 void** new_storage = (void**)malloc(sizeof(void*) * new_size);
+#ifndef BOOST_NO_EXCEPTIONS
+ if (new_storage == NULL) throw std::bad_alloc();
+#endif
for (index_type i = 0; i < new_size; ++i)
new_storage[i] = 0;
@@ -5284,7 +6053,7 @@ we're still sending the metadata../src/metadata_transfer.cpp:356 | ||
relevance 0 | ../src/part_file.cpp:252 | what do we do if someone is currently reading from the disk from this piece? does it matter? Since we won't actively erase the data from disk, but it may be overwritten soon, it's probably not that big of a deal |
what do we do if someone is currently reading from the disk
+ | ||
relevance 0 | ../src/part_file.cpp:252 | what do we do if someone is currently reading from the disk from this piece? does it matter? Since we won't actively erase the data from disk, but it may be overwritten soon, it's probably not that big of a deal |
what do we do if someone is currently reading from the disk
from this piece? does it matter? Since we won't actively erase the
data from disk, but it may be overwritten soon, it's probably not that
big of a deal../src/part_file.cpp:252 if (((mode & file::rw_mask) != file::read_only)
@@ -5300,7 +6069,7 @@ big of a deal../src/part_file.cpp:252 | ||
relevance 0 | ../src/part_file.cpp:350 | instead of rebuilding the whole file header and flushing it, update the slot entries as we go |
instead of rebuilding the whole file header
-and flushing it, update the slot entries as we go../src/part_file.cpp:350 if (block_to_copy == m_piece_size)
+ | ||
relevance 0 | ../src/part_file.cpp:353 | instead of rebuilding the whole file header and flushing it, update the slot entries as we go |
instead of rebuilding the whole file header
+and flushing it, update the slot entries as we go../src/part_file.cpp:353 if (block_to_copy == m_piece_size)
{
m_free_slots.push_back(i->second);
m_piece_map.erase(i);
@@ -5390,8 +6159,8 @@ and flushing it, update the slot entries as we go../src/part_file.cpp:3
write_uint32(m_max_pieces, ptr);
write_uint32(m_piece_size, ptr);
- | ||
relevance 0 | ../src/peer_connection.cpp:509 | it would be neat to be able to print this straight into the alert's stack allocator |
it would be neat to be able to print this straight into the
-alert's stack allocator../src/peer_connection.cpp:509 if (!interested) send_not_interested();
+ | ||
relevance 0 | ../src/peer_connection.cpp:512 | it would be neat to be able to print this straight into the alert's stack allocator |
it would be neat to be able to print this straight into the
+alert's stack allocator../src/peer_connection.cpp:512 if (!interested) send_not_interested();
else t->peer_is_interesting(*this);
TORRENT_ASSERT(in_handshake() || is_interesting() == interested);
@@ -5442,7 +6211,7 @@ alert's stack allocator../src/peer_connection.cpp:509relevance 0 | ../src/peer_connection.cpp:1009 | this should be the global download rate |
|
this should be the global download rate../src/peer_connection.cpp:1009
+ | ||
relevance 0 | ../src/peer_connection.cpp:1013 | this should be the global download rate |
this should be the global download rate../src/peer_connection.cpp:1013
int rate = 0;
// if we haven't received any data recently, the current download rate
@@ -5476,7 +6245,7 @@ alert's stack allocator../src/peer_connection.cpp:509 | ||
relevance 0 | ../src/peer_connection.cpp:3282 | sort the allowed fast set in priority order |
sort the allowed fast set in priority order../src/peer_connection.cpp:3282
+ | ||
relevance 0 | ../src/peer_connection.cpp:3290 | sort the allowed fast set in priority order |
sort the allowed fast set in priority order../src/peer_connection.cpp:3290
// if the peer has the piece and we want
// to download it, request it
if (int(m_have_piece.size()) > index
@@ -5522,7 +6291,7 @@ alert's stack allocator../src/peer_connection.cpp:509 | ||
relevance 0 | ../src/peer_connection.cpp:6048 | The stats checks can not be honored when authenticated encryption is in use because we may have encrypted data which we cannot authenticate yet |
The stats checks can not be honored when authenticated encryption is in use
-because we may have encrypted data which we cannot authenticate yet../src/peer_connection.cpp:6048 peer_log(peer_log_alert::incoming, "READ"
+ | ||
relevance 0 | ../src/peer_connection.cpp:6092 | The stats checks can not be honored when authenticated encryption is in use because we may have encrypted data which we cannot authenticate yet |
The stats checks can not be honored when authenticated encryption is in use
+because we may have encrypted data which we cannot authenticate yet../src/peer_connection.cpp:6092 peer_log(peer_log_alert::incoming, "READ"
, "%d bytes", int(bytes_transferred));
#endif
// correct the dl quota usage, if not all of the buffer was actually read
@@ -5596,11 +6365,11 @@ because we may have encrypted data which we cannot authenticate yet../s
}
if (num_loops > read_loops) break;
- | ||
relevance 0 | ../src/piece_picker.cpp:2070 | this could probably be optimized by incrementally calling partial_sort to sort one more element in the list. Because chances are that we'll just need a single piece, and once we've picked from it we're done. Sorting the rest of the list in that case is a waste of time. |
this could probably be optimized by incrementally
+ | ||
relevance 0 | ../src/piece_picker.cpp:2048 | this could probably be optimized by incrementally calling partial_sort to sort one more element in the list. Because chances are that we'll just need a single piece, and once we've picked from it we're done. Sorting the rest of the list in that case is a waste of time. |
this could probably be optimized by incrementally
calling partial_sort to sort one more element in the list. Because
chances are that we'll just need a single piece, and once we've
picked from it we're done. Sorting the rest of the list in that
-case is a waste of time.../src/piece_picker.cpp:2070 , end(m_downloads[piece_pos::piece_downloading].end()); i != end; ++i)
+case is a waste of time.../src/piece_picker.cpp:2048 , end(m_downloads[piece_pos::piece_downloading].end()); i != end; ++i)
{
pc.inc_stats_counter(counters::piece_picker_partial_loops);
@@ -5651,8 +6420,8 @@ case is a waste of time.../src/piece_picker.cpp:2070relevance 0 | ../src/piece_picker.cpp:2575 | when expanding pieces for cache stripe reasons, the !downloading condition doesn't make much sense |
|
when expanding pieces for cache stripe reasons,
-the !downloading condition doesn't make much sense../src/piece_picker.cpp:2575 TORRENT_ASSERT(index < (int)m_piece_map.size() || m_piece_map.empty());
+ | ||
relevance 0 | ../src/piece_picker.cpp:2553 | when expanding pieces for cache stripe reasons, the !downloading condition doesn't make much sense |
when expanding pieces for cache stripe reasons,
+the !downloading condition doesn't make much sense../src/piece_picker.cpp:2553 TORRENT_ASSERT(index < (int)m_piece_map.size() || m_piece_map.empty());
if (index+1 == (int)m_piece_map.size())
return m_blocks_in_last_piece;
else
@@ -5700,8 +6469,8 @@ the !downloading condition doesn't make much sense../src/piece_picker.c
// blocks from this piece.
// the second bool is true if this is the only active peer that is requesting
// and downloading blocks from this piece. Active means having a connection.
- | ||
relevance 0 | ../src/session_impl.cpp:504 | there's no rule here to make uTP connections not have the global or local rate limits apply to it. This used to be the default. |
there's no rule here to make uTP connections not have the global or
-local rate limits apply to it. This used to be the default.../src/session_impl.cpp:504 m_global_class = m_classes.new_peer_class("global");
+ | ||
relevance 0 | ../src/session_impl.cpp:520 | there's no rule here to make uTP connections not have the global or local rate limits apply to it. This used to be the default. |
there's no rule here to make uTP connections not have the global or
+local rate limits apply to it. This used to be the default.../src/session_impl.cpp:520 m_global_class = m_classes.new_peer_class("global");
m_tcp_peer_class = m_classes.new_peer_class("tcp");
m_local_peer_class = m_classes.new_peer_class("local");
// local peers are always unchoked
@@ -5724,10 +6493,8 @@ local rate limits apply to it. This used to be the default.../src/sessi
#ifndef TORRENT_DISABLE_LOGGING
- session_log("config: %s\n"
- "version: %s\n"
- "revision: %s\n\n"
- , TORRENT_CFG_STRING
+ session_log("config: %s version: %s revision: %s"
+ , TORRENT_CFG_STRING
, LIBTORRENT_VERSION
, LIBTORRENT_REVISION);
@@ -5752,11 +6519,64 @@ local rate limits apply to it. This used to be the default.../src/sessi
, int(rl.rlim_cur * 8 / 10)));
// 20% goes towards regular files (see disk_io_thread)
#ifndef TORRENT_DISABLE_LOGGING
- | ||
relevance 0 | ../src/session_impl.cpp:1731 | instead of having a special case for this, just make the default listen interfaces be "0.0.0.0:6881,[::1]:6881" and use the generic path. That would even allow for not listening at all. |
instead of having a special case for this, just make the
+ session_log(" max connections: %d", m_settings.get_int(settings_pack::connections_limit));
+ session_log(" max files: %d", int(rl.rlim_cur * 2 / 10));
+ | ||
relevance 0 | ../src/session_impl.cpp:1555 | it would be nice to reserve() these vectors up front |
it would be nice to reserve() these vectors up front../src/session_impl.cpp:1555
+ bandwidth_channel* ch = &p->channel[peer_connection::download_channel];
+ if (use_quota_overhead(ch, amount_down))
+ ret |= 1 << peer_connection::download_channel;
+ ch = &p->channel[peer_connection::upload_channel];
+ if (use_quota_overhead(ch, amount_up))
+ ret |= 1 << peer_connection::upload_channel;
+ }
+ return ret;
+ }
+
+ // session_impl is responsible for deleting 'pack'
+ void session_impl::apply_settings_pack(boost::shared_ptr<settings_pack> pack)
+ {
+ apply_settings_pack_impl(*pack);
+ }
+
+ settings_pack session_impl::get_settings() const
+ {
+ settings_pack ret;
+ for (int i = settings_pack::string_type_base;
+ i < settings_pack::max_string_setting_internal; ++i)
+ {
+ ret.set_str(i, m_settings.get_str(i));
+ }
+ for (int i = settings_pack::int_type_base;
+ i < settings_pack::max_int_setting_internal; ++i)
+ {
+ ret.set_int(i, m_settings.get_int(i));
+ }
+ for (int i = settings_pack::bool_type_base;
+ i < settings_pack::max_bool_setting_internal; ++i)
+ {
+ ret.set_bool(i, m_settings.get_bool(i));
+ }
+ return ret;
+ }
+
+ void session_impl::apply_settings_pack_impl(settings_pack const& pack)
+ {
+ bool reopen_listen_port =
+ (pack.has_val(settings_pack::ssl_listen)
+ && pack.get_int(settings_pack::ssl_listen)
+ != m_settings.get_int(settings_pack::ssl_listen))
+ || (pack.has_val(settings_pack::listen_interfaces)
+ && pack.get_str(settings_pack::listen_interfaces)
+ != m_settings.get_str(settings_pack::listen_interfaces));
+
+ apply_pack(&pack, m_settings, this);
+ m_disk_thread.set_settings(&pack, m_alerts);
+
+ | ||
relevance 0 | ../src/session_impl.cpp:1798 | instead of having a special case for this, just make the default listen interfaces be "0.0.0.0:6881,[::1]:6881" and use the generic path. That would even allow for not listening at all. |
instead of having a special case for this, just make the
default listen interfaces be "0.0.0.0:6881,[::1]:6881" and use
-the generic path. That would even allow for not listening at all.../src/session_impl.cpp:1731
- // reset the retry counter
- m_listen_port_retries = m_settings.get_int(settings_pack::max_retry_port_bind);
+the generic path. That would even allow for not listening at all.../src/session_impl.cpp:1798 error_code ec;
+
+ int listen_port_retries = m_settings.get_int(settings_pack::max_retry_port_bind);
retry:
@@ -5778,12 +6598,13 @@ retry:
{
// this means we should open two listen sockets
// one for IPv4 and one for IPv6
-
+ int retries = m_settings.get_int(settings_pack::max_retry_port_bind);
+
listen_socket_t s = setup_listener("0.0.0.0", true
, m_listen_interface.port()
- , m_listen_port_retries, flags, ec);
+ , flags, ec);
- if (s.sock)
+ if (!ec && s.sock)
{
// update the listen_interface member with the
// actual port we ended up listening on, so that the other
@@ -5797,20 +6618,19 @@ retry:
#ifdef TORRENT_USE_OPENSSL
if (m_settings.get_int(settings_pack::ssl_listen))
{
- int retries = 10;
+ int retries = m_settings.get_int(settings_pack::max_retry_port_bind);
listen_socket_t s = setup_listener("0.0.0.0", true
, m_settings.get_int(settings_pack::ssl_listen)
- , retries, flags | open_ssl_socket, ec);
+ , flags | open_ssl_socket, ec);
- if (s.sock)
+ if (!ec && s.sock)
{
- TORRENT_ASSERT(!m_abort);
- | ||
relevance 0 | ../src/session_impl.cpp:2624 | should this function take a shared_ptr instead? |
should this function take a shared_ptr instead?../src/session_impl.cpp:2624 {
+ | ||
relevance 0 | ../src/session_impl.cpp:2687 | should this function take a shared_ptr instead? |
should this function take a shared_ptr instead?../src/session_impl.cpp:2687 {
#if defined TORRENT_ASIO_DEBUGGING
complete_async("session_impl::on_socks_accept");
#endif
m_socks_listen_socket.reset();
- if (e == asio::error::operation_aborted) return;
+ if (e == boost::asio::error::operation_aborted) return;
if (e)
{
if (m_alerts.should_post<listen_failed_alert>())
@@ -5856,7 +6676,7 @@ retry:
TORRENT_ASSERT(sp.use_count() > 0);
connection_map::iterator i = m_connections.find(sp);
- | ||
relevance 0 | ../src/session_impl.cpp:2983 | have a separate list for these connections, instead of having to loop through all of them |
have a separate list for these connections, instead of having to loop through all of them../src/session_impl.cpp:2983 if (m_auto_manage_time_scaler < 0)
+ | ||
relevance 0 | ../src/session_impl.cpp:3035 | have a separate list for these connections, instead of having to loop through all of them |
have a separate list for these connections, instead of having to loop through all of them../src/session_impl.cpp:3035 if (m_auto_manage_time_scaler < 0)
{
INVARIANT_CHECK;
m_auto_manage_time_scaler = settings().get_int(settings_pack::auto_manage_interval);
@@ -5876,8 +6696,11 @@ retry:
// are ticked through the torrents' second_tick
if (!p->associated_torrent().expired()) continue;
- if (m_last_tick - p->connected_time()
- > seconds(m_settings.get_int(settings_pack::handshake_timeout)))
+ int timeout = m_settings.get_int(settings_pack::handshake_timeout);
+ #if TORRENT_USE_I2P
+ timeout *= is_i2p(*p->get_socket()) ? 4 : 1;
+#endif
+ if (m_last_tick - p->connected_time () > seconds(timeout))
p->disconnect(errors::timed_out, op_bittorrent);
}
@@ -5904,8 +6727,7 @@ retry:
// to not miss the torrent after it
if (!t.want_tick()) --i;
}
-
- | ||
relevance 0 | ../src/session_impl.cpp:3013 | this should apply to all bandwidth channels |
this should apply to all bandwidth channels../src/session_impl.cpp:3013#if TORRENT_DEBUG_STREAMING > 0
+ | ||
relevance 0 | ../src/session_impl.cpp:3068 | this should apply to all bandwidth channels |
this should apply to all bandwidth channels../src/session_impl.cpp:3068#if TORRENT_DEBUG_STREAMING > 0
printf("\033[2J\033[0;0H");
#endif
@@ -5949,126 +6771,16 @@ retry:
m_peak_up_rate = (std::max)(m_stat.upload_rate(), m_peak_up_rate);
m_peak_down_rate = (std::max)(m_stat.download_rate(), m_peak_down_rate);
-
+
m_stat.second_tick(tick_interval_ms);
// --------------------------------------------------------------
// scrape paused torrents that are auto managed
// (unless the session is paused)
// --------------------------------------------------------------
- | ||
relevance 0 | ../src/session_impl.cpp:3500 | these vectors could be copied from m_torrent_lists, if we would maintain them. That way the first pass over all torrents could be avoided. It would be especially efficient if most torrents are not auto-managed whenever we receive a scrape response (or anything that may change the rank of a torrent) that one torrent could re-sort itself in a list that's kept sorted at all times. That way, this pass over all torrents could be avoided alltogether. |
these vectors could be copied from m_torrent_lists,
-if we would maintain them. That way the first pass over
-all torrents could be avoided. It would be especially
-efficient if most torrents are not auto-managed
-whenever we receive a scrape response (or anything
-that may change the rank of a torrent) that one torrent
-could re-sort itself in a list that's kept sorted at all
-times. That way, this pass over all torrents could be
-avoided alltogether.../src/session_impl.cpp:3500 if (t->allows_peers())
- t->log_to_all_peers("auto manager pausing torrent");
-#endif
- // use graceful pause for auto-managed torrents
- t->set_allow_peers(false, true);
- }
- }
- }
-
- void session_impl::recalculate_auto_managed_torrents()
- {
- INVARIANT_CHECK;
-
- m_last_auto_manage = time_now();
- m_need_auto_manage = false;
-
- if (is_paused()) return;
-
- // these vectors are filled with auto managed torrents
-
- std::vector<torrent*> checking;
- std::vector<torrent*> downloaders;
- downloaders.reserve(m_torrents.size());
- std::vector<torrent*> seeds;
- seeds.reserve(m_torrents.size());
-
- // these counters are set to the number of torrents
- // of each kind we're allowed to have active
- int num_downloaders = settings().get_int(settings_pack::active_downloads);
- int num_seeds = settings().get_int(settings_pack::active_seeds);
- int checking_limit = 1;
- int dht_limit = settings().get_int(settings_pack::active_dht_limit);
- int tracker_limit = settings().get_int(settings_pack::active_tracker_limit);
- int lsd_limit = settings().get_int(settings_pack::active_lsd_limit);
- int hard_limit = settings().get_int(settings_pack::active_limit);
-
- if (num_downloaders == -1)
- num_downloaders = (std::numeric_limits<int>::max)();
- if (num_seeds == -1)
- num_seeds = (std::numeric_limits<int>::max)();
- if (hard_limit == -1)
- hard_limit = (std::numeric_limits<int>::max)();
- if (dht_limit == -1)
- dht_limit = (std::numeric_limits<int>::max)();
- if (lsd_limit == -1)
- lsd_limit = (std::numeric_limits<int>::max)();
- if (tracker_limit == -1)
- tracker_limit = (std::numeric_limits<int>::max)();
-
- for (torrent_map::iterator i = m_torrents.begin()
- , end(m_torrents.end()); i != end; ++i)
- | ||
relevance 0 | ../src/session_impl.cpp:3577 | allow extensions to sort torrents for queuing |
allow extensions to sort torrents for queuing../src/session_impl.cpp:3577 if (t->is_finished())
- seeds.push_back(t);
- else
- downloaders.push_back(t);
- }
- else if (!t->is_paused())
- {
- if (t->state() == torrent_status::checking_files)
- {
- if (checking_limit > 0) --checking_limit;
- continue;
- }
- TORRENT_ASSERT(t->m_resume_data_loaded || !t->valid_metadata());
- --hard_limit;
- }
- }
-
- bool handled_by_extension = false;
-
-#ifndef TORRENT_DISABLE_EXTENSIONS
-#endif
-
- if (!handled_by_extension)
- {
- std::sort(checking.begin(), checking.end()
- , boost::bind(&torrent::sequence_number, _1) < boost::bind(&torrent::sequence_number, _2));
-
- std::sort(downloaders.begin(), downloaders.end()
- , boost::bind(&torrent::sequence_number, _1) < boost::bind(&torrent::sequence_number, _2));
-
- std::sort(seeds.begin(), seeds.end()
- , boost::bind(&torrent::seed_rank, _1, boost::ref(m_settings))
- > boost::bind(&torrent::seed_rank, _2, boost::ref(m_settings)));
- }
-
- auto_manage_torrents(checking, checking_limit, dht_limit, tracker_limit, lsd_limit
- , hard_limit, num_downloaders);
-
- if (settings().get_bool(settings_pack::auto_manage_prefer_seeds))
- {
- auto_manage_torrents(seeds, checking_limit, dht_limit, tracker_limit, lsd_limit
- , hard_limit, num_seeds);
- auto_manage_torrents(downloaders, checking_limit, dht_limit, tracker_limit, lsd_limit
- , hard_limit, num_downloaders);
- }
- else
- {
- auto_manage_torrents(downloaders, checking_limit, dht_limit, tracker_limit, lsd_limit
- , hard_limit, num_downloaders);
- auto_manage_torrents(seeds, checking_limit, dht_limit, tracker_limit, lsd_limit
- , hard_limit, num_seeds);
- | ||
relevance 0 | ../src/session_impl.cpp:3750 | use a lower limit than m_settings.connections_limit to allocate the to 10% or so of connection slots for incoming connections |
use a lower limit than m_settings.connections_limit
+ | ||
relevance 0 | ../src/session_impl.cpp:3791 | use a lower limit than m_settings.connections_limit to allocate the to 10% or so of connection slots for incoming connections |
use a lower limit than m_settings.connections_limit
to allocate the to 10% or so of connection slots for incoming
-connections../src/session_impl.cpp:3750 // robin fashion, so that every torrent is equally likely to connect to a
+connections../src/session_impl.cpp:3791 // robin fashion, so that every torrent is equally likely to connect to a
// peer
// boost connections are connections made by torrent connection
@@ -6119,13 +6831,9 @@ connections../src/session_impl.cpp:3750relevance 0 | ../src/session_impl.cpp:3893 | post a message to have this happen immediately instead of waiting for the next tick |
|
post a message to have this happen
-immediately instead of waiting for the next tick../src/session_impl.cpp:3893 torrent* t = p->associated_torrent().lock().get();
- torrent_peer* pi = p->peer_info_struct();
-
- if (p->ignore_unchoke_slots() || t == 0 || pi == 0
- || pi->web_seed || t->is_paused())
- continue;
+ | ||
relevance 0 | ../src/session_impl.cpp:3941 | post a message to have this happen immediately instead of waiting for the next tick |
post a message to have this happen
+immediately instead of waiting for the next tick../src/session_impl.cpp:3941 continue;
+ }
if (!p->is_peer_interested()
|| p->is_disconnecting()
@@ -6133,7 +6841,11 @@ immediately instead of waiting for the next tick../src/session_impl.cpp
{
// this peer is not unchokable. So, if it's unchoked
// already, make sure to choke it.
- if (p->is_choked()) continue;
+ if (p->is_choked())
+ {
+ p->reset_choke_counters();
+ continue;
+ }
if (pi && pi->optimistically_unchoked)
{
m_stats_counters.inc_stats_counter(counters::num_peers_up_unchoked_optimistic, -1);
@@ -6142,6 +6854,7 @@ immediately instead of waiting for the next tick../src/session_impl.cpp
m_optimistic_unchoke_time_scaler = 0;
}
t->choke_peer(*p);
+ p->reset_choke_counters();
continue;
}
@@ -6169,68 +6882,16 @@ immediately instead of waiting for the next tick../src/session_impl.cpp
m_stats_counters.set_value(counters::num_unchoke_slots
, allowed_upload_slots);
- int num_opt_unchoke = m_settings.get_int(settings_pack::num_optimistic_unchoke_slots);
- if (num_opt_unchoke == 0) num_opt_unchoke = (std::max)(1, allowed_upload_slots / 5);
- | ||
relevance 0 | ../src/session_impl.cpp:3940 | this should be called for all peers! |
this should be called for all peers!../src/session_impl.cpp:3940 , unchoke_interval, m_settings);
- m_stats_counters.set_value(counters::num_unchoke_slots
- , allowed_upload_slots);
-
- int num_opt_unchoke = m_settings.get_int(settings_pack::num_optimistic_unchoke_slots);
- if (num_opt_unchoke == 0) num_opt_unchoke = (std::max)(1, allowed_upload_slots / 5);
-
- // reserve some upload slots for optimistic unchokes
- int unchoke_set_size = allowed_upload_slots;
-
- // go through all the peers and unchoke the first ones and choke
- // all the other ones.
- for (std::vector<peer_connection*>::iterator i = peers.begin()
- , end(peers.end()); i != end; ++i)
- {
- peer_connection* p = *i;
- TORRENT_ASSERT(p);
- TORRENT_ASSERT(!p->ignore_unchoke_slots());
-
- // this will update the m_uploaded_at_last_unchoke
- p->reset_choke_counters();
-
- torrent* t = p->associated_torrent().lock().get();
- TORRENT_ASSERT(t);
-
- if (unchoke_set_size > 0)
- {
- // yes, this peer should be unchoked
- if (p->is_choked())
- {
- if (!t->unchoke_peer(*p))
- continue;
- }
-
- --unchoke_set_size;
-
- TORRENT_ASSERT(p->peer_info_struct());
- if (p->peer_info_struct()->optimistically_unchoked)
- {
- // force a new optimistic unchoke
- // since this one just got promoted into the
- // proper unchoke set
- m_optimistic_unchoke_time_scaler = 0;
- p->peer_info_struct()->optimistically_unchoked = false;
- m_stats_counters.inc_stats_counter(counters::num_peers_up_unchoked_optimistic, -1);
- }
- }
- else
- {
- // no, this peer should be choked
- TORRENT_ASSERT(p->peer_info_struct());
- | ||
relevance 0 | ../src/session_impl.cpp:4346 | it might be a nice feature here to limit the number of torrents to send in a single update. By just posting the first n torrents, they would nicely be round-robined because the torrent lists are always pushed back. Perhaps the status_update_alert could even have a fixed array of n entries rather than a vector, to further improve memory locality. |
it might be a nice feature here to limit the number of torrents
+#ifndef TORRENT_DISABLE_LOGGING
+ | ||
relevance 0 | ../src/session_impl.cpp:4324 | it might be a nice feature here to limit the number of torrents to send in a single update. By just posting the first n torrents, they would nicely be round-robined because the torrent lists are always pushed back. Perhaps the status_update_alert could even have a fixed array of n entries rather than a vector, to further improve memory locality. |
it might be a nice feature here to limit the number of torrents
to send in a single update. By just posting the first n torrents, they
would nicely be round-robined because the torrent lists are always
pushed back. Perhaps the status_update_alert could even have a fixed
array of n entries rather than a vector, to further improve memory
-locality.../src/session_impl.cpp:4346 t->status(&*i, flags);
+locality.../src/session_impl.cpp:4324 t->status(&*i, flags);
}
}
-
+
void session_impl::post_torrent_updates(boost::uint32_t flags)
{
INVARIANT_CHECK;
@@ -6278,7 +6939,59 @@ locality.../src/session_impl.cpp:4346relevance 0 | ../src/storage.cpp:731 | make this more generic to not just work if files have been renamed, but also if they have been merged into a single file for instance maybe use the same format as .torrent files and reuse some code from torrent_info |
|
make this more generic to not just work if files have been
+ | ||
relevance 0 | ../src/session_impl.cpp:4530 | this logic could probably be less spaghetti looking by being moved to a function with early exits |
this logic could probably be less spaghetti looking by being
+moved to a function with early exits../src/session_impl.cpp:4530 }
+
+ // figure out the info hash of the torrent
+ sha1_hash const* ih = 0;
+ sha1_hash tmp;
+ if (params.ti) ih = ¶ms.ti->info_hash();
+ else if (!params.url.empty())
+ {
+ // in order to avoid info-hash collisions, for
+ // torrents where we don't have an info-hash, but
+ // just a URL, set the temporary info-hash to the
+ // hash of the URL. This will be changed once we
+ // have the actual .torrent file
+ tmp = hasher(¶ms.url[0], params.url.size()).final();
+ ih = &tmp;
+ }
+ else ih = ¶ms.info_hash;
+
+ // we don't have a torrent file. If the user provided
+ // resume data, there may be some metadata in there
+ if ((!params.ti || !params.ti->is_valid())
+ && !params.resume_data.empty())
+ {
+ int pos;
+ error_code ec;
+ bdecode_node tmp;
+ bdecode_node info;
+#ifndef TORRENT_DISABLE_LOGGING
+ session_log("adding magnet link with resume data");
+#endif
+ if (bdecode(¶ms.resume_data[0], ¶ms.resume_data[0]
+ + params.resume_data.size(), tmp, ec, &pos) == 0
+ && tmp.type() == bdecode_node::dict_t
+ && (info = tmp.dict_find_dict("info")))
+ {
+#ifndef TORRENT_DISABLE_LOGGING
+ session_log("found metadata in resume data");
+#endif
+ // verify the info-hash of the metadata stored in the resume file matches
+ // the torrent we're loading
+
+ std::pair<char const*, int> buf = info.data_section();
+ sha1_hash resume_ih = hasher(buf.first, buf.second).final();
+
+ // if url is set, the info_hash is not actually the info-hash of the
+ // torrent, but the hash of the URL, until we have the full torrent
+ // only require the info-hash to match if we actually passed in one
+ if (resume_ih == params.info_hash
+ || !params.url.empty()
+ || params.info_hash.is_all_zeros())
+ {
+ | ||
relevance 0 | ../src/storage.cpp:731 | make this more generic to not just work if files have been renamed, but also if they have been merged into a single file for instance maybe use the same format as .torrent files and reuse some code from torrent_info |
make this more generic to not just work if files have been
renamed, but also if they have been merged into a single file for instance
maybe use the same format as .torrent files and reuse some code from torrent_info../src/storage.cpp:731 if (file_offset < files().file_size(file_index))
break;
@@ -6287,7 +7000,7 @@ maybe use the same format as .torrent files and reuse some code from torrent_inf
++file_index;
TORRENT_ASSERT(file_index != files().num_files());
}
-
+
error_code ec;
file_handle handle = open_file_impl(file_index, file::read_only, ec);
if (ec) return slot;
@@ -6311,7 +7024,7 @@ maybe use the same format as .torrent files and reuse some code from torrent_inf
m_mapped_files->rename_file(i, new_filename);
}
}
-
+
bdecode_node file_priority = rd.dict_find_list("file_priority");
if (file_priority && file_priority.list_size()
== files().num_files())
@@ -6329,9 +7042,9 @@ maybe use the same format as .torrent files and reuse some code from torrent_inf
ec.operation = storage_error::check_resume;
return false;
}
-
+
if (file_sizes_ent.list_size() == 0)
- | ||
relevance 0 | ../src/storage.cpp:1062 | if everything moves OK, except for the partfile we currently won't update the save path, which breaks things. it would probably make more sense to give up on the partfile |
if everything moves OK, except for the partfile
+ | ||
relevance 0 | ../src/storage.cpp:1062 | if everything moves OK, except for the partfile we currently won't update the save path, which breaks things. it would probably make more sense to give up on the partfile |
if everything moves OK, except for the partfile
we currently won't update the save path, which breaks things.
it would probably make more sense to give up on the partfile../src/storage.cpp:1062 if (ec)
{
@@ -6358,7 +7071,7 @@ it would probably make more sense to give up on the partfile../src/stor
{
ec.file = -1;
ec.operation = storage_error::partfile_move;
- return piece_manager::fatal_disk_error;
+ return piece_manager::fatal_disk_error;
}
}
@@ -6384,7 +7097,7 @@ it would probably make more sense to give up on the partfile../src/stor
{
fileop op = { &file::writev
, file::read_write | flags };
- | ||
relevance 0 | ../src/string_util.cpp:60 | warning C4146: unary minus operator applied to unsigned type, result still unsigned |
warning C4146: unary minus operator applied to unsigned type,
+ | ||
relevance 0 | ../src/string_util.cpp:60 | warning C4146: unary minus operator applied to unsigned type, result still unsigned |
warning C4146: unary minus operator applied to unsigned type,
result still unsigned../src/string_util.cpp:60
#include <boost/tuple/tuple.hpp>
@@ -6436,8 +7149,59 @@ namespace libtorrent
return (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c;
}
- | ||
relevance 0 | ../src/torrent.cpp:515 | if the existing torrent doesn't have metadata, insert the metadata we just downloaded into it. |
if the existing torrent doesn't have metadata, insert
-the metadata we just downloaded into it.../src/torrent.cpp:515
+ | ||
relevance 0 | ../src/torrent.cpp:97 | factor out cache_status to its own header |
factor out cache_status to its own header../src/torrent.cpp:97#include "libtorrent/extensions.hpp"
+#include "libtorrent/aux_/session_interface.hpp"
+#include "libtorrent/instantiate_connection.hpp"
+#include "libtorrent/assert.hpp"
+#include "libtorrent/broadcast_socket.hpp"
+#include "libtorrent/kademlia/dht_tracker.hpp"
+#include "libtorrent/peer_info.hpp"
+#include "libtorrent/http_connection.hpp"
+#include "libtorrent/random.hpp"
+#include "libtorrent/peer_class.hpp" // for peer_class
+#include "libtorrent/socket_io.hpp" // for read_*_endpoint
+#include "libtorrent/ip_filter.hpp"
+#include "libtorrent/request_blocks.hpp"
+#include "libtorrent/performance_counters.hpp" // for counters
+#include "libtorrent/resolver_interface.hpp"
+#include "libtorrent/alloca.hpp"
+#include "libtorrent/resolve_links.hpp"
+#include "libtorrent/aux_/file_progress.hpp"
+#include "libtorrent/alert_manager.hpp"
+#include "libtorrent/disk_interface.hpp"
+#include "libtorrent/disk_io_thread.hpp" // for cache_status
+
+#ifndef TORRENT_DISABLE_LOGGING
+#include "libtorrent/aux_/session_impl.hpp" // for tracker_logger
+#endif
+
+using namespace libtorrent;
+using boost::tuples::tuple;
+using boost::tuples::get;
+using boost::tuples::make_tuple;
+
+namespace libtorrent
+{
+ namespace {
+
+ int root2(int x)
+ {
+ int ret = 0;
+ x >>= 1;
+ while (x > 0)
+ {
+ // if this assert triggers, the block size
+ // is not an even 2 exponent!
+ TORRENT_ASSERT(x == 1 || (x & 1) == 0);
+ ++ret;
+ x >>= 1;
+ }
+ return ret;
+ }
+
+ } // anonymous namespace
+ | ||
relevance 0 | ../src/torrent.cpp:458 | if the existing torrent doesn't have metadata, insert the metadata we just downloaded into it. |
if the existing torrent doesn't have metadata, insert
+the metadata we just downloaded into it.../src/torrent.cpp:458
m_torrent_file = tf;
// now, we might already have this torrent in the session.
@@ -6488,8 +7252,8 @@ the metadata we just downloaded into it.../src/torrent.cpp:515 | ||
relevance 0 | ../src/torrent.cpp:666 | if the existing torrent doesn't have metadata, insert the metadata we just downloaded into it. |
if the existing torrent doesn't have metadata, insert
-the metadata we just downloaded into it.../src/torrent.cpp:666 m_torrent_file = tf;
+ | ||
relevance 0 | ../src/torrent.cpp:608 | if the existing torrent doesn't have metadata, insert the metadata we just downloaded into it. |
if the existing torrent doesn't have metadata, insert
+the metadata we just downloaded into it.../src/torrent.cpp:608 m_torrent_file = tf;
m_info_hash = tf->info_hash();
// now, we might already have this torrent in the session.
@@ -6540,12 +7304,12 @@ the metadata we just downloaded into it.../src/torrent.cpp:666 | ||
relevance 0 | ../src/torrent.cpp:1475 | is verify_peer_cert called once per certificate in the chain, and this function just tells us which depth we're at right now? If so, the comment makes sense. any certificate that isn't the leaf (i.e. the one presented by the peer) should be accepted automatically, given preverified is true. The leaf certificate need to be verified to make sure its DN matches the info-hash |
is verify_peer_cert called once per certificate in the chain, and
+ | ||
relevance 0 | ../src/torrent.cpp:1534 | is verify_peer_cert called once per certificate in the chain, and this function just tells us which depth we're at right now? If so, the comment makes sense. any certificate that isn't the leaf (i.e. the one presented by the peer) should be accepted automatically, given preverified is true. The leaf certificate need to be verified to make sure its DN matches the info-hash |
is verify_peer_cert called once per certificate in the chain, and
this function just tells us which depth we're at right now? If so, the comment
makes sense.
any certificate that isn't the leaf (i.e. the one presented by the peer)
should be accepted automatically, given preverified is true. The leaf certificate
-need to be verified to make sure its DN matches the info-hash../src/torrent.cpp:1475 if (pp) p->add_extension(pp);
+need to be verified to make sure its DN matches the info-hash../src/torrent.cpp:1534 if (pp) p->add_extension(pp);
}
// if files are checked for this torrent, call the extension
@@ -6596,17 +7360,17 @@ need to be verified to make sure its DN matches the info-hash../src/tor
{
#ifndef TORRENT_DISABLE_LOGGING
match = true;
- | ||
relevance 0 | ../src/torrent.cpp:1882 | instead of creating the picker up front here, maybe this whole section should move to need_picker() |
instead of creating the picker up front here,
-maybe this whole section should move to need_picker()../src/torrent.cpp:1882
- if (m_seed_mode)
- {
- m_have_all = true;
+ | ||
relevance 0 | ../src/torrent.cpp:1942 | instead of creating the picker up front here, maybe this whole section should move to need_picker() |
instead of creating the picker up front here,
+maybe this whole section should move to need_picker()../src/torrent.cpp:1942 m_have_all = true;
m_ses.get_io_service().post(boost::bind(&torrent::files_checked, shared_from_this()));
m_resume_data.reset();
update_gauge();
+ update_state_list();
return;
}
+ set_state(torrent_status::checking_resume_data);
+
int num_pad_files = 0;
TORRENT_ASSERT(block_size() > 0);
file_storage const& fs = m_torrent_file->files();
@@ -6616,7 +7380,7 @@ maybe this whole section should move to need_picker()../src/torrent.cpp
if (!fs.pad_file_at(i) || fs.file_size(i) == 0) continue;
m_padding += boost::uint32_t(fs.file_size(i));
-
+
need_picker();
peer_request pr = m_torrent_file->map_file(i, 0, fs.file_size(i));
@@ -6648,8 +7412,8 @@ maybe this whole section should move to need_picker()../src/torrent.cpp
// need to consider it finished
std::vector<piece_picker::downloading_piece> dq
- | ||
relevance 0 | ../src/torrent.cpp:1957 | this could be optimized by looking up which files are complete and just look at those |
this could be optimized by looking up which files are
-complete and just look at those../src/torrent.cpp:1957 if (!need_loaded()) return;
+ | ||
relevance 0 | ../src/torrent.cpp:2016 | this could be optimized by looking up which files are complete and just look at those |
this could be optimized by looking up which files are
+complete and just look at those../src/torrent.cpp:2016 if (!need_loaded()) return;
if (num_pad_files > 0)
m_picker->set_num_pad_files(num_pad_files);
@@ -6683,8 +7447,8 @@ complete and just look at those../src/torrent.cpp:1957relevance 0 | ../src/torrent.cpp:1973 | this could be optimized by looking up which files are complete and just look at those |
|
this could be optimized by looking up which files are
-complete and just look at those../src/torrent.cpp:1973 i != end; ++i)
+ | ||
relevance 0 | ../src/torrent.cpp:2032 | this could be optimized by looking up which files are complete and just look at those |
this could be optimized by looking up which files are
+complete and just look at those../src/torrent.cpp:2032 i != end; ++i)
{
boost::shared_ptr<torrent> t = m_ses.find_torrent(*i).lock();
if (!t) continue;
@@ -6735,10 +7499,10 @@ complete and just look at those../src/torrent.cpp:1973relevance 0 | ../src/torrent.cpp:2140 | there may be peer extensions relying on the torrent extension still being alive. Only do this if there are no peers. And when the last peer is disconnected, if the torrent is unloaded, clear the extensions m_extensions.clear(); |
|
there may be peer extensions relying on the torrent extension
+ | ||
relevance 0 | ../src/torrent.cpp:2199 | there may be peer extensions relying on the torrent extension still being alive. Only do this if there are no peers. And when the last peer is disconnected, if the torrent is unloaded, clear the extensions m_extensions.clear(); |
there may be peer extensions relying on the torrent extension
still being alive. Only do this if there are no peers. And when the last peer
is disconnected, if the torrent is unloaded, clear the extensions
-m_extensions.clear();../src/torrent.cpp:2140 // pinned torrents are not allowed to be swapped out
+m_extensions.clear();../src/torrent.cpp:2199 // pinned torrents are not allowed to be swapped out
TORRENT_ASSERT(!m_pinned);
m_should_be_loaded = false;
@@ -6789,9 +7553,9 @@ m_extensions.clear();../src/torrent.cpp:2140relevance 0 | ../src/torrent.cpp:2816 | this pattern is repeated in a few places. Factor this into a function and generalize the concept of a torrent having a dedicated listen port |
|
this pattern is repeated in a few places. Factor this into
+ | ||
relevance 0 | ../src/torrent.cpp:2884 | this pattern is repeated in a few places. Factor this into a function and generalize the concept of a torrent having a dedicated listen port |
this pattern is repeated in a few places. Factor this into
a function and generalize the concept of a torrent having a
-dedicated listen port../src/torrent.cpp:2816 // if the files haven't been checked yet, we're
+dedicated listen port../src/torrent.cpp:2884 // if the files haven't been checked yet, we're
// not ready for peers. Except, if we don't have metadata,
// we need peers to download from
if (!m_files_checked && valid_metadata()) return;
@@ -6819,7 +7583,7 @@ dedicated listen port../src/torrent.cpp:2816 | ||
relevance 0 | ../src/torrent.cpp:3593 | add one peer per IP the hostname resolves to |
add one peer per IP the hostname resolves to../src/torrent.cpp:3593#endif
+ | ||
relevance 0 | ../src/torrent.cpp:3669 | add one peer per IP the hostname resolves to |
add one peer per IP the hostname resolves to../src/torrent.cpp:3669#endif
void torrent::on_peer_name_lookup(error_code const& e
, std::vector<address> const& host_list, int port)
@@ -6864,8 +7628,7 @@ dedicated listen port../src/torrent.cpp:2816 tcp::endpoint host(host_list.front(), port);
- if (m_apply_ip_filter
- && m_ses.get_ip_filter().access(host.address()) & ip_filter::blocked)
+ if (m_ip_filter && m_ip_filter->access(host.address()) & ip_filter::blocked)
{
#ifndef TORRENT_DISABLE_LOGGING
error_code ec;
@@ -6893,7 +7656,8 @@ dedicated listen port../src/torrent.cpp:2816relevance 0 | ../src/torrent.cpp:4587 | update suggest_piece? |
|
update suggest_piece?../src/torrent.cpp:4587
+// INVARIANT_CHECK;
+ | ||
relevance 0 | ../src/torrent.cpp:4601 | update suggest_piece? |
update suggest_piece?../src/torrent.cpp:4601
void torrent::peer_has_all(peer_connection const* peer)
{
if (has_picker())
@@ -6944,8 +7708,8 @@ dedicated listen port../src/torrent.cpp:2816relevance 0 | ../src/torrent.cpp:4730 | really, we should just keep the picker around in this case to maintain the availability counters |
|
really, we should just keep the picker around
-in this case to maintain the availability counters../src/torrent.cpp:4730 pieces.reserve(cs.pieces.size());
+ | ||
relevance 0 | ../src/torrent.cpp:4744 | really, we should just keep the picker around in this case to maintain the availability counters |
really, we should just keep the picker around
+in this case to maintain the availability counters../src/torrent.cpp:4744 pieces.reserve(cs.pieces.size());
// sort in ascending order, to get most recently used first
std::sort(cs.pieces.begin(), cs.pieces.end()
@@ -6996,17 +7760,17 @@ in this case to maintain the availability counters../src/torrent.cpp:47
}
void torrent::abort()
- | ||
relevance 0 | ../src/torrent.cpp:6704 | make this more generic to not just work if files have been renamed, but also if they have been merged into a single file for instance maybe use the same format as .torrent files and reuse some code from torrent_info The mapped_files needs to be read both in the network thread and in the disk thread, since they both have their own mapped files structures which are kept in sync |
make this more generic to not just work if files have been
+ | ||
relevance 0 | ../src/torrent.cpp:6734 | make this more generic to not just work if files have been renamed, but also if they have been merged into a single file for instance maybe use the same format as .torrent files and reuse some code from torrent_info The mapped_files needs to be read both in the network thread and in the disk thread, since they both have their own mapped files structures which are kept in sync |
make this more generic to not just work if files have been
renamed, but also if they have been merged into a single file for instance
maybe use the same format as .torrent files and reuse some code from torrent_info
The mapped_files needs to be read both in the network thread
and in the disk thread, since they both have their own mapped files structures
-which are kept in sync../src/torrent.cpp:6704 m_last_upload = tmp == -1 ? (std::numeric_limits<boost::int16_t>::min)() : now - tmp;
-
- if (m_use_resume_save_path)
- {
- std::string p = rd.dict_find_string_value("save_path");
- if (!p.empty()) m_save_path = p;
+which are kept in sync../src/torrent.cpp:6734 {
+ m_save_path = p;
+#ifndef TORRENT_DISABLE_LOGGING
+ debug_log("loaded resume data: save-path: %s", m_save_path.c_str());
+#endif
+ }
}
m_url = rd.dict_find_string_value("url");
@@ -7031,33 +7795,33 @@ which are kept in sync../src/torrent.cpp:6704 | ||
relevance 0 | ../src/torrent.cpp:6822 | if this is a merkle torrent and we can't restore the tree, we need to wipe all the bits in the have array, but not necessarily we might want to do a full check to see if we have all the pieces. This is low priority since almost no one uses merkle torrents |
if this is a merkle torrent and we can't
+ // this is suspicious, leave seed mode
+ if (m_file_priority[i] == 0) m_seed_mode = false;
+ | ||
relevance 0 | ../src/torrent.cpp:6858 | if this is a merkle torrent and we can't restore the tree, we need to wipe all the bits in the have array, but not necessarily we might want to do a full check to see if we have all the pieces. This is low priority since almost no one uses merkle torrents |
if this is a merkle torrent and we can't
restore the tree, we need to wipe all the
bits in the have array, but not necessarily
we might want to do a full check to see if we have
all the pieces. This is low priority since almost
-no one uses merkle torrents../src/torrent.cpp:6822 add_web_seed(url, web_seed_entry::http_seed);
+no one uses merkle torrents../src/torrent.cpp:6858 add_web_seed(url, web_seed_entry::http_seed);
}
}
@@ -7085,32 +7849,32 @@ no one uses merkle torrents../src/torrent.cpp:6822 | ||
relevance 0 | ../src/torrent.cpp:7013 | make this more generic to not just work if files have been renamed, but also if they have been merged into a single file for instance. using file_base |
make this more generic to not just work if files have been
+ bdecode_node piece_priority = rd.dict_find_string("piece_priority");
+ if (piece_priority && piece_priority.string_length()
+ == m_torrent_file->num_pieces())
+ {
+ | ||
relevance 0 | ../src/torrent.cpp:7083 | make this more generic to not just work if files have been renamed, but also if they have been merged into a single file for instance. using file_base |
make this more generic to not just work if files have been
renamed, but also if they have been merged into a single file for instance.
-using file_base../src/torrent.cpp:7013 pieces.resize(m_torrent_file->num_pieces());
+using file_base../src/torrent.cpp:7083 pieces.resize(m_torrent_file->num_pieces());
if (!has_picker())
{
std::memset(&pieces[0], m_have_all, pieces.size());
@@ -7161,9 +7925,9 @@ using file_base../src/torrent.cpp:7013relevance 0 | ../src/torrent.cpp:9028 | add a flag to ignore stats, and only care about resume data for content. For unchanged files, don't trigger a load of the metadata just to save an empty resume data file |
|
add a flag to ignore stats, and only care about resume data for
+ | ||
relevance 0 | ../src/torrent.cpp:9255 | add a flag to ignore stats, and only care about resume data for content. For unchanged files, don't trigger a load of the metadata just to save an empty resume data file |
add a flag to ignore stats, and only care about resume data for
content. For unchanged files, don't trigger a load of the metadata
-just to save an empty resume data file../src/torrent.cpp:9028 if (m_complete != 0xffffff) seeds = m_complete;
+just to save an empty resume data file../src/torrent.cpp:9255 if (m_complete != 0xffffff) seeds = m_complete;
else seeds = m_peer_list ? m_peer_list->num_seeds() : 0;
if (m_incomplete != 0xffffff) downloaders = m_incomplete;
@@ -7187,7 +7951,7 @@ just to save an empty resume data file../src/torrent.cpp:9028 {
TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK;
-
+
if (!valid_metadata())
{
alerts().emplace_alert<save_resume_data_failed_alert>(get_handle()
@@ -7214,8 +7978,8 @@ just to save an empty resume data file../src/torrent.cpp:9028 | ||
relevance 0 | ../src/torrent.cpp:10640 | instead of resorting the whole list, insert the peers directly into the right place |
instead of resorting the whole list, insert the peers
-directly into the right place../src/torrent.cpp:10640 printf("timed out [average-piece-time: %d ms ]\n"
+ | ||
relevance 0 | ../src/torrent.cpp:10859 | instead of resorting the whole list, insert the peers directly into the right place |
instead of resorting the whole list, insert the peers
+directly into the right place../src/torrent.cpp:10859 printf("timed out [average-piece-time: %d ms ]\n"
, m_average_piece_time);
#endif
}
@@ -7266,7 +8030,7 @@ directly into the right place../src/torrent.cpp:10640relevance 0 | ../src/torrent_peer.cpp:179 | how do we deal with our external address changing? |
|
how do we deal with our external address changing?../src/torrent_peer.cpp:179 , is_v6_addr(false)
+ | ||
relevance 0 | ../src/torrent_peer.cpp:179 | how do we deal with our external address changing? |
how do we deal with our external address changing?../src/torrent_peer.cpp:179 , is_v6_addr(false)
#endif
#if TORRENT_USE_I2P
, is_i2p_addr(false)
@@ -7293,6 +8057,17 @@ directly into the right place../src/torrent.cpp:10640 | ||
relevance 0 | ../src/udp_socket.cpp:288 | it would be nice to detect this on posix systems also |
it would be nice to detect this on posix systems also../src/udp_socket.cpp:288 --m_v6_outstanding;
+ | ||
relevance 0 | ../src/udp_socket.cpp:288 | it would be nice to detect this on posix systems also |
it would be nice to detect this on posix systems also../src/udp_socket.cpp:288 --m_v6_outstanding;
}
else
#endif
@@ -7326,7 +8090,7 @@ directly into the right place../src/torrent.cpp:10640#ifdef TORRENT_WINDOWS
if ((ec == error_code(ERROR_MORE_DATA, system_category())
@@ -7350,8 +8114,8 @@ directly into the right place../src/torrent.cpp:10640relevance 0 | ../src/udp_socket.cpp:779 | use the system resolver_interface here |
|
use the system resolver_interface here../src/udp_socket.cpp:779
+ | ||
relevance 0 | ../src/udp_socket.cpp:788 | use the system resolver_interface here |
use the system resolver_interface here../src/udp_socket.cpp:788
void udp_socket::set_proxy_settings(proxy_settings const& ps)
{
CHECK_MAGIC;
@@ -7377,7 +8141,7 @@ void udp_socket::set_proxy_settings(proxy_settings const& ps)
error_code ec;
m_socks5_sock.close(ec);
m_tunnel_packets = false;
-
+
m_proxy_settings = ps;
if (m_abort) return;
@@ -7419,8 +8183,8 @@ void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator
+ m_outstanding_socks);
if (m_abort) return;
- | ||
relevance 0 | ../src/ut_metadata.cpp:313 | we really need to increment the refcounter on the torrent while this buffer is still in the peer's send buffer |
we really need to increment the refcounter on the torrent
-while this buffer is still in the peer's send buffer../src/ut_metadata.cpp:313 if (!m_tp.need_loaded()) return;
+ | ||
relevance 0 | ../src/ut_metadata.cpp:315 | we really need to increment the refcounter on the torrent while this buffer is still in the peer's send buffer |
we really need to increment the refcounter on the torrent
+while this buffer is still in the peer's send buffer../src/ut_metadata.cpp:315 if (!m_tp.need_loaded()) return;
metadata = m_tp.metadata().begin + offset;
metadata_piece_size = (std::min)(
int(m_tp.get_metadata_size() - offset), 16 * 1024);
@@ -7471,10 +8235,8 @@ while this buffer is still in the peer's send buffer../src/ut_metadata.
{
#ifndef TORRENT_DISABLE_LOGGING
m_pc.peer_log(peer_log_alert::incoming_message, "UT_METADATA"
- | ||
relevance 0 | ../src/utp_stream.cpp:1709 | this loop is not very efficient. It could be fixed by having a separate list of sequence numbers that need resending |
this loop is not very efficient. It could be fixed by having
-a separate list of sequence numbers that need resending../src/utp_stream.cpp:1709
- char* m_buf;
-};
+ | ||
relevance 0 | ../src/utp_stream.cpp:1718 | this loop is not very efficient. It could be fixed by having a separate list of sequence numbers that need resending |
this loop is not very efficient. It could be fixed by having
+a separate list of sequence numbers that need resending../src/utp_stream.cpp:1718};
// sends a packet, pulls data from the write buffer (if there's any)
// if ack is true, we need to send a packet regardless of if there's
@@ -7484,7 +8246,9 @@ a separate list of sequence numbers that need resending../src/utp_strea
// congestion window, false if there is no more space.
bool utp_socket_impl::send_pkt(int flags)
{
+#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
INVARIANT_CHECK;
+#endif
bool force = (flags & pkt_ack) || (flags & pkt_fin);
@@ -7523,7 +8287,7 @@ bool utp_socket_impl::send_pkt(int flags)
if (sack > 32) sack = 32;
}
- | ||
relevance 0 | ../src/web_connection_base.cpp:73 | introduce a web-seed default class which has a low download priority |
introduce a web-seed default class which has a low download priority../src/web_connection_base.cpp:73{
+ | ||
relevance 0 | ../src/web_connection_base.cpp:73 | introduce a web-seed default class which has a low download priority |
introduce a web-seed default class which has a low download priority../src/web_connection_base.cpp:73{
web_connection_base::web_connection_base(
peer_connection_args const& pack
, web_seed_t& web)
@@ -7574,8 +8338,8 @@ bool utp_socket_impl::send_pkt(int flags)
// according to the settings.
return m_settings.get_int(settings_pack::urlseed_timeout);
}
- | ||
relevance 0 | ../src/kademlia/dht_tracker.cpp:307 | ideally this function would be called when the put completes |
ideally this function would be called when the
-put completes../src/kademlia/dht_tracker.cpp:307 // since it controls whether we re-put the content
+ | ||
relevance 0 | ../src/kademlia/dht_tracker.cpp:264 | ideally this function would be called when the put completes |
ideally this function would be called when the
+put completes../src/kademlia/dht_tracker.cpp:264 // since it controls whether we re-put the content
TORRENT_ASSERT(!it.is_mutable());
f(it);
return false;
@@ -7626,7 +8390,7 @@ put completes../src/kademlia/dht_tracker.cpp:307relevance 0 | ../include/libtorrent/block_cache.hpp:219 | make this 32 bits and to count seconds since the block cache was created |
|
make this 32 bits and to count seconds since the block cache was created../include/libtorrent/block_cache.hpp:219
+ | ||
relevance 0 | ../include/libtorrent/block_cache.hpp:219 | make this 32 bits and to count seconds since the block cache was created |
make this 32 bits and to count seconds since the block cache was created../include/libtorrent/block_cache.hpp:219
bool operator==(cached_piece_entry const& rhs) const
{ return storage.get() == rhs.storage.get() && piece == rhs.piece; }
@@ -7652,7 +8416,7 @@ put completes../src/kademlia/dht_tracker.cpp:307 | ||
relevance 0 | ../include/libtorrent/config.hpp:339 | Make this count Unicode characters instead of bytes on windows |
Make this count Unicode characters instead of bytes on windows../include/libtorrent/config.hpp:339#pragma message ( "unknown OS, assuming BSD" )
+ | ||
relevance 0 | ../include/libtorrent/config.hpp:349 | Make this count Unicode characters instead of bytes on windows |
Make this count Unicode characters instead of bytes on windows../include/libtorrent/config.hpp:349#pragma message ( "unknown OS, assuming BSD" )
#else
#warning "unknown OS, assuming BSD"
#endif
@@ -7728,7 +8492,7 @@ put completes../src/kademlia/dht_tracker.cpp:307relevance 0 | ../include/libtorrent/disk_buffer_pool.hpp:137 | try to remove the observers, only using the async_allocate handlers |
|
try to remove the observers, only using the async_allocate handlers../include/libtorrent/disk_buffer_pool.hpp:137
+ | ||
relevance 0 | ../include/libtorrent/disk_buffer_pool.hpp:137 | try to remove the observers, only using the async_allocate handlers |
try to remove the observers, only using the async_allocate handlers../include/libtorrent/disk_buffer_pool.hpp:137
// number of bytes per block. The BitTorrent
// protocol defines the block size to 16 KiB.
const int m_block_size;
@@ -7779,7 +8543,7 @@ put completes../src/kademlia/dht_tracker.cpp:307relevance 0 | ../include/libtorrent/file.hpp:173 | move this into a separate header file, TU pair |
|
move this into a separate header file, TU pair../include/libtorrent/file.hpp:173 TORRENT_EXTRA_EXPORT std::string parent_path(std::string const& f);
+ | ||
relevance 0 | ../include/libtorrent/file.hpp:173 | move this into a separate header file, TU pair |
move this into a separate header file, TU pair../include/libtorrent/file.hpp:173 TORRENT_EXTRA_EXPORT std::string parent_path(std::string const& f);
TORRENT_EXTRA_EXPORT bool has_parent_path(std::string const& f);
TORRENT_EXTRA_EXPORT char const* filename_cstr(char const* f);
@@ -7830,7 +8594,7 @@ put completes../src/kademlia/dht_tracker.cpp:307relevance 0 | ../include/libtorrent/heterogeneous_queue.hpp:185 | if this throws, should we do anything? |
|
if this throws, should we do anything?../include/libtorrent/heterogeneous_queue.hpp:185 - 1) / sizeof(uintptr_t);
+ | ||
relevance 0 | ../include/libtorrent/heterogeneous_queue.hpp:184 | if this throws, should we do anything? |
if this throws, should we do anything?../include/libtorrent/heterogeneous_queue.hpp:184 - 1) / sizeof(uintptr_t);
void grow_capacity(int size)
{
@@ -7881,10 +8645,53 @@ put completes../src/kademlia/dht_tracker.cpp:307relevance 0 | ../include/libtorrent/peer_connection.hpp:204 | make this a raw pointer (to save size in the first cache line) and make the constructor take a raw pointer. torrent objects should always outlive their peers |
|
make this a raw pointer (to save size in
+ | ||
relevance 0 | ../include/libtorrent/identify_client.hpp:50 | hide these declarations when deprecaated functions are disabled, and expose them internally in a header under aux_. |
hide these declarations when deprecaated functions are disabled, and
+expose them internally in a header under aux_.../include/libtorrent/identify_client.hpp:50
+*/
+
+#ifndef TORRENT_IDENTIFY_CLIENT_HPP_INCLUDED
+#define TORRENT_IDENTIFY_CLIENT_HPP_INCLUDED
+
+#include "libtorrent/config.hpp"
+
+#include "libtorrent/aux_/disable_warnings_push.hpp"
+
+#include <boost/optional.hpp>
+
+#include "libtorrent/aux_/disable_warnings_pop.hpp"
+
+#include "libtorrent/peer_id.hpp"
+#include "libtorrent/fingerprint.hpp"
+
+namespace libtorrent
+{
+
+
+ // these functions don't really need to be public. This mechanism of
+ // advertising client software and version is also out-dated.
+
+ // This function can can be used to extract a string describing a client
+ // version from its peer-id. It will recognize most clients that have this
+ // kind of identification in the peer-id.
+ TORRENT_DEPRECATED_EXPORT TORRENT_DEPRECATED
+ std::string identify_client(const peer_id& p);
+
+ // Returns an optional fingerprint if any can be identified from the peer
+ // id. This can be used to automate the identification of clients. It will
+ // not be able to identify peers with non- standard encodings. Only Azureus
+ // style, Shadow's style and Mainline style.
+ TORRENT_DEPRECATED_EXPORT TORRENT_DEPRECATED
+ boost::optional<fingerprint>
+ client_fingerprint(peer_id const& p);
+
+}
+
+#endif // TORRENT_IDENTIFY_CLIENT_HPP_INCLUDED
+
+ | ||
relevance 0 | ../include/libtorrent/peer_connection.hpp:205 | make this a raw pointer (to save size in the first cache line) and make the constructor take a raw pointer. torrent objects should always outlive their peers |
make this a raw pointer (to save size in
the first cache line) and make the constructor
take a raw pointer. torrent objects should always
-outlive their peers../include/libtorrent/peer_connection.hpp:204 , m_connecting(!t.expired())
+outlive their peers../include/libtorrent/peer_connection.hpp:205 , m_connecting(!t.expired())
, m_endgame_mode(false)
, m_snubbed(false)
, m_interesting(false)
@@ -7905,7 +8712,7 @@ outlive their peers../include/libtorrent/peer_connection.hpp:204 boost::weak_ptr<torrent> m_torrent;
-
+
public:
// a back reference to the session
@@ -7914,7 +8721,7 @@ outlive their peers ../include/libtorrent/peer_connection.hpp:204../include/libtorrent/peer_connection.hpp:204 | ||
relevance 0 | ../include/libtorrent/peer_connection.hpp:1043 | factor this out into its own class with a virtual interface torrent and session should implement this interface |
factor this out into its own class with a virtual interface
-torrent and session should implement this interface../include/libtorrent/peer_connection.hpp:1043
+ | ||
relevance 0 | ../include/libtorrent/peer_connection.hpp:1050 | factor this out into its own class with a virtual interface torrent and session should implement this interface |
factor this out into its own class with a virtual interface
+torrent and session should implement this interface../include/libtorrent/peer_connection.hpp:1050
// the local endpoint for this peer, i.e. our address
// and our port. If this is set for outgoing connections
// before the connection completes, it means we want to
@@ -7944,7 +8751,7 @@ torrent and session should implement this interface../include/libtorren
// if it ends up being bound to a different local IP, the connection
// is closed.
tcp::endpoint m_local;
-
+
// remote peer's id
peer_id m_peer_id;
@@ -7976,18 +8783,18 @@ torrent and session should implement this interface../include/libtorren
// from disk, that will be added to the send
// buffer as soon as they complete
int m_reading_bytes;
-
+
// options used for the piece picker. These flags will
// be augmented with flags controlled by other settings
// like sequential download etc. These are here to
// let plugins control flags that should always be set
int m_picker_options;
-
+
// the number of invalid piece-requests
// we have got from this peer. If the request
// queue gets empty, and there have been
// invalid requests, we can assume the
- | ||
relevance 0 | ../include/libtorrent/peer_connection_interface.hpp:47 | make this interface smaller! |
make this interface smaller!../include/libtorrent/peer_connection_interface.hpp:47CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ | ||
relevance 0 | ../include/libtorrent/peer_connection_interface.hpp:47 | make this interface smaller! |
make this interface smaller!../include/libtorrent/peer_connection_interface.hpp:47CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
@@ -8035,7 +8842,7 @@ namespace libtorrent
#endif
- | ||
relevance 0 | ../include/libtorrent/performance_counters.hpp:139 | should keepalives be in here too? how about dont-have, share-mode, upload-only |
should keepalives be in here too?
+ | ||
relevance 0 | ../include/libtorrent/performance_counters.hpp:139 | should keepalives be in here too? how about dont-have, share-mode, upload-only |
should keepalives be in here too?
how about dont-have, share-mode, upload-only../include/libtorrent/performance_counters.hpp:139 // a connect candidate
connection_attempt_loops,
// successful incoming connections (not rejected for any reason)
@@ -8087,7 +8894,7 @@ how about dont-have, share-mode, upload-only../include/libtorrent/perfo
num_outgoing_cancel,
num_outgoing_dht_port,
num_outgoing_suggest,
- | ||
relevance 0 | ../include/libtorrent/performance_counters.hpp:451 | some space could be saved here by making gauges 32 bits |
some space could be saved here by making gauges 32 bits../include/libtorrent/performance_counters.hpp:451 | ||
relevance 0 | ../include/libtorrent/performance_counters.hpp:452 | restore these to regular integers. Instead have one copy of the counters per thread and collect them at convenient synchronization points |
restore these to regular integers. Instead have one copy
+ | ||
relevance 0 | ../include/libtorrent/performance_counters.hpp:451 | some space could be saved here by making gauges 32 bits |
some space could be saved here by making gauges 32 bits../include/libtorrent/performance_counters.hpp:451 | ||
relevance 0 | ../include/libtorrent/performance_counters.hpp:452 | restore these to regular integers. Instead have one copy of the counters per thread and collect them at convenient synchronization points |
restore these to regular integers. Instead have one copy
of the counters per thread and collect them at convenient
synchronization points../include/libtorrent/performance_counters.hpp:452 num_utp_deleted,
@@ -8122,7 +8929,7 @@ synchronization points../include/libtorrent/performance_counters.hpp:45
#endif
- | ||
relevance 0 | ../include/libtorrent/piece_picker.hpp:762 | should this be allocated lazily? |
should this be allocated lazily?../include/libtorrent/piece_picker.hpp:762
+ | ||
relevance 0 | ../include/libtorrent/piece_picker.hpp:760 | should this be allocated lazily? |
should this be allocated lazily?../include/libtorrent/piece_picker.hpp:760
std::vector<downloading_piece>::const_iterator find_dl_piece(int queue, int index) const;
std::vector<downloading_piece>::iterator find_dl_piece(int queue, int index);
@@ -8173,7 +8980,7 @@ synchronization points../include/libtorrent/performance_counters.hpp:45
// this holds the information of the blocks in partially downloaded
// pieces. the downloading_piece::info index point into this vector for
- | ||
relevance 0 | ../include/libtorrent/proxy_base.hpp:173 | it would be nice to remember the bind port and bind once we know where the proxy is m_sock.bind(endpoint, ec); |
it would be nice to remember the bind port and bind once we know where the proxy is
+ | ||
relevance 0 | ../include/libtorrent/proxy_base.hpp:173 | it would be nice to remember the bind port and bind once we know where the proxy is m_sock.bind(endpoint, ec); |
it would be nice to remember the bind port and bind once we know where the proxy is
m_sock.bind(endpoint, ec);../include/libtorrent/proxy_base.hpp:173 void bind(endpoint_type const& /* endpoint */)
{
// m_sock.bind(endpoint);
@@ -8225,7 +9032,7 @@ m_sock.bind(endpoint, ec);../include/libtorrent/proxy_base.hpp:173
m_sock.close(ec);
m_resolver.cancel();
}
- | ||
relevance 0 | ../include/libtorrent/receive_buffer.hpp:258 | Detect when the start of the next crpyto packet is aligned with the start of piece data and the crpyto packet is at least as large as the piece data. With a little extra work we could receive directly into a disk buffer in that case. |
Detect when the start of the next crpyto packet is aligned
+ | ||
relevance 0 | ../include/libtorrent/receive_buffer.hpp:258 | Detect when the start of the next crpyto packet is aligned with the start of piece data and the crpyto packet is at least as large as the piece data. With a little extra work we could receive directly into a disk buffer in that case. |
Detect when the start of the next crpyto packet is aligned
with the start of piece data and the crpyto packet is at least
as large as the piece data. With a little extra work
we could receive directly into a disk buffer in that case.../include/libtorrent/receive_buffer.hpp:258
@@ -8268,21 +9075,21 @@ private:
} // namespace libtorrent
#endif // #ifndef TORRENT_RECEIVE_BUFFER_HPP_INCLUDED
- | ||
relevance 0 | ../include/libtorrent/session.hpp:844 | add get_peer_class_type_filter() as well |
add get_peer_class_type_filter() as well../include/libtorrent/session.hpp:844 //
+ | ||
relevance 0 | ../include/libtorrent/session_handle.hpp:654 | add get_peer_class_type_filter() as well |
add get_peer_class_type_filter() as well../include/libtorrent/session_handle.hpp:654 //
// The ``peer_class`` argument cannot be greater than 31. The bitmasks
// representing peer classes in the ``peer_class_filter`` are 32 bits.
- //
+ //
// For more information, see peer-classes_.
void set_peer_class_filter(ip_filter const& f);
// Sets and gets the *peer class type filter*. This is controls automatic
// peer class assignments to peers based on what kind of socket it is.
- //
+ //
// It does not only support assigning peer classes, it also supports
// removing peer classes based on socket type.
//
// The order of these rules being applied are:
- //
+ //
// 1. peer-class IP filter
// 2. peer-class type filter, removing classes
// 3. peer-class type filter, adding classes
@@ -8294,11 +9101,11 @@ private:
// returned integer is the new peer class' identifier. Peer classes may
// have the same name, so each invocation of this function creates a new
// class and returns a unique identifier.
- //
+ //
// Identifiers are assigned from low numbers to higher. So if you plan on
// using certain peer classes in a call to `set_peer_class_filter()`_,
// make sure to create those early on, to get low identifiers.
- //
+ //
// For more information on peer classes, see peer-classes_.
int create_peer_class(char const* name);
@@ -8308,21 +9115,32 @@ private:
// may only call this function **once** per peer class you create.
// Calling it more than once for the same class will lead to memory
// corruption.
- //
+ //
// Since peer classes are reference counted, this function will not
// remove the peer class if it's still assigned to torrents or peers. It
// will however remove it once the last peer and torrent drops their
// references to it.
- //
+ //
// There is no need to call this function for custom peer classes. All
// peer classes will be properly destructed when the session object
// destructs.
- //
+ //
// For more information on peer classes, see peer-classes_.
- | ||
relevance 0 | ../include/libtorrent/settings_pack.hpp:1097 | deprecate this ``max_rejects`` is the number of piece requests we will reject in a row while a peer is choked before the peer is considered abusive and is disconnected. |
deprecate this
+ | ||
relevance 0 | ../include/libtorrent/settings_pack.hpp:1086 | deprecate this ``max_rejects`` is the number of piece requests we will reject in a row while a peer is choked before the peer is considered abusive and is disconnected. |
deprecate this
``max_rejects`` is the number of piece requests we will reject in a
row while a peer is choked before the peer is considered abusive
-and is disconnected.../include/libtorrent/settings_pack.hpp:1097 auto_manage_startup,
+and is disconnected.../include/libtorrent/settings_pack.hpp:1086
+ // this is the minimum allowed announce interval for a tracker. This
+ // is specified in seconds and is used as a sanity check on what is
+ // returned from a tracker. It mitigates hammering misconfigured
+ // trackers.
+ min_announce_interval,
+
+ // this is the number of seconds a torrent is considered active after
+ // it was started, regardless of upload and download speed. This is so
+ // that newly started torrents are not considered inactive until they
+ // have a fair chance to start downloading.
+ auto_manage_startup,
// ``seeding_piece_quota`` is the number of pieces to send to a peer,
// when seeding, before rotating in another peer to the unchoke set.
@@ -8331,17 +9149,6 @@ and is disconnected.../include/libtorrent/settings_pack.hpp:1097 max_rejects,
// ``recv_socket_buffer_size`` and ``send_socket_buffer_size``
@@ -8373,7 +9180,7 @@ and is disconnected. ../include/libtorrent/settings_pack.hpp:1097 | ||
relevance 0 | ../include/libtorrent/torrent.hpp:1263 | this wastes 5 bits per file |
this wastes 5 bits per file../include/libtorrent/torrent.hpp:1263 typedef std::list<boost::shared_ptr<torrent_plugin> > extension_list_t;
+ | ||
relevance 0 | ../include/libtorrent/torrent.hpp:1265 | this wastes 5 bits per file |
this wastes 5 bits per file../include/libtorrent/torrent.hpp:1265 typedef std::list<boost::shared_ptr<torrent_plugin> > extension_list_t;
extension_list_t m_extensions;
#endif
@@ -8395,12 +9202,8 @@ and is disconnected.../include/libtorrent/settings_pack.hpp:1097 std::vector<boost::uint8_t> m_file_priority;
- // this vector contains the number of bytes completely
- // downloaded (as in passed-hash-check) in each file.
- // this lets us trigger on individual files completing
- // the vector is allocated lazily, when file progress
- // is first queried by the client
- std::vector<boost::uint64_t> m_file_progress;
+ // this object is used to track download progress of individual files
+ aux::file_progress m_file_progress;
// these are the pieces we're currently
// suggesting to peers.
@@ -8424,7 +9227,11 @@ and is disconnected. ../include/libtorrent/settings_pack.hpp:1097 | ||
relevance 0 | ../include/libtorrent/torrent.hpp:1322 | These two bitfields should probably be coalesced into one |
These two bitfields should probably be coalesced into one../include/libtorrent/torrent.hpp:1322 // the .torrent file from m_url
+ std::string m_uuid;
+
+ // if this torrent was added by an RSS feed, this is the
+ // URL to that feed
+ | ||
relevance 0 | ../include/libtorrent/torrent.hpp:1320 | These two bitfields should probably be coalesced into one |
These two bitfields should probably be coalesced into one../include/libtorrent/torrent.hpp:1320 // the .torrent file from m_url
// std::vector<char> m_torrent_file_buf;
// this is a list of all pieces that we have announced
@@ -8475,8 +9282,8 @@ and is disconnected.../include/libtorrent/settings_pack.hpp:1097 | ||
relevance 0 | ../include/libtorrent/torrent_info.hpp:115 | include the number of peers received from this tracker, at last announce |
include the number of peers received from this tracker, at last
-announce../include/libtorrent/torrent_info.hpp:115
+ | ||
relevance 0 | ../include/libtorrent/torrent_info.hpp:118 | include the number of peers received from this tracker, at last announce |
include the number of peers received from this tracker, at last
+announce../include/libtorrent/torrent_info.hpp:118
// if this tracker failed the last time it was contacted
// this error code specifies what error occurred
error_code last_error;
@@ -8527,8 +9334,8 @@ announce../include/libtorrent/torrent_info.hpp:115relevance 0 | ../include/libtorrent/torrent_info.hpp:262 | there may be some opportunities to optimize the size if torrent_info. specifically to turn some std::string and std::vector into pointers |
|
there may be some opportunities to optimize the size if torrent_info.
-specifically to turn some std::string and std::vector into pointers../include/libtorrent/torrent_info.hpp:262 // The URL of the web seed
+ | ||
relevance 0 | ../include/libtorrent/torrent_info.hpp:265 | there may be some opportunities to optimize the size if torrent_info. specifically to turn some std::string and std::vector into pointers |
there may be some opportunities to optimize the size if torrent_info.
+specifically to turn some std::string and std::vector into pointers../include/libtorrent/torrent_info.hpp:265 // The URL of the web seed
std::string url;
// Optional authentication. If this is set, it's passed
@@ -8579,18 +9386,18 @@ specifically to turn some std::string and std::vector into pointers../i
// error occur, they will simply set the error code to describe what went
// wrong and not fully initialize the torrent_info object. The overloads
// that do not take the extra error_code parameter will always throw if
- | ||
relevance 0 | ../include/libtorrent/tracker_manager.hpp:380 | this should be unique_ptr in the future |
this should be unique_ptr in the future../include/libtorrent/tracker_manager.hpp:380 // this is only used for SOCKS packets, since
+ | ||
relevance 0 | ../include/libtorrent/tracker_manager.hpp:380 | this should be unique_ptr in the future |
this should be unique_ptr in the future../include/libtorrent/tracker_manager.hpp:380
+ // this is only used for SOCKS packets, since
// they may be addressed to hostname
virtual bool incoming_packet(error_code const& e, char const* hostname
- , char const* buf, int size);
-
+ , char const* buf, int size) TORRENT_OVERRIDE;
+
void update_transaction_id(
boost::shared_ptr<udp_tracker_connection> c
, boost::uint64_t tid);
aux::session_settings const& settings() const { return m_settings; }
udp_socket& get_udp_socket() { return m_udp_socket; }
- struct ip_filter const& ip_filter() const { return m_ip_filter; }
resolver_interface& host_resolver() { return m_host_resolver; }
private:
@@ -8606,7 +9413,6 @@ specifically to turn some std::string and std::vector into pointers../i
typedef std::vector<boost::shared_ptr<http_tracker_connection> > http_conns_t;
http_conns_t m_http_conns;
- struct ip_filter const& m_ip_filter;
class udp_socket& m_udp_socket;
resolver_interface& m_host_resolver;
aux::session_settings const& m_settings;
@@ -8621,7 +9427,7 @@ specifically to turn some std::string and std::vector into pointers../i
#endif // TORRENT_TRACKER_MANAGER_HPP_INCLUDED
- | ||
relevance 0 | ../include/libtorrent/upnp.hpp:108 | support using the windows API for UPnP operations as well |
support using the windows API for UPnP operations as well../include/libtorrent/upnp.hpp:108 external_port_must_be_wildcard = 727
+ | ||
relevance 0 | ../include/libtorrent/upnp.hpp:108 | support using the windows API for UPnP operations as well |
support using the windows API for UPnP operations as well../include/libtorrent/upnp.hpp:108 external_port_must_be_wildcard = 727
};
// hidden
@@ -8659,24 +9465,24 @@ public:
// Attempts to add a port mapping for the specified protocol. Valid protocols are
// ``upnp::tcp`` and ``upnp::udp`` for the UPnP class and ``natpmp::tcp`` and
// ``natpmp::udp`` for the NAT-PMP class.
- //
+ //
// ``external_port`` is the port on the external address that will be mapped. This
// is a hint, you are not guaranteed that this port will be available, and it may
// end up being something else. In the portmap_alert_ notification, the actual
// external port is reported.
- //
+ //
// ``local_port`` is the port in the local machine that the mapping should forward
// to.
- //
+ //
// The return value is an index that identifies this port mapping. This is used
// to refer to mappings that fails or succeeds in the portmap_error_alert_ and
// portmap_alert_ respectively. If The mapping fails immediately, the return value
// is -1, which means failure. There will not be any error alert notification for
- | ||
relevance 0 | ../include/libtorrent/utp_stream.hpp:402 | implement blocking write. Low priority since it's not used (yet) |
implement blocking write. Low priority since it's not used (yet)../include/libtorrent/utp_stream.hpp:402 for (typename Mutable_Buffers::const_iterator i = buffers.begin()
+ | ||
relevance 0 | ../include/libtorrent/utp_stream.hpp:402 | implement blocking write. Low priority since it's not used (yet) |
implement blocking write. Low priority since it's not used (yet)../include/libtorrent/utp_stream.hpp:402 for (typename Mutable_Buffers::const_iterator i = buffers.begin()
, end(buffers.end()); i != end; ++i)
{
- using asio::buffer_cast;
- using asio::buffer_size;
+ using boost::asio::buffer_cast;
+ using boost::asio::buffer_size;
add_read_buffer(buffer_cast<void*>(*i), buffer_size(*i));
#if TORRENT_USE_ASSERTS
buf_size += buffer_size(*i);
@@ -8723,7 +9529,7 @@ public:
if (m_impl == 0)
{
m_io_service.post(boost::bind<void>(handler
- | ||
relevance 0 | ../include/libtorrent/kademlia/item.hpp:61 | since this is a public function, it should probably be moved out of this header and into one with other public functions. |
since this is a public function, it should probably be moved
+ | ||
relevance 0 | ../include/libtorrent/kademlia/item.hpp:61 | since this is a public function, it should probably be moved out of this header and into one with other public functions. |
since this is a public function, it should probably be moved
out of this header and into one with other public functions.../include/libtorrent/kademlia/item.hpp:61#include <boost/array.hpp>
namespace libtorrent { namespace dht
@@ -8775,9 +9581,9 @@ public:
item(entry const& v
, std::pair<char const*, int> salt
, boost::uint64_t seq, char const* pk, char const* sk);
- | ||
relevance 0 | ../include/libtorrent/aux_/session_impl.hpp:851 | should this be renamed m_outgoing_interfaces? |
should this be renamed m_outgoing_interfaces?../include/libtorrent/aux_/session_impl.hpp:851 // listen socket. For each retry the port number
- // is incremented by one
- int m_listen_port_retries;
+ | ||
relevance 0 | ../include/libtorrent/aux_/session_impl.hpp:846 | should this be renamed m_outgoing_interfaces? |
should this be renamed m_outgoing_interfaces?../include/libtorrent/aux_/session_impl.hpp:846 // client with the tracker only. It is randomized
+ // at startup
+ int m_key;
// the addresses or device names of the interfaces we are supposed to
// listen on. if empty, it means that we should let the os decide
@@ -8802,7 +9608,7 @@ public:
// on this machine
tcp::endpoint m_ipv6_interface;
tcp::endpoint m_ipv4_interface;
-
+
// since we might be listening on multiple interfaces
// we might need more than one listen socket
std::list<listen_socket_t> m_listen_sockets;
@@ -8826,7 +9632,7 @@ public:
// round-robin index into m_net_interfaces
mutable boost::uint8_t m_interface_index;
- | ||
relevance 0 | ../include/libtorrent/aux_/session_impl.hpp:902 | replace this by a proper asio timer |
replace this by a proper asio timer../include/libtorrent/aux_/session_impl.hpp:902
+ | ||
relevance 0 | ../include/libtorrent/aux_/session_impl.hpp:897 | replace this by a proper asio timer |
replace this by a proper asio timer../include/libtorrent/aux_/session_impl.hpp:897
void open_new_incoming_socks_connection();
enum listen_on_flags_t
@@ -8835,9 +9641,9 @@ public:
};
listen_socket_t setup_listener(std::string const& device
- , bool ipv4, int port, int& retries, int flags, error_code& ec);
+ , bool ipv4, int port, int flags, error_code& ec);
-#ifndef TORRENT_DISABLE_DHT
+#ifndef TORRENT_DISABLE_DHT
entry m_dht_state;
#endif
@@ -8850,14 +9656,14 @@ public:
// this is used to decide when to recalculate which
// torrents to keep queued and which to activate
- | ||
relevance 0 | ../include/libtorrent/aux_/session_impl.hpp:907 | replace this by a proper asio timer |
replace this by a proper asio timer../include/libtorrent/aux_/session_impl.hpp:907 {
+ | ||
relevance 0 | ../include/libtorrent/aux_/session_impl.hpp:902 | replace this by a proper asio timer |
replace this by a proper asio timer../include/libtorrent/aux_/session_impl.hpp:902 {
open_ssl_socket = 0x10
};
listen_socket_t setup_listener(std::string const& device
- , bool ipv4, int port, int& retries, int flags, error_code& ec);
+ , bool ipv4, int port, int flags, error_code& ec);
-#ifndef TORRENT_DISABLE_DHT
+#ifndef TORRENT_DISABLE_DHT
entry m_dht_state;
#endif
@@ -8876,8 +9682,8 @@ public:
// is only decresed when the unchoke set
// is recomputed, and when it reaches zero,
// the optimistic unchoke is moved to another peer.
- | ||
relevance 0 | ../include/libtorrent/aux_/session_impl.hpp:914 | replace this by a proper asio timer |
replace this by a proper asio timer../include/libtorrent/aux_/session_impl.hpp:914
-#ifndef TORRENT_DISABLE_DHT
+ | ||
relevance 0 | ../include/libtorrent/aux_/session_impl.hpp:909 | replace this by a proper asio timer |
replace this by a proper asio timer../include/libtorrent/aux_/session_impl.hpp:909
+#ifndef TORRENT_DISABLE_DHT
entry m_dht_state;
#endif
@@ -8927,7 +9733,7 @@ public:
int m_suggest_timer;
// statistics gathered from all torrents.
- | ||
relevance 0 | ../include/libtorrent/aux_/session_interface.hpp:242 | it would be nice to not have this be part of session_interface |
it would be nice to not have this be part of session_interface../include/libtorrent/aux_/session_interface.hpp:242
+ | ||
relevance 0 | ../include/libtorrent/aux_/session_interface.hpp:241 | it would be nice to not have this be part of session_interface |
it would be nice to not have this be part of session_interface../include/libtorrent/aux_/session_interface.hpp:241
// load the specified torrent. also evict one torrent, except
// for the one specified, if we are at the limit of loaded torrents
virtual bool load_torrent(torrent* t) = 0;
@@ -8961,7 +9767,7 @@ public:
virtual void trigger_auto_manage() = 0;
- virtual void apply_settings_pack(settings_pack* pack) = 0;
+ virtual void apply_settings_pack(boost::shared_ptr<settings_pack> pack) = 0;
virtual session_settings const& settings() const = 0;
virtual void queue_tracker_request(tracker_request& req
@@ -8978,7 +9784,7 @@ public:
virtual bandwidth_manager* get_bandwidth_manager(int channel) = 0;
- | ||
relevance 0 | ../include/libtorrent/aux_/session_settings.hpp:78 | make this a bitfield |
make this a bitfield../include/libtorrent/aux_/session_settings.hpp:78 if ((name & settings_pack::type_mask) != settings_pack:: type ## _type_base) return default_val; \
+ | ||
relevance 0 | ../include/libtorrent/aux_/session_settings.hpp:78 | make this a bitfield |
make this a bitfield../include/libtorrent/aux_/session_settings.hpp:78 if ((name & settings_pack::type_mask) != settings_pack:: type ## _type_base) return default_val; \
return m_ ## type ## s[name - settings_pack:: type ## _type_base]
struct TORRENT_EXTRA_EXPORT session_settings
| ||