Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: src/tracker/tracker_manager.cc
- ===================================================================
- --- src/tracker/tracker_manager.cc (revision 1087)
- +++ src/tracker/tracker_manager.cc (working copy)
- @@ -252,7 +252,7 @@
- if (m_control->has_active())
- throw internal_error("TrackerManager::receive_timeout() called but m_control->has_active() == true.");
- - if (!m_active)
- + if (!m_active && !m_control->state() == DownloadInfo::STOPPED)
- return;
- m_control->send_state((DownloadInfo::State)m_control->state());
- @@ -265,33 +265,42 @@
- if (m_control->state() == DownloadInfo::STOPPED || !m_active)
- return m_slotSuccess(l);
- - if (m_control->state() == DownloadInfo::STARTED)
- + if (m_control->state() == DownloadInfo::STARTED && !info()->is_utorrent_style())
- m_initialTracker = std::distance(m_control->begin(), m_control->focus());
- - // Don't reset the focus when we're requesting more peers. If we
- - // want to query the next tracker in the list we need to remember
- - // the current focus.
- - if (m_isRequesting) {
- - m_numRequests++;
- + if (!info()->is_utorrent_style())
- + {
- + // Don't reset the focus when we're requesting more peers. If we
- + // want to query the next tracker in the list we need to remember
- + // the current focus.
- + if (m_isRequesting) {
- + m_numRequests++;
- + } else {
- + m_numRequests = 1;
- + m_control->set_focus(m_control->begin());
- + }
- +
- + // Reset m_isRequesting so a new call to request_*() is needed to
- + // try from the rest of the trackers in the list. If not called, the
- + // next tracker request will reset the focus to the first tracker.
- + m_isRequesting = false;
- +
- + m_control->set_state(DownloadInfo::NONE);
- + priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(m_control->focus_normal_interval())).round_seconds());
- } else {
- - m_numRequests = 1;
- - m_control->set_focus(m_control->begin());
- + if(m_control->focus_next_group()) {
- + priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(10)).round_seconds());
- + } else {
- + m_control->set_focus(m_control->begin());
- + priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(m_control->focus_normal_interval())).round_seconds());
- + }
- }
- -
- - // Reset m_isRequesting so a new call to request_*() is needed to
- - // try from the rest of the trackers in the list. If not called, the
- - // next tracker request will reset the focus to the first tracker.
- - m_isRequesting = false;
- -
- - m_control->set_state(DownloadInfo::NONE);
- - priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(m_control->focus_normal_interval())).round_seconds());
- -
- m_slotSuccess(l);
- }
- void
- TrackerManager::receive_failed(const std::string& msg) {
- - if (m_control->state() == DownloadInfo::STOPPED || !m_active)
- + if ((m_control->state() == DownloadInfo::STOPPED || !m_active) && (!info()->is_utorrent_style())) // We need to sent STOPPED to other trackers
- return m_slotFailed(msg);
- if (m_isRequesting) {
- @@ -306,7 +315,7 @@
- priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(20)).round_seconds());
- }
- - } else {
- + } else if(!info()->is_utorrent_style()) {
- // Normal retry.
- if (m_control->focus() == m_control->end()) {
- @@ -316,6 +325,16 @@
- }
- priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(std::min<uint32_t>(600, 20 + 20 * m_failedRequests))).round_seconds());
- + } else {
- + if (m_control->focus() == m_control->end() && m_control->state()) {
- + // Entire list covered, stop cycling now
- + m_control->set_focus(m_control->begin());
- + if (m_control->state() != DownloadInfo::STOPPED) {
- + priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(m_control->focus_normal_interval())).round_seconds());
- + }
- + } else {
- + priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(10)).round_seconds());
- + }
- }
- m_slotFailed(msg);
- Index: src/download/download_main.cc
- ===================================================================
- --- src/download/download_main.cc (revision 1087)
- +++ src/download/download_main.cc (working copy)
- @@ -302,7 +302,7 @@
- void
- DownloadMain::receive_tracker_success() {
- - if (!info()->is_active())
- + if (!info()->is_active() || info()->is_utorrent_style())
- return;
- priority_queue_erase(&taskScheduler, &m_taskTrackerRequest);
- Index: src/download/download_info.h
- ===================================================================
- --- src/download/download_info.h (revision 1087)
- +++ src/download/download_info.h (working copy)
- @@ -78,6 +78,7 @@
- m_isPrivate(false),
- m_pexEnabled(true),
- m_pexActive(true),
- + m_isUtorrentStyle(false),
- m_upRate(60),
- m_downRate(60),
- @@ -121,6 +122,9 @@
- bool is_pex_active() const { return m_pexActive; }
- void set_pex_active(bool active) { m_pexActive = active; }
- +
- + bool is_utorrent_style() const { return m_isUtorrentStyle; }
- + void set_utorrent_style(bool s) { m_isUtorrentStyle = s; }
- Rate* up_rate() { return &m_upRate; }
- Rate* down_rate() { return &m_downRate; }
- @@ -167,6 +171,7 @@
- bool m_isPrivate;
- bool m_pexEnabled;
- bool m_pexActive;
- + bool m_isUtorrentStyle;
- Rate m_upRate;
- Rate m_downRate;
Advertisement
Add Comment
Please, Sign In to add comment