From 44b81359b81b3ee72999947108ef310379056506 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 20 Jan 2013 23:28:06 +0000 Subject: [PATCH] generate proper html escape sequencies --- docs/todo.html | 1266 ++++++++++++++++++++++++------------------------ gen_todo.py | 15 +- 2 files changed, 645 insertions(+), 636 deletions(-) diff --git a/docs/todo.html b/docs/todo.html index 132069bcc..482a4ad08 100644 --- a/docs/todo.html +++ b/docs/todo.html @@ -49,34 +49,34 @@ more primitive platforms

src/alert.cpp:370

src/storage.cpp:989use binary search to find the file entry

use binary search to find the file entry

src/storage.cpp:989

		size_type ret = 0;
-		if (f && !ec) ret = f->phys_offset(file_offset);
+		if (f && !ec) ret = f->phys_offset(file_offset);
 
 		if (ret == 0)
 		{
@@ -90,57 +90,57 @@ more primitive platforms

src/alert.cpp:370

		for (file_iter = files().begin();;)
 		{
-			if (file_offset < file_iter->size)
+			if (file_offset < file_iter->size)
 				break;
 
-			file_offset -= file_iter->size;
+			file_offset -= file_iter->size;
 			++file_iter;
 			TORRENT_ASSERT(file_iter != files().end());
 		}
 
-		boost::intrusive_ptr file_handle;
+		boost::intrusive_ptr<file> file_handle;
 		int bytes_left = size;
-		int slot_size = static_cast(m_files.piece_size(slot));
+		int slot_size = static_cast<int>(m_files.piece_size(slot));
 
-		if (offset + bytes_left > slot_size)
+		if (offset + bytes_left > slot_size)
 			bytes_left = slot_size - offset;
 
-		TORRENT_ASSERT(bytes_left >= 0);
+		TORRENT_ASSERT(bytes_left >= 0);
 
 		int file_bytes_left;
-		for (;bytes_left > 0; ++file_iter, bytes_left -= file_bytes_left)
+		for (;bytes_left > 0; ++file_iter, bytes_left -= file_bytes_left)
 		{
 			TORRENT_ASSERT(file_iter != files().end());
 
 			file_bytes_left = bytes_left;
-			if (file_offset + file_bytes_left > file_iter->size)
-				file_bytes_left = (std::max)(static_cast(file_iter->size - file_offset), 0);
+			if (file_offset + file_bytes_left > file_iter->size)
+				file_bytes_left = (std::max)(static_cast<int>(file_iter->size - file_offset), 0);
 
 			if (file_bytes_left == 0) continue;
 
-			if (file_iter->pad_file) continue;
-
relevance 3src/storage.cpp:1095use binary search to find the file entry

use binary search to find the file entry

src/storage.cpp:1095

		TORRENT_ASSERT(offset >= 0);
-		TORRENT_ASSERT(offset < m_files.piece_size(slot));
-		TORRENT_ASSERT(num_bufs > 0);
+			if (file_iter->pad_file) continue;
+
relevance 3src/storage.cpp:1095use binary search to find the file entry

use binary search to find the file entry

src/storage.cpp:1095

		TORRENT_ASSERT(offset >= 0);
+		TORRENT_ASSERT(offset < m_files.piece_size(slot));
+		TORRENT_ASSERT(num_bufs > 0);
 
 		int size = bufs_size(bufs, num_bufs);
-		TORRENT_ASSERT(size > 0);
+		TORRENT_ASSERT(size > 0);
 
 #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
-		std::vector slices
+		std::vector<file_slice> slices
 			= files().map_block(slot, offset, size);
 		TORRENT_ASSERT(!slices.empty());
 #endif
 
 		size_type start = slot * (size_type)m_files.piece_length() + offset;
-		TORRENT_ASSERT(start + size <= m_files.total_size());
+		TORRENT_ASSERT(start + size <= m_files.total_size());
 
 		// find the file iterator and file offset
 		size_type file_offset = start;
@@ -148,10 +148,10 @@ more primitive platforms

src/alert.cpp:370

		for (file_iter = files().begin();;)
 		{
-			if (file_offset < file_iter->size)
+			if (file_offset < file_iter->size)
 				break;
 
-			file_offset -= file_iter->size;
+			file_offset -= file_iter->size;
 			++file_iter;
 			TORRENT_ASSERT(file_iter != files().end());
 		}
@@ -159,14 +159,14 @@ more primitive platforms

src/alert.cpp:370

= 0, but the calculations performed on
+	// the value is always >= 0, but the calculations performed on
 	// it in do_ledbat() are signed.
 	boost::int64_t m_cwnd;
 
@@ -273,26 +273,26 @@ POSSIBILITY OF SUCH DAMAGE.
 
 
#include "libtorrent/aux_/session_impl.hpp"
-#include +#include <boost/bind.hpp> -#include -#include -#include -#include // for generate_random_id -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // time() +#include <libtorrent/io.hpp> +#include <libtorrent/random.hpp> +#include <libtorrent/invariant_check.hpp> +#include <libtorrent/kademlia/node_id.hpp> // for generate_random_id +#include <libtorrent/kademlia/rpc_manager.hpp> +#include <libtorrent/kademlia/logging.hpp> +#include <libtorrent/kademlia/routing_table.hpp> +#include <libtorrent/kademlia/find_data.hpp> +#include <libtorrent/kademlia/refresh.hpp> +#include <libtorrent/kademlia/node.hpp> +#include <libtorrent/kademlia/observer.hpp> +#include <libtorrent/kademlia/dht_observer.hpp> +#include <libtorrent/hasher.hpp> +#include <libtorrent/time.hpp> +#include <time.h> // time() #ifdef TORRENT_DHT_VERBOSE_LOGGING -#include +#include <fstream> #endif namespace libtorrent { namespace dht @@ -303,20 +303,20 @@ namespace io = libtorrent::detail; #ifdef TORRENT_DHT_VERBOSE_LOGGING TORRENT_DEFINE_LOG(rpc)
relevance 3include/libtorrent/kademlia/find_data.hpp:60rename this class to find_peers, since that's what it does find_data is an unnecessarily generic name

rename this class to find_peers, since that's what it does -find_data is an unnecessarily generic name

include/libtorrent/kademlia/find_data.hpp:60

#include 
-#include 
-#include 
-#include 
-#include 
+find_data is an unnecessarily generic name

include/libtorrent/kademlia/find_data.hpp:60

#include <libtorrent/kademlia/node_id.hpp>
+#include <libtorrent/kademlia/routing_table.hpp>
+#include <libtorrent/kademlia/rpc_manager.hpp>
+#include <libtorrent/kademlia/observer.hpp>
+#include <libtorrent/kademlia/msg.hpp>
 
-#include 
-#include 
-#include 
+#include <boost/optional.hpp>
+#include <boost/function/function1.hpp>
+#include <boost/function/function2.hpp>
 
 namespace libtorrent { namespace dht
 {
 
-typedef std::vector packet_t;
+typedef std::vector<char> packet_t;
 
 class rpc_manager;
 class node_impl;
@@ -326,16 +326,16 @@ class node_impl;
 
class find_data : public traversal_algorithm
{ public: - typedef boost::function const&)> data_callback; - typedef boost::function > const&, bool)> nodes_callback; + typedef boost::function<void(std::vector<tcp::endpoint> const&)> data_callback; + typedef boost::function<void(std::vector<std::pair<node_entry, std::string> > const&, bool)> nodes_callback; - void got_peers(std::vector const& peers); - void got_write_token(node_id const& n, std::string const& write_token) + void got_peers(std::vector<tcp::endpoint> const& peers); + void got_write_token(node_id const& n, std::string const& write_token) { m_write_tokens[n] = write_token; } - find_data(node_impl& node, node_id target - , data_callback const& dcallback - , nodes_callback const& ncallback + find_data(node_impl& node, node_id target + , data_callback const& dcallback + , nodes_callback const& ncallback , bool noseeds); virtual char const* name() const { return "get_peers"; } @@ -345,19 +345,19 @@ public: protected: void done(); - observer_ptr new_observer(void* ptr, udp::endpoint const& ep, node_id const& id); + observer_ptr new_observer(void* ptr, udp::endpoint const& ep, node_id const& id); virtual bool invoke(observer_ptr o); private: data_callback m_data_callback; nodes_callback m_nodes_callback; - std::map m_write_tokens; + std::map<node_id, std::string> m_write_tokens; node_id const m_target;
relevance 2src/torrent.cpp:5790pass in ec along with the alert

pass in ec along with the alert

src/torrent.cpp:5790

-		if (info_hash != m_torrent_file->info_hash())
+		if (info_hash != m_torrent_file->info_hash())
 		{
-			if (alerts().should_post())
+			if (alerts().should_post<metadata_failed_alert>())
 			{
 				alerts().post_alert(metadata_failed_alert(get_handle()));
 			}
@@ -367,12 +367,12 @@ private:
 		lazy_entry metadata;
 		error_code ec;
 		int ret = lazy_bdecode(metadata_buf, metadata_buf + metadata_size, metadata, ec);
-		if (ret != 0 || !m_torrent_file->parse_info_section(metadata, ec, 0))
+		if (ret != 0 || !m_torrent_file->parse_info_section(metadata, ec, 0))
 		{
 			// this means the metadata is correct, since we
 			// verified it against the info-hash, but we
 			// failed to parse it. Pause the torrent
-			if (alerts().should_post())
+			if (alerts().should_post<metadata_failed_alert>())
 			{
 
alerts().post_alert(metadata_failed_alert(get_handle()));
} @@ -381,7 +381,7 @@ private: return false; } - if (m_ses.m_alerts.should_post()) + if (m_ses.m_alerts.should_post<metadata_received_alert>()) { m_ses.m_alerts.post_alert(metadata_received_alert( get_handle())); @@ -400,11 +400,11 @@ private: init(); // disconnect redundant peers - for (std::set::iterator i = m_connections.begin() + for (std::set<peer_connection*>::iterator i = m_connections.begin() , end(m_connections.end()); i != end;) { - std::set::iterator p = i++; - (*p)->disconnect_if_redundant(); + std::set<peer_connection*>::iterator p = i++; + (*p)->disconnect_if_redundant();
relevance 2src/utp_stream.cpp:617support the option to turn it off

support the option to turn it off

src/utp_stream.cpp:617

		UTP_STATE_ERROR_WAIT,
 
 		// there are no more references to this socket
@@ -474,12 +474,12 @@ are pushed back and items are popped from the front

include/libtorrent/t int peers; // the piece index int piece; - bool operator<(time_critical_piece const& rhs) const - { return deadline < rhs.deadline; } + bool operator<(time_critical_piece const& rhs) const + { return deadline < rhs.deadline; } }; // this list is sorted by time_critical_piece::deadline -
std::list m_time_critical_pieces; +
std::list<time_critical_piece> m_time_critical_pieces;
std::string m_trackerid; std::string m_username; @@ -488,7 +488,7 @@ are pushed back and items are popped from the front

include/libtorrent/t // the network interfaces outgoing connections // are opened through. If there is more then one, // they are used in a round-robin fasion - std::vector m_net_interfaces; + std::vector<union_endpoint> m_net_interfaces; std::string m_save_path; @@ -506,7 +506,7 @@ are pushed back and items are popped from the front

include/libtorrent/t // this is used as temporary storage while downloading // the .torrent file from m_url - std::vector m_torrent_file_buf; + std::vector<char> m_torrent_file_buf; // each bit represents a piece. a set bit means // the piece has had its hash verified. This @@ -550,18 +550,18 @@ for the routing table

include/libtorrent/kademlia/node_entry.hpp:92

#endif
relevance 1src/http_seed_connection.cpp:120in 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:120

	boost::optional
+the chunk headers should be subtracted from the receive_buffer_size

src/http_seed_connection.cpp:120

	boost::optional<piece_block_progress>
 	http_seed_connection::downloading_piece_progress() const
 	{
 		if (m_requests.empty())
-			return boost::optional();
+			return boost::optional<piece_block_progress>();
 
-		boost::shared_ptr t = associated_torrent().lock();
+		boost::shared_ptr<torrent> t = associated_torrent().lock();
 		TORRENT_ASSERT(t);
 
 		piece_block_progress ret;
 
-		peer_request const& pr = m_requests.front();
+		peer_request const& pr = m_requests.front();
 		ret.piece_index = pr.piece;
 		if (!m_parser.header_finished())
 		{
@@ -570,33 +570,33 @@ the chunk headers should be subtracted from the receive_buffer_size

src/ else { int receive_buffer_size = receive_buffer().left() - m_parser.body_start(); -
TORRENT_ASSERT(receive_buffer_size <= t->block_size()); -
ret.bytes_downloaded = t->block_size() - receive_buffer_size; +
TORRENT_ASSERT(receive_buffer_size <= t->block_size()); +
ret.bytes_downloaded = t->block_size() - receive_buffer_size; } // this is used to make sure that the block_index stays within // bounds. If the entire piece is downloaded, the block_index // would otherwise point to one past the end int correction = ret.bytes_downloaded ? -1 : 0; - ret.block_index = (pr.start + ret.bytes_downloaded + correction) / t->block_size(); - ret.full_block_bytes = t->block_size(); - const int last_piece = t->torrent_file().num_pieces() - 1; - if (ret.piece_index == last_piece && ret.block_index - == t->torrent_file().piece_size(last_piece) / t->block_size()) - ret.full_block_bytes = t->torrent_file().piece_size(last_piece) % t->block_size(); + ret.block_index = (pr.start + ret.bytes_downloaded + correction) / t->block_size(); + ret.full_block_bytes = t->block_size(); + const int last_piece = t->torrent_file().num_pieces() - 1; + if (ret.piece_index == last_piece && ret.block_index + == t->torrent_file().piece_size(last_piece) / t->block_size()) + ret.full_block_bytes = t->torrent_file().piece_size(last_piece) % t->block_size(); return ret; } - void http_seed_connection::write_request(peer_request const& r) + void http_seed_connection::write_request(peer_request const& r) { INVARIANT_CHECK; - boost::shared_ptr t = associated_torrent().lock(); + boost::shared_ptr<torrent> t = associated_torrent().lock(); TORRENT_ASSERT(t); - TORRENT_ASSERT(t->valid_metadata()); + TORRENT_ASSERT(t->valid_metadata()); // http_seeds don't support requesting more than one piece // at a time - TORRENT_ASSERT(r.length <= t->torrent_file().piece_size(r.piece)); + TORRENT_ASSERT(r.length <= t->torrent_file().piece_size(r.piece)); std::string request; request.reserve(400); @@ -613,8 +613,8 @@ all completed disk operations

src/peer_connection.cpp:2488

 t)
+	void peer_connection::on_disk_write_complete(int ret, disk_io_job const& j
+		, peer_request p, boost::shared_ptr<torrent> t)
 	{
 #ifdef TORRENT_STATS
 		++m_ses.m_num_messages[aux::session_impl::on_disk_write_counter];
@@ -627,11 +627,11 @@ all completed disk operations

src/peer_connection.cpp:2488

= 0);
+		TORRENT_ASSERT(m_outstanding_writing_bytes >= 0);
 
 #if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
-//		(*m_ses.m_logger) << time_now_string() << " *** DISK_WRITE_COMPLETE [ p: "
-//			<< p.piece << " o: " << p.start << " ]\n";
+//		(*m_ses.m_logger) << time_now_string() << " *** DISK_WRITE_COMPLETE [ p: "
+//			<< p.piece << " o: " << p.start << " ]\n";
 #endif
 
 		if (!t)
@@ -644,19 +644,19 @@ all completed disk operations

src/peer_connection.cpp:2488

block_size());
+		piece_block block_finished(p.piece, p.start / t->block_size());
 
 		if (ret == -1)
 		{
 			// handle_disk_error may disconnect us
-			t->handle_disk_error(j, this);
+			t->handle_disk_error(j, this);
 			return;
 		}
 
 
relevance 1src/session_impl.cpp:6135we 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:6135

	void session_impl::set_external_address(address const& ip
-		, int source_type, address const& source)
+is kind of expensive, it would be nice to not do it unnecessarily

src/session_impl.cpp:6135

	void session_impl::set_external_address(address const& ip
+		, int source_type, address const& source)
 	{
 #if defined TORRENT_VERBOSE_LOGGING
 		session_log(": set_external_address(%s, %d, %s)", print_address(ip).c_str()
@@ -669,7 +669,7 @@ is kind of expensive, it would be nice to not do it unnecessarily

src/se session_log(" external IP updated"); #endif - if (m_alerts.should_post()) + if (m_alerts.should_post<external_ip_alert>()) m_alerts.post_alert(external_ip_alert(ip)); // since we have a new external IP now, we need to @@ -677,14 +677,14 @@ is kind of expensive, it would be nice to not do it unnecessarily

src/se #ifndef TORRENT_DISABLE_DHT
if (m_dht)
{ - entry s = m_dht->state(); + entry s = m_dht->state(); int cur_state = 0; int prev_state = 0; entry* nodes1 = s.find_key("nodes"); - if (nodes1 && nodes1->type() == entry::list_t) cur_state = nodes1->list().size(); + if (nodes1 && nodes1->type() == entry::list_t) cur_state = nodes1->list().size(); entry* nodes2 = m_dht_state.find_key("nodes"); - if (nodes2 && nodes2->type() == entry::list_t) prev_state = nodes2->list().size(); - if (cur_state > prev_state) m_dht_state = s; + if (nodes2 && nodes2->type() == entry::list_t) prev_state = nodes2->list().size(); + if (cur_state > prev_state) m_dht_state = s; start_dht(m_dht_state); } #endif @@ -705,9 +705,9 @@ is kind of expensive, it would be nice to not do it unnecessarily

src/se TORRENT_ASSERT(is_network_thread()); #ifdef TORRENT_DISK_STATS - TORRENT_ASSERT(m_buffer_allocations >= 0); + TORRENT_ASSERT(m_buffer_allocations >= 0);

relevance 1src/torrent.cpp:5294save 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:5294

						? (1 << k) : 0;
+it may pose an issue when downgrading though

src/torrent.cpp:5294

						? (1 << k) : 0;
 					bitmask.append(1, v);
 					TORRENT_ASSERT(bits == 8 || j == num_bitmask_bytes - 1);
 				}
@@ -720,23 +720,23 @@ it may pose an issue when downgrading though

src/torrent.cpp:5294

::const_iterator i = m_trackers.begin() + for (std::vector<announce_entry>::const_iterator i = m_trackers.begin() , end(m_trackers.end()); i != end; ++i) { // don't save trackers we can't trust -

if (i->send_stats == false) continue; -
if (i->tier == tier) +
if (i->send_stats == false) continue; +
if (i->tier == tier) { - tr_list.back().list().push_back(i->url); + tr_list.back().list().push_back(i->url); } else { tr_list.push_back(entry::list_t); - tr_list.back().list().push_back(i->url); - tier = i->tier; + tr_list.back().list().push_back(i->url); + tier = i->tier; } } } @@ -744,21 +744,21 @@ it may pose an issue when downgrading though

src/torrent.cpp:5294

::const_iterator i = m_web_seeds.begin() + entry::list_type& url_list = ret["url-list"].list(); + entry::list_type& httpseed_list = ret["httpseeds"].list(); + for (std::list<web_seed_entry>::const_iterator i = m_web_seeds.begin() , end(m_web_seeds.end()); i != end; ++i) { - if (i->type == web_seed_entry::url_seed) - url_list.push_back(i->url); - else if (i->type == web_seed_entry::http_seed) - httpseed_list.push_back(i->url); + if (i->type == web_seed_entry::url_seed) + url_list.push_back(i->url); + else if (i->type == web_seed_entry::http_seed) + httpseed_list.push_back(i->url); } } // write have bitmask // the pieces string has one byte per piece. Each -

relevance 0src/bt_peer_connection.cpp:660this could be optimized using knuth morris pratt

this could be optimized using knuth morris pratt

src/bt_peer_connection.cpp:660

		if (m_encrypted && m_rc4_encrypted)
+
relevance 0src/bt_peer_connection.cpp:660this could be optimized using knuth morris pratt

this could be optimized using knuth morris pratt

src/bt_peer_connection.cpp:660

		if (m_encrypted && m_rc4_encrypted)
 		{
 			fun = encrypt;
 			userdata = m_enc_handler.get();
@@ -771,14 +771,14 @@ it may pose an issue when downgrading though

src/torrent.cpp:5294

= src_size); - TORRENT_ASSERT(src_size > 0); + TORRENT_ASSERT(target_size >= src_size); + TORRENT_ASSERT(src_size > 0); TORRENT_ASSERT(src); TORRENT_ASSERT(target); int traverse_limit = target_size - src_size; -

for (int i = 0; i < traverse_limit; ++i) +
for (int i = 0; i < traverse_limit; ++i)
{ char const* target_ptr = target + i; if (std::equal(src, src+src_size, target_ptr)) @@ -786,22 +786,22 @@ it may pose an issue when downgrading though

src/torrent.cpp:5294

ret; +// std::pair<const char*, const char*> ret; // int src_sync_size; -// if (i > traverse_limit) // partial sync test +// if (i > traverse_limit) // partial sync test // { -// ret = std::mismatch(src, src + src_size - (i - traverse_limit), &target[i]); +// 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]); +// ret = std::mismatch(src, src + src_size, &target[i]); // src_sync_size = ret.first - src; // if (src_sync_size == src_size) // return i; @@ -812,13 +812,13 @@ it may pose an issue when downgrading though

src/torrent.cpp:5294

relevance 0src/bt_peer_connection.cpp:1755don't trust this blindly

don't trust this blindly

src/bt_peer_connection.cpp:1755

		// but where do we put that info?
 
 		int last_seen_complete = boost::uint8_t(root.dict_find_int_value("complete_ago", -1));
-		if (last_seen_complete >= 0) set_last_seen_complete(last_seen_complete);
+		if (last_seen_complete >= 0) set_last_seen_complete(last_seen_complete);
 		
 		std::string client_info = root.dict_find_string_value("v");
 		if (!client_info.empty()) m_client_version = client_info;
 
 		int reqq = int(root.dict_find_int_value("reqq"));
-		if (reqq > 0) m_max_out_request_queue = reqq;
+		if (reqq > 0) m_max_out_request_queue = reqq;
 
 		if (root.dict_find_int_value("upload_only", 0))
 			set_upload_only(true);
@@ -854,16 +854,16 @@ it may pose an issue when downgrading though

src/torrent.cpp:5294

is_finished() && upload_only() - && t->settings().close_redundant_connections - && !t->share_mode()) + if (t->is_finished() && upload_only() + && t->settings().close_redundant_connections + && !t->share_mode()) disconnect(errors::upload_upload_connection); } -

relevance 0src/bt_peer_connection.cpp:2069if we're finished, send upload_only message

if we're finished, send upload_only message

src/bt_peer_connection.cpp:2069

			if (msg[5 + k / 8] & (0x80 >> (k % 8))) bitfield_string[k] = '1';
+
relevance 0src/bt_peer_connection.cpp:2069if we're finished, send upload_only message

if we're finished, send upload_only message

src/bt_peer_connection.cpp:2069

			if (msg[5 + k / 8] & (0x80 >> (k % 8))) bitfield_string[k] = '1';
 			else bitfield_string[k] = '0';
 		}
-		peer_log("==> BITFIELD [ %s ]", bitfield_string.c_str());
+		peer_log("==> BITFIELD [ %s ]", bitfield_string.c_str());
 #endif
 #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
 		m_sent_bitfield = true;
@@ -871,12 +871,12 @@ it may pose an issue when downgrading though

src/torrent.cpp:5294

0) + if (num_lazy_pieces > 0) { - for (int i = 0; i < num_lazy_pieces; ++i) + for (int i = 0; i < num_lazy_pieces; ++i) { #ifdef TORRENT_VERBOSE_LOGGING - peer_log("==> HAVE [ piece: %d ]", lazy_pieces[i]); + peer_log("==> HAVE [ piece: %d ]", lazy_pieces[i]); #endif write_have(lazy_pieces[i]); } @@ -895,7 +895,7 @@ it may pose an issue when downgrading though

src/torrent.cpp:5294

src/torrent.cpp:5294

out(remote_address); + std::back_insert_iterator<std::string> out(remote_address); detail::write_address(remote().address(), out); handshake["yourip"] = remote_address; handshake["reqq"] = m_ses.settings().max_allowed_in_request_queue;

relevance 0src/bt_peer_connection.cpp:3308move the erasing into the loop above remove all payload ranges that has been sent

move the erasing into the loop above -remove all payload ranges that has been sent

src/bt_peer_connection.cpp:3308

			for (std::vector::iterator i = m_payloads.begin();
+remove all payload ranges that has been sent

src/bt_peer_connection.cpp:3308

			for (std::vector<range>::iterator i = m_payloads.begin();
 				i != m_payloads.end(); ++i)
 			{
-				i->start -= bytes_transferred;
-				if (i->start < 0)
+				i->start -= bytes_transferred;
+				if (i->start < 0)
 				{
-					if (i->start + i->length <= 0)
+					if (i->start + i->length <= 0)
 					{
-						amount_payload += i->length;
+						amount_payload += i->length;
 					}
 					else
 					{
-						amount_payload += -i->start;
-						i->length -= -i->start;
-						i->start = 0;
+						amount_payload += -i->start;
+						i->length -= -i->start;
+						i->start = 0;
 					}
 				}
 			}
@@ -936,21 +936,21 @@ remove all payload ranges that has been sent

src/bt_peer_connection.cpp:

std::remove_if(m_payloads.begin(), m_payloads.end(), range_below_zero) , m_payloads.end()); - TORRENT_ASSERT(amount_payload <= (int)bytes_transferred); + TORRENT_ASSERT(amount_payload <= (int)bytes_transferred); m_statistics.sent_bytes(amount_payload, bytes_transferred - amount_payload); - if (amount_payload > 0) + if (amount_payload > 0) { - boost::shared_ptr t = associated_torrent().lock(); + boost::shared_ptr<torrent> t = associated_torrent().lock(); TORRENT_ASSERT(t); - if (t) t->update_last_upload(); + if (t) t->update_last_upload(); } } #ifdef TORRENT_DEBUG void bt_peer_connection::check_invariant() const { - boost::shared_ptr t = associated_torrent().lock(); + boost::shared_ptr<torrent> t = associated_torrent().lock(); #ifndef TORRENT_DISABLE_ENCRYPTION TORRENT_ASSERT( (bool(m_state != read_pe_dhkey) || m_dh_key_exchange.get()) @@ -981,12 +981,12 @@ remove all payload ranges that has been sent

src/bt_peer_connection.cpp: radvisory r; r.ra_offset = file_offset; r.ra_count = len; - fcntl(m_fd, F_RDADVISE, &r); + fcntl(m_fd, F_RDADVISE, &r); #else
#endif
} - size_type file::readv(size_type file_offset, iovec_t const* bufs, int num_bufs, error_code& ec) + size_type file::readv(size_type file_offset, iovec_t const* bufs, int num_bufs, error_code& ec) { #ifdef TORRENT_WINDOWS if (m_file_handle == INVALID_HANDLE_VALUE) @@ -1001,9 +1001,9 @@ remove all payload ranges that has been sent

src/bt_peer_connection.cpp: return -1; } #endif - TORRENT_ASSERT((m_open_mode & rw_mask) == read_only || (m_open_mode & rw_mask) == read_write); + TORRENT_ASSERT((m_open_mode & rw_mask) == read_only || (m_open_mode & rw_mask) == read_write); TORRENT_ASSERT(bufs); - TORRENT_ASSERT(num_bufs > 0); + TORRENT_ASSERT(num_bufs > 0); TORRENT_ASSERT(is_open()); #if defined TORRENT_WINDOWS || defined TORRENT_LINUX || defined TORRENT_DEBUG @@ -1012,11 +1012,11 @@ remove all payload ranges that has been sent

src/bt_peer_connection.cpp: #endif #ifdef TORRENT_DEBUG - if (m_open_mode & no_buffer) + if (m_open_mode & no_buffer) { -

relevance 0src/http_tracker_connection.cpp:99support authentication (i.e. user name and password) in the URL

support authentication (i.e. user name and password) in the URL

src/http_tracker_connection.cpp:99

		, aux::session_impl const& ses
-		, proxy_settings const& ps
-		, std::string const& auth
+
relevance 0src/http_tracker_connection.cpp:99support authentication (i.e. user name and password) in the URL

support authentication (i.e. user name and password) in the URL

src/http_tracker_connection.cpp:99

		, aux::session_impl const& ses
+		, proxy_settings const& ps
+		, std::string const& auth
 #if TORRENT_USE_I2P
 		, i2p_connection* i2p_conn
 #endif
@@ -1044,7 +1044,7 @@ remove all payload ranges that has been sent

src/bt_peer_connection.cpp: std::size_t pos = url.find("announce"); if (pos == std::string::npos) { - m_ios.post(boost::bind(&http_tracker_connection::fail_disp, self() + m_ios.post(boost::bind(&http_tracker_connection::fail_disp, self() , error_code(errors::scrape_not_available))); return; } @@ -1057,21 +1057,21 @@ remove all payload ranges that has been sent

src/bt_peer_connection.cpp: static const bool i2p = false; #endif - session_settings const& settings = m_ses.settings(); + session_settings const& settings = m_ses.settings(); // if request-string already contains // some parameters, append an ampersand instead // of a question mark size_t arguments_start = url.find('?'); if (arguments_start != std::string::npos) - url += "&"; + url += "&";

relevance 0src/i2p_stream.cpp:172move this to proxy_base and use it in all proxies

move this to proxy_base and use it in all proxies

src/i2p_stream.cpp:172

	{
 		m_state = sam_idle;
 
-		std::string name = m_sam_socket->name_lookup();
+		std::string name = m_sam_socket->name_lookup();
 		if (!m_name_lookup.empty())
 		{
-			std::pair& nl = m_name_lookup.front();
+			std::pair<std::string, name_lookup_handler>& nl = m_name_lookup.front();
 			do_name_lookup(nl.first, nl.second);
 			m_name_lookup.pop_front();
 		}
@@ -1085,7 +1085,7 @@ remove all payload ranges that has been sent

src/bt_peer_connection.cpp: handler(ec, name.c_str()); } -
bool i2p_stream::handle_error(error_code const& e, boost::shared_ptr const& h) +
bool i2p_stream::handle_error(error_code const& e, boost::shared_ptr<handler_type> const& h)
{ if (!e) return false; // fprintf(stderr, "i2p error \"%s\"\n", e.message().c_str()); @@ -1095,8 +1095,8 @@ remove all payload ranges that has been sent

src/bt_peer_connection.cpp: return true; } - void i2p_stream::do_connect(error_code const& e, tcp::resolver::iterator i - , boost::shared_ptr h) + void i2p_stream::do_connect(error_code const& e, tcp::resolver::iterator i + , boost::shared_ptr<handler_type> h) { if (e || i == tcp::resolver::iterator()) { @@ -1106,26 +1106,26 @@ remove all payload ranges that has been sent

src/bt_peer_connection.cpp: return; } - m_sock.async_connect(i->endpoint(), boost::bind( - &i2p_stream::connected, this, _1, h)); + m_sock.async_connect(i->endpoint(), boost::bind( + &i2p_stream::connected, this, _1, h)); } - void i2p_stream::connected(error_code const& e, boost::shared_ptr h) + void i2p_stream::connected(error_code const& e, boost::shared_ptr<handler_type> h) { if (handle_error(e, h)) return; // send hello command m_state = read_hello_response; -

relevance 0src/packet_buffer.cpp:176use 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;
+
relevance 0src/packet_buffer.cpp:176use 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);
 
-		for (index_type i = 0; i < new_size; ++i)
+		for (index_type i = 0; i < new_size; ++i)
 			new_storage[i] = 0;
 
-		for (index_type i = m_first; i < (m_first + m_capacity); ++i)
-			new_storage[i & (new_size - 1)] = m_storage[i & (m_capacity - 1)];
+		for (index_type i = m_first; i < (m_first + m_capacity); ++i)
+			new_storage[i & (new_size - 1)] = m_storage[i & (m_capacity - 1)];
 
 		free(m_storage);
 
@@ -1136,15 +1136,15 @@ remove all payload ranges that has been sent

src/bt_peer_connection.cpp: void* packet_buffer::remove(index_type idx) { INVARIANT_CHECK; -
if (idx >= m_first + m_capacity) +
if (idx >= m_first + m_capacity)
return 0; if (compare_less_wrap(idx, m_first, 0xffff)) return 0; const int mask = (m_capacity - 1); - void* old_value = m_storage[idx & mask]; - m_storage[idx & mask] = 0; + void* old_value = m_storage[idx & mask]; + m_storage[idx & mask] = 0; if (old_value) { @@ -1152,21 +1152,21 @@ remove all payload ranges that has been sent

src/bt_peer_connection.cpp: if (m_size == 0) m_last = m_first; } - if (idx == m_first && m_size != 0) + if (idx == m_first && m_size != 0) { ++m_first; - for (boost::uint32_t i = 0; i < m_capacity; ++i, ++m_first) - if (m_storage[m_first & mask]) break; - m_first &= 0xffff; + for (boost::uint32_t i = 0; i < m_capacity; ++i, ++m_first) + if (m_storage[m_first & mask]) break; + m_first &= 0xffff; } - if (((idx + 1) & 0xffff) == m_last && m_size != 0) + if (((idx + 1) & 0xffff) == m_last && m_size != 0) { --m_last; - for (boost::uint32_t i = 0; i < m_capacity; ++i, --m_last) - if (m_storage[m_last & mask]) break; + for (boost::uint32_t i = 0; i < m_capacity; ++i, --m_last) + if (m_storage[m_last & mask]) break; ++m_last; - m_last &= 0xffff; + m_last &= 0xffff;

relevance 0src/peer_connection.cpp:2651this might need something more so that once we have the metadata we can construct a full bitfield

this might need something more so that once we have the metadata we can construct a full bitfield

src/peer_connection.cpp:2651

@@ -1174,7 +1174,7 @@ we can construct a full bitfield

src/peer_connection.cpp:2651

get_policy().set_seed(m_peer_info, true);
+		t->get_policy().set_seed(m_peer_info, true);
 		m_upload_only = true;
 		m_bitfield_received = true;
 
@@ -1182,11 +1182,11 @@ we can construct a full bitfield

src/peer_connection.cpp:2651

ready_for_connections())
+		if (!t->ready_for_connections())
 		{
 			// assume seeds are interesting when we
 			// don't even have the metadata
-			t->get_policy().peer_is_interesting(*this);
+			t->get_policy().peer_is_interesting(*this);
 
 			disconnect_if_redundant();
 
return; @@ -1196,11 +1196,11 @@ we can construct a full bitfield

src/peer_connection.cpp:2651

peer_has_all(this);
+		t->peer_has_all(this);
 
 		// if we're finished, we're not interested
-		if (t->is_upload_only()) send_not_interested();
-		else t->get_policy().peer_is_interesting(*this);
+		if (t->is_upload_only()) send_not_interested();
+		else t->get_policy().peer_is_interesting(*this);
 
 		disconnect_if_redundant();
 	}
@@ -1214,10 +1214,10 @@ we can construct a full bitfield

src/peer_connection.cpp:2651

 t = m_torrent.lock();
+		boost::shared_ptr<torrent> t = m_torrent.lock();
 		TORRENT_ASSERT(t);
 
 
relevance 0src/peer_connection.cpp:2782sort the allowed fast set in priority order

sort the allowed fast set in priority order

src/peer_connection.cpp:2782

		// this piece index later
@@ -1225,19 +1225,19 @@ we can construct a full bitfield

src/peer_connection.cpp:2651

 index
-			&& m_have_piece[index]
-			&& t->valid_metadata()
-			&& t->has_picker()
-			&& t->picker().piece_priority(index) > 0)
+		if (int(m_have_piece.size()) > index
+			&& m_have_piece[index]
+			&& t->valid_metadata()
+			&& t->has_picker()
+			&& t->picker().piece_priority(index) > 0)
 		{
-			t->get_policy().peer_is_interesting(*this);
+			t->get_policy().peer_is_interesting(*this);
 		}
 	}
 
-	std::vector const& peer_connection::allowed_fast()
+	std::vector<int> const& peer_connection::allowed_fast()
 	{
-		boost::shared_ptr t = m_torrent.lock();
+		boost::shared_ptr<torrent> t = m_torrent.lock();
 		TORRENT_ASSERT(t);
 
 
return m_allowed_fast; @@ -1247,28 +1247,28 @@ we can construct a full bitfield

src/peer_connection.cpp:2651

 m_desired_queue_size * 2) return false;
+			> m_desired_queue_size * 2) return false;
 		if (on_parole()) return false; 
 		if (m_disconnecting) return false;
-		boost::shared_ptr t = m_torrent.lock();
+		boost::shared_ptr<torrent> t = m_torrent.lock();
 		TORRENT_ASSERT(t);
-		if (t->upload_mode()) return false;
+		if (t->upload_mode()) return false;
 		return true;
 	}
 
-	void peer_connection::make_time_critical(piece_block const& block)
+	void peer_connection::make_time_critical(piece_block const& block)
 	{
-		std::vector::iterator rit = std::find_if(m_request_queue.begin()
+		std::vector<pending_block>::iterator rit = std::find_if(m_request_queue.begin()
 			, m_request_queue.end(), has_block(block));
 		if (rit == m_request_queue.end()) return;
 #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
-		boost::shared_ptr t = m_torrent.lock();
+		boost::shared_ptr<torrent> t = m_torrent.lock();
 		TORRENT_ASSERT(t);
-		TORRENT_ASSERT(t->has_picker());
-		TORRENT_ASSERT(t->picker().is_requested(block));
+		TORRENT_ASSERT(t->has_picker());
+		TORRENT_ASSERT(t->picker().is_requested(block));
 #endif
 		// ignore it if it's already time critical
-		if (rit - m_request_queue.begin() < m_queued_time_critical) return;
+		if (rit - m_request_queue.begin() < m_queued_time_critical) return;
 		pending_block b = *rit;
 		m_request_queue.erase(rit);
 
relevance 0src/peer_connection.cpp:3892we should probably just send a HAVE_ALL here

we should probably just send a HAVE_ALL here

src/peer_connection.cpp:3892

		std::fill(m_recv_buffer.begin() + m_recv_pos, m_recv_buffer.end(), 0);
@@ -1288,14 +1288,14 @@ we can construct a full bitfield

src/peer_connection.cpp:2651

 t = m_torrent.lock();
+			boost::shared_ptr<torrent> t = m_torrent.lock();
 			assert(t);
 
-
for (int i = 0; i < int(m_have_piece.size()); ++i) +
for (int i = 0; i < int(m_have_piece.size()); ++i)
{ - if (m_have_piece[i] || !t->have_piece(i)) continue; + if (m_have_piece[i] || !t->have_piece(i)) continue; #ifdef TORRENT_VERBOSE_LOGGING - peer_log("==> HAVE [ piece: %d] (ending super seed)", i); + peer_log("==> HAVE [ piece: %d] (ending super seed)", i); #endif write_have(i); } @@ -1306,11 +1306,11 @@ we can construct a full bitfield

src/peer_connection.cpp:2651

 HAVE    [ piece: %d ] (super seed)", new_piece);
+		peer_log("==> HAVE    [ piece: %d ] (super seed)", new_piece);
 #endif
 		write_have(new_piece);
 
-		if (replace_piece >= 0)
+		if (replace_piece >= 0)
 		{
 			// move the piece we're replacing to the tail
 			if (m_superseed_piece[0] == replace_piece)
@@ -1325,9 +1325,9 @@ we can construct a full bitfield

src/peer_connection.cpp:2651

relevance 0src/peer_connection.cpp:4475peers should really be corked/uncorked outside of all completed disk operations

peers should really be corked/uncorked outside of all completed disk operations

src/peer_connection.cpp:4475

				// this means we're in seed mode and we haven't yet
 				// verified this piece (r.piece)
-				t->filesystem().async_read_and_hash(r, boost::bind(&peer_connection::on_disk_read_complete
+				t->filesystem().async_read_and_hash(r, boost::bind(&peer_connection::on_disk_read_complete
 					, self(), _1, _2, r), cache.second);
-				t->verified(r.piece);
+				t->verified(r.piece);
 			}
 
 			m_reading_bytes += r.length;
@@ -1336,11 +1336,11 @@ all completed disk operations

src/peer_connection.cpp:4475

share_mode() && sent_a_piece)
-			t->recalc_share_mode();
+		if (t->share_mode() && sent_a_piece)
+			t->recalc_share_mode();
 	}
 
-	void peer_connection::on_disk_read_complete(int ret, disk_io_job const& j, peer_request r)
+	void peer_connection::on_disk_read_complete(int ret, disk_io_job const& j, peer_request r)
 	{
 		// flush send buffer at the end of this scope
 
cork _c(*this); @@ -1357,7 +1357,7 @@ all completed disk operations

src/peer_connection.cpp:4475

 t = m_torrent.lock();
+		boost::shared_ptr<torrent> t = m_torrent.lock();
 		if (!t)
 		{
 			disconnect(j.error);
@@ -1369,14 +1369,14 @@ all completed disk operations

src/peer_connection.cpp:4475

 REJECT_PIECE [ piece: %d s: %d l: %d ]"
+				peer_log("==> REJECT_PIECE [ piece: %d s: %d l: %d ]"
 					, r.piece , r.start , r.length);
 #endif
 				write_reject_request(r);
-				if (t->seed_mode()) t->leave_seed_mode(false);
+				if (t->seed_mode()) t->leave_seed_mode(false);
 
relevance 0src/policy.cpp:857only allow _one_ connection to use this override at a time

only allow _one_ connection to use this -override at a time

src/policy.cpp:857

				" external: " << external.external_address(m_peers[candidate]->address()) <<
-				" t: " << (session_time - m_peers[candidate]->last_connected) <<
+override at a time

src/policy.cpp:857

				" external: " << external.external_address(m_peers[candidate]->address()) <<
+				" t: " << (session_time - m_peers[candidate]->last_connected) <<
 				" ]\n";
 		}
 #endif
@@ -1385,7 +1385,7 @@ override at a time

src/policy.cpp:857

		error_code ec;
-
TORRENT_ASSERT(c.remote() == c.get_socket()->remote_endpoint(ec) || ec); - TORRENT_ASSERT(!m_torrent->is_paused()); +
TORRENT_ASSERT(c.remote() == c.get_socket()->remote_endpoint(ec) || ec); + TORRENT_ASSERT(!m_torrent->is_paused()); #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING - if (c.remote().address() == m_torrent->current_tracker().address()) + if (c.remote().address() == m_torrent->current_tracker().address()) { - m_torrent->debug_log("overriding connection limit for tracker NAT-check"); + m_torrent->debug_log("overriding connection limit for tracker NAT-check"); } #endif @@ -1410,15 +1410,15 @@ override at a time

src/policy.cpp:857

		if (peer_rank == 0)
 
peer_rank = peer_priority( - tcp::endpoint(external.external_address(this->address()), external_port) - , tcp::endpoint(this->address(), this->port)); + tcp::endpoint(external.external_address(this->address()), external_port) + , tcp::endpoint(this->address(), this->port)); return peer_rank; } @@ -1458,11 +1458,11 @@ override at a time

src/policy.cpp:857

statistics().total_payload_upload();
+			return connection->statistics().total_payload_upload();
 		}
 		else
 		{
-			return size_type(prev_amount_upload) << 10;
+			return size_type(prev_amount_upload) << 10;
 		}
 
relevance 0src/session_impl.cpp:1887recalculate all connect candidates for all torrents

recalculate all connect candidates for all torrents

src/session_impl.cpp:1887

		m_upload_rate.close();
 
@@ -1494,12 +1494,12 @@ override at a time

src/policy.cpp:857

	}
 
- void session_impl::set_ip_filter(ip_filter const& f) + void session_impl::set_ip_filter(ip_filter const& f) { INVARIANT_CHECK; @@ -1509,10 +1509,10 @@ override at a time

src/policy.cpp:857

relevance 0src/session_impl.cpp:4267allow extensions to sort torrents for queuing

allow extensions to sort torrents for queuing

src/session_impl.cpp:4267

			else if (!t->is_paused())
+
relevance 0src/session_impl.cpp:4267allow extensions to sort torrents for queuing

allow extensions to sort torrents for queuing

src/session_impl.cpp:4267

			else if (!t->is_paused())
 			{
-				TORRENT_ASSERT(t->m_resume_data_loaded || !t->valid_metadata());
+				TORRENT_ASSERT(t->m_resume_data_loaded || !t->valid_metadata());
 				--hard_limit;
 			  	if (is_active(t, settings()))
 				{
 					// this is not an auto managed torrent,
 					// if it's running and active, decrease the
 					// counters.
-					if (t->is_finished())
+					if (t->is_finished())
 						--num_seeds;
 					else
 						--num_downloaders;
@@ -1553,11 +1553,11 @@ override at a time

src/policy.cpp:857

relevance 0src/session_impl.cpp:4423use 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:4423

		{
-			if (m_boost_connections > max_connections)
+			if (m_boost_connections > max_connections)
 			{
 				m_boost_connections -= max_connections;
 				max_connections = 0;
@@ -1598,20 +1598,20 @@ connections

src/session_impl.cpp:4423

		if (!m_torrents.empty()
-			&& free_slots > -m_half_open.limit()
-			&& num_connections() < m_settings.connections_limit
-			&& !m_abort
-			&& m_settings.connection_speed > 0
-			&& max_connections > 0)
+			&& free_slots > -m_half_open.limit()
+			&& num_connections() < m_settings.connections_limit
+			&& !m_abort
+			&& m_settings.connection_speed > 0
+			&& max_connections > 0)
 		{
 			// this is the maximum number of connections we will
 			// attempt this tick
 			int average_peers = 0;
-			if (num_downloads > 0)
+			if (num_downloads > 0)
 				average_peers = num_downloads_peers / num_downloads;
 
 			if (m_next_connect_torrent == m_torrents.end())
@@ -1621,7 +1621,7 @@ connections

src/session_impl.cpp:4423

relevance 0src/session_impl.cpp:4457make this bias configurable

make this bias configurable

src/session_impl.cpp:4457

relevance 0src/session_impl.cpp:4458also take average_peers into account, to create a bias for downloading torrents with < average peers

also take average_peers into account, to create a bias for downloading torrents with < average peers

src/session_impl.cpp:4458

		{
-			if (m_boost_connections > max_connections)
+			if (m_boost_connections > max_connections)
 			{
 				m_boost_connections -= max_connections;
 				max_connections = 0;
@@ -1649,13 +1649,13 @@ connections

src/session_impl.cpp:4423

						TORRENT_ASSERT(m_num_active_downloading > 0);
+
TORRENT_ASSERT(m_num_active_downloading > 0);
num_attempts += m_num_active_finished / m_num_active_downloading; } - while (m_current_connect_attempts < num_attempts) + while (m_current_connect_attempts < num_attempts) { TORRENT_TRY { @@ -1670,34 +1670,34 @@ connections

src/session_impl.cpp:4423

src/session_impl.cpp:4602make configurable

make configurable

src/session_impl.cpp:4602

 #ifdef TORRENT_DEBUG
-			for (std::vector::const_iterator i = peers.begin()
+			for (std::vector<peer_connection*>::const_iterator i = peers.begin()
 				, end(peers.end()), prev(peers.end()); i != end; ++i)
 			{
 				if (prev != end)
 				{
-					boost::shared_ptr t1 = (*prev)->associated_torrent().lock();
+					boost::shared_ptr<torrent> t1 = (*prev)->associated_torrent().lock();
 					TORRENT_ASSERT(t1);
-					boost::shared_ptr t2 = (*i)->associated_torrent().lock();
+					boost::shared_ptr<torrent> t2 = (*i)->associated_torrent().lock();
 					TORRENT_ASSERT(t2);
-					TORRENT_ASSERT((*prev)->uploaded_since_unchoke() * 1000
-						* (1 + t1->priority()) / total_milliseconds(unchoke_interval)
-						>= (*i)->uploaded_since_unchoke() * 1000
-						* (1 + t2->priority()) / total_milliseconds(unchoke_interval));
+					TORRENT_ASSERT((*prev)->uploaded_since_unchoke() * 1000
+						* (1 + t1->priority()) / total_milliseconds(unchoke_interval)
+						>= (*i)->uploaded_since_unchoke() * 1000
+						* (1 + t2->priority()) / total_milliseconds(unchoke_interval));
 				}
 				prev = i;
 			}
@@ -1705,32 +1705,32 @@ connections

src/session_impl.cpp:4423

			int rate_threshold = 1024;
 
-			for (std::vector::const_iterator i = peers.begin()
+			for (std::vector<peer_connection*>::const_iterator i = peers.begin()
 				, end(peers.end()); i != end; ++i)
 			{
-				peer_connection const& p = **i;
+				peer_connection const& p = **i;
 				int rate = int(p.uploaded_since_unchoke()
 					* 1000 / total_milliseconds(unchoke_interval));
 
-				if (rate < rate_threshold) break;
+				if (rate < rate_threshold) break;
 
 				++m_allowed_upload_slots;
 
 
relevance 0src/session_impl.cpp:4616make configurable

make configurable

src/session_impl.cpp:4616

 #ifdef TORRENT_DEBUG
-			for (std::vector::const_iterator i = peers.begin()
+			for (std::vector<peer_connection*>::const_iterator i = peers.begin()
 				, end(peers.end()), prev(peers.end()); i != end; ++i)
 			{
 				if (prev != end)
 				{
-					boost::shared_ptr t1 = (*prev)->associated_torrent().lock();
+					boost::shared_ptr<torrent> t1 = (*prev)->associated_torrent().lock();
 					TORRENT_ASSERT(t1);
-					boost::shared_ptr t2 = (*i)->associated_torrent().lock();
+					boost::shared_ptr<torrent> t2 = (*i)->associated_torrent().lock();
 					TORRENT_ASSERT(t2);
-					TORRENT_ASSERT((*prev)->uploaded_since_unchoke() * 1000
-						* (1 + t1->priority()) / total_milliseconds(unchoke_interval)
-						>= (*i)->uploaded_since_unchoke() * 1000
-						* (1 + t2->priority()) / total_milliseconds(unchoke_interval));
+					TORRENT_ASSERT((*prev)->uploaded_since_unchoke() * 1000
+						* (1 + t1->priority()) / total_milliseconds(unchoke_interval)
+						>= (*i)->uploaded_since_unchoke() * 1000
+						* (1 + t2->priority()) / total_milliseconds(unchoke_interval));
 				}
 				prev = i;
 			}
@@ -1747,7 +1747,7 @@ connections

src/session_impl.cpp:4423

throttle();
+		int upload_limit = m_bandwidth_channel[peer_connection::upload_channel]->throttle();
 		if (m_settings.choking_algorithm == session_settings::auto_expand_choker
-			&& upload_limit > 0)
+			&& upload_limit > 0)
 		{
 			// if our current upload rate is less than 90% of our 
 			// limit AND most torrents are not "congested", i.e.
@@ -1785,19 +1785,19 @@ connections

src/session_impl.cpp:4423

 		if (torrent_ptr)
 		{
-			if ((params.flags & add_torrent_params::flag_duplicate_is_error) == 0)
+			if ((params.flags & add_torrent_params::flag_duplicate_is_error) == 0)
 			{
-				if (!params.uuid.empty() && torrent_ptr->uuid().empty())
-					torrent_ptr->set_uuid(params.uuid);
-				if (!params.url.empty() && torrent_ptr->url().empty())
-					torrent_ptr->set_url(params.url);
-				if (!params.source_feed_url.empty() && torrent_ptr->source_feed_url().empty())
-					torrent_ptr->set_source_feed_url(params.source_feed_url);
+				if (!params.uuid.empty() && torrent_ptr->uuid().empty())
+					torrent_ptr->set_uuid(params.uuid);
+				if (!params.url.empty() && torrent_ptr->url().empty())
+					torrent_ptr->set_url(params.url);
+				if (!params.source_feed_url.empty() && torrent_ptr->source_feed_url().empty())
+					torrent_ptr->set_source_feed_url(params.source_feed_url);
 				return torrent_handle(torrent_ptr);
 			}
 
@@ -1809,34 +1809,34 @@ connections

src/session_impl.cpp:4423

src/session_impl.cpp:5469report the proper address of the router

report the proper address of the router

src/session_impl.cpp:5469

	}
 
-	void session_impl::on_port_mapping(int mapping, address const& ip, int port
-		, error_code const& ec, int map_transport)
+	void session_impl::on_port_mapping(int mapping, address const& ip, int port
+		, error_code const& ec, int map_transport)
 	{
 		TORRENT_ASSERT(is_network_thread());
 
-		TORRENT_ASSERT(map_transport >= 0 && map_transport <= 1);
+		TORRENT_ASSERT(map_transport >= 0 && map_transport <= 1);
 
-		if (mapping == m_udp_mapping[map_transport] && port != 0)
+		if (mapping == m_udp_mapping[map_transport] && port != 0)
 		{
 			m_external_udp_port = port;
-			if (m_alerts.should_post())
+			if (m_alerts.should_post<portmap_alert>())
 				m_alerts.post_alert(portmap_alert(mapping, port
 					, map_transport));
 			return;
 		}
 
-		if (mapping == m_tcp_mapping[map_transport] && port != 0)
+		if (mapping == m_tcp_mapping[map_transport] && port != 0)
 		{
 
if (ip != address()) set_external_address(ip, source_router
, address()); @@ -1845,7 +1845,7 @@ connections

src/session_impl.cpp:4423

())
+			if (m_alerts.should_post<portmap_error_alert>())
 				m_alerts.post_alert(portmap_error_alert(mapping
 					, map_transport, ec));
 		}
 		else
 		{
-			if (m_alerts.should_post())
+			if (m_alerts.should_post<portmap_alert>())
 				m_alerts.post_alert(portmap_alert(mapping, port
 					, map_transport));
 		}
@@ -1871,7 +1871,7 @@ connections

src/session_impl.cpp:4423

src/session_impl.cpp:5673report errors as alerts

report errors as alerts

src/session_impl.cpp:5673

	}
 
-	void session_impl::add_dht_router(std::pair const& node)
+	void session_impl::add_dht_router(std::pair<std::string, int> const& node)
 	{
 #if defined TORRENT_ASIO_DEBUGGING
 		add_outstanding_async("session_impl::on_dht_router_name_lookup");
@@ -1880,10 +1880,10 @@ connections

src/session_impl.cpp:4423

src/session_impl.cpp:4423

get_mapping(m_udp_mapping[nat], local, external, protocol))
+				if (m_natpmp->get_mapping(m_udp_mapping[nat], local, external, protocol))
 				{
 					// we already have a mapping. If it's the same, don't do anything
-					if (local == local_port && external == external_port && protocol == natpmp::udp)
+					if (local == local_port && external == external_port && protocol == natpmp::udp)
 						return;
 				}
-				m_natpmp->delete_mapping(m_udp_mapping[nat]);
+				m_natpmp->delete_mapping(m_udp_mapping[nat]);
 			}
-			m_udp_mapping[nat] = m_natpmp->add_mapping(natpmp::udp
+			m_udp_mapping[nat] = m_natpmp->add_mapping(natpmp::udp
 				, local_port, external_port);
 			return;
 		}
 
relevance 0src/storage.cpp:325if the read fails, set error and exit immediately

if the read fails, set error and exit immediately

src/storage.cpp:325

			int block_size = 16 * 1024;
-			if (m_storage->disk_pool()) block_size = m_storage->disk_pool()->block_size();
+			if (m_storage->disk_pool()) block_size = m_storage->disk_pool()->block_size();
 			int size = slot_size;
 			int num_blocks = (size + block_size - 1) / block_size;
 
@@ -1930,25 +1930,25 @@ connections

src/session_impl.cpp:4423

readv(bufs, slot, ph.offset, num_blocks);
+				num_read = m_storage->readv(bufs, slot, ph.offset, num_blocks);
 
-
for (int i = 0; i < num_blocks; ++i) + for (int i = 0; i < num_blocks; ++i) { - if (small_hash && small_piece_size <= block_size) + if (small_hash && small_piece_size <= block_size) { ph.h.update((char const*)bufs[i].iov_base, small_piece_size); *small_hash = hasher(ph.h).final(); small_hash = 0; // avoid this case again - if (int(bufs[i].iov_len) > small_piece_size) + if (int(bufs[i].iov_len) > small_piece_size) ph.h.update((char const*)bufs[i].iov_base + small_piece_size , bufs[i].iov_len - small_piece_size); } @@ -1958,20 +1958,20 @@ connections

src/session_impl.cpp:4423

readv(&buf, slot, ph.offset, 1);
-
relevance 0src/storage.cpp:358if the read fails, set error and exit immediately

if the read fails, set error and exit immediately

src/storage.cpp:358

			if (m_storage->disk_pool()) block_size = m_storage->disk_pool()->block_size();
+					int ret = m_storage->readv(&buf, slot, ph.offset, 1);
+
relevance 0src/storage.cpp:358if the read fails, set error and exit immediately

if the read fails, set error and exit immediately

src/storage.cpp:358

			if (m_storage->disk_pool()) block_size = m_storage->disk_pool()->block_size();
 			int size = slot_size;
 			int num_blocks = (size + block_size - 1) / block_size;
 
@@ -1980,24 +1980,24 @@ connections

src/session_impl.cpp:4423

readv(bufs, slot, ph.offset, num_blocks);
-					if (ret > 0) num_read += ret;
+				num_read = m_storage->readv(bufs, slot, ph.offset, num_blocks);
+					if (ret > 0) num_read += ret;
 
-
if (small_hash && small_piece_size <= block_size) + if (small_hash && small_piece_size <= block_size) { - if (small_piece_size > 0) ph.h.update((char const*)buf.iov_base, small_piece_size); + if (small_piece_size > 0) ph.h.update((char const*)buf.iov_base, small_piece_size); *small_hash = hasher(ph.h).final(); small_hash = 0; // avoid this case again - if (int(buf.iov_len) > small_piece_size) + if (int(buf.iov_len) > small_piece_size) ph.h.update((char const*)buf.iov_base + small_piece_size , buf.iov_len - small_piece_size); } @@ -2016,8 +2016,8 @@ connections

src/session_impl.cpp:4423

src/storage.cpp:623

		for (file_iter = files().begin();;)
 		{
-			if (file_offset < file_iter->size)
+			if (file_offset < file_iter->size)
 				break;
 
-			file_offset -= file_iter->size;
+			file_offset -= file_iter->size;
 			++file_iter;
 			TORRENT_ASSERT(file_iter != files().end());
 		}
 	
 		error_code ec;
-		boost::intrusive_ptr file_handle = open_file(file_iter, file::read_only, ec);
+		boost::intrusive_ptr<file> file_handle = open_file(file_iter, file::read_only, ec);
 		if (!file_handle || ec) return slot;
 
-		size_type data_start = file_handle->sparse_end(file_offset);
+		size_type data_start = file_handle->sparse_end(file_offset);
 		return int((data_start + m_files.piece_length() - 1) / m_files.piece_length());
 	}
 
-	bool default_storage::verify_resume_data(lazy_entry const& rd, error_code& error)
+	bool default_storage::verify_resume_data(lazy_entry const& rd, error_code& error)
 	{
 
lazy_entry const* mapped_files = rd.dict_find_list("mapped_files"); -
if (mapped_files && mapped_files->list_size() == m_files.num_files()) + if (mapped_files && mapped_files->list_size() == m_files.num_files()) { m_mapped_files.reset(new file_storage(m_files)); - for (int i = 0; i < m_files.num_files(); ++i) + for (int i = 0; i < m_files.num_files(); ++i) { - std::string new_filename = mapped_files->list_string_value_at(i); + std::string new_filename = mapped_files->list_string_value_at(i); if (new_filename.empty()) continue; - m_mapped_files->rename_file(i, new_filename); + m_mapped_files->rename_file(i, new_filename); } } lazy_entry const* file_priority = rd.dict_find_list("file_priority"); - if (file_priority && file_priority->list_size() + if (file_priority && file_priority->list_size() == files().num_files()) { - m_file_priority.resize(file_priority->list_size()); - for (int i = 0; i < file_priority->list_size(); ++i) - m_file_priority[i] = boost::uint8_t(file_priority->list_int_value_at(i, 1)); + m_file_priority.resize(file_priority->list_size()); + for (int i = 0; i < file_priority->list_size(); ++i) + m_file_priority[i] = boost::uint8_t(file_priority->list_int_value_at(i, 1)); } - std::vector > file_sizes; + std::vector<std::pair<size_type, std::time_t> > file_sizes; lazy_entry const* file_sizes_ent = rd.dict_find_list("file sizes"); if (file_sizes_ent == 0) { @@ -2073,7 +2073,7 @@ maybe use the same format as .torrent files and reuse some code from torrent_inf return false; } - for (int i = 0; i < file_sizes_ent->list_size(); ++i) + for (int i = 0; i < file_sizes_ent->list_size(); ++i) {
relevance 0src/storage.cpp:1208what if file_base is used to merge several virtual files into a single physical file? We should probably disable this if file_base is used. This is not a widely used feature though

what if file_base is used to merge several virtual files into a single physical file? We should probably disable this @@ -2083,28 +2083,28 @@ if file_base is used. This is not a widely used feature though

src/stora // special read that reads aligned buffers and copies // it into the one supplied size_type adjusted_offset = files().file_base(*file_iter) + file_offset; - if ((file_handle->open_mode() & file::no_buffer) - && ((adjusted_offset & (file_handle->pos_alignment()-1)) != 0 - || (uintptr_t(tmp_bufs->iov_base) & (file_handle->buf_alignment()-1)) != 0)) + if ((file_handle->open_mode() & file::no_buffer) + && ((adjusted_offset & (file_handle->pos_alignment()-1)) != 0 + || (uintptr_t(tmp_bufs->iov_base) & (file_handle->buf_alignment()-1)) != 0)) { - bytes_transferred = (int)(this->*op.unaligned_op)(file_handle, adjusted_offset + bytes_transferred = (int)(this->*op.unaligned_op)(file_handle, adjusted_offset , tmp_bufs, num_tmp_bufs, ec); if (op.mode == file::read_write - && adjusted_offset + bytes_transferred >= file_iter->size - && (file_handle->pos_alignment() > 0 || file_handle->size_alignment() > 0)) + && adjusted_offset + bytes_transferred >= file_iter->size + && (file_handle->pos_alignment() > 0 || file_handle->size_alignment() > 0)) { // we were writing, and we just wrote the last block of the file // we likely wrote a bit too much, since we're restricted to // a specific alignment for writes. Make sure to truncate the size -
file_handle->set_size(file_iter->size, ec); +
file_handle->set_size(file_iter->size, ec);
} } else { bytes_transferred = (int)((*file_handle).*op.regular_op)(adjusted_offset , tmp_bufs, num_tmp_bufs, ec); - TORRENT_ASSERT(bytes_transferred <= bufs_size(tmp_bufs, num_tmp_bufs)); + TORRENT_ASSERT(bytes_transferred <= bufs_size(tmp_bufs, num_tmp_bufs)); } file_offset = 0; @@ -2118,7 +2118,7 @@ if file_base is used. This is not a widely used feature though

src/stora return bytes_transferred; advance_bufs(current_buf, bytes_transferred); - TORRENT_ASSERT(count_bufs(current_buf, bytes_left - file_bytes_left) <= num_bufs); + TORRENT_ASSERT(count_bufs(current_buf, bytes_left - file_bytes_left) <= num_bufs); } return size; } @@ -2132,19 +2132,19 @@ if file_base is used. This is not a widely used feature though

src/stora 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:1112

			if (c) c->disconnect(errors::no_memory);
+up to the highest written piece in each file

src/torrent.cpp:1112

			if (c) c->disconnect(errors::no_memory);
 			return;
 		}
 
 		// notify the user of the error
-		if (alerts().should_post())
+		if (alerts().should_post<file_error_alert>())
 			alerts().post_alert(file_error_alert(j.error_file, get_handle(), j.error));
 
 		// put the torrent in an error-state
 		set_error(j.error, j.error_file);
 
 		if (j.action == disk_io_job::write
-			&& (j.error == boost::system::errc::read_only_file_system
+			&& (j.error == boost::system::errc::read_only_file_system
 			|| j.error == boost::system::errc::permission_denied
 			|| j.error == boost::system::errc::operation_not_permitted
 			|| j.error == boost::system::errc::no_space_on_device
@@ -2160,34 +2160,34 @@ up to the highest written piece in each file

src/torrent.cpp:1112

blocks_left; + --rp->blocks_left; if (ret != r.length) { - rp->fail = true; + rp->fail = true; handle_disk_error(j); } else { - std::memcpy(rp->piece_data.get() + r.start, j.buffer, r.length); + std::memcpy(rp->piece_data.get() + r.start, j.buffer, r.length); } - if (rp->blocks_left == 0) + if (rp->blocks_left == 0) { - int size = m_torrent_file->piece_size(r.piece); - if (rp->fail) + int size = m_torrent_file->piece_size(r.piece); + if (rp->fail) { - rp->piece_data.reset(); + rp->piece_data.reset();

relevance 0src/torrent.cpp:1505filter out peers that are disconnecting

filter out peers that are disconnecting

src/torrent.cpp:1505

		snprintf(filename, sizeof(filename), "/tmp/%d.pem", rand());
 		FILE* f = fopen(filename, "w+");
 		fwrite(cert.c_str(), cert.size(), 1, f);
 		fclose(f);
-		ctx->load_verify_file(filename);
+		ctx->load_verify_file(filename);
 #endif
 		// if all went well, set the torrent ssl context to this one
 		m_ssl_ctx = ctx;
@@ -2204,8 +2204,8 @@ up to the highest written piece in each file

src/torrent.cpp:1112

const_peer_iterator lowest_rank = std::min_element(begin(), end() - , boost::bind(&peer_connection::peer_rank, _1) - < boost::bind(&peer_connection::peer_rank, _2)); + , boost::bind(&peer_connection::peer_rank, _1) + < boost::bind(&peer_connection::peer_rank, _2)); if (lowest_rank == end()) return NULL; return *lowest_rank; @@ -2216,28 +2216,28 @@ up to the highest written piece in each file

src/torrent.cpp:1112

is_valid()); - TORRENT_ASSERT(m_torrent_file->num_files() > 0); - TORRENT_ASSERT(m_torrent_file->total_size() >= 0); + TORRENT_ASSERT(m_torrent_file->is_valid()); + TORRENT_ASSERT(m_torrent_file->num_files() > 0); + TORRENT_ASSERT(m_torrent_file->total_size() >= 0); #ifdef TORRENT_USE_OPENSSL - std::string cert = m_torrent_file->ssl_cert(); + std::string cert = m_torrent_file->ssl_cert(); if (!cert.empty()) init_ssl(cert); #endif - m_file_priority.resize(m_torrent_file->num_files(), 1); - m_file_progress.resize(m_torrent_file->num_files(), 0); + m_file_priority.resize(m_torrent_file->num_files(), 1); + m_file_progress.resize(m_torrent_file->num_files(), 0); - m_block_size_shift = root2((std::min)(int(block_size()), m_torrent_file->piece_length())); + m_block_size_shift = root2((std::min)(int(block_size()), m_torrent_file->piece_length())); - if (m_torrent_file->num_pieces() > piece_picker::max_pieces) + if (m_torrent_file->num_pieces() > piece_picker::max_pieces) { set_error(errors::too_many_pieces_in_torrent, ""); pause();

relevance 0src/torrent.cpp:2289this 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:2289

			req.downloaded -= m_total_redundant_bytes;
-		if (req.downloaded < 0) req.downloaded = 0;
+		if (req.downloaded < 0) req.downloaded = 0;
 
 		req.event = e;
 		error_code ec;
@@ -2272,14 +2272,14 @@ dedicated listen port

src/torrent.cpp:2289

tier: %d tier: %d "
+				" i->tier: %d tier: %d "
 				" is_working: %d fails: %d fail_limit: %d updating: %d"
 				" can_announce: %d sent_announce: %d ]"
 				, ae.url.c_str(), settings().announce_to_all_tiers
@@ -2292,7 +2292,7 @@ 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:5028

		if (m_seed_mode) m_verified.resize(m_torrent_file->num_pieces(), false);
+which are kept in sync

src/torrent.cpp:5028

		if (m_seed_mode) m_verified.resize(m_torrent_file->num_pieces(), false);
 		super_seeding(rd.dict_find_int_value("super_seeding", 0));
 
 		m_last_scrape = rd.dict_find_int_value("last_scrape", 0);
@@ -2305,7 +2305,7 @@ which are kept in sync

src/torrent.cpp:5028

		lazy_entry const* mapped_files = rd.dict_find_list("mapped_files");
-		if (mapped_files && mapped_files->list_size() == m_torrent_file->num_files())
+		if (mapped_files && mapped_files->list_size() == m_torrent_file->num_files())
 		{
-			for (int i = 0; i < m_torrent_file->num_files(); ++i)
+			for (int i = 0; i < m_torrent_file->num_files(); ++i)
 			{
-				std::string new_filename = mapped_files->list_string_value_at(i);
+				std::string new_filename = mapped_files->list_string_value_at(i);
 				if (new_filename.empty()) continue;
-				m_torrent_file->rename_file(i, new_filename);
+				m_torrent_file->rename_file(i, new_filename);
 			}
 		}
 		
 		m_added_time = rd.dict_find_int_value("added_time", m_added_time);
 		m_completed_time = rd.dict_find_int_value("completed_time", m_completed_time);
-		if (m_completed_time != 0 && m_completed_time < m_added_time)
+		if (m_completed_time != 0 && m_completed_time < m_added_time)
 			m_completed_time = m_added_time;
 
 		lazy_entry const* file_priority = rd.dict_find_list("file_priority");
-		if (file_priority && file_priority->list_size()
-			== m_torrent_file->num_files())
+		if (file_priority && file_priority->list_size()
+			== m_torrent_file->num_files())
 		{
-			for (int i = 0; i < file_priority->list_size(); ++i)
-				m_file_priority[i] = file_priority->list_int_value_at(i, 1);
+			for (int i = 0; i < file_priority->list_size(); ++i)
+				m_file_priority[i] = file_priority->list_int_value_at(i, 1);
 			update_piece_priorities();
 		}
 
 		lazy_entry const* piece_priority = rd.dict_find_string("piece_priority");
-		if (piece_priority && piece_priority->string_length()
-			== m_torrent_file->num_pieces())
+		if (piece_priority && piece_priority->string_length()
+			== m_torrent_file->num_pieces())
 		{
-			char const* p = piece_priority->string_ptr();
-			for (int i = 0; i < piece_priority->string_length(); ++i)
+			char const* p = piece_priority->string_ptr();
+			for (int i = 0; i < piece_priority->string_length(); ++i)
 
relevance 0src/torrent.cpp:5164if 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

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 @@ -2351,19 +2351,19 @@ all the pieces

src/torrent.cpp:5164

 tree;
-				tree.resize(m_torrent_file->merkle_tree().size());
-				std::memcpy(&tree[0], mt->string_ptr()
-					, (std::min)(mt->string_length(), int(tree.size()) * 20));
-				if (mt->string_length() < int(tree.size()) * 20)
-					std::memset(&tree[0] + mt->string_length() / 20, 0
-						, tree.size() - mt->string_length() / 20);
-				m_torrent_file->set_merkle_tree(tree);
+				std::vector<sha1_hash> tree;
+				tree.resize(m_torrent_file->merkle_tree().size());
+				std::memcpy(&tree[0], mt->string_ptr()
+					, (std::min)(mt->string_length(), int(tree.size()) * 20));
+				if (mt->string_length() < int(tree.size()) * 20)
+					std::memset(&tree[0] + mt->string_length() / 20, 0
+						, tree.size() - mt->string_length() / 20);
+				m_torrent_file->set_merkle_tree(tree);
 			}
 			else
 			{
@@ -2372,15 +2372,15 @@ all the pieces

src/torrent.cpp:5164

src/torrent.cpp:5164

relevance 0src/torrent.cpp:5351make 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

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

src/torrent.cpp:5351

		entry::string_type& pieces = ret["pieces"].string();
-		pieces.resize(m_torrent_file->num_pieces());
+renamed, but also if they have been merged into a single file for instance

src/torrent.cpp:5351

		entry::string_type& pieces = ret["pieces"].string();
+		pieces.resize(m_torrent_file->num_pieces());
 		if (is_seed())
 		{
-			std::memset(&pieces[0], 1, pieces.size());
+			std::memset(&pieces[0], 1, pieces.size());
 		}
 		else
 		{
-			for (int i = 0, end(pieces.size()); i < end; ++i)
-				pieces[i] = m_picker->have_piece(i) ? 1 : 0;
+			for (int i = 0, end(pieces.size()); i < end; ++i)
+				pieces[i] = m_picker->have_piece(i) ? 1 : 0;
 		}
 
 		if (m_seed_mode)
 		{
 			TORRENT_ASSERT(m_verified.size() == pieces.size());
-			for (int i = 0, end(pieces.size()); i < end; ++i)
+			for (int i = 0, end(pieces.size()); i < end; ++i)
 				pieces[i] |= m_verified[i] ? 2 : 0;
 		}
 
 		// write renamed files
-
if (&m_torrent_file->files() != &m_torrent_file->orig_files() -
&& m_torrent_file->files().num_files() == m_torrent_file->orig_files().num_files()) +
if (&m_torrent_file->files() != &m_torrent_file->orig_files() +
&& m_torrent_file->files().num_files() == m_torrent_file->orig_files().num_files()) { - entry::list_type& fl = ret["mapped_files"].list(); - for (torrent_info::file_iterator i = m_torrent_file->begin_files() - , end(m_torrent_file->end_files()); i != end; ++i) + entry::list_type& fl = ret["mapped_files"].list(); + for (torrent_info::file_iterator i = m_torrent_file->begin_files() + , end(m_torrent_file->end_files()); i != end; ++i) { - fl.push_back(m_torrent_file->files().file_path(*i)); + fl.push_back(m_torrent_file->files().file_path(*i)); } } // write local peers - std::back_insert_iterator peers(ret["peers"].string()); - std::back_insert_iterator banned_peers(ret["banned_peers"].string()); + std::back_insert_iterator<entry::string_type> peers(ret["peers"].string()); + std::back_insert_iterator<entry::string_type> banned_peers(ret["banned_peers"].string()); #if TORRENT_USE_IPV6 - std::back_insert_iterator peers6(ret["peers6"].string()); - std::back_insert_iterator banned_peers6(ret["banned_peers6"].string()); + std::back_insert_iterator<entry::string_type> peers6(ret["peers6"].string()); + std::back_insert_iterator<entry::string_type> banned_peers6(ret["banned_peers6"].string()); #endif // failcount is a 5 bit value @@ -2449,47 +2449,47 @@ renamed, but also if they have been merged into a single file for instance< { error_code ec; policy::peer const* p = *i; - address addr = p->address(); + address addr = p->address();
relevance 0src/torrent.cpp:5928ideally, we would disconnect the oldest connection i.e. the one that has waited the longest to connect.

ideally, we would disconnect the oldest connection i.e. the one that has waited the longest to connect.

src/torrent.cpp:5928

			return false;
 		}
 
 		if (m_ses.is_aborted())
 		{
-			p->disconnect(errors::session_closing);
+			p->disconnect(errors::session_closing);
 			return false;
 		}
 
 		bool maybe_replace_peer = false;
 
-		if (m_connections.size() >= m_max_connections)
+		if (m_connections.size() >= m_max_connections)
 		{
 			// if more than 10% of the connections are outgoing
 			// connection attempts that haven't completed yet,
 			// disconnect one of them and let this incoming
 			// connection through.
-			if (m_num_connecting > m_max_connections / 10)
+			if (m_num_connecting > m_max_connections / 10)
 			{
 				// find one of the connecting peers and disconnect it
 
// find any peer that's connecting (i.e. a half-open TCP connection) // that's also not disconnecting - std::set::iterator i = std::find_if(begin(), end() - , boost::bind(&peer_connection::is_connecting, _1) - && !boost::bind(&peer_connection::is_disconnecting, _1)); + std::set<peer_connection*>::iterator i = std::find_if(begin(), end() + , boost::bind(&peer_connection::is_connecting, _1) + && !boost::bind(&peer_connection::is_disconnecting, _1)); if (i == end()) { // this seems odd, but we might as well handle it - p->disconnect(errors::too_many_connections); + p->disconnect(errors::too_many_connections); return false; } - (*i)->disconnect(errors::too_many_connections); + (*i)->disconnect(errors::too_many_connections); // if this peer was let in via connections slack, // it has done its duty of causing the disconnection // of another peer - p->peer_disconnected_other(); + p->peer_disconnected_other(); } else { @@ -2508,10 +2508,10 @@ i.e. the one that has waited the longest to connect.

src/torrent.cpp:592 m_connections.insert(p); #ifdef TORRENT_DEBUG error_code ec; - TORRENT_ASSERT(p->remote() == p->get_socket()->remote_endpoint(ec) || ec); + TORRENT_ASSERT(p->remote() == p->get_socket()->remote_endpoint(ec) || ec); #endif - TORRENT_ASSERT(p->peer_info_struct() != NULL); + TORRENT_ASSERT(p->peer_info_struct() != NULL); // we need to do this after we've added the peer to the policy // since that's when the peer is assigned its peer_info object, @@ -2522,14 +2522,14 @@ i.e. the one that has waited the longest to connect.

src/torrent.cpp:592 // if it's lower rank than the incoming connection peer_connection* peer = find_lowest_ranking_peer(); -
if (peer && peer->peer_rank() < p->peer_rank()) +
if (peer && peer->peer_rank() < p->peer_rank())
{ - peer->disconnect(errors::too_many_connections); - p->peer_disconnected_other(); + peer->disconnect(errors::too_many_connections); + p->peer_disconnected_other(); } else { - p->disconnect(errors::too_many_connections); + p->disconnect(errors::too_many_connections); // 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 // to let policy know we're removing it @@ -2538,7 +2538,7 @@ i.e. the one that has waited the longest to connect.

src/torrent.cpp:592 } } -#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS m_policy.check_invariant(); #endif @@ -2550,9 +2550,9 @@ i.e. the one that has waited the longest to connect.

src/torrent.cpp:592 bool torrent::want_more_peers() const { - return m_connections.size() < m_max_connections - && !is_paused() - && ((m_state != torrent_status::checking_files + return m_connections.size() < m_max_connections + && !is_paused() + && ((m_state != torrent_status::checking_files

relevance 0src/torrent.cpp:6180should disconnect all peers that have the pieces we have not just seeds

should disconnect all peers that have the pieces we have not just seeds

src/torrent.cpp:6180

		}
 #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
@@ -2574,22 +2574,22 @@ not just seeds

src/torrent.cpp:6180

		std::vector seeds;
+
std::vector<peer_connection*> seeds;
for (peer_iterator i = m_connections.begin(); i != m_connections.end(); ++i) { peer_connection* p = *i; - TORRENT_ASSERT(p->associated_torrent().lock().get() == this); - if (p->upload_only()) + TORRENT_ASSERT(p->associated_torrent().lock().get() == this); + if (p->upload_only()) { #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING - p->peer_log("*** SEED, CLOSING CONNECTION"); + p->peer_log("*** SEED, CLOSING CONNECTION"); #endif seeds.push_back(p); } } std::for_each(seeds.begin(), seeds.end() - , boost::bind(&peer_connection::disconnect, _1, errors::torrent_finished, 0)); + , boost::bind(&peer_connection::disconnect, _1, errors::torrent_finished, 0)); if (m_abort) return; @@ -2597,8 +2597,8 @@ not just seeds

src/torrent.cpp:6180

src/torrent.cpp:8047if there's been long enough since we requested something from this piece, request one of the backup blocks (the one with the least number of requests to it) and update the last request timestamp

if there's been long enough since we requested something from this piece, request one of the backup blocks (the one with the least number of requests to it) and update the last request -timestamp

src/torrent.cpp:8047

				std::vector const& rq = c.request_queue();
+timestamp

src/torrent.cpp:8047

				std::vector<pending_block> const& rq = c.request_queue();
 
 				bool added_request = false;
 
-				if (!interesting_blocks.empty() && std::find_if(rq.begin(), rq.end()
+				if (!interesting_blocks.empty() && std::find_if(rq.begin(), rq.end()
 					, has_block(interesting_blocks.front())) != rq.end())
 				{
 					c.make_time_critical(interesting_blocks.front());
@@ -2685,8 +2685,8 @@ timestamp

src/torrent.cpp:8047

 				if (added_request)
 				{
-					peers_with_requests.insert(peers_with_requests.begin(), &c);
-					if (i->first_requested == min_time()) i->first_requested = now;
+					peers_with_requests.insert(peers_with_requests.begin(), &c);
+					if (i->first_requested == min_time()) i->first_requested = now;
 
 					if (!c.can_request_time_critical())
 					{
@@ -2695,7 +2695,7 @@ timestamp

src/torrent.cpp:8047

::iterator i = peers_with_requests.begin()
+		for (std::set<peer_connection*>::iterator i = peers_with_requests.begin()
 			, end(peers_with_requests.end()); i != end; ++i)
 		{
-			(*i)->send_block_requests();
+			(*i)->send_block_requests();
 		}
 	}
 
relevance 0src/torrent.cpp:8718with some response codes, we should just consider the tracker as a failure and not retry it anymore

with some response codes, we should just consider the tracker as a failure and not retry it anymore

src/torrent.cpp:8718

		TORRENT_ASSERT(m_ses.is_network_thread());
-		TORRENT_ASSERT(b > 0);
+		TORRENT_ASSERT(b > 0);
 		m_total_failed_bytes += b;
 		m_ses.add_failed_bytes(b);
 //		TORRENT_ASSERT(m_total_redundant_bytes + m_total_failed_bytes
-//			<= m_stat.total_payload_download());
+//			<= m_stat.total_payload_download());
 	}
 
 	int torrent::num_seeds() const
@@ -2729,14 +2729,14 @@ it anymore

src/torrent.cpp:8718

	void torrent::tracker_request_error(tracker_request const& r
-		, int response_code, error_code const& ec, const std::string& msg
+
void torrent::tracker_request_error(tracker_request const& r +
, int response_code, error_code const& ec, const std::string& msg , int retry_interval) { TORRENT_ASSERT(m_ses.is_network_thread()); @@ -2751,19 +2751,19 @@ it anymore

src/torrent.cpp:8718

fails);
+				debug_log("*** increment tracker fail count [%d]", ae->fails);
 #endif
 				deprioritize_tracker(tracker_index);
 			}
-			if (m_ses.m_alerts.should_post())
+			if (m_ses.m_alerts.should_post<tracker_error_alert>())
 			{
 				m_ses.m_alerts.post_alert(tracker_error_alert(get_handle()
-					, ae?ae->fails:0, response_code, r.url, ec, msg));
+					, ae?ae->fails:0, response_code, r.url, ec, msg));
 			}
 		}
 
relevance 0src/torrent_info.cpp:187should this take a char const*?

should this take a char const*?

src/torrent_info.cpp:187

			{
@@ -2786,7 +2786,7 @@ it anymore

src/torrent.cpp:8718

	bool valid_path_element(std::string const& element)
+
bool valid_path_element(std::string const& element)
{ if (element.empty() || element == "." || element == ".." @@ -2796,14 +2796,14 @@ it anymore

src/torrent.cpp:8718

relevance 0src/torrent_info.cpp:366this logic should be a separate step done once the torrent is loaded, and the original filenames should be preserved!

this logic should be a separate step done once the torrent is loaded, and the original @@ -2824,23 +2824,23 @@ filenames should be preserved!

src/torrent_info.cpp:366

			int cnt = 0;
-			std::set files;
+			std::set<std::string, string_less_no_case> files;
 
 			// as long as this file already exists
 			// increase the counter
@@ -2851,39 +2851,39 @@ filenames should be preserved!

src/torrent_info.cpp:366

string_ptr() + info_ptr_diff : 0);
+			target.add_file(e, file_hash ? file_hash->string_ptr() + info_ptr_diff : 0);
 
 			// This is a memory optimization! Instead of having
 			// each entry keep a string for its filename, make it
 			// simply point into the info-section buffer
-			internal_file_entry const& fe = *target.rbegin();
+			internal_file_entry const& fe = *target.rbegin();
 
relevance 0src/torrent_info.cpp:387once the filename renaming is removed from here this check can be removed as well

once the filename renaming is removed from here this check can be removed as well

src/torrent_info.cpp:387

			}
 			return false;
 		}
 	};
 
-	bool extract_files(lazy_entry const& list, file_storage& target
-		, std::string const& root_dir, ptrdiff_t info_ptr_diff)
+	bool extract_files(lazy_entry const& list, file_storage& target
+		, std::string const& root_dir, ptrdiff_t info_ptr_diff)
 	{
 		if (list.type() != lazy_entry::list_t) return false;
 		target.reserve(list.list_size());
-		for (int i = 0, end(list.list_size()); i < end; ++i)
+		for (int i = 0, end(list.list_size()); i < end; ++i)
 		{
 			lazy_entry const* file_hash = 0;
 			time_t mtime = 0;
 			file_entry e;
 			lazy_entry const* fee = 0;
 			if (!extract_single_file(*list.list_at(i), e, root_dir
-				, &file_hash, &fee, &mtime))
+				, &file_hash, &fee, &mtime))
 				return false;
 
-
if (fee && fe.filename() == fee->string_value()) +
if (fee && fe.filename() == fee->string_value())
{ // this string pointer does not necessarily point into // the m_info_section buffer. - char const* str_ptr = fee->string_ptr() + info_ptr_diff; - const_cast(fe).set_name(str_ptr, fee->string_length()); + char const* str_ptr = fee->string_ptr() + info_ptr_diff; + const_cast<internal_file_entry&>(fe).set_name(str_ptr, fee->string_length()); } } return true; @@ -2892,33 +2892,33 @@ this check can be removed as well

src/torrent_info.cpp:387

 0);
+		TORRENT_ASSERT(tree_node > 0);
 		return (tree_node - 1) / 2;
 	}
 
 	int merkle_get_sibling(int tree_node)
 	{
 		// node 0 doesn't have a sibling
-		TORRENT_ASSERT(tree_node > 0);
+		TORRENT_ASSERT(tree_node > 0);
 		// even numbers have their sibling to the left
 		// odd numbers have their sibling to the right
-		return tree_node + (tree_node&1?1:-1);
+		return tree_node + (tree_node&1?1:-1);
 	}
 
 	int merkle_num_nodes(int leafs)
 	{
-		TORRENT_ASSERT(leafs > 0);
-		return (leafs << 1) - 1;
-
relevance 0src/udp_tracker_connection.cpp:548don't use a string here. The problem is that some trackers will respond with actual strings. Especially i2p trackers

don't use a string here. The problem is that -some trackers will respond with actual strings. -Especially i2p trackers

src/udp_tracker_connection.cpp:548

		}
+		TORRENT_ASSERT(leafs > 0);
+		return (leafs << 1) - 1;
+
relevance 0src/udp_tracker_connection.cpp:548it would be more efficient to not use a string here. however, the problem is that some trackers will respond with actual strings. For example i2p trackers

it would be more efficient to not use a string here. +however, the problem is that some trackers will respond +with actual strings. For example i2p trackers

src/udp_tracker_connection.cpp:548

		}
 
-		boost::shared_ptr cb = requester();
+		boost::shared_ptr<request_callback> cb = requester();
 #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
 		if (cb)
 		{
-			boost::shared_ptr cb = requester();
-			cb->debug_log("<== UDP_TRACKER_RESPONSE [ url: %s ]", tracker_req().url.c_str());
+			boost::shared_ptr<request_callback> cb = requester();
+			cb->debug_log("<== UDP_TRACKER_RESPONSE [ url: %s ]", tracker_req().url.c_str());
 		}
 #endif
 
@@ -2928,8 +2928,8 @@ Especially i2p trackers

src/udp_tracker_connection.cpp:548

 peer_list;
-		for (int i = 0; i < num_peers; ++i)
+		std::vector<peer_entry> peer_list;
+		for (int i = 0; i < num_peers; ++i)
 		{
 
peer_entry e;
char ip_string[100]; @@ -2944,14 +2944,14 @@ Especially i2p trackers

src/udp_tracker_connection.cpp:548

 ip_list;
-		for (std::list::const_iterator i = m_endpoints.begin()
+		std::list<address> ip_list;
+		for (std::list<tcp::endpoint>::const_iterator i = m_endpoints.begin()
 			, end(m_endpoints.end()); i != end; ++i)
 		{
-			ip_list.push_back(i->address());
+			ip_list.push_back(i->address());
 		}
 
-		cb->tracker_response(tracker_req(), m_target.address(), ip_list
+		cb->tracker_response(tracker_req(), m_target.address(), ip_list
 			, peer_list, interval, min_interval, complete, incomplete, address(), "" /*trackerid*/);
 
 		close();
@@ -2964,25 +2964,25 @@ Especially i2p trackers

src/udp_tracker_connection.cpp:548

relevance 0src/utp_stream.cpp:1846we might want to do something else here as well, to resend the packet immediately without it being an MTU probe

we might want to do something else here as well, to resend the packet immediately without -it being an MTU probe

src/utp_stream.cpp:1846

		, boost::uint32_t(h->timestamp_difference_microseconds), int(p->mtu_probe)
-		, h->extension);
+it being an MTU probe

src/utp_stream.cpp:1846

		, boost::uint32_t(h->timestamp_difference_microseconds), int(p->mtu_probe)
+		, h->extension);
 #endif
 
 	error_code ec;
 #ifdef TORRENT_DEBUG
 	// simulate 1% packet loss
-//	if ((rand() % 100) > 0)
+//	if ((rand() % 100) > 0)
 #endif
-	m_sm->send_packet(udp::endpoint(m_remote_address, m_port)
-		, (char const*)h, p->size, ec
-		, p->mtu_probe ? utp_socket_manager::dont_fragment : 0);
+	m_sm->send_packet(udp::endpoint(m_remote_address, m_port)
+		, (char const*)h, p->size, ec
+		, p->mtu_probe ? utp_socket_manager::dont_fragment : 0);
 
 	++m_out_packets;
 
 	if (ec == error::message_size)
 	{
-		m_mtu_ceiling = p->size - 1;
-		if (m_mtu_floor > m_mtu_ceiling) m_mtu_floor = m_mtu_ceiling;
+		m_mtu_ceiling = p->size - 1;
+		if (m_mtu_floor > m_mtu_ceiling) m_mtu_floor = m_mtu_ceiling;
 		update_mtu_limits();
 
}
else if (ec == error::would_block || ec == error::try_again) @@ -2993,7 +2993,7 @@ it being an MTU probe

src/utp_stream.cpp:1846

num_transmissions;
+		++p->num_transmissions;
 
 	// if we have payload, we need to save the packet until it's acked
 	// and progress m_seq_nr
-	if (p->size > p->header_size)
+	if (p->size > p->header_size)
 	{
 		// if we're sending a payload packet, there should not
 		// be a nagle packet waiting for more data
@@ -3020,12 +3020,12 @@ it being an MTU probe

src/utp_stream.cpp:1846

src/kademlia/dht_tracker.cpp:641

#ifdef TORRENT_DHT_VERBOSE_LOGGING
 		std::stringstream log_line;
 		lazy_entry print;
-		int ret = lazy_bdecode(&m_send_buf[0], &m_send_buf[0] + m_send_buf.size(), print, ec);
+		int ret = lazy_bdecode(&m_send_buf[0], &m_send_buf[0] + m_send_buf.size(), print, ec);
 		TORRENT_ASSERT(ret == 0);
-		log_line << print_entry(print, true);
+		log_line << print_entry(print, true);
 #endif
 
-		if (m_sock.send(addr, &m_send_buf[0], (int)m_send_buf.size(), ec, send_flags))
+		if (m_sock.send(addr, &m_send_buf[0], (int)m_send_buf.size(), ec, send_flags))
 		{
 			if (ec) return false;
 
@@ -3042,14 +3042,14 @@ m_replies_bytes_sent[e["r"]] += int(m_send_buf.size());

src/kademlia/dht { m_queries_out_bytes += m_send_buf.size(); } - TORRENT_LOG(dht_tracker) << "==> " << addr << " " << log_line.str(); + TORRENT_LOG(dht_tracker) << "==> " << addr << " " << log_line.str(); #endif return true; } else { #ifdef TORRENT_DHT_VERBOSE_LOGGING - TORRENT_LOG(dht_tracker) << "==> " << addr << " DROPPED " << log_line.str(); + TORRENT_LOG(dht_tracker) << "==> " << addr << " DROPPED " << log_line.str(); #endif return false; } @@ -3073,7 +3073,7 @@ m_replies_bytes_sent[e["r"]] += int(m_send_buf.size());

src/kademlia/dht namespace libtorrent { namespace dht { -void incoming_error(entry& e, char const* msg); +void incoming_error(entry& e, char const* msg); using detail::write_endpoint; @@ -3084,16 +3084,16 @@ TORRENT_DEFINE_LOG(node) #endif // remove peers that have timed out -void purge_peers(std::set& peers) +void purge_peers(std::set<peer_entry>& peers) { - for (std::set::iterator i = peers.begin() + for (std::set<peer_entry>::iterator i = peers.begin() , end(peers.end()); i != end;) { // the peer has timed out - if (i->added + minutes(int(announce_interval * 1.5f)) < time_now()) + if (i->added + minutes(int(announce_interval * 1.5f)) < time_now()) { #ifdef TORRENT_DHT_VERBOSE_LOGGING - TORRENT_LOG(node) << "peer timed out at: " << i->addr; + TORRENT_LOG(node) << "peer timed out at: " << i->addr; #endif peers.erase(i++); } @@ -3106,10 +3106,10 @@ void nop() {} node_impl::node_impl(alert_dispatcher* alert_disp , udp_socket_interface* sock - , dht_settings const& settings, node_id nid, address const& external_address + , dht_settings const& settings, node_id nid, address const& external_address , dht_observer* observer)

relevance 0src/kademlia/node.cpp:690find_node should write directly to the response entry

find_node should write directly to the response entry

src/kademlia/node.cpp:690

		{
-			TORRENT_LOG(node) << " values: " << reply["values"].list().size();
+			TORRENT_LOG(node) << " values: " << reply["values"].list().size();
 		}
 #endif
 	}
@@ -3126,7 +3126,7 @@ node_impl::node_impl(alert_dispatcher* alert_disp
 			return;
 		}
 
-		sha1_hash target(msg_keys[0]->string_ptr());
+		sha1_hash target(msg_keys[0]->string_ptr());
 
 
nodes_t n;
m_table.find_node(target, n, 0); @@ -3155,12 +3155,12 @@ node_impl::node_impl(alert_dispatcher* alert_disp return; } - int port = int(msg_keys[1]->int_value()); - if (port < 0 || port >= 65536) + int port = int(msg_keys[1]->int_value()); + if (port < 0 || port >= 65536) { #ifdef TORRENT_DHT_VERBOSE_LOGGING
relevance 0src/kademlia/rpc_manager.cpp:439don't call short_timeout() again if we've already called it once

don't call short_timeout() again if we've -already called it once

src/kademlia/rpc_manager.cpp:439

	std::for_each(timeouts.begin(), timeouts.end(), boost::bind(&observer::timeout, _1));
+already called it once

src/kademlia/rpc_manager.cpp:439

	std::for_each(timeouts.begin(), timeouts.end(), boost::bind(&observer::timeout, _1));
 	timeouts.clear();
 
 	for (transactions_t::iterator i = m_transactions.begin();
@@ -3171,29 +3171,29 @@ already called it once

src/kademlia/rpc_manager.cpp:439

		timeouts.push_back(o);
 
} - std::for_each(timeouts.begin(), timeouts.end(), boost::bind(&observer::short_timeout, _1)); + std::for_each(timeouts.begin(), timeouts.end(), boost::bind(&observer::short_timeout, _1)); return ret; } -void rpc_manager::add_our_id(entry& e) +void rpc_manager::add_our_id(entry& e) { e["id"] = m_our_id.to_string(); } -bool rpc_manager::invoke(entry& e, udp::endpoint target_addr +bool rpc_manager::invoke(entry& e, udp::endpoint target_addr , observer_ptr o) { INVARIANT_CHECK; @@ -3201,13 +3201,13 @@ bool rpc_manager::invoke(entry& e, udp::endpoint target_addr if (m_destructing) return false; e["y"] = "q"; - entry& a = e["a"]; + entry& a = e["a"]; add_our_id(a); std::string transaction_id; transaction_id.resize(2); - char* out = &transaction_id[0]; - int tid = random() ^ (random() << 5); + char* out = &transaction_id[0]; + int tid = random() ^ (random() << 5); io::write_uint16(tid, out); e["t"] = transaction_id; @@ -3257,13 +3257,13 @@ bool rpc_manager::invoke(entry& e, udp::endpoint target_addr #endif -#if defined TORRENT_WINDOWS && !defined TORRENT_MINGW +#if defined TORRENT_WINDOWS && !defined TORRENT_MINGW -#include +#include <stdarg.h> inline int snprintf(char* buf, int len, char const* fmt, ...) -
relevance 0include/libtorrent/ip_voter.hpp:100instead, 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:100

		bloom_filter<32> m_external_address_voters;
-		std::vector m_external_addresses;
+
relevance 0include/libtorrent/ip_voter.hpp:100instead, 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:100

		bloom_filter<32> m_external_address_voters;
+		std::vector<external_ip_t> m_external_addresses;
 		address m_external_address;
 	};
 
@@ -3273,10 +3273,10 @@ inline int snprintf(char* buf, int len, char const* fmt, ...)
 	{
 		// returns true if a different IP is the top vote now
 		// i.e. we changed our idea of what our external IP is
-		bool cast_vote(address const& ip, int source_type, address const& source);
+		bool cast_vote(address const& ip, int source_type, address const& source);
 
 		// the external IP as it would be observed from `ip`
-		address external_address(address const& ip) const;
+		address external_address(address const& ip) const;
 
 	private:
 
@@ -3295,13 +3295,13 @@ m_sock.bind(endpoint, ec);

include/libtorrent/proxy_base.hpp:152

include/libtorrent/proxy_base.hpp:152

} #ifndef BOOST_NO_EXCEPTIONS - void open(protocol_type const& p) + void open(protocol_type const& p) { // m_sock.open(p); } #endif - void open(protocol_type const& p, error_code& ec) + void open(protocol_type const& p, error_code& ec) { // we need to ignore this for the same reason as stated // for ignoring bind() @@ -3335,7 +3335,7 @@ m_sock.bind(endpoint, ec);

include/libtorrent/proxy_base.hpp:152

include/libtorrent/proxy_base.hpp:152

relevance 0include/libtorrent/torrent_info.hpp:448these strings could be lazy_entry* to save memory

these strings could be lazy_entry* to save memory

include/libtorrent/torrent_info.hpp:448

 		// the urls to the trackers
-		std::vector m_urls;
-		std::vector m_web_seeds;
+		std::vector<announce_entry> m_urls;
+		std::vector<web_seed_entry> m_web_seeds;
 		nodes_t m_nodes;
 
 		// if this is a merkle torrent, this is the merkle
 		// tree. It has space for merkle_num_nodes(merkle_num_leafs(num_pieces))
 		// hashes
-		std::vector m_merkle_tree;
+		std::vector<sha1_hash> m_merkle_tree;
 
 		// this is a copy of the info section from the torrent.
 		// it use maintained in this flat format in order to
 		// make it available through the metadata extension
-		boost::shared_array m_info_section;
+		boost::shared_array<char> m_info_section;
 
 		// this is a pointer into the m_info_section buffer
 		// pointing to the first byte of the first sha-1 hash
@@ -3392,23 +3392,23 @@ m_sock.bind(endpoint, ec);

include/libtorrent/proxy_base.hpp:152

relevance 0include/libtorrent/udp_socket.hpp:195move this debug facility into a base class. It's used in a lot of places

move this debug facility into a base class. It's used in a lot of places

include/libtorrent/udp_socket.hpp:195

			, error_code const& e, std::size_t bytes_transferred);
-		void on_name_lookup(error_code const& e, tcp::resolver::iterator i);
+
relevance 0include/libtorrent/udp_socket.hpp:195move this debug facility into a base class. It's used in a lot of places

move this debug facility into a base class. It's used in a lot of places

include/libtorrent/udp_socket.hpp:195

			, error_code const& e, std::size_t bytes_transferred);
+		void on_name_lookup(error_code const& e, tcp::resolver::iterator i);
 		void on_timeout();
 		void on_connect(int ticket);
-		void on_connected(error_code const& ec);
-		void handshake1(error_code const& e);
-		void handshake2(error_code const& e);
-		void handshake3(error_code const& e);
-		void handshake4(error_code const& e);
+		void on_connected(error_code const& ec);
+		void handshake1(error_code const& e);
+		void handshake2(error_code const& e);
+		void handshake3(error_code const& e);
+		void handshake4(error_code const& e);
 		void socks_forward_udp();
-		void connect1(error_code const& e);
-		void connect2(error_code const& e);
-		void hung_up(error_code const& e);
+		void connect1(error_code const& e);
+		void connect2(error_code const& e);
+		void hung_up(error_code const& e);
 
-		void wrap(udp::endpoint const& ep, char const* p, int len, error_code& ec);
-		void wrap(char const* hostname, int port, char const* p, int len, error_code& ec);
-		void unwrap(error_code const& e, char const* buf, int size);
+		void wrap(udp::endpoint const& ep, char const* p, int len, error_code& ec);
+		void wrap(char const* hostname, int port, char const* p, int len, error_code& ec);
+		void unwrap(error_code const& e, char const* buf, int size);
 
 #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
 
@@ -3448,27 +3448,27 @@ m_sock.bind(endpoint, ec);

include/libtorrent/proxy_base.hpp:152

(*i), buffer_size(*i)); + add_read_buffer(buffer_cast<void*>(*i), buffer_size(*i)); #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS buf_size += buffer_size(*i); #endif } std::size_t ret = read_some(true); - TORRENT_ASSERT(ret <= buf_size); - TORRENT_ASSERT(ret > 0); + TORRENT_ASSERT(ret <= buf_size); + TORRENT_ASSERT(ret > 0); return ret; } - template - std::size_t write_some(Const_Buffers const& buffers, error_code& ec) + template <class Const_Buffers> + std::size_t write_some(Const_Buffers const& buffers, error_code& ec) { - TORRENT_ASSERT(false && "not implemented!"); + TORRENT_ASSERT(false && "not implemented!");
return 0;
} #ifndef BOOST_NO_EXCEPTIONS - template - std::size_t read_some(Mutable_Buffers const& buffers) + template <class Mutable_Buffers> + std::size_t read_some(Mutable_Buffers const& buffers) { error_code ec; std::size_t ret = read_some(buffers, ec); @@ -3477,8 +3477,8 @@ m_sock.bind(endpoint, ec);

include/libtorrent/proxy_base.hpp:152

- std::size_t write_some(Const_Buffers const& buffers) + template <class Const_Buffers> + std::size_t write_some(Const_Buffers const& buffers) { error_code ec; std::size_t ret = write_some(buffers, ec); @@ -3488,12 +3488,12 @@ m_sock.bind(endpoint, ec);

include/libtorrent/proxy_base.hpp:152

- void async_write_some(Const_Buffers const& buffers, Handler const& handler) + template <class Const_Buffers, class Handler> + void async_write_some(Const_Buffers const& buffers, Handler const& handler) { if (m_impl == 0) { - m_io_service.post(boost::bind(handler, asio::error::not_connected, 0)); + m_io_service.post(boost::bind<void>(handler, asio::error::not_connected, 0));
relevance 0include/libtorrent/web_peer_connection.hpp:127if 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:127

@@ -3506,17 +3506,17 @@ use allocate_disk_receive_buffer and release_disk_receive_buffer

include // block. If the peer isn't downloading // a piece for the moment, the boost::optional // will be invalid. - boost::optional downloading_piece_progress() const; + boost::optional<piece_block_progress> downloading_piece_progress() const; // this has one entry per http-request // (might be more than the bt requests) - std::deque m_file_requests; + std::deque<int> m_file_requests; std::string m_url; // this is used for intermediate storage of pieces // that are received in more than one HTTP response -
std::vector m_piece; +
std::vector<char> m_piece;
// the number of bytes received in the current HTTP // response. used to know where in the buffer the @@ -3565,35 +3565,35 @@ namespace libtorrent { namespace dht friend void intrusive_ptr_add_ref(dht_tracker const*); friend void intrusive_ptr_release(dht_tracker const*); -
dht_tracker(libtorrent::aux::session_impl& ses, rate_limited_udp_socket& sock -
, dht_settings const& settings, entry const* state = 0); +
dht_tracker(libtorrent::aux::session_impl& ses, rate_limited_udp_socket& sock +
, dht_settings const& settings, entry const* state = 0); virtual ~dht_tracker(); - void start(entry const& bootstrap); + void start(entry const& bootstrap); void stop(); void add_node(udp::endpoint node); - void add_node(std::pair const& node); - void add_router_node(udp::endpoint const& node); + void add_node(std::pair<std::string, int> const& node); + void add_router_node(udp::endpoint const& node); entry state() const; - void announce(sha1_hash const& ih, int listen_port, bool seed - , boost::function const&)> f); + void announce(sha1_hash const& ih, int listen_port, bool seed + , boost::function<void(std::vector<tcp::endpoint> const&)> f); - void dht_status(session_status& s); - void network_stats(int& sent, int& received); + void dht_status(session_status& s); + void network_stats(int& sent, int& received); // translate bittorrent kademlia message into the generic kademlia message // used by the library - virtual bool incoming_packet(error_code const& ec - , udp::endpoint const&, char const* buf, int size); + virtual bool incoming_packet(error_code const& ec + , udp::endpoint const&, char const* buf, int size); private: - boost::intrusive_ptr self() - { return boost::intrusive_ptr(this); } + boost::intrusive_ptr<dht_tracker> self() + { return boost::intrusive_ptr<dht_tracker>(this); } - void on_name_lookup(error_code const& e + void on_name_lookup(error_code const& e , udp::resolver::iterator host);

\ No newline at end of file diff --git a/gen_todo.py b/gen_todo.py index 71338c952..ac5f8b0ac 100644 --- a/gen_todo.py +++ b/gen_todo.py @@ -16,6 +16,15 @@ items = [] # todo-items context = [] +def html_sanitize(s): + ret = '' + for i in s: + if i == '<': ret += '<' + elif i == '>': ret += '>' + elif i == '&': ret += '&' + else: ret += i + return ret + for f in files: h = open(f) @@ -39,7 +48,7 @@ for f in files: continue if state == '': - context.append(l) + context.append(html_sanitize(l)) if len(context) > 20: context.pop(0) continue @@ -49,12 +58,12 @@ for f in files: items[-1]['todo'] += line[2:].strip() else: state = 'context' - items[-1]['context'] = ''.join(context) + '
' + l + '
'; + items[-1]['context'] = ''.join(context) + '
' + html_sanitize(l) + '
'; context_lines = 1 continue if state == 'context': - items[-1]['context'] += l + items[-1]['context'] += html_sanitize(l) context_lines += 1 if context_lines > 30: state = ''