[package] update libtorrent to r1093 (#5218)
authorFlorian Fainelli <florian@openwrt.org>
Wed, 27 May 2009 12:07:38 +0000 (12:07 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Wed, 27 May 2009 12:07:38 +0000 (12:07 +0000)
SVN-Revision: 16103

libs/libtorrent/Makefile
libs/libtorrent/patches/010-bencode_check_info_only.patch [new file with mode: 0644]
libs/libtorrent/patches/010-fix-dht_get_peers_crash.patch [deleted file]
libs/libtorrent/patches/011-pipe_size.patch [new file with mode: 0644]
libs/libtorrent/patches/100-fix-includes-for-gcc44.patch [deleted file]

index 06ee346..c8d7172 100644 (file)
@@ -9,9 +9,9 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=libtorrent
 
-PKG_REV:=1087
+PKG_REV:=1093
 PKG_VERSION:=0.12.4_r$(PKG_REV)
-PKG_RELEASE:=4
+PKG_RELEASE:=5
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=svn://rakshasa.no/libtorrent/trunk/libtorrent
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
@@ -38,10 +38,14 @@ define Package/libtorrent/description
  the speed of the official client.
 endef
 
-TARGET_CFLAGS += $(FPIC)
+ifneq ($(CONFIG_GCC_VERSION_3_4)$(CONFIG_GCC_VERSION_4_1),)
+TARGET_CPPFLAGS += -fno-strict-aliasing -fno-inline
+endif
+
+ifneq ($(CONFIG_GCC_VERSION_4_2)$(CONFIG_GCC_VERSION_4_3),)
+TARGET_CPPFLAGS += -fno-inline
+endif
 
-TARGET_CPPFLAGS +=  \
-       -fno-strict-aliasing -fno-inline \
 
 # XXX: rtorrent needs encryption (--enable-openssl)
 CONFIGURE_ARGS+= \
diff --git a/libs/libtorrent/patches/010-bencode_check_info_only.patch b/libs/libtorrent/patches/010-bencode_check_info_only.patch
new file mode 100644 (file)
index 0000000..6378969
--- /dev/null
@@ -0,0 +1,82 @@
+# Limit the unordered bencode dictionary check to the info dictionary and all its elements.
+Index: libtorrent/src/torrent/object.h
+===================================================================
+--- libtorrent/src/torrent/object.h    (revision 1093)
++++ libtorrent/src/torrent/object.h    (working copy)
+@@ -75,6 +75,8 @@
+   static const uint32_t mask_internal = 0xffff;
+   static const uint32_t mask_public   = ~mask_internal;
++  static const uint32_t flag_unordered = 0x100;    // bencode dictionary was not sorted
++
+   enum type_type {
+     TYPE_NONE,
+     TYPE_VALUE,
+@@ -109,6 +111,9 @@
+   void                set_flags(uint32_t f)                   { m_flags |= f & mask_public; }
+   void                unset_flags(uint32_t f)                 { m_flags &= ~(f & mask_public); }
++  void                set_internal_flags(uint32_t f)          { m_flags |= f & (mask_internal & ~mask_type); }
++  void                unset_internal_flags(uint32_t f)        { m_flags &= ~(f & (mask_internal & ~mask_type)); }
++
+   // Add functions for setting/clearing the public flags.
+   bool                is_value() const                        { return type() == TYPE_VALUE; }
+Index: libtorrent/src/torrent/object_stream.cc
+===================================================================
+--- libtorrent/src/torrent/object_stream.cc    (revision 1093)
++++ libtorrent/src/torrent/object_stream.cc    (working copy)
+@@ -96,6 +96,9 @@
+       Object::list_iterator itr = object->as_list().insert(object->as_list().end(), Object());
+       object_read_bencode(input, &*itr, depth);
++
++      if (itr->flags() & Object::flag_unordered)
++        object->set_internal_flags(Object::flag_unordered);
+     }
+     break;
+@@ -107,7 +110,7 @@
+     if (++depth >= 1024)
+       break;
+-    //    Object::string_type last;
++    Object::string_type last;
+     while (input->good()) {
+       if (input->peek() == 'e') {
+@@ -120,12 +123,16 @@
+       if (!object_read_string(input, str))
+       break;
+-      //      if (last >= str)
+-      //        break;
++      if (last >= str)
++        object->set_internal_flags(Object::flag_unordered);
+-      object_read_bencode(input, &object->as_map()[str], depth);
++      Object* value = &object->as_map()[str];
++      object_read_bencode(input, value, depth);
+-      //      str.swap(last);
++      if (value->flags() & Object::flag_unordered)
++        object->set_internal_flags(Object::flag_unordered);
++
++      str.swap(last);
+     }
+     break;
+Index: libtorrent/src/download/download_constructor.cc
+===================================================================
+--- libtorrent/src/download/download_constructor.cc    (revision 1093)
++++ libtorrent/src/download/download_constructor.cc    (working copy)
+@@ -132,6 +132,9 @@
+   if (!fileList->empty())
+     throw internal_error("parse_info received an already initialized Content object.");
++  if (b.flags() & Object::flag_unordered)
++    throw input_error("Download has unordered info dictionary.");
++
+   uint32_t chunkSize = b.get_key_value("piece length");
+   if (chunkSize <= (1 << 10) || chunkSize > (128 << 20))
diff --git a/libs/libtorrent/patches/010-fix-dht_get_peers_crash.patch b/libs/libtorrent/patches/010-fix-dht_get_peers_crash.patch
deleted file mode 100644 (file)
index 747d90a..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-# Fixes a crash when parsing a malformed get_peers (or find_node) response throws
-# an exception and fails to remove the corresponding transaction. Ticket #1622.
-Index: libtorrent/src/dht/dht_server.cc
-===================================================================
---- libtorrent/src/dht/dht_server.cc   (revision 1087)
-+++ libtorrent/src/dht/dht_server.cc   (working copy)
-@@ -335,36 +335,44 @@
-   m_repliesReceived++;
-   m_networkUp = true;
--  DhtTransaction* transaction = itr->second;
-+  // Make sure transaction is erased even if an exception is thrown.
-+  try {
-+    DhtTransaction* transaction = itr->second;
- #ifdef USE_EXTRA_DEBUG
--  if (DhtTransaction::key(sa, transactionId) != transaction->key(transactionId))
--    throw internal_error("DhtServer::process_response key mismatch.");
-+    if (DhtTransaction::key(sa, transactionId) != transaction->key(transactionId))
-+      throw internal_error("DhtServer::process_response key mismatch.");
- #endif
--  // If we contact a node but its ID is not the one we expect, ignore the reply
--  // to prevent interference from rogue nodes.
--  if ((id != transaction->id() && transaction->id() != m_router->zero_id))
--    return;
-+    // If we contact a node but its ID is not the one we expect, ignore the reply
-+    // to prevent interference from rogue nodes.
-+    if ((id != transaction->id() && transaction->id() != m_router->zero_id))
-+      return;
--  const Object& response = request.get_key("r");
-+    const Object& response = request.get_key("r");
--  switch (transaction->type()) {
--    case DhtTransaction::DHT_FIND_NODE:
--      parse_find_node_reply(transaction->as_find_node(), response.get_key_string("nodes"));
--      break;
-+    switch (transaction->type()) {
-+      case DhtTransaction::DHT_FIND_NODE:
-+        parse_find_node_reply(transaction->as_find_node(), response.get_key_string("nodes"));
-+        break;
--    case DhtTransaction::DHT_GET_PEERS:
--      parse_get_peers_reply(transaction->as_get_peers(), response);
--      break;
-+      case DhtTransaction::DHT_GET_PEERS:
-+        parse_get_peers_reply(transaction->as_get_peers(), response);
-+        break;
--    // Nothing to do for DHT_PING and DHT_ANNOUNCE_PEER
--    default:
--      break;
-+      // Nothing to do for DHT_PING and DHT_ANNOUNCE_PEER
-+      default:
-+        break;
-+    }
-+
-+    // Mark node responsive only if all processing was successful, without errors.
-+    m_router->node_replied(id, sa);
-+
-+  } catch (std::exception& e) {
-+    delete itr->second;
-+    m_transactions.erase(itr);
-+    throw;
-   }
--  // Mark node responsive only if all processing was successful, without errors.
--  m_router->node_replied(id, sa);
--
-   delete itr->second;
-   m_transactions.erase(itr);
- }
-@@ -611,7 +619,17 @@
-     else
-       transaction->as_find_node()->complete(false);
--    find_node_next(transaction->as_find_node());
-+    try {
-+      find_node_next(transaction->as_find_node());
-+
-+    } catch (std::exception& e) {
-+      if (!quick) {
-+        delete itr->second;
-+        m_transactions.erase(itr);
-+      }
-+
-+      throw;
-+    }
-   }
-   if (quick) {
diff --git a/libs/libtorrent/patches/011-pipe_size.patch b/libs/libtorrent/patches/011-pipe_size.patch
new file mode 100644 (file)
index 0000000..1a5b62a
--- /dev/null
@@ -0,0 +1,76 @@
+# Adjust number of pieces requested from peer if we're
+# uploading too slowly but downloading very fast so it exhausts the
+# queue before we finish sending a piece and can request more. See ticket #1302 - libtorrent.rakshasa.no
+Index: libtorrent/src/protocol/peer_connection_base.cc
+===================================================================
+--- libtorrent/src/protocol/peer_connection_base.cc    (revision 1060)
++++ libtorrent/src/protocol/peer_connection_base.cc    (working copy)
+@@ -783,8 +783,11 @@
+   if (download_queue()->queued_empty())
+     m_downStall = 0;
+-  uint32_t pipeSize = download_queue()->calculate_pipe_size(m_peerChunks.download_throttle()->rate()->rate());
++  uint32_t upRate = (!m_upChoke.choked() && !m_peerChunks.upload_queue()->empty()) ?
++                    m_peerChunks.upload_throttle()->rate()->rate() : 0;
++  uint32_t pipeSize = download_queue()->calculate_pipe_size(m_peerChunks.download_throttle()->rate()->rate(), upRate);
++
+   // Don't start requesting if we can't do it in large enough chunks.
+   if (download_queue()->queued_size() >= (pipeSize + 10) / 2)
+     return false;
+Index: libtorrent/src/protocol/request_list.cc
+===================================================================
+--- libtorrent/src/protocol/request_list.cc    (revision 1060)
++++ libtorrent/src/protocol/request_list.cc    (working copy)
+@@ -263,22 +263,30 @@
+ }
+ uint32_t
+-RequestList::calculate_pipe_size(uint32_t rate) {
++RequestList::calculate_pipe_size(uint32_t downRate, uint32_t upRate) {
++  // Compute how many pieces we will receive while transmitting one.
++  // Since we can't request during that time, make sure the pipe is
++  // big enough so it doesn't run dry.
++  if (upRate)
++    upRate = downRate / upRate;
++
+   // Change into KB.
+-  rate /= 1024;
++  downRate /= 1024;
+   if (!m_delegator->get_aggressive()) {
+-    if (rate < 20)
+-      return rate + 2;
++    if (downRate < 20)
++      downRate = downRate + 2;
+     else
+-      return rate / 5 + 18;
++      downRate = downRate / 5 + 18;
+   } else {
+-    if (rate < 10)
+-      return rate / 5 + 1;
++    if (downRate < 10)
++      downRate = downRate / 5 + 1;
+     else
+-      return rate / 10 + 2;
++      downRate = downRate / 10 + 2;
+   }
++
++  return std::max(downRate, 1 + upRate);
+ }
+ }
+Index: libtorrent/src/protocol/request_list.h
+===================================================================
+--- libtorrent/src/protocol/request_list.h     (revision 1060)
++++ libtorrent/src/protocol/request_list.h     (working copy)
+@@ -87,7 +87,7 @@
+   bool                 canceled_empty() const             { return m_canceled.empty(); }
+   size_t               canceled_size() const              { return m_queued.size(); }
+-  uint32_t             calculate_pipe_size(uint32_t rate);
++  uint32_t             calculate_pipe_size(uint32_t downRate, uint32_t upRate);
+   void                 set_delegator(Delegator* d)       { m_delegator = d; }
+   void                 set_peer_chunks(PeerChunks* b)    { m_peerChunks = b; }
diff --git a/libs/libtorrent/patches/100-fix-includes-for-gcc44.patch b/libs/libtorrent/patches/100-fix-includes-for-gcc44.patch
deleted file mode 100644 (file)
index 774b5fb..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-diff -urN libtorrent-0.12.4.orig/src/protocol/extensions.cc libtorrent-0.12.4/src/protocol/extensions.cc
---- libtorrent-0.12.4.orig/src/protocol/extensions.cc  2009-05-01 11:21:41.646024324 +0000
-+++ libtorrent-0.12.4/src/protocol/extensions.cc       2009-05-01 11:41:30.107790553 +0000
-@@ -39,6 +39,8 @@
- #include <limits>
- #include <sstream>
-+#include <cstdio>
-+
- #include "download/available_list.h"
- #include "download/download_main.h"
- #include "protocol/peer_connection_base.h"
-diff -urN libtorrent-0.12.4.orig/src/torrent/poll_epoll.cc libtorrent-0.12.4/src/torrent/poll_epoll.cc
---- libtorrent-0.12.4.orig/src/torrent/poll_epoll.cc   2009-05-01 11:21:41.656024827 +0000
-+++ libtorrent-0.12.4/src/torrent/poll_epoll.cc        2009-05-01 11:40:31.152785407 +0000
-@@ -38,6 +38,7 @@
- #include <cerrno>
- #include <cstring>
-+#include <cstdio>
- #include <unistd.h>
- #include <torrent/exceptions.h>
-diff -urN libtorrent-0.12.4.orig/src/tracker/tracker_dht.cc libtorrent-0.12.4/src/tracker/tracker_dht.cc
---- libtorrent-0.12.4.orig/src/tracker/tracker_dht.cc  2009-05-01 11:21:41.658024592 +0000
-+++ libtorrent-0.12.4/src/tracker/tracker_dht.cc       2009-05-01 11:41:43.124798870 +0000
-@@ -37,6 +37,7 @@
- #include "config.h"
- #include <sstream>
-+#include <cstdio>
- #include "dht/dht_router.h"
- #include "torrent/connection_manager.h"
-diff -urN libtorrent-0.12.4.orig/src/tracker/tracker_udp.cc libtorrent-0.12.4/src/tracker/tracker_udp.cc
---- libtorrent-0.12.4.orig/src/tracker/tracker_udp.cc  2009-05-01 11:21:41.658024592 +0000
-+++ libtorrent-0.12.4/src/tracker/tracker_udp.cc       2009-05-01 11:39:57.184784529 +0000
-@@ -38,6 +38,7 @@
- #include <sigc++/adaptors/bind.h>
- #include <torrent/connection_manager.h>
-+#include <cstdio>
- #include "download/download_info.h"
- #include "net/address_list.h"