../src/web_peer_co
{
// we should not try this server again.
t->remove_web_seed(this);
-relevance 3 | ../src/kademlia/routing_table.cpp:131 | cache the depth! |
cache the depth!../src/kademlia/routing_table.cpp:131{
- int deepest_bucket = 0;
- int deepest_size = 0;
- for (table_t::const_iterator i = m_buckets.begin()
- , end(m_buckets.end()); i != end; ++i)
- {
- deepest_size = i->live_nodes.size(); // + i->replacements.size();
- if (deepest_size < m_bucket_size) break;
- // this bucket is full
- ++deepest_bucket;
- }
-
- if (deepest_bucket == 0) return 1 + deepest_size;
-
- if (deepest_size < m_bucket_size / 2) return (size_type(1) << deepest_bucket) * m_bucket_size;
- else return (size_type(2) << deepest_bucket) * deepest_size;
-}
-
-int routing_table::depth() const
-{
- int deepest_bucket = 0;
- for (table_t::const_iterator i = m_buckets.begin()
- , end(m_buckets.end()); i != end; ++i)
- {
- if (i->live_nodes.size() < m_bucket_size / 2)
- break;
- // this bucket is full
- ++deepest_bucket;
- }
- return deepest_bucket;
-}
-
-#if (defined TORRENT_DHT_VERBOSE_LOGGING || defined TORRENT_DEBUG) && TORRENT_USE_IOSTREAM
-
-void routing_table::print_state(std::ostream& os) const
-{
- os << "kademlia routing table state\n"
- << "bucket_size: " << m_bucket_size << "\n"
- << "global node count: " << num_global_nodes() << "\n"
- << "node_id: " << m_id << "\n\n";
-
- os << "number of nodes per bucket:\n-- live ";
- for (int i = 8; i < 160; ++i)
- os << "-";
- os << "\n";
-
- int max_size = bucket_limit(0);
- for (int k = 0; k < max_size; ++k)
- {
- for (table_t::const_iterator i = m_buckets.begin(), end(m_buckets.end());
- i != end; ++i)
- | ||
relevance 3 | ../include/libtorrent/kademlia/find_data.hpp:60 | rename this class to get_peers, since that's what it does find_data is an unnecessarily generic name |
rename this class to get_peers, since that's what it does
+ | ||
relevance 3 | ../include/libtorrent/kademlia/find_data.hpp:60 | rename this class to get_peers, since that's what it does find_data is an unnecessarily generic name |
rename this class to get_peers, since that's what it does
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>
@@ -287,7 +236,7 @@ protected:
nodes_callback m_nodes_callback;
std::map<node_id, std::string> m_write_tokens;
node_id const m_target;
- | ||
relevance 2 | ../src/torrent.cpp:8369 | will pick_pieces ever return an empty set? |
will pick_pieces ever return an empty set?../src/torrent.cpp:8369 if (added_request)
+ | ||
relevance 2 | ../src/torrent.cpp:8369 | will pick_pieces ever return an empty set? |
will pick_pieces ever return an empty set?../src/torrent.cpp:8369 if (added_request)
{
peers_with_requests.insert(peers_with_requests.begin(), &c);
if (i->first_requested == min_time()) i->first_requested = now;
@@ -338,7 +287,7 @@ protected:
void torrent::remove_web_seed(std::string const& url, web_seed_entry::type_t type)
{
std::list<web_seed_entry>::iterator i = std::find_if(m_web_seeds.begin(), m_web_seeds.end()
- | ||
relevance 2 | ../src/utp_stream.cpp:1862 | we 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
+ | ||
relevance 2 | ../src/utp_stream.cpp:1862 | we 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:1862// if ((rand() % 100) > 0)
#endif
@@ -391,7 +340,7 @@ it being an MTU probe../src/utp_stream.cpp:1862relevance 2 | ../src/utp_stream.cpp:2505 | sequence number, source IP and connection ID should be verified before accepting a reset packet |
|
sequence number, source IP and connection ID should be
+ | ||
relevance 2 | ../src/utp_stream.cpp:2505 | sequence number, source IP and connection ID should be verified before accepting a reset packet |
sequence number, source IP and connection ID should be
verified before accepting a reset packet../src/utp_stream.cpp:2505 m_reply_micro = boost::uint32_t(total_microseconds(receive_time - min_time()))
- ph->timestamp_microseconds;
boost::uint32_t prev_base = m_their_delay_hist.initialized() ? m_their_delay_hist.base() : 0;
@@ -443,7 +392,7 @@ verified before accepting a reset packet../src/utp_stream.cpp:2505
, this, int(ph->ack_nr), m_seq_nr);
m_sm->inc_stats_counter(utp_socket_manager::redundant_pkts_in);
return true;
- | ||
relevance 2 | ../src/web_peer_connection.cpp:546 | create a mapping of file-index to redirection URLs. Use that to form URLs instead. Support to reconnect to a new server without destructing this peer_connection |
create a mapping of file-index to redirection URLs. Use that to form URLs instead. Support to reconnect to a new server without destructing this peer_connection../src/web_peer_connection.cpp:546 t->remove_web_seed(this);
+ | ||
relevance 2 | ../src/web_peer_connection.cpp:546 | create a mapping of file-index to redirection URLs. Use that to form URLs instead. Support to reconnect to a new server without destructing this peer_connection |
create a mapping of file-index to redirection URLs. Use that to form URLs instead. Support to reconnect to a new server without destructing this peer_connection../src/web_peer_connection.cpp:546 t->remove_web_seed(this);
disconnect(errors::missing_location, 2);
#ifdef TORRENT_DEBUG
TORRENT_ASSERT(m_statistics.last_payload_downloaded()
@@ -494,7 +443,7 @@ verified before accepting a reset packet../src/utp_stream.cpp:2505
return;
}
- | ||
relevance 2 | ../src/kademlia/node.cpp:69 | make this configurable in dht_settings |
make this configurable in dht_settings../src/kademlia/node.cpp:69#include "libtorrent/kademlia/routing_table.hpp"
+ | ||
relevance 2 | ../src/kademlia/node.cpp:69 | make this configurable in dht_settings |
make this configurable in dht_settings../src/kademlia/node.cpp:69#include "libtorrent/kademlia/routing_table.hpp"
#include "libtorrent/kademlia/node.hpp"
#include <libtorrent/kademlia/dht_observer.hpp>
@@ -545,7 +494,7 @@ void purge_peers(std::set<peer_entry>& peers)
void nop() {}
- | ||
relevance 1 | ../src/http_seed_connection.cpp:117 | in chunked encoding mode, this assert won't hold. the chunk headers should be subtracted from the receive_buffer_size |
in chunked encoding mode, this assert won't hold.
+ | ||
relevance 1 | ../src/http_seed_connection.cpp:117 | in chunked encoding mode, this assert won't hold. the chunk headers should be subtracted from the receive_buffer_size |
in chunked encoding mode, this assert won't hold.
the chunk headers should be subtracted from the receive_buffer_size../src/http_seed_connection.cpp:117 boost::optional<piece_block_progress>
http_seed_connection::downloading_piece_progress() const
{
@@ -597,7 +546,7 @@ the chunk headers should be subtracted from the receive_buffer_size../s
std::string request;
request.reserve(400);
- | ||
relevance 1 | ../src/peer_connection.cpp:2570 | peers should really be corked/uncorked outside of all completed disk operations |
peers should really be corked/uncorked outside of
+ | ||
relevance 1 | ../src/peer_connection.cpp:2570 | peers 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:2570 }
if (is_disconnecting()) return;
@@ -649,8 +598,8 @@ all completed disk operations../src/peer_connection.cpp:2570 | ||
relevance 1 | ../src/session_impl.cpp:5720 | report the proper address of the router as the source IP of this understanding of our external address, instead of the empty address |
report the proper address of the router as the source IP of
-this understanding of our external address, instead of the empty address../src/session_impl.cpp:5720 void session_impl::on_port_mapping(int mapping, address const& ip, int port
+ | ||
relevance 1 | ../src/session_impl.cpp:5717 | report the proper address of the router as the source IP of this understanding of our external address, instead of the empty address |
report the proper address of the router as the source IP of
+this understanding of our external address, instead of the empty address../src/session_impl.cpp:5717 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());
@@ -701,7 +650,7 @@ this understanding of our external address, instead of the empty address | ||
relevance 1 | ../src/session_impl.cpp:5930 | report errors as alerts |
report errors as alerts../src/session_impl.cpp:5930 }
+ | ||
relevance 1 | ../src/session_impl.cpp:5927 | report errors as alerts |
report errors as alerts../src/session_impl.cpp:5927 }
void session_impl::add_dht_router(std::pair<std::string, int> const& node)
{
@@ -752,9 +701,9 @@ this understanding of our external address, instead of the empty address | ||
relevance 1 | ../src/session_impl.cpp:6401 | we only need to do this if our global IPv4 address has changed since the DHT (currently) only supports IPv4. Since restarting the DHT is kind of expensive, it would be nice to not do it unnecessarily |
we only need to do this if our global IPv4 address has changed
+ | ||
relevance 1 | ../src/session_impl.cpp:6398 | we only need to do this if our global IPv4 address has changed since the DHT (currently) only supports IPv4. Since restarting the DHT is kind of expensive, it would be nice to not do it unnecessarily |
we only need to do this if our global IPv4 address has changed
since the DHT (currently) only supports IPv4. Since restarting the DHT
-is kind of expensive, it would be nice to not do it unnecessarily../src/session_impl.cpp:6401 void session_impl::set_external_address(address const& ip
+is kind of expensive, it would be nice to not do it unnecessarily../src/session_impl.cpp:6398 void session_impl::set_external_address(address const& ip
, int source_type, address const& source)
{
#if defined TORRENT_VERBOSE_LOGGING
@@ -805,7 +754,7 @@ is kind of expensive, it would be nice to not do it unnecessarily../src
#ifdef TORRENT_DISK_STATS
TORRENT_ASSERT(m_buffer_allocations >= 0);
- | ||
relevance 1 | ../src/torrent.cpp:1158 | make this depend on the error and on the filesystem the files are being downloaded to. If the error is no_space_left_on_device and the filesystem doesn't support sparse files, only zero the priorities of the pieces that are at the tails of all files, leaving everything up to the highest written piece in each file |
make this depend on the error and on the filesystem the
+ | ||
relevance 1 | ../src/torrent.cpp:1158 | make this depend on the error and on the filesystem the files are being downloaded to. If the error is no_space_left_on_device and the filesystem doesn't support sparse files, only zero the priorities of the pieces that are at the tails of all files, leaving everything up to the highest written piece in each file |
make this depend on the error and on the filesystem the
files are being downloaded to. If the error is no_space_left_on_device
and the filesystem doesn't support sparse files, only zero the priorities
of the pieces that are at the tails of all files, leaving everything
@@ -860,7 +809,7 @@ up to the highest written piece in each file../src/torrent.cpp:1158 | ||
relevance 1 | ../src/torrent.cpp:5444 | save the send_stats state instead of throwing them away it may pose an issue when downgrading though |
save the send_stats state instead of throwing them away
+ | ||
relevance 1 | ../src/torrent.cpp:5444 | save the send_stats state instead of throwing them away it may pose an issue when downgrading though |
save the send_stats state instead of throwing them away
it may pose an issue when downgrading though../src/torrent.cpp:5444 ? (1 << k) : 0;
bitmask.append(1, v);
TORRENT_ASSERT(bits == 8 || j == num_bitmask_bytes - 1);
@@ -912,7 +861,7 @@ it may pose an issue when downgrading though../src/torrent.cpp:5444 | ||
relevance 1 | ../src/torrent.cpp:6350 | should disconnect all peers that have the pieces we have not just seeds. It would be pretty expensive to check all pieces for all peers though |
should disconnect all peers that have the pieces we have
+ | ||
relevance 1 | ../src/torrent.cpp:6350 | should disconnect all peers that have the pieces we have not just seeds. It would be pretty expensive to check all pieces for all peers though |
should disconnect all peers that have the pieces we have
not just seeds. It would be pretty expensive to check all pieces
for all peers though../src/torrent.cpp:6350 TORRENT_ASSERT(m_state != torrent_status::finished && m_state != torrent_status::seeding);
@@ -965,7 +914,7 @@ for all peers though../src/torrent.cpp:6350relevance 1 | ../src/torrent_info.cpp:181 | we might save constructing a std::string if this would take a char const* instead |
|
we might save constructing a std::string if this would take a char const* instead../src/torrent_info.cpp:181 {
+ | ||
relevance 1 | ../src/torrent_info.cpp:181 | we might save constructing a std::string if this would take a char const* instead |
we might save constructing a std::string if this would take a char const* instead../src/torrent_info.cpp:181 {
tmp_path += i[0];
tmp_path += i[1];
tmp_path += i[2];
@@ -1016,7 +965,7 @@ for all peers though../src/torrent.cpp:6350relevance 1 | ../src/torrent_info.cpp:387 | this 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
+ | ||
relevance 1 | ../src/torrent_info.cpp:387 | this 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
filenames should be preserved!../src/torrent_info.cpp:387
while (*s1 != 0 || *s2 != 0)
@@ -1053,33 +1002,36 @@ filenames should be preserved!../src/torrent_info.cpp:387 | ||
relevance 1 | ../src/torrent_info.cpp:418 | once 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:418 if (!extract_single_file(*list.list_at(i), e, root_dir
- , &file_hash, &fee, &mtime))
- return false;
-
- // as long as this file already exists
- // increase the counter
+ | ||
relevance 1 | ../src/torrent_info.cpp:423 | once 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:423 // increase the counter
int cnt = 0;
- while (!files.insert(e.path).second)
+ if (!files.insert(e.path).second)
{
- ++cnt;
- char suffix[50];
- snprintf(suffix, sizeof(suffix), "%d%s", cnt, extension(e.path).c_str());
- replace_extension(e.path, suffix);
+ std::string base = remove_extension(e.path);
+ std::string ext = extension(e.path);
+ do
+ {
+ ++cnt;
+ char new_ext[50];
+ snprintf(new_ext, sizeof(new_ext), ".%d%s", cnt, ext.c_str());
+ e.path = base + new_ext;
+ } while (!files.insert(e.path).second);
}
target.add_file(e, file_hash ? file_hash->string_ptr() + info_ptr_diff : 0);
@@ -1118,7 +1070,7 @@ this check can be removed as well../src/torrent_info.cpp:418 | ||
relevance 1 | ../src/kademlia/node.cpp:772 | find_node should write directly to the response entry |
find_node should write directly to the response entry../src/kademlia/node.cpp:772 {
+ | ||
relevance 1 | ../src/kademlia/node.cpp:772 | find_node should write directly to the response entry |
find_node should write directly to the response entry../src/kademlia/node.cpp:772 {
TORRENT_LOG(node) << " values: " << reply["values"].list().size();
}
#endif
@@ -1169,7 +1121,7 @@ this check can be removed as well../src/torrent_info.cpp:418 | ||
relevance 1 | ../include/libtorrent/ip_voter.hpp:100 | instead, have one instance per possible subnet, global IPv4, global IPv6, loopback, 192.168.x.x, 10.x.x.x, etc. |
instead, have one instance per possible subnet, global IPv4, global IPv6, loopback, 192.168.x.x, 10.x.x.x, etc.../include/libtorrent/ip_voter.hpp:100 bloom_filter<32> m_external_address_voters;
+ | ||
relevance 1 | ../include/libtorrent/ip_voter.hpp:100 | instead, have one instance per possible subnet, global IPv4, global IPv6, loopback, 192.168.x.x, 10.x.x.x, etc. |
instead, have one instance per possible subnet, global IPv4, global IPv6, loopback, 192.168.x.x, 10.x.x.x, etc.../include/libtorrent/ip_voter.hpp:100 bloom_filter<32> m_external_address_voters;
std::vector<external_ip_t> m_external_addresses;
address m_external_address;
};
@@ -1196,7 +1148,7 @@ this check can be removed as well../src/torrent_info.cpp:418 | ||
relevance 1 | ../include/libtorrent/utp_stream.hpp:376 | implement blocking write. Low priority since it's not used (yet) |
implement blocking write. Low priority since it's not used (yet)../include/libtorrent/utp_stream.hpp:376 for (typename Mutable_Buffers::const_iterator i = buffers.begin()
+ | ||
relevance 1 | ../include/libtorrent/utp_stream.hpp:377 | implement blocking write. Low priority since it's not used (yet) |
implement blocking write. Low priority since it's not used (yet)../include/libtorrent/utp_stream.hpp:377 for (typename Mutable_Buffers::const_iterator i = buffers.begin()
, end(buffers.end()); i != end; ++i)
{
using asio::buffer_cast;
@@ -1247,7 +1199,7 @@ this check can be removed as well../src/torrent_info.cpp:418 | ||
relevance 1 | ../include/libtorrent/web_peer_connection.hpp:126 | if we make this be a disk_buffer_holder instead we would save a copy sometimes use allocate_disk_receive_buffer and release_disk_receive_buffer |
if we make this be a disk_buffer_holder instead
+ | ||
relevance 1 | ../include/libtorrent/web_peer_connection.hpp:126 | if we make this be a disk_buffer_holder instead we would save a copy sometimes use allocate_disk_receive_buffer and release_disk_receive_buffer |
if we make this be a disk_buffer_holder instead
we would save a copy sometimes
use allocate_disk_receive_buffer and release_disk_receive_buffer../include/libtorrent/web_peer_connection.hpp:126
bool maybe_harvest_block();
@@ -1300,7 +1252,7 @@ use allocate_disk_receive_buffer and release_disk_receive_buffer../incl
};
}
- | ||
relevance 0 | ../src/bt_peer_connection.cpp:617 | this could be optimized using knuth morris pratt |
this could be optimized using knuth morris pratt../src/bt_peer_connection.cpp:617 {
+ | ||
relevance 0 | ../src/bt_peer_connection.cpp:617 | this could be optimized using knuth morris pratt |
this could be optimized using knuth morris pratt../src/bt_peer_connection.cpp:617 {
disconnect(errors::no_memory);
return;
}
@@ -1351,7 +1303,7 @@ use allocate_disk_receive_buffer and release_disk_receive_buffer../incl
// }
// no complete sync
- | ||
relevance 0 | ../src/bt_peer_connection.cpp:2083 | if we're finished, send upload_only message |
if we're finished, send upload_only message../src/bt_peer_connection.cpp:2083 if (msg[5 + k / 8] & (0x80 >> (k % 8))) bitfield_string[k] = '1';
+ | ||
relevance 0 | ../src/bt_peer_connection.cpp:2083 | if we're finished, send upload_only message |
if we're finished, send upload_only message../src/bt_peer_connection.cpp:2083 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());
@@ -1402,7 +1354,7 @@ use allocate_disk_receive_buffer and release_disk_receive_buffer../incl
std::back_insert_iterator<std::string> out(remote_address);
detail::write_address(remote().address(), out);
handshake["yourip"] = remote_address;
- | ||
relevance 0 | ../src/bt_peer_connection.cpp:3325 | move the erasing into the loop above remove all payload ranges that has been sent |
move the erasing into the loop above
+ | ||
relevance 0 | ../src/bt_peer_connection.cpp:3325 | move 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:3325 for (std::vector<range>::iterator i = m_payloads.begin();
i != m_payloads.end(); ++i)
{
@@ -1454,7 +1406,7 @@ remove all payload ranges that has been sent../src/bt_peer_connection.c
TORRENT_ASSERT(m_sent_handshake);
}
- | ||
relevance 0 | ../src/file.cpp:1346 | is there any way to pre-fetch data from a file on windows? |
is there any way to pre-fetch data from a file on windows?../src/file.cpp:1346
+ | ||
relevance 0 | ../src/file.cpp:1358 | is there any way to pre-fetch data from a file on windows? |
is there any way to pre-fetch data from a file on windows?../src/file.cpp:1358
void file::init_file()
{
if (m_page_size != 0) return;
@@ -1505,7 +1457,7 @@ remove all payload ranges that has been sent../src/bt_peer_connection.c
#ifdef TORRENT_DEBUG
if (m_open_mode & no_buffer)
{
- | ||
relevance 0 | ../src/http_tracker_connection.cpp:99 | support 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
+ | ||
relevance 0 | ../src/http_tracker_connection.cpp:99 | support 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
@@ -1556,7 +1508,7 @@ remove all payload ranges that has been sent../src/bt_peer_connection.c
if (arguments_start != std::string::npos)
url += "&";
else
- | ||
relevance 0 | ../src/i2p_stream.cpp:204 | move 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:204
+ | ||
relevance 0 | ../src/i2p_stream.cpp:204 | move 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:204
i2p_stream::i2p_stream(io_service& io_service)
: proxy_base(io_service)
, m_id(0)
@@ -1607,7 +1559,7 @@ remove all payload ranges that has been sent../src/bt_peer_connection.c
void i2p_stream::connected(error_code const& e, boost::shared_ptr<handler_type> h)
{
TORRENT_ASSERT(m_magic == 0x1337);
- | ||
relevance 0 | ../src/packet_buffer.cpp:176 | use compare_less_wrap for this comparison as well |
use compare_less_wrap for this comparison as well../src/packet_buffer.cpp:176 while (new_size < size)
+ | ||
relevance 0 | ../src/packet_buffer.cpp:176 | use compare_less_wrap for this comparison as well |
use compare_less_wrap for this comparison as well../src/packet_buffer.cpp:176 while (new_size < size)
new_size <<= 1;
void** new_storage = (void**)malloc(sizeof(void*) * new_size);
@@ -1658,7 +1610,7 @@ remove all payload ranges that has been sent../src/bt_peer_connection.c
if (m_storage[m_last & mask]) break;
++m_last;
m_last &= 0xffff;
- | ||
relevance 0 | ../src/peer_connection.cpp:2733 | this might need something more so that once we have the metadata we can construct a full bitfield |
this might need something more
+ | ||
relevance 0 | ../src/peer_connection.cpp:2733 | this 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:2733
#ifdef TORRENT_VERBOSE_LOGGING
@@ -1711,7 +1663,7 @@ we can construct a full bitfield../src/peer_connection.cpp:2733 | ||
relevance 0 | ../src/peer_connection.cpp:2864 | sort the allowed fast set in priority order |
sort the allowed fast set in priority order../src/peer_connection.cpp:2864 // this piece index later
+ | ||
relevance 0 | ../src/peer_connection.cpp:2864 | sort the allowed fast set in priority order |
sort the allowed fast set in priority order../src/peer_connection.cpp:2864 // this piece index later
m_allowed_fast.push_back(index);
// if the peer has the piece and we want
@@ -1762,7 +1714,7 @@ we can construct a full bitfield../src/peer_connection.cpp:2733 | ||
relevance 0 | ../src/peer_connection.cpp:4577 | peers should really be corked/uncorked outside of all completed disk operations |
peers should really be corked/uncorked outside of
+ | ||
relevance 0 | ../src/peer_connection.cpp:4577 | peers 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:4577 // 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
@@ -1814,7 +1766,7 @@ all completed disk operations../src/peer_connection.cpp:4577 | ||
relevance 0 | ../src/policy.cpp:857 | only allow _one_ connection to use this override at a time |
only allow _one_ connection to use this
+ | ||
relevance 0 | ../src/policy.cpp:857 | only 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) <<
" ]\n";
@@ -1866,7 +1818,7 @@ override at a time../src/policy.cpp:857relevance 0 | ../src/policy.cpp:1902 | how do we deal with our external address changing? Pass in a force-update maybe? and keep a version number in policy |
|
how do we deal with our external address changing? Pass in a force-update maybe? and keep a version number in policy../src/policy.cpp:1902#endif
+ | ||
relevance 0 | ../src/policy.cpp:1902 | how do we deal with our external address changing? Pass in a force-update maybe? and keep a version number in policy |
how do we deal with our external address changing? Pass in a force-update maybe? and keep a version number in policy../src/policy.cpp:1902#endif
, on_parole(false)
, banned(false)
#ifndef TORRENT_DISABLE_DHT
@@ -1917,7 +1869,7 @@ override at a time../src/policy.cpp:857relevance 0 | ../src/session_impl.cpp:1943 | recalculate all connect candidates for all torrents |
|
recalculate all connect candidates for all torrents../src/session_impl.cpp:1943 m_upload_rate.close();
+ | ||
relevance 0 | ../src/session_impl.cpp:1940 | recalculate all connect candidates for all torrents |
recalculate all connect candidates for all torrents../src/session_impl.cpp:1940 m_upload_rate.close();
// #error closing the udp socket here means that
// the uTP connections cannot be closed gracefully
@@ -1968,7 +1920,7 @@ override at a time../src/policy.cpp:857relevance 0 | ../src/session_impl.cpp:3394 | have a separate list for these connections, instead of having to loop through all of them |
|
have a separate list for these connections, instead of having to loop through all of them../src/session_impl.cpp:3394 // --------------------------------------------------------------
+ | ||
relevance 0 | ../src/session_impl.cpp:3391 | have a separate list for these connections, instead of having to loop through all of them |
have a separate list for these connections, instead of having to loop through all of them../src/session_impl.cpp:3391 // --------------------------------------------------------------
if (!m_paused) m_auto_manage_time_scaler--;
if (m_auto_manage_time_scaler < 0)
{
@@ -2019,7 +1971,7 @@ override at a time../src/policy.cpp:857relevance 0 | ../src/session_impl.cpp:4484 | allow extensions to sort torrents for queuing |
|
allow extensions to sort torrents for queuing../src/session_impl.cpp:4484 else if (!t->is_paused())
+ | ||
relevance 0 | ../src/session_impl.cpp:4481 | allow extensions to sort torrents for queuing |
allow extensions to sort torrents for queuing../src/session_impl.cpp:4481 else if (!t->is_paused())
{
TORRENT_ASSERT(t->m_resume_data_loaded || !t->valid_metadata());
--hard_limit;
@@ -2070,9 +2022,9 @@ override at a time../src/policy.cpp:857relevance 0 | ../src/session_impl.cpp:4640 | use a lower limit than m_settings.connections_limit to allocate the to 10% or so of connection slots for incoming connections |
|
use a lower limit than m_settings.connections_limit
+ | ||
relevance 0 | ../src/session_impl.cpp:4637 | use a lower limit than m_settings.connections_limit to allocate the to 10% or so of connection slots for incoming connections |
use a lower limit than m_settings.connections_limit
to allocate the to 10% or so of connection slots for incoming
-connections../src/session_impl.cpp:4640 {
+connections../src/session_impl.cpp:4637 {
if (m_boost_connections > max_connections)
{
m_boost_connections -= max_connections;
@@ -2123,7 +2075,7 @@ connections../src/session_impl.cpp:4640relevance 0 | ../src/session_impl.cpp:4674 | make this bias configurable |
|
make this bias configurable../src/session_impl.cpp:4674 | ||
relevance 0 | ../src/session_impl.cpp:4675 | also 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:4675 average_peers = num_downloads_peers / num_downloads;
+ | ||
relevance 0 | ../src/session_impl.cpp:4671 | make this bias configurable |
make this bias configurable../src/session_impl.cpp:4671 | ||
relevance 0 | ../src/session_impl.cpp:4672 | also 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:4672 average_peers = num_downloads_peers / num_downloads;
if (m_next_connect_torrent == m_torrents.end())
m_next_connect_torrent = m_torrents.begin();
@@ -2174,7 +2126,7 @@ connections../src/session_impl.cpp:4640relevance 0 | ../src/session_impl.cpp:4819 | make configurable |
|
make configurable../src/session_impl.cpp:4819
+ | ||
relevance 0 | ../src/session_impl.cpp:4816 | make configurable |
make configurable../src/session_impl.cpp:4816
#ifdef TORRENT_DEBUG
for (std::vector<peer_connection*>::const_iterator i = peers.begin()
, end(peers.end()), prev(peers.end()); i != end; ++i)
@@ -2207,7 +2159,7 @@ connections../src/session_impl.cpp:4640relevance 0 | ../src/session_impl.cpp:4833 | make configurable |
|
make configurable../src/session_impl.cpp:4833 >= (*i)->uploaded_in_last_round() * 1000
+ | ||
relevance 0 | ../src/session_impl.cpp:4830 | make configurable |
make configurable../src/session_impl.cpp:4830 >= (*i)->uploaded_in_last_round() * 1000
* (1 + t2->priority()) / total_milliseconds(unchoke_interval));
}
prev = i;
@@ -2258,7 +2210,7 @@ connections../src/session_impl.cpp:4640 | ||
relevance 0 | ../src/storage.cpp:324 | if the read fails, set error and exit immediately |
if the read fails, set error and exit immediately../src/storage.cpp:324 if (m_storage->disk_pool()) block_size = m_storage->disk_pool()->block_size();
+ | ||
relevance 0 | ../src/storage.cpp:324 | if the read fails, set error and exit immediately |
if the read fails, set error and exit immediately../src/storage.cpp:324 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;
@@ -2309,7 +2261,7 @@ connections../src/session_impl.cpp:4640relevance 0 | ../src/storage.cpp:358 | if the read fails, set error and exit immediately |
|
if the read fails, set error and exit immediately../src/storage.cpp:358 {
+ | ||
relevance 0 | ../src/storage.cpp:358 | if the read fails, set error and exit immediately |
if the read fails, set error and exit immediately../src/storage.cpp:358 {
ph.h.update((char const*)bufs[i].iov_base, bufs[i].iov_len);
small_piece_size -= bufs[i].iov_len;
}
@@ -2360,7 +2312,7 @@ connections../src/session_impl.cpp:4640relevance 0 | ../src/storage.cpp:629 | make this more generic to not just work if files have been renamed, but also if they have been merged into a single file for instance maybe use the same format as .torrent files and reuse some code from torrent_info |
|
make this more generic to not just work if files have been
+ | ||
relevance 0 | ../src/storage.cpp:629 | make this more generic to not just work if files have been renamed, but also if they have been merged into a single file for instance maybe use the same format as .torrent files and reuse some code from torrent_info |
make this more generic to not just work if files have been
renamed, but also if they have been merged into a single file for instance
maybe use the same format as .torrent files and reuse some code from torrent_info../src/storage.cpp:629 for (;;)
{
@@ -2413,7 +2365,7 @@ maybe use the same format as .torrent files and reuse some code from torrent_inf
for (int i = 0; i < file_sizes_ent->list_size(); ++i)
{
- | ||
relevance 0 | ../src/storage.cpp:1246 | what 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
+ | ||
relevance 0 | ../src/storage.cpp:1246 | what 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
if file_base is used. This is not a widely used feature though../src/storage.cpp:1246 int bytes_transferred = 0;
// if the file is opened in no_buffer mode, and the
@@ -2466,7 +2418,7 @@ if file_base is used. This is not a widely used feature though../src/st
// makes unaligned requests (and the disk cache is disabled or fully utilized
// for write cache).
- | ||
relevance 0 | ../src/torrent.cpp:1359 | is verify_peer_cert called once per certificate in the chain, and this function just tells us which depth we're at right now? If so, the comment makes sense. any certificate that isn't the leaf (i.e. the one presented by the peer) should be accepted automatically, given preverified is true. The leaf certificate need to be verified to make sure its DN matches the info-hash |
is verify_peer_cert called once per certificate in the chain, and
+ | ||
relevance 0 | ../src/torrent.cpp:1359 | is verify_peer_cert called once per certificate in the chain, and this function just tells us which depth we're at right now? If so, the comment makes sense. any certificate that isn't the leaf (i.e. the one presented by the peer) should be accepted automatically, given preverified is true. The leaf certificate need to be verified to make sure its DN matches the info-hash |
is verify_peer_cert called once per certificate in the chain, and
this function just tells us which depth we're at right now? If so, the comment
makes sense.
any certificate that isn't the leaf (i.e. the one presented by the peer)
@@ -2522,7 +2474,7 @@ need to be verified to make sure its DN matches the info-hash../src/tor
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
match = true;
- | ||
relevance 0 | ../src/torrent.cpp:5177 | make this more generic to not just work if files have been renamed, but also if they have been merged into a single file for instance maybe use the same format as .torrent files and reuse some code from torrent_info The mapped_files needs to be read both in the network thread and in the disk thread, since they both have their own mapped files structures which are kept in sync |
make this more generic to not just work if files have been
+ | ||
relevance 0 | ../src/torrent.cpp:5177 | make this more generic to not just work if files have been renamed, but also if they have been merged into a single file for instance maybe use the same format as .torrent files and reuse some code from torrent_info The mapped_files needs to be read both in the network thread and in the disk thread, since they both have their own mapped files structures which are kept in sync |
make this more generic to not just work if files have been
renamed, but also if they have been merged into a single file for instance
maybe use the same format as .torrent files and reuse some code from torrent_info
The mapped_files needs to be read both in the network thread
@@ -2578,7 +2530,7 @@ which are kept in sync../src/torrent.cpp:5177relevance 0 | ../src/torrent.cpp:5313 | if this is a merkle torrent and we can't restore the tree, we need to wipe all the bits in the have array, but not necessarily we might want to do a full check to see if we have all the pieces. This is low priority since almost no one uses merkle torrents |
|
if this is a merkle torrent and we can't
+ | ||
relevance 0 | ../src/torrent.cpp:5313 | if this is a merkle torrent and we can't restore the tree, we need to wipe all the bits in the have array, but not necessarily we might want to do a full check to see if we have all the pieces. This is low priority since almost no one uses merkle torrents |
if this is a merkle torrent and we can't
restore the tree, we need to wipe all the
bits in the have array, but not necessarily
we might want to do a full check to see if we have
@@ -2634,7 +2586,7 @@ no one uses merkle torrents../src/torrent.cpp:5313 | ||
relevance 0 | ../src/torrent.cpp:5501 | make this more generic to not just work if files have been renamed, but also if they have been merged into a single file for instance. using file_base |
make this more generic to not just work if files have been
+ | ||
relevance 0 | ../src/torrent.cpp:5501 | make this more generic to not just work if files have been renamed, but also if they have been merged into a single file for instance. using file_base |
make this more generic to not just work if files have been
renamed, but also if they have been merged into a single file for instance.
using file_base../src/torrent.cpp:5501 entry::string_type& pieces = ret["pieces"].string();
pieces.resize(m_torrent_file->num_pieces());
@@ -2687,7 +2639,7 @@ using file_base../src/torrent.cpp:5501relevance 0 | ../src/torrent.cpp:8048 | go through the pieces we have and count the total number of downloaders we have. Only count peers that are interested in us since some peers might not send have messages for pieces we have it num_interested == 0, we need to pick a new piece |
|
go through the pieces we have and count the total number
+ | ||
relevance 0 | ../src/torrent.cpp:8048 | go through the pieces we have and count the total number of downloaders we have. Only count peers that are interested in us since some peers might not send have messages for pieces we have it num_interested == 0, we need to pick a new piece |
go through the pieces we have and count the total number
of downloaders we have. Only count peers that are interested in us
since some peers might not send have messages for pieces we have
it num_interested == 0, we need to pick a new piece../src/torrent.cpp:8048 }
@@ -2741,7 +2693,7 @@ it num_interested == 0, we need to pick a new piece../src/torrent.cpp:8
{
m_picker->get_availability(avail_vec);
}
- | ||
relevance 0 | ../src/udp_tracker_connection.cpp:550 | 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 |
it would be more efficient to not use a string here.
+ | ||
relevance 0 | ../src/udp_tracker_connection.cpp:550 | 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 |
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:550 }
@@ -2794,7 +2746,7 @@ with actual strings. For example i2p trackers../src/udp_tracker_connect
{
restart_read_timeout();
int action = detail::read_int32(buf);
- | ||
relevance 0 | ../src/utp_stream.cpp:1573 | this loop may not be very efficient |
this loop may not be very efficient../src/utp_stream.cpp:1573 TORRENT_ASSERT(p->header_size >= sizeof(utp_header) + sack_size + 2);
+ | ||
relevance 0 | ../src/utp_stream.cpp:1573 | this loop may not be very efficient |
this loop may not be very efficient../src/utp_stream.cpp:1573 TORRENT_ASSERT(p->header_size >= sizeof(utp_header) + sack_size + 2);
memmove(ptr, ptr + sack_size + 2, p->size - p->header_size);
p->header_size -= sack_size + 2;
p->size -= sack_size + 2;
@@ -2845,8 +2797,8 @@ bool utp_socket_impl::send_pkt(int flags)
if (sack > 32) sack = 32;
}
- | ||
relevance 0 | ../src/kademlia/routing_table.cpp:280 | instad of refreshing a bucket by using find_nodes, ping each node periodically |
instad of refreshing a bucket by using find_nodes,
-ping each node periodically../src/kademlia/routing_table.cpp:280 os << "]\n";
+ | ||
relevance 0 | ../src/kademlia/routing_table.cpp:291 | instad of refreshing a bucket by using find_nodes, ping each node periodically |
instad of refreshing a bucket by using find_nodes,
+ping each node periodically../src/kademlia/routing_table.cpp:291 os << "]\n";
}
}
@@ -2897,7 +2849,7 @@ bool compare_bucket_refresh(routing_table_node const& lhs, routing_table_nod
// target = (target & ~mask) | (root & mask)
node_id root = m_id;
root &= mask;
- | ||
relevance 0 | ../include/libtorrent/config.hpp:305 | Make this count Unicode characters instead of bytes on windows |
Make this count Unicode characters instead of bytes on windows../include/libtorrent/config.hpp:305
+ | ||
relevance 0 | ../include/libtorrent/config.hpp:305 | Make this count Unicode characters instead of bytes on windows |
Make this count Unicode characters instead of bytes on windows../include/libtorrent/config.hpp:305
// ==== eCS(OS/2) ===
#elif defined __OS2__
#define TORRENT_OS2
@@ -2948,7 +2900,7 @@ bool compare_bucket_refresh(routing_table_node const& lhs, routing_table_nod
#include <stdarg.h>
// internal
- | ||
relevance 0 | ../include/libtorrent/proxy_base.hpp:166 | it would be nice to remember the bind port and bind once we know where the proxy is m_sock.bind(endpoint, ec); |
it would be nice to remember the bind port and bind once we know where the proxy is
+ | ||
relevance 0 | ../include/libtorrent/proxy_base.hpp:166 | it would be nice to remember the bind port and bind once we know where the proxy is m_sock.bind(endpoint, ec); |
it would be nice to remember the bind port and bind once we know where the proxy is
m_sock.bind(endpoint, ec);../include/libtorrent/proxy_base.hpp:166 {
return m_sock.get_option(opt, ec);
}
@@ -3000,7 +2952,7 @@ m_sock.bind(endpoint, ec);../include/libtorrent/proxy_base.hpp:166
m_sock.close(ec);
m_resolver.cancel();
}
- | ||
relevance 0 | ../include/libtorrent/torrent_info.hpp:123 | include the number of peers received from this tracker, at last announce |
include the number of peers received from this tracker, at last announce../include/libtorrent/torrent_info.hpp:123
+ | ||
relevance 0 | ../include/libtorrent/torrent_info.hpp:123 | include the number of peers received from this tracker, at last announce |
include the number of peers received from this tracker, at last announce../include/libtorrent/torrent_info.hpp:123
// if this tracker failed the last time it was contacted
// this error code specifies what error occurred
error_code last_error;
@@ -3051,7 +3003,7 @@ m_sock.bind(endpoint, ec);../include/libtorrent/proxy_base.hpp:166
// flags for the source bitmask, each indicating where
// we heard about this tracker
enum tracker_source
- | ||
relevance 0 | ../include/libtorrent/upnp.hpp:121 | support using the windows API for UPnP operations as well |
support using the windows API for UPnP operations as well../include/libtorrent/upnp.hpp:121 {
+ | ||
relevance 0 | ../include/libtorrent/upnp.hpp:121 | support using the windows API for UPnP operations as well |
support using the windows API for UPnP operations as well../include/libtorrent/upnp.hpp:121 {
virtual const char* name() const BOOST_SYSTEM_NOEXCEPT;
virtual std::string message(int ev) const BOOST_SYSTEM_NOEXCEPT;
virtual boost::system::error_condition default_error_condition(int ev) const BOOST_SYSTEM_NOEXCEPT
diff --git a/include/libtorrent/disk_buffer_holder.hpp b/include/libtorrent/disk_buffer_holder.hpp
index c5f57cf56..a19c8c8c0 100644
--- a/include/libtorrent/disk_buffer_holder.hpp
+++ b/include/libtorrent/disk_buffer_holder.hpp
@@ -43,7 +43,15 @@ namespace libtorrent
namespace aux { struct session_impl; }
struct disk_buffer_pool;
- struct TORRENT_EXTRA_EXPORT disk_buffer_holder
+ // The disk buffer holder acts like a ``scoped_ptr`` that frees a disk buffer
+ // when it's destructed, unless it's released. ``release`` returns the disk
+ // buffer and transferres ownership and responsibility to free it to the caller.
+ //
+ // A disk buffer is freed by passing it to ``session_impl::free_disk_buffer()``.
+ //
+ // ``buffer()`` returns the pointer without transferring responsibility. If
+ // this buffer has been released, ``buffer()`` will return 0.
+ struct TORRENT_EXPORT disk_buffer_holder
{
disk_buffer_holder(aux::session_impl& ses, char* buf);
disk_buffer_holder(disk_buffer_pool& disk_pool, char* buf);
diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp
index b5c2a0dc6..4f5f6d15c 100644
--- a/include/libtorrent/disk_io_thread.hpp
+++ b/include/libtorrent/disk_io_thread.hpp
@@ -171,6 +171,7 @@ namespace libtorrent
// relevant for the disk io thread and disk cache.
struct TORRENT_EXPORT cache_status
{
+ // initializes all counters to 0
cache_status()
: blocks_written(0)
, writes(0)
diff --git a/include/libtorrent/extensions.hpp b/include/libtorrent/extensions.hpp
index b30694547..4e3d2c3a1 100644
--- a/include/libtorrent/extensions.hpp
+++ b/include/libtorrent/extensions.hpp
@@ -33,6 +33,136 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_EXTENSIONS_HPP_INCLUDED
#define TORRENT_EXTENSIONS_HPP_INCLUDED
+// OVERVIEW
+//
+// libtorrent has a plugin interface for implementing extensions to the protocol.
+// These can be general extensions for transferring metadata or peer exchange
+// extensions, or it could be used to provide a way to customize the protocol
+// to fit a particular (closed) network.
+//
+// In short, the plugin interface makes it possible to:
+//
+// * register extension messages (sent in the extension handshake), see
+// extensions_.
+// * add data and parse data from the extension handshake.
+// * send extension messages and standard bittorrent messages.
+// * override or block the handling of standard bittorrent messages.
+// * save and restore state via the session state
+// * see all alerts that are posted
+//
+// .. _extensions: extension_protocol.html
+//
+// a word of caution
+// -----------------
+//
+// Writing your own plugin is a very easy way to introduce serious bugs such as
+// dead locks and race conditions. Since a plugin has access to internal
+// structures it is also quite easy to sabotage libtorrent's operation.
+//
+// All the callbacks in this interface are called with the main libtorrent thread
+// mutex locked. And they are always called from the libtorrent network thread. In
+// case portions of your plugin are called from other threads, typically the main
+// thread, you cannot use any of the member functions on the internal structures
+// in libtorrent, since those require the mutex to be locked. Futhermore, you would
+// also need to have a mutex on your own shared data within the plugin, to make
+// sure it is not accessed at the same time from the libtorrent thread (through a
+// callback). See `boost thread's mutex`_. If you need to send out a message from
+// another thread, it is advised to use an internal queue, and do the actual
+// sending in ``tick()``.
+//
+// Since the plugin interface gives you easy access to internal structures, it
+// is not supported as a stable API. Plugins should be considered spcific to a
+// specific version of libtorrent. Although, in practice the internals mostly
+// don't change that dramatically.
+//
+// .. _`boost thread's mutex`: http://www.boost.org/doc/html/mutex.html
+//
+//
+// plugin-interface
+// ================
+//
+// The plugin interface consists of three base classes that the plugin may
+// implement. These are called ``plugin``, ``torrent_plugin`` and ``peer_plugin``.
+// They are found in the ```` header.
+//
+// These plugins are instantiated for each session, torrent and possibly each peer,
+// respectively.
+//
+// For plugins that only need per torrent state, it is enough to only implement
+// ``torrent_plugin`` and pass a constructor function or function object to
+// ``session::add_extension()`` or ``torrent_handle::add_extension()`` (if the
+// torrent has already been started and you want to hook in the extension at
+// run-time).
+//
+// The signature of the function is::
+//
+// boost::shared_ptr (*)(torrent*, void*);
+//
+// The first argument is the internal torrent object, the second argument
+// is the userdata passed to ``session::add_torrent()`` or
+// ``torrent_handle::add_extension()``.
+//
+// The function should return a ``boost::shared_ptr`` which
+// may or may not be 0. If it is a null pointer, the extension is simply ignored
+// for this torrent. If it is a valid pointer (to a class inheriting
+// ``torrent_plugin``), it will be associated with this torrent and callbacks
+// will be made on torrent events.
+//
+// For more elaborate plugins which require session wide state, you would
+// implement ``plugin``, construct an object (in a ``boost::shared_ptr``) and pass
+// it in to ``session::add_extension()``.
+//
+// custom alerts
+// =============
+//
+// Since plugins are running within internal libtorrent threads, one convenient
+// way to communicate with the client is to post custom alerts.
+//
+// The expected interface of any alert, apart from deriving from the alert
+// base class, looks like this:
+//
+// .. parsed-literal::
+//
+// const static int alert_type = **;
+// virtual int type() const { return alert_type; }
+//
+// virtual std::string message() const;
+//
+// virtual std::auto_ptr clone() const
+// { return std::auto_ptr(new name(\*this)); }
+//
+// const static int static_category = **;
+// virtual int category() const { return static_category; }
+//
+// virtual char const* what() const { return **; }
+//
+// The ``alert_type`` is used for the type-checking in ``alert_cast``. It must
+// not collide with any other alert. The built-in alerts in libtorrent will
+// not use alert type IDs greater than ``user_alert_id``. When defining your
+// own alert, make sure it's greater than this constant.
+//
+// ``type()`` is the run-time equivalence of the ``alert_type``.
+//
+// The ``message()`` virtual function is expected to construct a useful
+// string representation of the alert and the event or data it represents.
+// Something convenient to put in a log file for instance.
+//
+// ``clone()`` is used internally to copy alerts. The suggested implementation
+// of simply allocating a new instance as a copy of ``*this`` is all that's
+// expected.
+//
+// The static category is required for checking wether or not the category
+// for a specific alert is enabled or not, without instantiating the alert.
+// The ``category`` virtual function is the run-time equivalence.
+//
+// The ``what()`` virtual function may simply be a string literal of the class
+// name of your alert.
+//
+// For more information, see the `alert section`_.
+//
+// .. _`alert section`: reference-Alerts.html
+
+
#ifndef TORRENT_DISABLE_EXTENSIONS
#ifdef _MSC_VER
@@ -67,6 +197,9 @@ namespace libtorrent
struct torrent_plugin;
class torrent;
+ // this is the base class for a session plugin. One primary feature
+ // is that it is notified of all torrents that are added to the session,
+ // and can add its own torrent_plugins.
struct TORRENT_EXPORT plugin
{
// hidden
@@ -109,28 +242,54 @@ namespace libtorrent
// hidden
virtual ~torrent_plugin() {}
- // throwing an exception closes the connection
- // returning a 0 pointer is valid and will not add
- // the peer_plugin to the peer_connection
+ // This function is called each time a new peer is connected to the torrent. You
+ // may choose to ignore this by just returning a default constructed
+ // ``shared_ptr`` (in which case you don't need to override this member
+ // function).
+ //
+ // If you need an extension to the peer connection (which most plugins do) you
+ // are supposed to return an instance of your ``peer_plugin`` class. Which in
+ // turn will have its hook functions called on event specific to that peer.
+ //
+ // The ``peer_connection`` will be valid as long as the ``shared_ptr`` is being
+ // held by the torrent object. So, it is generally a good idea to not keep a
+ // ``shared_ptr`` to your own peer_plugin. If you want to keep references to it,
+ // use ``weak_ptr``.
+ //
+ // If this function throws an exception, the connection will be closed.
virtual boost::shared_ptr new_connection(peer_connection*)
{ return boost::shared_ptr(); }
- // called when a piece passes or fails the hash check.
- // the argument is the piece index.
+ // These hooks are called when a piece passes the hash check or fails the hash
+ // check, respectively. The ``index`` is the piece index that was downloaded.
+ // It is possible to access the list of peers that participated in sending the
+ // piece through the ``torrent`` and the ``piece_picker``.
virtual void on_piece_pass(int /*index*/) {}
virtual void on_piece_failed(int /*index*/) {}
- // called aproximately once every second
+ // This hook is called approximately once per second. It is a way of making it
+ // easy for plugins to do timed events, for sending messages or whatever.
virtual void tick() {}
- // if true is returned, it means the handler handled the event,
- // and no other plugins will have their handlers called, and the
- // default behavior will be skipped
+ // These hooks are called when the torrent is paused and unpaused respectively.
+ // The return value indicates if the event was handled. A return value of
+ // ``true`` indicates that it was handled, and no other plugin after this one
+ // will have this hook function called, and the standard handler will also not be
+ // invoked. So, returning true effectively overrides the standard behavior of
+ // pause or unpause.
+ //
+ // Note that if you call ``pause()`` or ``resume()`` on the torrent from your
+ // handler it will recurse back into your handler, so in order to invoke the
+ // standard handler, you have to keep your own state on whether you want standard
+ // behavior or overridden behavior.
virtual bool on_pause() { return false; }
virtual bool on_resume() { return false; }
- // this is called when the initial checking of
- // files is completed.
+ // This function is called when the initial files of the torrent have been
+ // checked. If there are no files to check, this function is called immediately.
+ //
+ // i.e. This function is always called when the torrent is in a state where it
+ // can start downloading.
virtual void on_files_checked() {}
// called when the torrent changes state
@@ -138,10 +297,6 @@ namespace libtorrent
// enum members
virtual void on_state(int /*s*/) {}
- // called every time policy::add_peer is called
- // src is a bitmask of which sources this peer
- // has been seen from. flags is a bitmask of:
-
enum flags_t {
// this is the first time we see this peer
first_time = 1,
@@ -214,7 +369,8 @@ namespace libtorrent
virtual bool on_have_none() { return false; }
virtual bool on_allowed_fast(int /*index*/) { return false; }
virtual bool on_request(peer_request const&) { return false; }
- virtual bool on_piece(peer_request const& /*piece*/, disk_buffer_holder& /*data*/) { return false; }
+ virtual bool on_piece(peer_request const& /*piece*/
+ , disk_buffer_holder& /*data*/) { return false; }
virtual bool on_cancel(peer_request const&) { return false; }
virtual bool on_reject(peer_request const&) { return false; }
virtual bool on_suggest(int /*index*/) { return false; }
| ||