add option to ignore min-interval from tracker, when force-reannouncing a tracker
This commit is contained in:
parent
214ace3efe
commit
2647ca2412
|
@ -1,3 +1,4 @@
|
||||||
|
* add option to ignore min-interval from trackers on force-reannounce
|
||||||
* raise default setting for active_limit
|
* raise default setting for active_limit
|
||||||
* fall back to copy+remove if rename_file fails
|
* fall back to copy+remove if rename_file fails
|
||||||
* improve handling of filesystems not supporting fallocate()
|
* improve handling of filesystems not supporting fallocate()
|
||||||
|
|
|
@ -393,7 +393,7 @@ void add_piece(torrent_handle& th, int piece, char const *data, int flags)
|
||||||
void bind_torrent_handle()
|
void bind_torrent_handle()
|
||||||
{
|
{
|
||||||
// arguments are: number of seconds and tracker index
|
// arguments are: number of seconds and tracker index
|
||||||
void (torrent_handle::*force_reannounce0)(int, int) const = &torrent_handle::force_reannounce;
|
void (torrent_handle::*force_reannounce0)(int, int, int) const = &torrent_handle::force_reannounce;
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
bool (torrent_handle::*super_seeding0)() const = &torrent_handle::super_seeding;
|
bool (torrent_handle::*super_seeding0)() const = &torrent_handle::super_seeding;
|
||||||
|
@ -496,7 +496,7 @@ void bind_torrent_handle()
|
||||||
.def("save_resume_data", _(&torrent_handle::save_resume_data), arg("flags") = 0)
|
.def("save_resume_data", _(&torrent_handle::save_resume_data), arg("flags") = 0)
|
||||||
.def("need_save_resume_data", _(&torrent_handle::need_save_resume_data))
|
.def("need_save_resume_data", _(&torrent_handle::need_save_resume_data))
|
||||||
.def("force_reannounce", _(force_reannounce0)
|
.def("force_reannounce", _(force_reannounce0)
|
||||||
, (arg("seconds") = 0, arg("tracker_idx") = -1))
|
, (arg("seconds") = 0, arg("tracker_idx") = -1, arg("flags") = 0))
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
.def("force_dht_announce", _(&torrent_handle::force_dht_announce))
|
.def("force_dht_announce", _(&torrent_handle::force_dht_announce))
|
||||||
#endif
|
#endif
|
||||||
|
@ -558,6 +558,10 @@ void bind_torrent_handle()
|
||||||
.value("only_if_modified", torrent_handle::only_if_modified)
|
.value("only_if_modified", torrent_handle::only_if_modified)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
enum_<torrent_handle::reannounce_flags_t>("reannounce_flags_t")
|
||||||
|
.value("ignore_min_interval", torrent_handle::ignore_min_interval)
|
||||||
|
;
|
||||||
|
|
||||||
enum_<torrent_handle::deadline_flags>("deadline_flags")
|
enum_<torrent_handle::deadline_flags>("deadline_flags")
|
||||||
.value("alert_when_available", torrent_handle::alert_when_available)
|
.value("alert_when_available", torrent_handle::alert_when_available)
|
||||||
;
|
;
|
||||||
|
|
|
@ -731,7 +731,7 @@ namespace libtorrent
|
||||||
void do_connect_boost();
|
void do_connect_boost();
|
||||||
|
|
||||||
// forcefully sets next_announce to the current time
|
// forcefully sets next_announce to the current time
|
||||||
void force_tracker_request(time_point, int tracker_idx);
|
void force_tracker_request(time_point, int tracker_idx, int flags);
|
||||||
void scrape_tracker(int idx, bool user_triggered);
|
void scrape_tracker(int idx, bool user_triggered);
|
||||||
void announce_with_tracker(boost::uint8_t e
|
void announce_with_tracker(boost::uint8_t e
|
||||||
= tracker_request::none);
|
= tracker_request::none);
|
||||||
|
|
|
@ -1092,6 +1092,15 @@ namespace libtorrent
|
||||||
void prioritize_files(std::vector<int> const& files) const;
|
void prioritize_files(std::vector<int> const& files) const;
|
||||||
std::vector<int> file_priorities() const;
|
std::vector<int> file_priorities() const;
|
||||||
|
|
||||||
|
// flags to be used with force_reannounce
|
||||||
|
enum reannounce_flags_t
|
||||||
|
{
|
||||||
|
// by default, force-reannounce will still honor the min-interval
|
||||||
|
// published by the tracker. If this flag is set, it will be ignored
|
||||||
|
// and the tracker is announced immediately.
|
||||||
|
ignore_min_interval = 1
|
||||||
|
};
|
||||||
|
|
||||||
// ``force_reannounce()`` will force this torrent to do another tracker
|
// ``force_reannounce()`` will force this torrent to do another tracker
|
||||||
// request, to receive new peers. The ``seconds`` argument specifies how
|
// request, to receive new peers. The ``seconds`` argument specifies how
|
||||||
// many seconds from now to issue the tracker announces.
|
// many seconds from now to issue the tracker announces.
|
||||||
|
@ -1104,9 +1113,13 @@ namespace libtorrent
|
||||||
// The ``tracker_index`` argument specifies which tracker to re-announce.
|
// The ``tracker_index`` argument specifies which tracker to re-announce.
|
||||||
// If set to -1 (which is the default), all trackers are re-announce.
|
// If set to -1 (which is the default), all trackers are re-announce.
|
||||||
//
|
//
|
||||||
|
// The ``flags`` argument can be used to affect the re-announce. See
|
||||||
|
// reannounce_flags_t.
|
||||||
|
//
|
||||||
// ``force_dht_announce`` will announce the torrent to the DHT
|
// ``force_dht_announce`` will announce the torrent to the DHT
|
||||||
// immediately.
|
// immediately.
|
||||||
void force_reannounce(int seconds = 0, int tracker_index = -1) const;
|
void force_reannounce(int seconds = 0, int tracker_index = -1) const;
|
||||||
|
void force_reannounce(int seconds, int tracker_index, int flags) const;
|
||||||
void force_dht_announce() const;
|
void force_dht_announce() const;
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
|
|
|
@ -194,7 +194,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
tracker_response()
|
tracker_response()
|
||||||
: interval(1800)
|
: interval(1800)
|
||||||
, min_interval(120)
|
, min_interval(1)
|
||||||
, complete(-1)
|
, complete(-1)
|
||||||
, incomplete(-1)
|
, incomplete(-1)
|
||||||
, downloaders(-1)
|
, downloaders(-1)
|
||||||
|
|
|
@ -3590,10 +3590,12 @@ namespace {
|
||||||
}
|
}
|
||||||
debug_log("TRACKER RESPONSE\n"
|
debug_log("TRACKER RESPONSE\n"
|
||||||
"interval: %d\n"
|
"interval: %d\n"
|
||||||
|
"min-interval: %d\n"
|
||||||
"external ip: %s\n"
|
"external ip: %s\n"
|
||||||
"resolved to: %s\n"
|
"resolved to: %s\n"
|
||||||
"we connected to: %s\n"
|
"we connected to: %s\n"
|
||||||
, interval
|
, interval
|
||||||
|
, resp.min_interval
|
||||||
, print_address(resp.external_ip).c_str()
|
, print_address(resp.external_ip).c_str()
|
||||||
, resolved_to.c_str()
|
, resolved_to.c_str()
|
||||||
, print_address(tracker_ip).c_str());
|
, print_address(tracker_ip).c_str());
|
||||||
|
@ -3815,7 +3817,8 @@ namespace {
|
||||||
// this is the entry point for the client to force a re-announce. It's
|
// this is the entry point for the client to force a re-announce. It's
|
||||||
// considered a client-initiated announce (as opposed to the regular ones,
|
// considered a client-initiated announce (as opposed to the regular ones,
|
||||||
// issued by libtorrent)
|
// issued by libtorrent)
|
||||||
void torrent::force_tracker_request(time_point t, int tracker_idx)
|
void torrent::force_tracker_request(time_point const t, int const tracker_idx
|
||||||
|
, int const flags)
|
||||||
{
|
{
|
||||||
if (is_paused()) return;
|
if (is_paused()) return;
|
||||||
if (tracker_idx == -1)
|
if (tracker_idx == -1)
|
||||||
|
@ -3823,7 +3826,10 @@ namespace {
|
||||||
for (std::vector<announce_entry>::iterator i = m_trackers.begin()
|
for (std::vector<announce_entry>::iterator i = m_trackers.begin()
|
||||||
, end(m_trackers.end()); i != end; ++i)
|
, end(m_trackers.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
i->next_announce = (std::max)(t, i->min_announce) + seconds(1);
|
i->next_announce = (flags & torrent_handle::ignore_min_interval)
|
||||||
|
? t + seconds(1)
|
||||||
|
: (std::max)(t, i->min_announce) + seconds(1);
|
||||||
|
i->min_announce = i->next_announce;
|
||||||
i->triggered_manually = true;
|
i->triggered_manually = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3833,7 +3839,10 @@ namespace {
|
||||||
if (tracker_idx < 0 || tracker_idx >= int(m_trackers.size()))
|
if (tracker_idx < 0 || tracker_idx >= int(m_trackers.size()))
|
||||||
return;
|
return;
|
||||||
announce_entry& e = m_trackers[tracker_idx];
|
announce_entry& e = m_trackers[tracker_idx];
|
||||||
e.next_announce = (std::max)(t, e.min_announce) + seconds(1);
|
e.next_announce = (flags & torrent_handle::ignore_min_interval)
|
||||||
|
? t + seconds(1)
|
||||||
|
: (std::max)(t, e.min_announce) + seconds(1);
|
||||||
|
e.min_announce = e.next_announce;
|
||||||
e.triggered_manually = true;
|
e.triggered_manually = true;
|
||||||
}
|
}
|
||||||
update_tracker_timer(clock_type::now());
|
update_tracker_timer(clock_type::now());
|
||||||
|
|
|
@ -709,8 +709,8 @@ namespace libtorrent
|
||||||
void torrent_handle::force_reannounce(
|
void torrent_handle::force_reannounce(
|
||||||
boost::posix_time::time_duration duration) const
|
boost::posix_time::time_duration duration) const
|
||||||
{
|
{
|
||||||
TORRENT_ASYNC_CALL2(force_tracker_request, aux::time_now()
|
TORRENT_ASYNC_CALL3(force_tracker_request, aux::time_now()
|
||||||
+ seconds(duration.total_seconds()), -1);
|
+ seconds(duration.total_seconds()), -1, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -723,7 +723,13 @@ namespace libtorrent
|
||||||
|
|
||||||
void torrent_handle::force_reannounce(int s, int idx) const
|
void torrent_handle::force_reannounce(int s, int idx) const
|
||||||
{
|
{
|
||||||
TORRENT_ASYNC_CALL2(force_tracker_request, aux::time_now() + seconds(s), idx);
|
TORRENT_ASYNC_CALL3(force_tracker_request, aux::time_now() + seconds(s), idx, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void torrent_handle::force_reannounce(int s, int idx, int flags) const
|
||||||
|
{
|
||||||
|
TORRENT_ASYNC_CALL3(force_tracker_request, aux::time_now() + seconds(s)
|
||||||
|
, idx, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrent_handle::file_status(std::vector<pool_file_status>& status) const
|
void torrent_handle::file_status(std::vector<pool_file_status>& status) const
|
||||||
|
|
|
@ -279,8 +279,6 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(req.num_want >= 0);
|
TORRENT_ASSERT(req.num_want >= 0);
|
||||||
TORRENT_ASSERT(!m_abort || req.event == tracker_request::stopped);
|
TORRENT_ASSERT(!m_abort || req.event == tracker_request::stopped);
|
||||||
if (m_abort && req.event != tracker_request::stopped) return;
|
if (m_abort && req.event != tracker_request::stopped) return;
|
||||||
if (req.event == tracker_request::stopped)
|
|
||||||
req.num_want = 0;
|
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
boost::shared_ptr<request_callback> cb = c.lock();
|
boost::shared_ptr<request_callback> cb = c.lock();
|
||||||
|
|
Loading…
Reference in New Issue