Changeset 1062

Show
Ignore:
Timestamp:
07/05/08 08:13:12 (4 years ago)
Author:
rakshasa
Message:

* Fix a slight memory leak in peer exchanges. Patch by Josef Drexler.

* Fixed mix-up in version numbers causing an incompatibility for .so
libraries. Patch by Josef Drexler for ticket #1333.

* Fix excessive HAVE messages being sent after handshake when download
has been active for a while. Patch by Josef Drexler for ticket #1372.

* Make --enable-ipv6 not break DHT on Mac OS X. Patch by Josef Drexler
for ticket #1359.

* Fix crash when contacting tracker. Patch by Josef Drexler for ticket
#1272.

* Fix stopping downloads not working properly. Patch by Josef Drexler
for ticket #1335.

Location:
trunk
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/libtorrent/configure.ac

    r1060 r1062  
    66 
    77LIBTORRENT_CURRENT=11 
    8 LIBTORRENT_REVISION=0 
    9 LIBTORRENT_AGE=2 
     8LIBTORRENT_REVISION=2 
     9LIBTORRENT_AGE=0 
    1010 
    1111LIBTORRENT_INTERFACE_VERSION_INFO=$LIBTORRENT_CURRENT:$LIBTORRENT_REVISION:$LIBTORRENT_AGE 
  • trunk/libtorrent/src/download/download_main.h

    r1058 r1062  
    111111  void                set_download_throttle(ThrottleList* t)     { m_downloadThrottle = t; } 
    112112 
    113   DataBuffer          get_ut_pex(bool initial)                   { return initial ? m_ut_pex_initial : m_ut_pex_delta; } 
     113  DataBuffer          get_ut_pex(bool initial)                   { return (initial ? m_ut_pex_initial : m_ut_pex_delta).clone(); } 
    114114 
    115115  bool                want_pex_msg()                             { return m_info->is_pex_active() && m_peerList.available_list()->want_more(); };  
  • trunk/libtorrent/src/net/data_buffer.h

    r980 r1062  
    4545// Recipient must call clear() when done with the buffer. 
    4646struct DataBuffer { 
    47   DataBuffer()                        : m_data(NULL), m_end(NULL), m_copied(false) {} 
    48   DataBuffer(char* data, char* end)   : m_data(data), m_end(end),  m_copied(false) {} 
     47  DataBuffer()                        : m_data(NULL), m_end(NULL), m_owned(true) {} 
     48  DataBuffer(char* data, char* end)   : m_data(data), m_end(end),  m_owned(true) {} 
     49 
     50  DataBuffer          clone() const        { DataBuffer d = *this; d.m_owned = false; return d; } 
    4951 
    5052  char*               data() const         { return m_data; } 
    5153  char*               end() const          { return m_end; } 
    5254 
    53   bool                copied() const       { return m_copied; } 
     55  bool                owned() const        { return m_owned; } 
    5456  bool                empty() const        { return m_data == NULL; } 
    5557  size_t              length() const       { return m_end - m_data; } 
    5658 
    5759  void                clear(); 
    58   void                set(char* data, char* end, bool copied); 
     60  void                set(char* data, char* end, bool owned); 
    5961 
    6062private: 
     
    6264  char*               m_end; 
    6365 
    64   // Used to indicate if buffer held by PCB is copied and needs to be 
    65   // deleted after transmission. 
    66   bool                m_copied; 
     66  // Used to indicate if buffer held by PCB is its own and needs to be 
     67  // deleted after transmission (false if shared with other connections). 
     68  bool                m_owned; 
    6769}; 
    6870 
     
    7375 
    7476  m_data = m_end = NULL; 
    75   m_copied = false; 
     77  m_owned = false; 
    7678} 
    7779 
    7880inline void 
    79 DataBuffer::set(char* data, char* end, bool copied) { 
     81DataBuffer::set(char* data, char* end, bool owned) { 
    8082  m_data = data; 
    8183  m_end = end; 
    82   m_copied = copied; 
     84  m_owned = owned; 
    8385} 
    8486 
  • trunk/libtorrent/src/net/socket_datagram.cc

    r939 r1062  
    7474 
    7575  if (sa != NULL) { 
    76     r = ::sendto(m_fileDesc, buffer, length, 0, sa->c_sockaddr(), sizeof(rak::socket_address)); 
     76    r = ::sendto(m_fileDesc, buffer, length, 0, sa->sa_inet()->c_sockaddr(), sizeof(rak::socket_address_inet)); 
    7777  } else { 
    7878    r = ::send(m_fileDesc, buffer, length, 0); 
  • trunk/libtorrent/src/protocol/handshake.cc

    r1058 r1062  
    8787  m_downloadThrottle(manager->download_throttle()->throttle_list()), 
    8888 
    89   m_initializedTime(cachedTime), 
    90  
    9189  m_readDone(false), 
    9290  m_writeDone(false), 
     
    525523    write_extension_handshake(); 
    526524 
     525  // Replay HAVE messages we receive after starting to send the bitfield. 
     526  // This avoids replaying HAVEs for pieces received between starting the 
     527  // handshake and now (e.g. when connecting takes longer). Ideally we 
     528  // should make a snapshot of the bitfield here in case it changes while 
     529  // we're sending it (if it can't be sent in one write() call). 
     530  m_initializedTime = cachedTime; 
     531 
    527532  // The download is just starting so we're not sending any 
    528533  // bitfield. Pretend we wrote it already. 
  • trunk/libtorrent/src/protocol/handshake_manager.cc

    r1058 r1062  
    209209                                                               &download->info()->hash()); 
    210210 
     211    pcb->peer_chunks()->set_have_timer(handshake->initialized_time()); 
     212 
    211213    if (handshake->unread_size() != 0) { 
    212214      if (handshake->unread_size() > PeerConnectionBase::ProtocolRead::buffer_size) 
     
    214216 
    215217      pcb->push_unread(handshake->unread_data(), handshake->unread_size()); 
    216       pcb->peer_chunks()->set_have_timer(handshake->initialized_time()); 
    217  
    218218      pcb->event_read(); 
    219219    } 
  • trunk/libtorrent/src/protocol/peer_connection_base.cc

    r1032 r1062  
    9393    delete m_extensions; 
    9494 
    95   if (m_extensionMessage.copied()) 
     95  if (m_extensionMessage.owned()) 
    9696    m_extensionMessage.clear(); 
    9797} 
     
    666666PeerConnectionBase::up_extension() { 
    667667  if (m_extensionOffset == extension_must_encrypt) { 
    668     if (m_extensionMessage.copied()) { 
     668    if (m_extensionMessage.owned()) { 
    669669      m_encryption.encrypt(m_extensionMessage.data(), m_extensionMessage.length()); 
    670670 
     
    691691  // clear() deletes the buffer, only do that if we made a copy, 
    692692  // otherwise the buffer is shared among all connections. 
    693   if (m_extensionMessage.copied()) 
     693  if (m_extensionMessage.owned()) 
    694694    m_extensionMessage.clear(); 
    695695  else  
  • trunk/libtorrent/src/tracker/tracker_manager.cc

    r1030 r1062  
    115115    throw internal_error("TrackerManager::send_later() m_control->set() == DownloadInfo::STOPPED."); 
    116116 
     117  rak::timer t(std::max(cachedTime + rak::timer::from_seconds(2), 
     118                        rak::timer::from_seconds(m_control->time_last_connection() + m_control->focus_min_interval()))); 
     119 
    117120  priority_queue_erase(&taskScheduler, &m_taskTimeout); 
    118   priority_queue_insert(&taskScheduler, &m_taskTimeout, rak::timer::from_seconds(m_control->time_last_connection() + m_control->focus_min_interval())); 
     121  priority_queue_insert(&taskScheduler, &m_taskTimeout, t); 
    119122} 
    120123 
  • trunk/rtorrent/src/main.cc

    r1051 r1062  
    188188 
    189189       "view_add = started\n" 
    190        "view_filter = started,false=\n" 
     190       "view_filter = started,d.get_state=\n" 
    191191       "view.event_added = started,scheduler.simple.added=\n" 
    192192       "view.event_removed = started,scheduler.simple.removed=\n" 
    193193 
    194194       "view_add = stopped\n" 
    195        "view_filter = stopped,false=\n" 
     195       "view_filter = stopped,not=$d.get_state=\n" 
    196196 
    197197       "view_add = complete\n"