parent
bd557ca2b2
commit
4d96939b7b
|
@ -35,28 +35,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
|
||||||
|
|
||||||
#ifdef __OBJC__
|
|
||||||
#define Protocol Protocol_
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
|
|
||||||
// asio assumes that the windows error codes are defined already
|
|
||||||
#include <winsock2.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/asio/ip/address.hpp>
|
|
||||||
|
|
||||||
#if defined TORRENT_BUILD_SIMULATOR
|
#if defined TORRENT_BUILD_SIMULATOR
|
||||||
#include "simulator/simulator.hpp"
|
#include "simulator/simulator.hpp"
|
||||||
#endif
|
#else
|
||||||
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
#include <boost/asio/ip/address.hpp>
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
#endif // SIMULATOR
|
||||||
#ifdef __OBJC__
|
|
||||||
#undef Protocol
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef TORRENT_ALERT_HPP_INCLUDED
|
#ifndef TORRENT_ALERT_HPP_INCLUDED
|
||||||
#define TORRENT_ALERT_HPP_INCLUDED
|
#define TORRENT_ALERT_HPP_INCLUDED
|
||||||
|
|
||||||
#include <deque>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// OVERVIEW
|
// OVERVIEW
|
||||||
|
|
|
@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define TORRENT_ANNOUNCE_ENTRY_HPP_INCLUDED
|
#define TORRENT_ANNOUNCE_ENTRY_HPP_INCLUDED
|
||||||
|
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/time.hpp" // for time_point
|
#include "libtorrent/time.hpp"
|
||||||
#include "libtorrent/error_code.hpp"
|
#include "libtorrent/error_code.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -42,10 +42,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
namespace aux {
|
|
||||||
struct session_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this class holds information about one bittorrent tracker, as it
|
// this class holds information about one bittorrent tracker, as it
|
||||||
// relates to a specific torrent.
|
// relates to a specific torrent.
|
||||||
struct TORRENT_EXPORT announce_entry
|
struct TORRENT_EXPORT announce_entry
|
||||||
|
@ -161,7 +157,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// updates the failure counter and time-outs for re-trying.
|
// updates the failure counter and time-outs for re-trying.
|
||||||
// This is called when the tracker announce fails.
|
// This is called when the tracker announce fails.
|
||||||
void failed(aux::session_settings const& sett, int retry_interval = 0);
|
void failed(time_duration tracker_backoff, int retry_interval = 0);
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// deprecated in 1.0
|
// deprecated in 1.0
|
||||||
|
|
|
@ -33,7 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef TORRENT_PROXY_SETTINGS_HPP_INCLUDED
|
#ifndef TORRENT_PROXY_SETTINGS_HPP_INCLUDED
|
||||||
#define TORRENT_PROXY_SETTINGS_HPP_INCLUDED
|
#define TORRENT_PROXY_SETTINGS_HPP_INCLUDED
|
||||||
|
|
||||||
#include "libtorrent/version.hpp"
|
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -138,8 +137,6 @@ namespace aux {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}}
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef TORRENT_AUX_SESSION_SETTINGS_HPP_INCLUDED
|
#ifndef TORRENT_AUX_SESSION_SETTINGS_HPP_INCLUDED
|
||||||
#define TORRENT_AUX_SESSION_SETTINGS_HPP_INCLUDED
|
#define TORRENT_AUX_SESSION_SETTINGS_HPP_INCLUDED
|
||||||
|
|
||||||
#include "libtorrent/version.hpp"
|
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/settings_pack.hpp"
|
#include "libtorrent/settings_pack.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
|
@ -102,4 +101,3 @@ namespace libtorrent { namespace aux
|
||||||
} }
|
} }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "libtorrent/kademlia/dht_storage.hpp"
|
#include "libtorrent/kademlia/dht_storage.hpp"
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
|
#include <deque>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
struct plugin;
|
struct plugin;
|
||||||
|
|
|
@ -61,7 +61,8 @@ namespace libtorrent
|
||||||
|
|
||||||
TORRENT_EXTRA_EXPORT boost::shared_ptr<settings_pack> load_pack_from_dict(bdecode_node const& settings);
|
TORRENT_EXTRA_EXPORT boost::shared_ptr<settings_pack> load_pack_from_dict(bdecode_node const& settings);
|
||||||
TORRENT_EXTRA_EXPORT void save_settings_to_dict(aux::session_settings const& s, entry::dictionary_type& sett);
|
TORRENT_EXTRA_EXPORT void save_settings_to_dict(aux::session_settings const& s, entry::dictionary_type& sett);
|
||||||
TORRENT_EXTRA_EXPORT void apply_pack(settings_pack const* pack, aux::session_settings& sett, aux::session_impl* ses = 0);
|
TORRENT_EXTRA_EXPORT void apply_pack(settings_pack const* pack, aux::session_settings& sett
|
||||||
|
, aux::session_impl* ses = nullptr);
|
||||||
|
|
||||||
TORRENT_EXPORT int setting_by_name(std::string const& name);
|
TORRENT_EXPORT int setting_by_name(std::string const& name);
|
||||||
TORRENT_EXPORT char const* name_for_setting(int s);
|
TORRENT_EXPORT char const* name_for_setting(int s);
|
||||||
|
|
|
@ -1223,7 +1223,7 @@ namespace libtorrent
|
||||||
// directory, if there is one. The source files will still be removed in
|
// directory, if there is one. The source files will still be removed in
|
||||||
// that case.
|
// that case.
|
||||||
//
|
//
|
||||||
// Files that have been renamed to have absolute pahts are not moved by
|
// Files that have been renamed to have absolute paths are not moved by
|
||||||
// this function. Keep in mind that files that don't belong to the
|
// this function. Keep in mind that files that don't belong to the
|
||||||
// torrent but are stored in the torrent's directory may be moved as
|
// torrent but are stored in the torrent's directory may be moved as
|
||||||
// well. This goes for files that have been renamed to absolute paths
|
// well. This goes for files that have been renamed to absolute paths
|
||||||
|
|
|
@ -41,10 +41,10 @@ namespace libtorrent
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
// wait at least 5 seconds before retrying a failed tracker
|
// wait at least 5 seconds before retrying a failed tracker
|
||||||
tracker_retry_delay_min = 5
|
tracker_retry_delay_min = 5,
|
||||||
// when tracker_failed_max trackers
|
// when tracker_failed_max trackers
|
||||||
// has failed, wait 60 minutes instead
|
// has failed, wait 60 minutes instead
|
||||||
, tracker_retry_delay_max = 60 * 60
|
tracker_retry_delay_max = 60 * 60
|
||||||
};
|
};
|
||||||
|
|
||||||
announce_entry::announce_entry(std::string const& u)
|
announce_entry::announce_entry(std::string const& u)
|
||||||
|
@ -99,14 +99,15 @@ namespace libtorrent
|
||||||
min_announce = min_time();
|
min_announce = min_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
void announce_entry::failed(aux::session_settings const& sett, int retry_interval)
|
void announce_entry::failed(time_duration const tracker_backoff, int const retry_interval)
|
||||||
{
|
{
|
||||||
++fails;
|
++fails;
|
||||||
// the exponential back-off ends up being:
|
// the exponential back-off ends up being:
|
||||||
// 7, 15, 27, 45, 95, 127, 165, ... seconds
|
// 7, 15, 27, 45, 95, 127, 165, ... seconds
|
||||||
// with the default tracker_backoff of 250
|
// with the default tracker_backoff of 250
|
||||||
|
int const tracker_backoff_seconds = total_seconds(tracker_backoff);
|
||||||
int delay = (std::min)(tracker_retry_delay_min + int(fails) * int(fails)
|
int delay = (std::min)(tracker_retry_delay_min + int(fails) * int(fails)
|
||||||
* tracker_retry_delay_min * sett.get_int(settings_pack::tracker_backoff) / 100
|
* tracker_retry_delay_min * tracker_backoff_seconds / 100
|
||||||
, int(tracker_retry_delay_max));
|
, int(tracker_retry_delay_max));
|
||||||
delay = (std::max)(delay, retry_interval);
|
delay = (std::max)(delay, retry_interval);
|
||||||
next_announce = aux::time_now() + seconds(delay);
|
next_announce = aux::time_now() + seconds(delay);
|
||||||
|
|
|
@ -42,7 +42,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/performance_counters.hpp" // for counters
|
#include "libtorrent/performance_counters.hpp" // for counters
|
||||||
#include "libtorrent/alert_manager.hpp"
|
#include "libtorrent/alert_manager.hpp"
|
||||||
|
|
||||||
#include <boost/next_prior.hpp>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
|
@ -55,9 +54,6 @@ using namespace std::placeholders;
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
class alert;
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
inline bool default_pred(std::string const&) { return true; }
|
inline bool default_pred(std::string const&) { return true; }
|
||||||
|
@ -740,6 +736,4 @@ namespace libtorrent
|
||||||
if (str == nullptr) m_created_by.clear();
|
if (str == nullptr) m_created_by.clear();
|
||||||
else m_created_by = str;
|
else m_created_by = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,18 +36,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/allocator.hpp"
|
#include "libtorrent/allocator.hpp"
|
||||||
#include "libtorrent/aux_/session_settings.hpp"
|
#include "libtorrent/aux_/session_settings.hpp"
|
||||||
#include "libtorrent/io_service.hpp"
|
#include "libtorrent/io_service.hpp"
|
||||||
#include "libtorrent/alert.hpp"
|
|
||||||
#include "libtorrent/alert_types.hpp"
|
|
||||||
#include "libtorrent/disk_observer.hpp"
|
#include "libtorrent/disk_observer.hpp"
|
||||||
#include "libtorrent/platform_util.hpp" // for total_physical_ram
|
#include "libtorrent/platform_util.hpp" // for total_physical_ram
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <functional>
|
|
||||||
#include <boost/system/error_code.hpp>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
|
|
||||||
#if TORRENT_HAVE_MMAP
|
#if TORRENT_HAVE_MMAP
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -75,4 +75,3 @@ proxy_settings::proxy_settings(aux::session_settings const& sett)
|
||||||
|
|
||||||
} // namespace aux
|
} // namespace aux
|
||||||
} // namespace libtorrent
|
} // namespace libtorrent
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -91,10 +84,10 @@ namespace
|
||||||
// CRCs from the time it failed and ban the peers that
|
// CRCs from the time it failed and ban the peers that
|
||||||
// sent bad blocks
|
// sent bad blocks
|
||||||
std::map<piece_block, block_entry>::iterator i = m_block_hashes.lower_bound(piece_block(p, 0));
|
std::map<piece_block, block_entry>::iterator i = m_block_hashes.lower_bound(piece_block(p, 0));
|
||||||
if (i == m_block_hashes.end() || int(i->first.piece_index) != p) return;
|
if (i == m_block_hashes.end() || i->first.piece_index != p) return;
|
||||||
|
|
||||||
int size = m_torrent.torrent_file().piece_size(p);
|
int size = m_torrent.torrent_file().piece_size(p);
|
||||||
peer_request r = {p, 0, (std::min)(16*1024, size)};
|
peer_request r = {p, 0, (std::min)(16 * 1024, size)};
|
||||||
piece_block pb(p, 0);
|
piece_block pb(p, 0);
|
||||||
while (size > 0)
|
while (size > 0)
|
||||||
{
|
{
|
||||||
|
@ -114,9 +107,9 @@ namespace
|
||||||
if (i == m_block_hashes.end() || int(i->first.piece_index) != p)
|
if (i == m_block_hashes.end() || int(i->first.piece_index) != p)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
r.start += 16*1024;
|
r.start += 16 * 1024;
|
||||||
size -= 16*1024;
|
size -= 16 * 1024;
|
||||||
r.length = (std::min)(16*1024, size);
|
r.length = (std::min)(16 * 1024, size);
|
||||||
++pb.block_index;
|
++pb.block_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -610,7 +610,6 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
m_stat_cache.reserve(files().num_files());
|
m_stat_cache.reserve(files().num_files());
|
||||||
|
|
||||||
std::string file_path;
|
|
||||||
for (int i = 0; i < files().num_files(); ++i)
|
for (int i = 0; i < files().num_files(); ++i)
|
||||||
{
|
{
|
||||||
std::int64_t sz = m_stat_cache.get_filesize(
|
std::int64_t sz = m_stat_cache.get_filesize(
|
||||||
|
@ -1541,7 +1540,7 @@ namespace libtorrent
|
||||||
// check if the fastresume data is up to date
|
// check if the fastresume data is up to date
|
||||||
// if it is, use it and return true. If it
|
// if it is, use it and return true. If it
|
||||||
// isn't return false and the full check
|
// isn't return false and the full check
|
||||||
// will be run. If the links pointer is non-nullptr, it has the same number
|
// will be run. If the links pointer is non-empty, it has the same number
|
||||||
// of elements as there are files. Each element is either empty or contains
|
// of elements as there are files. Each element is either empty or contains
|
||||||
// the absolute path to a file identical to the corresponding file in this
|
// the absolute path to a file identical to the corresponding file in this
|
||||||
// torrent. The storage must create hard links (or copy) those files. If
|
// torrent. The storage must create hard links (or copy) those files. If
|
||||||
|
|
|
@ -11256,7 +11256,8 @@ namespace libtorrent
|
||||||
announce_entry* ae = find_tracker(r);
|
announce_entry* ae = find_tracker(r);
|
||||||
if (ae)
|
if (ae)
|
||||||
{
|
{
|
||||||
ae->failed(settings(), retry_interval);
|
ae->failed(seconds(settings().get_int(settings_pack::tracker_backoff))
|
||||||
|
, retry_interval);
|
||||||
ae->last_error = ec;
|
ae->last_error = ec;
|
||||||
ae->message = msg;
|
ae->message = msg;
|
||||||
int tracker_index = ae - &m_trackers[0];
|
int tracker_index = ae - &m_trackers[0];
|
||||||
|
@ -11272,7 +11273,7 @@ namespace libtorrent
|
||||||
|| r.triggered_manually)
|
|| r.triggered_manually)
|
||||||
{
|
{
|
||||||
m_ses.alerts().emplace_alert<tracker_error_alert>(get_handle()
|
m_ses.alerts().emplace_alert<tracker_error_alert>(get_handle()
|
||||||
, ae?ae->fails:0, response_code, r.url, ec, msg);
|
, ae ? ae->fails : 0, response_code, r.url, ec, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -80,7 +80,7 @@ namespace libtorrent
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
// fixes invalid UTF-8 sequences
|
// fixes invalid UTF-8 sequences
|
||||||
TORRENT_EXTRA_EXPORT bool verify_encoding(std::string& target)
|
bool verify_encoding(std::string& target)
|
||||||
{
|
{
|
||||||
if (target.empty()) return true;
|
if (target.empty()) return true;
|
||||||
|
|
||||||
|
|
|
@ -107,13 +107,13 @@ namespace libtorrent
|
||||||
if (e1 > e2) swap(e1, e2);
|
if (e1 > e2) swap(e1, e2);
|
||||||
address_v6::bytes_type b1 = e1.address().to_v6().to_bytes();
|
address_v6::bytes_type b1 = e1.address().to_v6().to_bytes();
|
||||||
address_v6::bytes_type b2 = e2.address().to_v6().to_bytes();
|
address_v6::bytes_type b2 = e2.address().to_v6().to_bytes();
|
||||||
int mask = memcmp(&b1[0], &b2[0], 4) ? 0
|
int const mask = std::memcmp(b1.data(), b2.data(), 4) ? 0
|
||||||
: memcmp(&b1[0], &b2[0], 6) ? 1 : 2;
|
: std::memcmp(b1.data(), b2.data(), 6) ? 1 : 2;
|
||||||
apply_mask(&b1[0], v6mask[mask], 8);
|
apply_mask(b1.data(), v6mask[mask], 8);
|
||||||
apply_mask(&b2[0], v6mask[mask], 8);
|
apply_mask(b2.data(), v6mask[mask], 8);
|
||||||
std::uint64_t addrbuf[4];
|
std::uint64_t addrbuf[4];
|
||||||
memcpy(&addrbuf[0], &b1[0], 16);
|
memcpy(&addrbuf[0], b1.data(), 16);
|
||||||
memcpy(&addrbuf[2], &b2[0], 16);
|
memcpy(&addrbuf[2], b2.data(), 16);
|
||||||
ret = crc32c(addrbuf, 4);
|
ret = crc32c(addrbuf, 4);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -313,4 +313,3 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,18 +32,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
|
||||||
|
|
||||||
#include "libtorrent/peer_connection.hpp"
|
#include "libtorrent/peer_connection.hpp"
|
||||||
#include "libtorrent/bt_peer_connection.hpp"
|
#include "libtorrent/bt_peer_connection.hpp"
|
||||||
#include "libtorrent/peer_connection_handle.hpp"
|
#include "libtorrent/peer_connection_handle.hpp"
|
||||||
|
|
|
@ -71,11 +71,10 @@ TORRENT_TEST(primitives)
|
||||||
// on failing announces
|
// on failing announces
|
||||||
announce_entry ae("dummy");
|
announce_entry ae("dummy");
|
||||||
int last = 0;
|
int last = 0;
|
||||||
aux::session_settings sett;
|
auto const tracker_backoff = seconds(250);
|
||||||
sett.set_int(settings_pack::tracker_backoff, 250);
|
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
ae.failed(sett, 5);
|
ae.failed(tracker_backoff, 5);
|
||||||
int delay = ae.next_announce_in();
|
int delay = ae.next_announce_in();
|
||||||
TEST_CHECK(delay > last);
|
TEST_CHECK(delay > last);
|
||||||
last = delay;
|
last = delay;
|
||||||
|
|
Loading…
Reference in New Issue