forked from premiere/premiere-libtorrent
fix warnings, some clean-up and todo comments
This commit is contained in:
parent
4fd230dbe5
commit
4d15f1410f
37
ChangeLog
37
ChangeLog
|
@ -2,8 +2,8 @@
|
|||
* deprecated RSS API
|
||||
* experimental support for BEP 38, "mutable torrents"
|
||||
* replaced lazy_bdecode with a new bdecoder that's a lot more efficient
|
||||
* deprecate time functions, expose typedefs of boost::chrono in the libtorrent
|
||||
namespace instead
|
||||
* deprecate time functions, expose typedefs of boost::chrono in the
|
||||
libtorrent namespace instead
|
||||
* deprecate file_base feature in file_storage/torrent_info
|
||||
* improve piece picker support for reverse picking (used for snubbed peers)
|
||||
to not cause priority inversion for regular peers
|
||||
|
@ -28,32 +28,43 @@
|
|||
* support SSL over uTP connections
|
||||
* support web seeds that resolve to multiple IPs
|
||||
* added auto-sequential feature. download well-seeded torrents in-order
|
||||
* removed built-in GeoIP support (this functionality is orthogonal to libtorrent)
|
||||
* removed built-in GeoIP support (this functionality is orthogonal to
|
||||
libtorrent)
|
||||
* deprecate proxy settings in favor of regular settings
|
||||
* deprecate separate settings for peer protocol encryption
|
||||
* support specifying listen interfaces and outgoing interfaces as device
|
||||
names (eth0, en2, tun0 etc.)
|
||||
* support for using purgrable memory as disk cache on Mac OS.
|
||||
* be more aggressive in corking sockets, to coalesce messages into larger packets.
|
||||
* be more aggressive in corking sockets, to coalesce messages into larger
|
||||
packets.
|
||||
* pre-emptively unchoke peers to save one round-trip at connection start-up.
|
||||
* add session constructor overload that takes a settings_pack
|
||||
* torrent_info is no longer an intrusive_ptr type. It is held by shared_ptr. This is a non-backwards compatible change
|
||||
* torrent_info is no longer an intrusive_ptr type. It is held by shared_ptr.
|
||||
This is a non-backwards compatible change
|
||||
* move listen interface and port to the settings
|
||||
* move use_interfaces() to be a setting
|
||||
* extend storage interface to allow deferred flushing and flush the part-file metadata periodically
|
||||
* extend storage interface to allow deferred flushing and flush the part-file
|
||||
metadata periodically
|
||||
* make statistics propagate instantly rather than on the second tick
|
||||
* support for partfiles, where partial pieces belonging to skipped files are put
|
||||
* support using multiple threads for socket operations (especially useful for high performance SSL connections)
|
||||
* allow setting rate limits for arbitrary peer groups. Generalizes per-torrent rate limits, and local peer limits
|
||||
* support for partfiles, where partial pieces belonging to skipped files are
|
||||
put
|
||||
* support using multiple threads for socket operations (especially useful for
|
||||
high performance SSL connections)
|
||||
* allow setting rate limits for arbitrary peer groups. Generalizes
|
||||
per-torrent rate limits, and local peer limits
|
||||
* improved disk cache complexity O(1) instead of O(log(n))
|
||||
* add feature to allow storing disk cache blocks in an mmapped file (presumably on an SSD)
|
||||
* optimize peer connection distribution logic across torrents to scale better with many torrents
|
||||
* replaced std::map with boost::unordered_map for torrent list, to scale better with many torrents
|
||||
* add feature to allow storing disk cache blocks in an mmapped file
|
||||
(presumably on an SSD)
|
||||
* optimize peer connection distribution logic across torrents to scale
|
||||
better with many torrents
|
||||
* replaced std::map with boost::unordered_map for torrent list, to scale
|
||||
better with many torrents
|
||||
* optimized piece picker
|
||||
* optimized disk cache
|
||||
* optimized .torrent file parsing
|
||||
* optimized initialization of storage when adding a torrent
|
||||
* added support for adding torrents asynchronously (for improved startup performance)
|
||||
* added support for adding torrents asynchronously (for improved startup
|
||||
performance)
|
||||
* added support for asynchronous disk I/O
|
||||
* almost completely changed the storage interface (for custom storage)
|
||||
* added support for hashing pieces in multiple threads
|
||||
|
|
4
Jamfile
4
Jamfile
|
@ -240,7 +240,11 @@ rule warnings ( properties * )
|
|||
result += <cflags>-Wno-exit-time-destructors ;
|
||||
result += <cflags>-Wno-documentation-unknown-command ;
|
||||
result += <cflags>-Wno-disabled-macro-expansion ;
|
||||
|
||||
# enable these warnings again, once the other ones are dealt with
|
||||
result += <cflags>-Wno-weak-vtables ;
|
||||
result += <cflags>-Wno-sign-compare ;
|
||||
result += <cflags>-Wno-sign-conversion ;
|
||||
}
|
||||
|
||||
if <toolset>gcc in $(properties)
|
||||
|
|
|
@ -97,6 +97,8 @@ namespace libtorrent
|
|||
static char const* job_names[7];
|
||||
};
|
||||
|
||||
// TODO: 3 this is defined in disk_io_thread.cpp. The implementation should
|
||||
// be moved out to a separate file and declared in its header
|
||||
char const* job_name(int j);
|
||||
|
||||
void print_piece_log(std::vector<piece_log_t> const& piece_log);
|
||||
|
|
|
@ -554,6 +554,7 @@ namespace libtorrent
|
|||
storage_error(error_code e): ec(e), file(-1), operation(0) {}
|
||||
|
||||
operator bool() const { return ec.value() != 0; }
|
||||
|
||||
// the error that occurred
|
||||
error_code ec;
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ namespace libtorrent
|
|||
{
|
||||
std::memcpy(reinterpret_cast<void*>(start), str.c_str(), str.size());
|
||||
start += str.size();
|
||||
return str.size();
|
||||
return int(str.size());
|
||||
}
|
||||
|
||||
template <class OutIt>
|
||||
|
|
|
@ -102,6 +102,8 @@ struct key_desc_t
|
|||
bool TORRENT_EXTRA_EXPORT verify_message(bdecode_node const& msg, key_desc_t const desc[]
|
||||
, bdecode_node ret[], int size , char* error, int error_size);
|
||||
|
||||
void incoming_error(entry& e, char const* msg, int error_code = 203);
|
||||
|
||||
// this is the entry for every peer
|
||||
// the timestamp is there to make it possible
|
||||
// to remove stale peers
|
||||
|
|
|
@ -50,7 +50,7 @@ struct sliding_average
|
|||
{
|
||||
// fixed point
|
||||
s *= 64;
|
||||
int deviation;
|
||||
int deviation = 0;
|
||||
|
||||
if (m_num_samples > 0)
|
||||
deviation = std::abs(m_mean - s);
|
||||
|
|
|
@ -315,7 +315,8 @@ namespace libtorrent
|
|||
>::value
|
||||
};
|
||||
|
||||
boost::int64_t m_data[(storage_size + sizeof(boost::int64_t) - 1) / sizeof(boost::int64_t)];
|
||||
boost::int64_t m_data[(storage_size + sizeof(boost::int64_t) - 1)
|
||||
/ sizeof(boost::int64_t)];
|
||||
};
|
||||
|
||||
// returns true if this socket is an SSL socket
|
||||
|
|
|
@ -456,8 +456,6 @@ namespace libtorrent
|
|||
// this is used to open the file, but also passed along as the
|
||||
// flags argument to the file operation (readv or writev)
|
||||
int mode;
|
||||
// used for error reporting
|
||||
int operation_type;
|
||||
};
|
||||
|
||||
void delete_one_file(std::string const& p, error_code& ec);
|
||||
|
|
|
@ -3260,6 +3260,7 @@ namespace libtorrent
|
|||
std::copy(recv_buffer.begin + 8, recv_buffer.begin + 28
|
||||
, (char*)info_hash.begin());
|
||||
|
||||
// TODO: 3 remove the allow_encrypted parameter
|
||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
||||
bool allow_encrypted = m_encrypted && m_rc4_encrypted;
|
||||
#else
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace libtorrent
|
|||
|
||||
class alert;
|
||||
|
||||
namespace detail
|
||||
namespace
|
||||
{
|
||||
inline bool default_pred(std::string const&) { return true; }
|
||||
|
||||
|
@ -157,50 +157,6 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
}
|
||||
} // detail namespace
|
||||
|
||||
#if TORRENT_USE_WSTRING
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
|
||||
void add_files(file_storage& fs, std::wstring const& wfile
|
||||
, boost::function<bool(std::string)> p, boost::uint32_t flags)
|
||||
{
|
||||
std::string utf8;
|
||||
wchar_utf8(wfile, utf8);
|
||||
detail::add_files_impl(fs, parent_path(complete(utf8))
|
||||
, filename(utf8), p, flags);
|
||||
}
|
||||
|
||||
void add_files(file_storage& fs
|
||||
, std::wstring const& wfile, boost::uint32_t flags)
|
||||
{
|
||||
std::string utf8;
|
||||
wchar_utf8(wfile, utf8);
|
||||
detail::add_files_impl(fs, parent_path(complete(utf8))
|
||||
, filename(utf8), detail::default_pred, flags);
|
||||
}
|
||||
|
||||
void set_piece_hashes(create_torrent& t, std::wstring const& p
|
||||
, boost::function<void(int)> f, error_code& ec)
|
||||
{
|
||||
std::string utf8;
|
||||
wchar_utf8(p, utf8);
|
||||
set_piece_hashes(t, utf8, f, ec);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void add_files(file_storage& fs, std::string const& file
|
||||
, boost::function<bool(std::string)> p, boost::uint32_t flags)
|
||||
{
|
||||
detail::add_files_impl(fs, parent_path(complete(file)), filename(file), p, flags);
|
||||
}
|
||||
|
||||
void add_files(file_storage& fs, std::string const& file, boost::uint32_t flags)
|
||||
{
|
||||
detail::add_files_impl(fs, parent_path(complete(file)), filename(file)
|
||||
, detail::default_pred, flags);
|
||||
}
|
||||
|
||||
void on_hash(disk_io_job const* j, create_torrent* t
|
||||
, boost::shared_ptr<piece_manager> storage, disk_io_thread* iothread
|
||||
|
@ -219,7 +175,8 @@ namespace libtorrent
|
|||
++(*completed_piece);
|
||||
if (*piece_counter < t->num_pieces())
|
||||
{
|
||||
iothread->async_hash(storage.get(), *piece_counter, disk_io_job::sequential_access
|
||||
iothread->async_hash(storage.get(), *piece_counter
|
||||
, disk_io_job::sequential_access
|
||||
, boost::bind(&on_hash, _1, t, storage, iothread
|
||||
, piece_counter, completed_piece, f, ec), (void*)0);
|
||||
++(*piece_counter);
|
||||
|
@ -231,6 +188,51 @@ namespace libtorrent
|
|||
iothread->submit_jobs();
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
#if TORRENT_USE_WSTRING
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
|
||||
void add_files(file_storage& fs, std::wstring const& wfile
|
||||
, boost::function<bool(std::string)> p, boost::uint32_t flags)
|
||||
{
|
||||
std::string utf8;
|
||||
wchar_utf8(wfile, utf8);
|
||||
add_files_impl(fs, parent_path(complete(utf8))
|
||||
, filename(utf8), p, flags);
|
||||
}
|
||||
|
||||
void add_files(file_storage& fs
|
||||
, std::wstring const& wfile, boost::uint32_t flags)
|
||||
{
|
||||
std::string utf8;
|
||||
wchar_utf8(wfile, utf8);
|
||||
add_files_impl(fs, parent_path(complete(utf8))
|
||||
, filename(utf8), default_pred, flags);
|
||||
}
|
||||
|
||||
void set_piece_hashes(create_torrent& t, std::wstring const& p
|
||||
, boost::function<void(int)> f, error_code& ec)
|
||||
{
|
||||
std::string utf8;
|
||||
wchar_utf8(p, utf8);
|
||||
set_piece_hashes(t, utf8, f, ec);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void add_files(file_storage& fs, std::string const& file
|
||||
, boost::function<bool(std::string)> p, boost::uint32_t flags)
|
||||
{
|
||||
add_files_impl(fs, parent_path(complete(file)), filename(file), p, flags);
|
||||
}
|
||||
|
||||
void add_files(file_storage& fs, std::string const& file, boost::uint32_t flags)
|
||||
{
|
||||
add_files_impl(fs, parent_path(complete(file)), filename(file)
|
||||
, default_pred, flags);
|
||||
}
|
||||
|
||||
void set_piece_hashes(create_torrent& t, std::string const& p
|
||||
, boost::function<void(int)> const& f, error_code& ec)
|
||||
{
|
||||
|
|
|
@ -71,8 +71,10 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
|
||||
char const* job_name(int j);
|
||||
|
||||
// TODO: 3 decleare this function in the header file, for block_cache.cpp
|
||||
void assert_print_piece(cached_piece_entry const* pe)
|
||||
{
|
||||
static const char* const cache_state[] =
|
||||
|
@ -977,7 +979,8 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
void disk_io_thread::flush_expired_write_blocks(tailqueue& completed_jobs, mutex::scoped_lock& l)
|
||||
void disk_io_thread::flush_expired_write_blocks(tailqueue& completed_jobs
|
||||
, mutex::scoped_lock& l)
|
||||
{
|
||||
DLOG("flush_expired_write_blocks\n");
|
||||
|
||||
|
@ -1024,10 +1027,12 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
typedef int (disk_io_thread::*disk_io_fun_t)(disk_io_job* j, tailqueue& completed_jobs);
|
||||
|
||||
// this is a jump-table for disk I/O jobs
|
||||
static const disk_io_fun_t job_functions[] =
|
||||
const disk_io_fun_t job_functions[] =
|
||||
{
|
||||
&disk_io_thread::do_read,
|
||||
&disk_io_thread::do_write,
|
||||
|
@ -1077,6 +1082,8 @@ namespace libtorrent
|
|||
"tick_storage",
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
#if TORRENT_USE_ASSERTS || DEBUG_DISK_THREAD
|
||||
char const* job_name(int j)
|
||||
{
|
||||
|
@ -1384,14 +1391,16 @@ namespace libtorrent
|
|||
return j->d.io.buffer_size;
|
||||
}
|
||||
|
||||
void disk_io_thread::maybe_issue_queued_read_jobs(cached_piece_entry* pe, tailqueue& completed_jobs)
|
||||
void disk_io_thread::maybe_issue_queued_read_jobs(cached_piece_entry* pe
|
||||
, tailqueue& completed_jobs)
|
||||
{
|
||||
TORRENT_PIECE_ASSERT(pe->outstanding_read == 1, pe);
|
||||
|
||||
// if we're shutting down, just cancel the jobs
|
||||
if (m_num_threads == 0)
|
||||
{
|
||||
fail_jobs_impl(storage_error(boost::asio::error::operation_aborted), pe->read_jobs, completed_jobs);
|
||||
fail_jobs_impl(storage_error(boost::asio::error::operation_aborted)
|
||||
, pe->read_jobs, completed_jobs);
|
||||
TORRENT_PIECE_ASSERT(pe->read_jobs.size() == 0, pe);
|
||||
pe->outstanding_read = 0;
|
||||
#if TORRENT_USE_ASSERTS
|
||||
|
@ -1548,7 +1557,8 @@ namespace libtorrent
|
|||
// flushes the piece to disk in case
|
||||
// it satisfies the condition for a write
|
||||
// piece to be flushed
|
||||
try_flush_hashed(pe, m_settings.get_int(settings_pack::write_cache_line_size), completed_jobs, l);
|
||||
try_flush_hashed(pe, m_settings.get_int(
|
||||
settings_pack::write_cache_line_size), completed_jobs, l);
|
||||
|
||||
--pe->piece_refcount;
|
||||
m_disk_cache.maybe_free_piece(pe);
|
||||
|
@ -1900,7 +1910,8 @@ namespace libtorrent
|
|||
j->callback = handler;
|
||||
add_fence_job(storage, j);
|
||||
|
||||
fail_jobs_impl(storage_error(boost::asio::error::operation_aborted), to_abort, completed_jobs);
|
||||
fail_jobs_impl(storage_error(boost::asio::error::operation_aborted)
|
||||
, to_abort, completed_jobs);
|
||||
|
||||
if (completed_jobs.size())
|
||||
add_completed_jobs(completed_jobs);
|
||||
|
@ -1990,7 +2001,8 @@ namespace libtorrent
|
|||
add_fence_job(storage, j);
|
||||
|
||||
tailqueue completed_jobs;
|
||||
fail_jobs_impl(storage_error(boost::asio::error::operation_aborted), to_abort, completed_jobs);
|
||||
fail_jobs_impl(storage_error(boost::asio::error::operation_aborted)
|
||||
, to_abort, completed_jobs);
|
||||
if (completed_jobs.size())
|
||||
add_completed_jobs(completed_jobs);
|
||||
}
|
||||
|
@ -2314,7 +2326,7 @@ namespace libtorrent
|
|||
return ret >= 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
int disk_io_thread::do_hash(disk_io_job* j, tailqueue& completed_jobs)
|
||||
int disk_io_thread::do_hash(disk_io_job* j, tailqueue& /* completed_jobs */ )
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -2562,7 +2574,7 @@ namespace libtorrent
|
|||
return ret < 0 ? ret : 0;
|
||||
}
|
||||
|
||||
int disk_io_thread::do_move_storage(disk_io_job* j, tailqueue& completed_jobs)
|
||||
int disk_io_thread::do_move_storage(disk_io_job* j, tailqueue& /* completed_jobs */ )
|
||||
{
|
||||
// if this assert fails, something's wrong with the fence logic
|
||||
TORRENT_ASSERT(j->storage->num_outstanding_jobs() == 1);
|
||||
|
@ -2599,14 +2611,15 @@ namespace libtorrent
|
|||
m_disk_cache.mark_deleted(*j->storage->files());
|
||||
#endif
|
||||
|
||||
flush_cache(j->storage.get(), flush_delete_cache | flush_expect_clear, completed_jobs, l);
|
||||
flush_cache(j->storage.get(), flush_delete_cache | flush_expect_clear
|
||||
, completed_jobs, l);
|
||||
l.unlock();
|
||||
|
||||
j->storage->get_storage_impl()->delete_files(j->error);
|
||||
return j->error ? -1 : 0;
|
||||
}
|
||||
|
||||
int disk_io_thread::do_check_fastresume(disk_io_job* j, tailqueue& completed_jobs)
|
||||
int disk_io_thread::do_check_fastresume(disk_io_job* j, tailqueue& /* completed_jobs */ )
|
||||
{
|
||||
// if this assert fails, something's wrong with the fence logic
|
||||
TORRENT_ASSERT(j->storage->num_outstanding_jobs() == 1);
|
||||
|
@ -2635,7 +2648,7 @@ namespace libtorrent
|
|||
return j->error ? -1 : 0;
|
||||
}
|
||||
|
||||
int disk_io_thread::do_rename_file(disk_io_job* j, tailqueue& completed_jobs)
|
||||
int disk_io_thread::do_rename_file(disk_io_job* j, tailqueue& /* completed_jobs */ )
|
||||
{
|
||||
// if this assert fails, something's wrong with the fence logic
|
||||
TORRENT_ASSERT(j->storage->num_outstanding_jobs() == 1);
|
||||
|
@ -2653,7 +2666,8 @@ namespace libtorrent
|
|||
// issue write commands for all dirty blocks
|
||||
// and clear all read jobs
|
||||
mutex::scoped_lock l(m_cache_mutex);
|
||||
flush_cache(j->storage.get(), flush_read_cache | flush_write_cache, completed_jobs, l);
|
||||
flush_cache(j->storage.get(), flush_read_cache | flush_write_cache
|
||||
, completed_jobs, l);
|
||||
l.unlock();
|
||||
|
||||
m_disk_cache.release_memory();
|
||||
|
@ -2662,7 +2676,7 @@ namespace libtorrent
|
|||
return j->error ? -1 : 0;
|
||||
}
|
||||
|
||||
int disk_io_thread::do_cache_piece(disk_io_job* j, tailqueue& completed_jobs)
|
||||
int disk_io_thread::do_cache_piece(disk_io_job* j, tailqueue& /* completed_jobs */ )
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_ASSERT(j->buffer == 0);
|
||||
|
@ -2693,7 +2707,8 @@ namespace libtorrent
|
|||
#if TORRENT_USE_ASSERTS
|
||||
pe->piece_log.push_back(piece_log_t(j->action));
|
||||
#endif
|
||||
TORRENT_PIECE_ASSERT(pe->cache_state <= cached_piece_entry::read_lru1 || pe->cache_state == cached_piece_entry::read_lru2, pe);
|
||||
TORRENT_PIECE_ASSERT(pe->cache_state <= cached_piece_entry::read_lru1
|
||||
|| pe->cache_state == cached_piece_entry::read_lru2, pe);
|
||||
++pe->piece_refcount;
|
||||
|
||||
int block_size = m_disk_cache.block_size();
|
||||
|
@ -2763,7 +2778,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
int disk_io_thread::do_finalize_file(disk_io_job* j, tailqueue& completed_jobs)
|
||||
int disk_io_thread::do_finalize_file(disk_io_job* j, tailqueue& /* completed_jobs */)
|
||||
{
|
||||
j->storage->get_storage_impl()->finalize_file(j->piece, j->error);
|
||||
return j->error ? -1 : 0;
|
||||
|
@ -2918,7 +2933,8 @@ namespace libtorrent
|
|||
#if TORRENT_USE_ASSERTS
|
||||
pe->piece_log.push_back(piece_log_t(j->action));
|
||||
#endif
|
||||
try_flush_hashed(pe, m_settings.get_int(settings_pack::write_cache_line_size), completed_jobs, l);
|
||||
try_flush_hashed(pe, m_settings.get_int(
|
||||
settings_pack::write_cache_line_size), completed_jobs, l);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2965,7 +2981,8 @@ namespace libtorrent
|
|||
// it satisfies the condition for a write
|
||||
// piece to be flushed
|
||||
// #error if hash checks are disabled, always just flush
|
||||
try_flush_hashed(pe, m_settings.get_int(settings_pack::write_cache_line_size), completed_jobs, l);
|
||||
try_flush_hashed(pe, m_settings.get_int(
|
||||
settings_pack::write_cache_line_size), completed_jobs, l);
|
||||
|
||||
TORRENT_ASSERT(l.locked());
|
||||
|
||||
|
@ -2985,13 +3002,13 @@ namespace libtorrent
|
|||
return 0;
|
||||
}
|
||||
|
||||
int disk_io_thread::do_trim_cache(disk_io_job* j, tailqueue& completed_jobs)
|
||||
int disk_io_thread::do_trim_cache(disk_io_job*, tailqueue& /* completed_jobs */)
|
||||
{
|
||||
//#error implement
|
||||
return 0;
|
||||
}
|
||||
|
||||
int disk_io_thread::do_file_priority(disk_io_job* j, tailqueue& completed_jobs)
|
||||
int disk_io_thread::do_file_priority(disk_io_job* j, tailqueue& /* completed_jobs */ )
|
||||
{
|
||||
std::vector<boost::uint8_t>* p = reinterpret_cast<std::vector<boost::uint8_t>*>(j->buffer);
|
||||
j->storage->get_storage_impl()->set_file_priority(*p, j->error);
|
||||
|
@ -2999,7 +3016,7 @@ namespace libtorrent
|
|||
return 0;
|
||||
}
|
||||
|
||||
int disk_io_thread::do_load_torrent(disk_io_job* j, tailqueue& completed_jobs)
|
||||
int disk_io_thread::do_load_torrent(disk_io_job* j, tailqueue& /* completed_jobs */ )
|
||||
{
|
||||
add_torrent_params* params = (add_torrent_params*)j->requester;
|
||||
|
||||
|
@ -3048,7 +3065,8 @@ namespace libtorrent
|
|||
tailqueue jobs;
|
||||
if (m_disk_cache.evict_piece(pe, jobs))
|
||||
{
|
||||
fail_jobs_impl(storage_error(boost::asio::error::operation_aborted), jobs, completed_jobs);
|
||||
fail_jobs_impl(storage_error(boost::asio::error::operation_aborted)
|
||||
, jobs, completed_jobs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3061,7 +3079,7 @@ namespace libtorrent
|
|||
return retry_job;
|
||||
}
|
||||
|
||||
int disk_io_thread::do_tick(disk_io_job* j, tailqueue& completed_jobs)
|
||||
int disk_io_thread::do_tick(disk_io_job* j, tailqueue& /* completed_jobs */ )
|
||||
{
|
||||
// true means this storage wants more ticks, false
|
||||
// disables ticking (until it's enabled again)
|
||||
|
|
|
@ -116,6 +116,8 @@ namespace libtorrent { namespace dht
|
|||
TORRENT_DEFINE_LOG(dht_tracker)
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
node_id extract_node_id(bdecode_node e)
|
||||
{
|
||||
if (!e || e.type() != bdecode_node::dict_t) return (node_id::min)();
|
||||
|
@ -133,6 +135,8 @@ namespace libtorrent { namespace dht
|
|||
return node_id(node_id(nid->string().c_str()));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// class that puts the networking and the kademlia node in a single
|
||||
// unit and connecting them together.
|
||||
dht_tracker::dht_tracker(libtorrent::aux::session_impl& ses
|
||||
|
@ -268,6 +272,8 @@ namespace libtorrent { namespace dht
|
|||
m_dht.announce(ih, listen_port, flags, f);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// these functions provide a slightly higher level
|
||||
// interface to the get/put functionality in the DHT
|
||||
bool get_immutable_item_callback(item& it, boost::function<void(item const&)> f)
|
||||
|
@ -305,6 +311,8 @@ namespace libtorrent { namespace dht
|
|||
return true;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void dht_tracker::get_item(sha1_hash const& target
|
||||
, boost::function<void(item const&)> cb)
|
||||
{
|
||||
|
@ -423,6 +431,8 @@ namespace libtorrent { namespace dht
|
|||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void add_node_fun(void* userdata, node_entry const& e)
|
||||
{
|
||||
entry* n = (entry*)userdata;
|
||||
|
@ -432,6 +442,8 @@ namespace libtorrent { namespace dht
|
|||
n->list().push_back(entry(node));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
entry dht_tracker::state() const
|
||||
{
|
||||
entry ret(entry::dictionary_t);
|
||||
|
|
|
@ -82,12 +82,16 @@ void find_data_observer::reply(msg const& m)
|
|||
done();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void add_entry_fun(void* userdata, node_entry const& e)
|
||||
{
|
||||
traversal_algorithm* f = (traversal_algorithm*)userdata;
|
||||
f->add_entry(e.id, e.ep(), observer::flag_initial);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
find_data::find_data(
|
||||
node_impl& node
|
||||
, node_id target
|
||||
|
|
|
@ -64,8 +64,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
namespace libtorrent { namespace dht
|
||||
{
|
||||
|
||||
void incoming_error(entry& e, char const* msg, int error_code = 203);
|
||||
|
||||
using detail::write_endpoint;
|
||||
|
||||
// TODO: 2 make this configurable in dht_settings
|
||||
|
@ -75,6 +73,8 @@ enum { announce_interval = 30 };
|
|||
TORRENT_DEFINE_LOG(node)
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
// remove peers that have timed out
|
||||
void purge_peers(std::set<peer_entry>& peers)
|
||||
{
|
||||
|
@ -96,6 +96,8 @@ void purge_peers(std::set<peer_entry>& peers)
|
|||
|
||||
void nop() {}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
node_impl::node_impl(udp_socket_interface* sock
|
||||
, dht_settings const& settings, node_id nid, address const& external_address
|
||||
, dht_observer* observer
|
||||
|
@ -645,7 +647,7 @@ void node_impl::lookup_peers(sha1_hash const& info_hash, entry& reply
|
|||
return;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
namespace
|
||||
{
|
||||
void TORRENT_EXTRA_EXPORT write_nodes_entry(entry& r, nodes_t const& nodes)
|
||||
{
|
||||
|
@ -661,8 +663,6 @@ namespace detail
|
|||
}
|
||||
}
|
||||
|
||||
using detail::write_nodes_entry;
|
||||
|
||||
// verifies that a message has all the required
|
||||
// entries and returns them in ret
|
||||
bool verify_message(bdecode_node const& message, key_desc_t const desc[]
|
||||
|
|
|
@ -268,10 +268,8 @@ void rpc_manager::unreachable(udp::endpoint const& ep)
|
|||
}
|
||||
}
|
||||
|
||||
// defined in node.cpp
|
||||
void incoming_error(entry& e, char const* msg, int error_code = 203);
|
||||
|
||||
bool rpc_manager::incoming(msg const& m, node_id* id, libtorrent::dht_settings const& settings)
|
||||
bool rpc_manager::incoming(msg const& m, node_id* id
|
||||
, libtorrent::dht_settings const& settings)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
|
|
@ -1132,10 +1132,13 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
// single_peer is true if the entire piece was received by a single
|
||||
// peer
|
||||
bool peer_connection::received_invalid_data(int index, bool single_peer)
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_UNUSED(single_peer);
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
|
@ -1145,6 +1148,8 @@ namespace libtorrent
|
|||
(*i)->on_piece_failed(index);
|
||||
} TORRENT_CATCH(std::exception&) {}
|
||||
}
|
||||
#else
|
||||
TORRENT_UNUSED(index);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -444,6 +444,9 @@ namespace libtorrent
|
|||
int h = have[i];
|
||||
TORRENT_ASSERT(m_piece_map[i].have_peers.count(p) == h);
|
||||
}
|
||||
#else
|
||||
TORRENT_UNUSED(have);
|
||||
TORRENT_UNUSED(p);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1152,6 +1155,8 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(i->have_peers.count(peer) == 0);
|
||||
i->have_peers.insert(peer);
|
||||
}
|
||||
#else
|
||||
TORRENT_UNUSED(peer);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1178,6 +1183,8 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(i->have_peers.count(peer) == 1);
|
||||
i->have_peers.erase(peer);
|
||||
}
|
||||
#else
|
||||
TORRENT_UNUSED(peer);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -1189,6 +1196,8 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DEBUG_REFCOUNTS
|
||||
TORRENT_ASSERT(i->have_peers.count(peer) == 1);
|
||||
i->have_peers.erase(peer);
|
||||
#else
|
||||
TORRENT_UNUSED(peer);
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(i->peer_count > 0);
|
||||
|
@ -1212,6 +1221,8 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DEBUG_REFCOUNTS
|
||||
TORRENT_ASSERT(p.have_peers.count(peer) == 0);
|
||||
p.have_peers.insert(peer);
|
||||
#else
|
||||
TORRENT_UNUSED(peer);
|
||||
#endif
|
||||
|
||||
int prev_priority = p.priority(this);
|
||||
|
@ -1274,6 +1285,8 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DEBUG_REFCOUNTS
|
||||
TORRENT_ASSERT(p.have_peers.count(peer) == 1);
|
||||
p.have_peers.erase(peer);
|
||||
#else
|
||||
TORRENT_UNUSED(peer);
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(p.peer_count > 0);
|
||||
|
@ -1341,6 +1354,8 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DEBUG_REFCOUNTS
|
||||
TORRENT_ASSERT(p.have_peers.count(peer) == 0);
|
||||
p.have_peers.insert(peer);
|
||||
#else
|
||||
TORRENT_UNUSED(peer);
|
||||
#endif
|
||||
int new_priority = p.priority(this);
|
||||
if (prev_priority == new_priority) continue;
|
||||
|
@ -1361,6 +1376,8 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DEBUG_REFCOUNTS
|
||||
TORRENT_ASSERT(m_piece_map[index].have_peers.count(peer) == 0);
|
||||
m_piece_map[index].have_peers.insert(peer);
|
||||
#else
|
||||
TORRENT_UNUSED(peer);
|
||||
#endif
|
||||
|
||||
++m_piece_map[index].peer_count;
|
||||
|
@ -1444,6 +1461,8 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DEBUG_REFCOUNTS
|
||||
TORRENT_ASSERT(p.have_peers.count(peer) == 1);
|
||||
p.have_peers.erase(peer);
|
||||
#else
|
||||
TORRENT_UNUSED(peer);
|
||||
#endif
|
||||
TORRENT_ASSERT(p.peer_count > 0);
|
||||
--p.peer_count;
|
||||
|
@ -1474,6 +1493,8 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DEBUG_REFCOUNTS
|
||||
TORRENT_ASSERT(p.have_peers.count(peer) == 1);
|
||||
p.have_peers.erase(peer);
|
||||
#else
|
||||
TORRENT_UNUSED(peer);
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(p.peer_count > 0);
|
||||
|
@ -1591,8 +1612,10 @@ namespace libtorrent
|
|||
piece_pos& p = m_piece_map[index];
|
||||
|
||||
#ifdef TORRENT_PICKER_LOG
|
||||
std::cerr << "[" << this << "] " << "piece_picker::we_dont_have(" << index << ")" << std::endl;
|
||||
std::cerr << "[" << this << "] " << "piece_picker::we_dont_have("
|
||||
<< index << ")" << std::endl;
|
||||
#endif
|
||||
|
||||
if (!p.have())
|
||||
{
|
||||
// even though we don't have the piece, it
|
||||
|
@ -1653,7 +1676,8 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(index < (int)m_piece_map.size());
|
||||
|
||||
#ifdef TORRENT_PICKER_LOG
|
||||
std::cerr << "[" << this << "] " << "piece_picker::we_have(" << index << ")" << std::endl;
|
||||
std::cerr << "[" << this << "] " << "piece_picker::we_have("
|
||||
<< index << ")" << std::endl;
|
||||
#endif
|
||||
piece_pos& p = m_piece_map[index];
|
||||
int info_index = p.index;
|
||||
|
@ -1743,7 +1767,8 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
#ifdef TORRENT_PICKER_LOG
|
||||
std::cerr << "[" << this << "] " << "set_piece_priority(" << index << ", " << new_piece_priority << ")" << std::endl;
|
||||
std::cerr << "[" << this << "] " << "set_piece_priority(" << index
|
||||
<< ", " << new_piece_priority << ")" << std::endl;
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(new_piece_priority >= 0);
|
||||
|
|
|
@ -680,7 +680,7 @@ namespace libtorrent
|
|||
, sha1_hash const& info_hash
|
||||
, char const* name
|
||||
, std::string const& save_path
|
||||
, entry const& e
|
||||
, entry const& resume_data
|
||||
, storage_mode_t storage_mode
|
||||
, bool paused
|
||||
, storage_constructor_type sc
|
||||
|
@ -690,8 +690,14 @@ namespace libtorrent
|
|||
p.tracker_url = tracker_url;
|
||||
p.info_hash = info_hash;
|
||||
p.save_path = save_path;
|
||||
p.storage_mode = storage_mode;
|
||||
p.paused = paused;
|
||||
p.userdata = userdata;
|
||||
p.name = name;
|
||||
if (resume_data.type() != entry::undefined_t)
|
||||
{
|
||||
bencode(std::back_inserter(p.resume_data), resume_data);
|
||||
}
|
||||
return add_torrent(p);
|
||||
}
|
||||
#endif // TORRENT_NO_DEPRECATE
|
||||
|
@ -1062,7 +1068,7 @@ namespace libtorrent
|
|||
return ret;
|
||||
}
|
||||
|
||||
void session::set_max_half_open_connections(int limit) {}
|
||||
void session::set_max_half_open_connections(int) {}
|
||||
int session::max_half_open_connections() const { return 8; }
|
||||
|
||||
int session::max_uploads() const
|
||||
|
|
|
@ -658,21 +658,25 @@ namespace libtorrent
|
|||
else
|
||||
{
|
||||
file_status s;
|
||||
error_code ec;
|
||||
stat_file(fs.file_path(i, m_save_path), &s, ec);
|
||||
if (!ec)
|
||||
error_code error;
|
||||
stat_file(fs.file_path(i, m_save_path), &s, error);
|
||||
if (!error)
|
||||
{
|
||||
file_size = s.file_size;
|
||||
file_time = s.mtime;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ec == boost::system::errc::no_such_file_or_directory)
|
||||
if (error == error_code(boost::system::errc::no_such_file_or_directory
|
||||
, generic_category()))
|
||||
{
|
||||
m_stat_cache.set_noexist(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.ec = error;
|
||||
ec.file = i;
|
||||
ec.operation = storage_error::stat;
|
||||
m_stat_cache.set_error(i);
|
||||
}
|
||||
}
|
||||
|
@ -1386,7 +1390,7 @@ namespace libtorrent
|
|||
// -- zero_storage ------------------------------------------------------
|
||||
|
||||
int zero_storage::readv(file::iovec_t const* bufs, int num_bufs
|
||||
, int piece, int offset, int flags, storage_error& ec)
|
||||
, int /* piece */, int /* offset */, int /* flags */, storage_error&)
|
||||
{
|
||||
int ret = 0;
|
||||
for (int i = 0; i < num_bufs; ++i)
|
||||
|
@ -1398,7 +1402,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
int zero_storage::writev(file::iovec_t const* bufs, int num_bufs
|
||||
, int piece, int offset, int flags, storage_error& ec)
|
||||
, int /* piece */, int /* offset */, int /* flags */, storage_error& ec)
|
||||
{
|
||||
int ret = 0;
|
||||
for (int i = 0; i < num_bufs; ++i)
|
||||
|
@ -1406,7 +1410,7 @@ namespace libtorrent
|
|||
return 0;
|
||||
}
|
||||
|
||||
storage_interface* zero_storage_constructor(storage_params const& params)
|
||||
storage_interface* zero_storage_constructor(storage_params const&)
|
||||
{
|
||||
return new zero_storage;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,8 @@ using boost::tuples::make_tuple;
|
|||
|
||||
namespace libtorrent
|
||||
{
|
||||
namespace {
|
||||
|
||||
int root2(int x)
|
||||
{
|
||||
int ret = 0;
|
||||
|
@ -120,6 +122,8 @@ namespace libtorrent
|
|||
return ret;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
web_seed_t::web_seed_t(web_seed_entry const& wse)
|
||||
: web_seed_entry(wse)
|
||||
, retry(aux::time_now())
|
||||
|
@ -1167,6 +1171,9 @@ namespace libtorrent
|
|||
|
||||
void torrent::on_piece_fail_sync(disk_io_job const* j, piece_block b)
|
||||
{
|
||||
TORRENT_UNUSED(j);
|
||||
TORRENT_UNUSED(b);
|
||||
|
||||
update_gauge();
|
||||
// some peers that previously was no longer interesting may
|
||||
// now have become interesting, since we lack this one piece now.
|
||||
|
@ -2018,6 +2025,8 @@ namespace libtorrent
|
|||
|
||||
void torrent::dec_refcount(char const* purpose)
|
||||
{
|
||||
TORRENT_UNUSED(purpose);
|
||||
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
TORRENT_ASSERT(m_refcount > 0);
|
||||
--m_refcount;
|
||||
|
@ -2033,6 +2042,8 @@ namespace libtorrent
|
|||
|
||||
void torrent::inc_refcount(char const* purpose)
|
||||
{
|
||||
TORRENT_UNUSED(purpose);
|
||||
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
TORRENT_ASSERT(is_loaded());
|
||||
++m_refcount;
|
||||
|
@ -2578,8 +2589,6 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
void nop() {}
|
||||
|
||||
// This is only used for checking of torrents. i.e. force-recheck or initial checking
|
||||
// of existing files
|
||||
void torrent::on_piece_hashed(disk_io_job const* j)
|
||||
|
@ -5646,8 +5655,12 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool has_empty_url(announce_entry const& e) { return e.url.empty(); }
|
||||
|
||||
}
|
||||
|
||||
void torrent::replace_trackers(std::vector<announce_entry> const& urls)
|
||||
{
|
||||
m_trackers.clear();
|
||||
|
@ -7545,6 +7558,8 @@ namespace libtorrent
|
|||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool connecting_time_compare(peer_connection const* lhs, peer_connection const* rhs)
|
||||
{
|
||||
bool lhs_connecting = lhs->is_connecting() && !lhs->is_disconnecting();
|
||||
|
@ -7558,6 +7573,8 @@ namespace libtorrent
|
|||
return lhs->connected_time() > rhs->connected_time();
|
||||
}
|
||||
|
||||
} // anonymous namespaec
|
||||
|
||||
bool torrent::attach_peer(peer_connection* p)
|
||||
{
|
||||
// INVARIANT_CHECK;
|
||||
|
@ -7926,6 +7943,8 @@ namespace libtorrent
|
|||
update_want_tick();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// this returns true if lhs is a better disconnect candidate than rhs
|
||||
bool compare_disconnect_peer(peer_connection const* lhs, peer_connection const* rhs)
|
||||
{
|
||||
|
@ -7965,6 +7984,8 @@ namespace libtorrent
|
|||
return lhs->last_received() < rhs->last_received();
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int torrent::disconnect_peers(int num, error_code const& ec)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
@ -10191,6 +10212,8 @@ namespace libtorrent
|
|||
}
|
||||
#endif // TORRENT_DEBUG_STREAMING
|
||||
|
||||
namespace {
|
||||
|
||||
struct busy_block_t
|
||||
{
|
||||
int peers;
|
||||
|
@ -10449,6 +10472,8 @@ namespace libtorrent
|
|||
} while (!interesting_blocks.empty());
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void torrent::request_time_critical_pieces()
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
|
|
|
@ -344,6 +344,11 @@ namespace libtorrent
|
|||
{
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
TORRENT_ASYNC_CALL4(set_ssl_cert, certificate, private_key, dh_params, passphrase);
|
||||
#else
|
||||
TORRENT_UNUSED(certificate);
|
||||
TORRENT_UNUSED(private_key);
|
||||
TORRENT_UNUSED(dh_params);
|
||||
TORRENT_UNUSED(passphrase);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -354,6 +359,10 @@ namespace libtorrent
|
|||
{
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
TORRENT_ASYNC_CALL3(set_ssl_cert_buffer, certificate, private_key, dh_params);
|
||||
#else
|
||||
TORRENT_UNUSED(certificate);
|
||||
TORRENT_UNUSED(private_key);
|
||||
TORRENT_UNUSED(dh_params);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -506,11 +515,11 @@ namespace libtorrent
|
|||
#ifndef TORRENT_NO_DEPRECATE
|
||||
// ============ start deprecation ===============
|
||||
|
||||
int torrent_handle::get_peer_upload_limit(tcp::endpoint ip) const { return -1; }
|
||||
int torrent_handle::get_peer_download_limit(tcp::endpoint ip) const { return -1; }
|
||||
void torrent_handle::set_peer_upload_limit(tcp::endpoint ip, int limit) const {}
|
||||
void torrent_handle::set_peer_download_limit(tcp::endpoint ip, int limit) const {}
|
||||
void torrent_handle::set_ratio(float ratio) const {}
|
||||
int torrent_handle::get_peer_upload_limit(tcp::endpoint) const { return -1; }
|
||||
int torrent_handle::get_peer_download_limit(tcp::endpoint) const { return -1; }
|
||||
void torrent_handle::set_peer_upload_limit(tcp::endpoint, int /* limit */) const {}
|
||||
void torrent_handle::set_peer_download_limit(tcp::endpoint, int /* limit */) const {}
|
||||
void torrent_handle::set_ratio(float) const {}
|
||||
void torrent_handle::use_interface(const char* net_interface) const
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(use_interface, std::string(net_interface));
|
||||
|
|
Loading…
Reference in New Issue