SOURCES: libtorrent-fix_have_timer.patch (NEW), libtorrent-fix_pex_leak.pat...

adamg adamg at pld-linux.org
Fri Jul 18 22:33:49 CEST 2008


Author: adamg                        Date: Fri Jul 18 20:33:49 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- new

---- Files affected:
SOURCES:
   libtorrent-fix_have_timer.patch (NONE -> 1.1)  (NEW), libtorrent-fix_pex_leak.patch (NONE -> 1.1)  (NEW), libtorrent-fix_write_datagram.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/libtorrent-fix_have_timer.patch
diff -u /dev/null SOURCES/libtorrent-fix_have_timer.patch:1.1
--- /dev/null	Fri Jul 18 22:33:49 2008
+++ SOURCES/libtorrent-fix_have_timer.patch	Fri Jul 18 22:33:43 2008
@@ -0,0 +1,47 @@
+Index: libtorrent/src/protocol/handshake_manager.cc
+===================================================================
+--- libtorrent/src/protocol/handshake_manager.cc	(revision 1060)
++++ libtorrent/src/protocol/handshake_manager.cc	(working copy)
+@@ -208,13 +208,13 @@
+                                                                e_none,
+                                                                &download->info()->hash());
+ 
++    pcb->peer_chunks()->set_have_timer(handshake->initialized_time());
++
+     if (handshake->unread_size() != 0) {
+       if (handshake->unread_size() > PeerConnectionBase::ProtocolRead::buffer_size)
+         throw internal_error("HandshakeManager::receive_succeeded(...) Unread data won't fit PCB's read buffer.");
+ 
+       pcb->push_unread(handshake->unread_data(), handshake->unread_size());
+-      pcb->peer_chunks()->set_have_timer(handshake->initialized_time());
+-
+       pcb->event_read();
+     }
+ 
+Index: libtorrent/src/protocol/handshake.cc
+===================================================================
+--- libtorrent/src/protocol/handshake.cc	(revision 1060)
++++ libtorrent/src/protocol/handshake.cc	(working copy)
+@@ -86,8 +86,6 @@
+   m_uploadThrottle(manager->upload_throttle()->throttle_list()),
+   m_downloadThrottle(manager->download_throttle()->throttle_list()),
+ 
+-  m_initializedTime(cachedTime),
+-
+   m_readDone(false),
+   m_writeDone(false),
+ 
+@@ -524,6 +522,13 @@
+   if (m_peerInfo->supports_extensions())
+     write_extension_handshake();
+ 
++  // Replay HAVE messages we receive after starting to send the bitfield.
++  // This avoids replaying HAVEs for pieces received between starting the
++  // handshake and now (e.g. when connecting takes longer). Ideally we
++  // should make a snapshot of the bitfield here in case it changes while
++  // we're sending it (if it can't be sent in one write() call).
++  m_initializedTime = cachedTime;
++
+   // The download is just starting so we're not sending any
+   // bitfield. Pretend we wrote it already.
+   if (m_download->file_list()->bitfield()->is_all_unset() || m_download->initial_seeding() != NULL) {

================================================================
Index: SOURCES/libtorrent-fix_pex_leak.patch
diff -u /dev/null SOURCES/libtorrent-fix_pex_leak.patch:1.1
--- /dev/null	Fri Jul 18 22:33:50 2008
+++ SOURCES/libtorrent-fix_pex_leak.patch	Fri Jul 18 22:33:43 2008
@@ -0,0 +1,102 @@
+Index: libtorrent/src/net/data_buffer.h
+===================================================================
+--- libtorrent/src/net/data_buffer.h	(revision 1026)
++++ libtorrent/src/net/data_buffer.h	(working copy)
+@@ -44,26 +44,28 @@
+ 
+ // Recipient must call clear() when done with the buffer.
+ struct DataBuffer {
+-  DataBuffer()                        : m_data(NULL), m_end(NULL), m_copied(false) {}
+-  DataBuffer(char* data, char* end)   : m_data(data), m_end(end),  m_copied(false) {}
++  DataBuffer()                        : m_data(NULL), m_end(NULL), m_owned(true) {}
++  DataBuffer(char* data, char* end)   : m_data(data), m_end(end),  m_owned(true) {}
+ 
++  DataBuffer          clone() const        { DataBuffer d = *this; d.m_owned = false; return d; }
++
+   char*               data() const         { return m_data; }
+   char*               end() const          { return m_end; }
+ 
+-  bool                copied() const       { return m_copied; }
++  bool                owned() const        { return m_owned; }
+   bool                empty() const        { return m_data == NULL; }
+   size_t              length() const       { return m_end - m_data; }
+ 
+   void                clear();
+-  void                set(char* data, char* end, bool copied);
++  void                set(char* data, char* end, bool owned);
+ 
+ private:
+   char*               m_data;
+   char*               m_end;
+ 
+-  // Used to indicate if buffer held by PCB is copied and needs to be
+-  // deleted after transmission.
+-  bool                m_copied;
++  // Used to indicate if buffer held by PCB is its own and needs to be
++  // deleted after transmission (false if shared with other connections).
++  bool                m_owned;
+ };
+ 
+ inline void
+@@ -72,14 +74,14 @@
+     delete[] m_data;
+ 
+   m_data = m_end = NULL;
+-  m_copied = false;
++  m_owned = false;
+ }
+ 
+ inline void
+-DataBuffer::set(char* data, char* end, bool copied) {
++DataBuffer::set(char* data, char* end, bool owned) {
+   m_data = data;
+   m_end = end;
+-  m_copied = copied;
++  m_owned = owned;
+ }
+ 
+ }
+Index: libtorrent/src/protocol/peer_connection_base.cc
+===================================================================
+--- libtorrent/src/protocol/peer_connection_base.cc	(revision 1026)
++++ libtorrent/src/protocol/peer_connection_base.cc	(working copy)
+@@ -92,7 +92,7 @@
+   if (m_extensions != NULL && !m_extensions->is_default())
+     delete m_extensions;
+ 
+-  if (m_extensionMessage.copied())
++  if (m_extensionMessage.owned())
+     m_extensionMessage.clear();
+ }
+ 
+@@ -665,7 +665,7 @@
+ bool
+ PeerConnectionBase::up_extension() {
+   if (m_extensionOffset == extension_must_encrypt) {
+-    if (m_extensionMessage.copied()) {
++    if (m_extensionMessage.owned()) {
+       m_encryption.encrypt(m_extensionMessage.data(), m_extensionMessage.length());
+ 
+     } else {
+@@ -690,7 +690,7 @@
+ 
+   // clear() deletes the buffer, only do that if we made a copy,
+   // otherwise the buffer is shared among all connections.
+-  if (m_extensionMessage.copied())
++  if (m_extensionMessage.owned())
+     m_extensionMessage.clear();
+   else 
+     m_extensionMessage.set(NULL, NULL, false);
+Index: libtorrent/src/download/download_main.h
+===================================================================
+--- libtorrent/src/download/download_main.h	(revision 1026)
++++ libtorrent/src/download/download_main.h	(working copy)
+@@ -105,7 +105,7 @@
+   ThrottleList*       download_throttle()                        { return m_downloadThrottle; }
+   void                set_download_throttle(ThrottleList* t)     { m_downloadThrottle = t; }
+ 
+-  DataBuffer          get_ut_pex(bool initial)                   { return initial ? m_ut_pex_initial : m_ut_pex_delta; }
++  DataBuffer          get_ut_pex(bool initial)                   { return (initial ? m_ut_pex_initial : m_ut_pex_delta).clone(); }
+ 
+   bool                want_pex_msg()                             { return m_info->is_pex_active() && m_peerList.available_list()->want_more(); }; 
+ 

================================================================
Index: SOURCES/libtorrent-fix_write_datagram.patch
diff -u /dev/null SOURCES/libtorrent-fix_write_datagram.patch:1.1
--- /dev/null	Fri Jul 18 22:33:50 2008
+++ SOURCES/libtorrent-fix_write_datagram.patch	Fri Jul 18 22:33:43 2008
@@ -0,0 +1,13 @@
+Index: libtorrent/src/net/socket_datagram.cc
+===================================================================
+--- libtorrent/src/net/socket_datagram.cc	(revision 1060)
++++ libtorrent/src/net/socket_datagram.cc	(working copy)
+@@ -73,7 +73,7 @@
+   int r;
+ 
+   if (sa != NULL) {
+-    r = ::sendto(m_fileDesc, buffer, length, 0, sa->c_sockaddr(), sizeof(rak::socket_address));
++    r = ::sendto(m_fileDesc, buffer, length, 0, sa->sa_inet()->c_sockaddr(), sizeof(rak::socket_address_inet));
+   } else {
+     r = ::send(m_fileDesc, buffer, length, 0);
+   }
================================================================


More information about the pld-cvs-commit mailing list