components/libtorrent/patches/rlibtorrent-05-tracker-usable.patch
changeset 6932 ae9e3811b2ec
parent 6931 f6f7269f85a9
child 6933 e1fa2aa7bad7
equal deleted inserted replaced
6931:f6f7269f85a9 6932:ae9e3811b2ec
     1 --- libtorrent-0.12.2.orig/src/torrent/tracker_list.cc	2008-07-01 22:21:49.641937000 -0400
       
     2 +++ libtorrent-0.12.2/src/torrent/tracker_list.cc	2008-07-01 22:22:08.525804085 -0400
       
     3 @@ -66,14 +66,9 @@
       
     4    return m_itr != end() && (*m_itr)->is_busy();
       
     5  }
       
     6  
       
     7 -// Need a custom predicate because the is_usable function is virtual.
       
     8 -struct tracker_usable_t : public std::unary_function<TrackerList::value_type, bool> {
       
     9 -  bool operator () (const TrackerList::value_type& value) const { return value->is_usable(); }
       
    10 -};
       
    11 -
       
    12  bool
       
    13  TrackerList::has_usable() const {
       
    14 -  return std::find_if(begin(), end(), tracker_usable_t()) != end();
       
    15 +  return find_usable(begin()) != end();
       
    16  }
       
    17  
       
    18  void
       
    19 @@ -90,6 +85,8 @@
       
    20  
       
    21    set_state(s);
       
    22    m_itr = find_usable(m_itr);
       
    23 +  if (m_itr == end())
       
    24 +    m_itr = find_usable(begin());
       
    25  
       
    26    if (m_itr != end())
       
    27      (*m_itr)->send_state(state());
       
    28 @@ -134,18 +131,12 @@
       
    29  
       
    30  TrackerList::iterator
       
    31  TrackerList::find_usable(iterator itr) {
       
    32 -  while (itr != end() && !tracker_usable_t()(*itr))
       
    33 -    ++itr;
       
    34 -
       
    35 -  return itr;
       
    36 +  return std::find_if(itr, end(), std::mem_fun(&Tracker::is_usable));
       
    37  }
       
    38  
       
    39  TrackerList::const_iterator
       
    40  TrackerList::find_usable(const_iterator itr) const {
       
    41 -  while (itr != end() && !tracker_usable_t()(*itr))
       
    42 -    ++itr;
       
    43 -
       
    44 -  return itr;
       
    45 +  return std::find_if(itr, end(), std::mem_fun(&Tracker::is_usable));
       
    46  }
       
    47  
       
    48  TrackerList::iterator