forked from premiere/premiere-libtorrent
parent
af2a9a875b
commit
93d8955750
|
@ -726,8 +726,7 @@ namespace libtorrent
|
|||
void set_tracker_login(std::string const& name, std::string const& pw);
|
||||
#endif
|
||||
|
||||
announce_entry* find_tracker(tracker_request const& r);
|
||||
|
||||
announce_entry* find_tracker(std::string const& url);
|
||||
// --------------------------------------------
|
||||
// PIECE MANAGEMENT
|
||||
|
||||
|
|
|
@ -302,7 +302,10 @@ namespace libtorrent
|
|||
e.fail_limit = 0;
|
||||
e.source = announce_entry::source_magnet_link;
|
||||
e.tier = tier;
|
||||
m_trackers.push_back(e);
|
||||
if (!find_tracker(e.url))
|
||||
{
|
||||
m_trackers.push_back(e);
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(m_trackers.begin(), m_trackers.end()
|
||||
|
@ -3101,7 +3104,7 @@ namespace libtorrent
|
|||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
announce_entry* ae = find_tracker(req);
|
||||
announce_entry* ae = find_tracker(req.url);
|
||||
if (ae)
|
||||
{
|
||||
ae->message = msg;
|
||||
|
@ -3119,7 +3122,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
TORRENT_ASSERT(0 != (req.kind & tracker_request::scrape_request));
|
||||
|
||||
announce_entry* ae = find_tracker(req);
|
||||
announce_entry* ae = find_tracker(req.url);
|
||||
if (ae)
|
||||
{
|
||||
if (incomplete >= 0) ae->scrape_incomplete = incomplete;
|
||||
|
@ -3199,7 +3202,7 @@ namespace libtorrent
|
|||
if (interval < settings().get_int(settings_pack::min_announce_interval))
|
||||
interval = settings().get_int(settings_pack::min_announce_interval);
|
||||
|
||||
announce_entry* ae = find_tracker(r);
|
||||
announce_entry* ae = find_tracker(r.url);
|
||||
if (ae)
|
||||
{
|
||||
if (resp.incomplete >= 0) ae->scrape_incomplete = resp.incomplete;
|
||||
|
@ -5551,14 +5554,12 @@ namespace libtorrent
|
|||
|
||||
bool torrent::add_tracker(announce_entry const& url)
|
||||
{
|
||||
std::vector<announce_entry>::iterator k = std::find_if(m_trackers.begin()
|
||||
, m_trackers.end(), [&url] (announce_entry const& u) { return u.url == url.url; });
|
||||
if (k != m_trackers.end())
|
||||
if(auto k = find_tracker(url.url))
|
||||
{
|
||||
k->source |= url.source;
|
||||
return false;
|
||||
}
|
||||
k = std::upper_bound(m_trackers.begin(), m_trackers.end(), url
|
||||
auto k = std::upper_bound(m_trackers.begin(), m_trackers.end(), url
|
||||
, [] (announce_entry const& lhs, announce_entry const& rhs)
|
||||
{ return lhs.tier < rhs.tier; });
|
||||
if (k - m_trackers.begin() < m_last_working_tracker) ++m_last_working_tracker;
|
||||
|
@ -10613,12 +10614,10 @@ namespace libtorrent
|
|||
, std::bind(&torrent::on_piece_verified, shared_from_this(), _1)
|
||||
, reinterpret_cast<void*>(1));
|
||||
}
|
||||
|
||||
announce_entry* torrent::find_tracker(tracker_request const& r)
|
||||
announce_entry* torrent::find_tracker(std::string const& url)
|
||||
{
|
||||
std::vector<announce_entry>::iterator i = std::find_if(
|
||||
m_trackers.begin(), m_trackers.end()
|
||||
, [&r] (announce_entry const& ae) { return ae.url == r.url; });
|
||||
auto i = std::find_if(m_trackers.begin(), m_trackers.end()
|
||||
, [&url](announce_entry const& ae) { return ae.url == url; });
|
||||
if (i == m_trackers.end()) return nullptr;
|
||||
return &*i;
|
||||
}
|
||||
|
@ -11296,7 +11295,7 @@ namespace libtorrent
|
|||
if (0 == (r.kind & tracker_request::scrape_request))
|
||||
{
|
||||
// announce request
|
||||
announce_entry* ae = find_tracker(r);
|
||||
announce_entry* ae = find_tracker(r.url);
|
||||
if (ae)
|
||||
{
|
||||
ae->failed(seconds(settings().get_int(settings_pack::tracker_backoff))
|
||||
|
@ -11325,7 +11324,7 @@ namespace libtorrent
|
|||
if (response_code == 410)
|
||||
{
|
||||
// never talk to this tracker again
|
||||
announce_entry* ae = find_tracker(r);
|
||||
announce_entry* ae = find_tracker(r.url);
|
||||
if (ae) ae->fail_limit = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -120,6 +120,7 @@ TORRENT_TEST(magnet)
|
|||
"&tr=http://1"
|
||||
"&tr=http://2"
|
||||
"&tr=http://3"
|
||||
"&tr=http://3"
|
||||
"&dn=foo"
|
||||
"&dht=127.0.0.1:43";
|
||||
torrent_handle t = s->add_torrent(p, ec);
|
||||
|
|
Loading…
Reference in New Issue