Guest User

Untitled

a guest
Apr 11th, 2010
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.91 KB | None | 0 0
  1. Index: src/tracker/tracker_manager.cc
  2. ===================================================================
  3. --- src/tracker/tracker_manager.cc      (revision 1087)
  4. +++ src/tracker/tracker_manager.cc      (working copy)
  5. @@ -252,7 +252,7 @@
  6.    if (m_control->has_active())
  7.      throw internal_error("TrackerManager::receive_timeout() called but m_control->has_active() == true.");
  8.  
  9. -  if (!m_active)
  10. +  if (!m_active && !m_control->state() == DownloadInfo::STOPPED)
  11.      return;
  12.  
  13.    m_control->send_state((DownloadInfo::State)m_control->state());
  14. @@ -265,33 +265,42 @@
  15.    if (m_control->state() == DownloadInfo::STOPPED || !m_active)
  16.      return m_slotSuccess(l);
  17.  
  18. -  if (m_control->state() == DownloadInfo::STARTED)
  19. +  if (m_control->state() == DownloadInfo::STARTED && !info()->is_utorrent_style())
  20.      m_initialTracker = std::distance(m_control->begin(), m_control->focus());
  21.  
  22. -  // Don't reset the focus when we're requesting more peers. If we
  23. -  // want to query the next tracker in the list we need to remember
  24. -  // the current focus.
  25. -  if (m_isRequesting) {
  26. -    m_numRequests++;
  27. +  if (!info()->is_utorrent_style())
  28. +  {
  29. +    // Don't reset the focus when we're requesting more peers. If we
  30. +    // want to query the next tracker in the list we need to remember
  31. +    // the current focus.
  32. +    if (m_isRequesting) {
  33. +      m_numRequests++;
  34. +    } else {
  35. +      m_numRequests = 1;
  36. +      m_control->set_focus(m_control->begin());
  37. +    }
  38. +
  39. +    // Reset m_isRequesting so a new call to request_*() is needed to
  40. +    // try from the rest of the trackers in the list. If not called, the
  41. +    // next tracker request will reset the focus to the first tracker.
  42. +    m_isRequesting = false;
  43. +
  44. +    m_control->set_state(DownloadInfo::NONE);
  45. +    priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(m_control->focus_normal_interval())).round_seconds());
  46.    } else {
  47. -    m_numRequests = 1;
  48. -    m_control->set_focus(m_control->begin());
  49. +    if(m_control->focus_next_group()) {
  50. +      priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(10)).round_seconds());
  51. +    } else {
  52. +      m_control->set_focus(m_control->begin());
  53. +      priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(m_control->focus_normal_interval())).round_seconds());
  54. +    }
  55.    }
  56. -
  57. -  // Reset m_isRequesting so a new call to request_*() is needed to
  58. -  // try from the rest of the trackers in the list. If not called, the
  59. -  // next tracker request will reset the focus to the first tracker.
  60. -  m_isRequesting = false;
  61. -
  62. -  m_control->set_state(DownloadInfo::NONE);
  63. -  priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(m_control->focus_normal_interval())).round_seconds());
  64. -
  65.    m_slotSuccess(l);
  66.  }
  67.  
  68.  void
  69.  TrackerManager::receive_failed(const std::string& msg) {
  70. -  if (m_control->state() == DownloadInfo::STOPPED || !m_active)
  71. +  if ((m_control->state() == DownloadInfo::STOPPED || !m_active) && (!info()->is_utorrent_style())) // We need to sent STOPPED to other trackers
  72.      return m_slotFailed(msg);
  73.  
  74.    if (m_isRequesting) {
  75. @@ -306,7 +315,7 @@
  76.        priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(20)).round_seconds());
  77.      }
  78.  
  79. -  } else {
  80. +  } else if(!info()->is_utorrent_style()) {
  81.      // Normal retry.
  82.  
  83.      if (m_control->focus() == m_control->end()) {
  84. @@ -316,6 +325,16 @@
  85.      }
  86.      
  87.      priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(std::min<uint32_t>(600, 20 + 20 * m_failedRequests))).round_seconds());
  88. +  } else {
  89. +    if (m_control->focus() == m_control->end() && m_control->state()) {
  90. +      // Entire list covered, stop cycling now
  91. +      m_control->set_focus(m_control->begin());
  92. +      if (m_control->state() != DownloadInfo::STOPPED) {
  93. +        priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(m_control->focus_normal_interval())).round_seconds());
  94. +      }
  95. +    } else {
  96. +      priority_queue_insert(&taskScheduler, &m_taskTimeout, (cachedTime + rak::timer::from_seconds(10)).round_seconds());
  97. +    }
  98.    }
  99.  
  100.    m_slotFailed(msg);
  101. Index: src/download/download_main.cc
  102. ===================================================================
  103. --- src/download/download_main.cc       (revision 1087)
  104. +++ src/download/download_main.cc       (working copy)
  105. @@ -302,7 +302,7 @@
  106.  
  107.  void
  108.  DownloadMain::receive_tracker_success() {
  109. -  if (!info()->is_active())
  110. +  if (!info()->is_active() || info()->is_utorrent_style())
  111.      return;
  112.  
  113.    priority_queue_erase(&taskScheduler, &m_taskTrackerRequest);
  114. Index: src/download/download_info.h
  115. ===================================================================
  116. --- src/download/download_info.h        (revision 1087)
  117. +++ src/download/download_info.h        (working copy)
  118. @@ -78,6 +78,7 @@
  119.      m_isPrivate(false),
  120.      m_pexEnabled(true),
  121.      m_pexActive(true),
  122. +    m_isUtorrentStyle(false),
  123.  
  124.      m_upRate(60),
  125.      m_downRate(60),
  126. @@ -121,6 +122,9 @@
  127.  
  128.    bool                is_pex_active() const                        { return m_pexActive; }
  129.    void                set_pex_active(bool active)                  { m_pexActive = active; }
  130. +  
  131. +  bool                is_utorrent_style() const                    { return m_isUtorrentStyle; }
  132. +  void                set_utorrent_style(bool s)                   { m_isUtorrentStyle = s; }
  133.  
  134.    Rate*               up_rate()                                    { return &m_upRate; }
  135.    Rate*               down_rate()                                  { return &m_downRate; }
  136. @@ -167,6 +171,7 @@
  137.    bool                m_isPrivate;
  138.    bool                m_pexEnabled;
  139.    bool                m_pexActive;
  140. +  bool                m_isUtorrentStyle;
  141.  
  142.    Rate                m_upRate;
  143.    Rate                m_downRate;
Advertisement
Add Comment
Please, Sign In to add comment