Index | Thread | Search

From:
"Anthony J. Bentley" <bentley@openbsd.org>
Subject:
(unfinished) UPDATE: net/rtorrent, net/libtorrent
To:
ports@openbsd.org
Cc:
kn@openbsd.org
Date:
Sat, 09 Nov 2024 08:45:27 -0700

Download raw body.

Thread
Hi,

I noticed recently that rtorrent in -current now segfaults on exit.
rtorrent and libtorrent haven't changed in some time, so it must be
some dependency that changed. There's a lot of curl in the backtrace,
so that's probably it.

Both rtorrent and libtorrent were updated in September. Unfortunately,
these have some weird issues (I count three).

Problem one: rtorrent no longer starts up, instead giving this error:

"Could not allocate socket for listening."

This is because SocketFd::open_stream() in libtorrent:src/net/socket_fd.cc 
now fails. Between 0.13.6 (what we have) and 0.14.0 (the new one), it
changed from:

bool
SocketFd::open_stream() {
  return (m_fd = socket(rak::socket_address::pf_inet, SOCK_STREAM, IPPROTO_TCP)) != -1;
}

to:

bool
SocketFd::open_stream() {
  m_fd = socket(rak::socket_address::pf_inet6, SOCK_STREAM, IPPROTO_TCP);

  if (m_fd == -1) {
    m_ipv6_socket = false;
    return (m_fd = socket(rak::socket_address::pf_inet, SOCK_STREAM, IPPROTO_TCP)) != -1;
  }

  m_ipv6_socket = true;

  if (!set_ipv6_v6only(false)) {
    close();
    return false;
  }

  return true;
}

Reverting to the older function gets past the error, but maybe that's
papering over something important, I don't know.

Problem two: the curl segfault still exists. This can be reproduced by
starting rtorrent, loading a torrent (waiting for hashing to finish if
necessary), then exiting with Ctrl-Q.

#0  thrkill () at /tmp/-:2
#1  0x1735af21d5d40e18 in ?? ()
#2  0x000002cf9684afeb in _libc_abort () at /usr/src/lib/libc/stdlib/abort.c:51
#3  0x000002ccdcd830a0 in do_panic (signum=11) at main.cc:634
#4  <signal handler called>
#5  torrent::thread_base::poll (this=0x80)
    at /usr/local/include/torrent/utils/thread_base.h:56
#6  core::CurlSocket::close (this=0x2cf145ff360) at core/curl_socket.cc:103
#7  core::CurlSocket::receive_socket (easy_handle=<optimized out>, 
    fd=<optimized out>, what=<optimized out>, userp=<optimized out>, 
    socketp=0x2cf145ff360) at core/curl_socket.cc:62
#8  0x000002cf4770ebac in Curl_multi_closed (data=0x2cef06cd000, s=15)
    at multi.c:3035
#9  0x000002cf476c66fe in socket_close (data=0x2cef06cd000, 
    conn=0x2cf4d283000, sock=15, use_callback=<optimized out>)
    at cf-socket.c:424
#10 cf_socket_close (cf=0x2cf6ebe9d80, data=0x2cef06cd000) at cf-socket.c:1005
#11 0x000002cf476cee12 in cf_he_close (cf=<optimized out>, data=0x2cef06cd000)
    at connect.c:1004
#12 0x000002cf4774598e in ssl_cf_close (cf=0x2cf145f8cf0, data=0x2cef06cd000)
    at vtls/vtls.c:1666
#13 0x000002cf476cf816 in cf_setup_close (cf=<optimized out>, 
    data=0x2cef06cd000) at connect.c:1359
--Type <RET> for more, q to quit, c to continue without paging--
#14 0x000002cf476c5280 in cf_hc_close (cf=<optimized out>, data=0x2cef06cd000)
    at cf-https-connect.c:496
#15 0x000002cf476c90df in Curl_conn_close (data=0x2cef06cd000, index=0)
    at cfilters.c:180
#16 0x000002cf476cc762 in cpool_close_and_destroy (cpool=<optimized out>, 
    conn=0x2cf4d283000, data=0x2cef06cd000, do_shutdown=<optimized out>)
    at conncache.c:1063
#17 0x000002cf476cb5e2 in cpool_shutdown_discard_all (cpool=0x2cf45b95b70)
    at conncache.c:641
#18 cpool_shutdown_all (cpool=0x2cf45b95b70, data=<optimized out>, 
    timeout_ms=0) at conncache.c:1195
#19 cpool_close_and_destroy_all (cpool=0x2cf45b95b70) at conncache.c:679
#20 Curl_cpool_destroy (cpool=0x2cf45b95b70) at conncache.c:189
#21 0x000002cf4770b57b in curl_multi_cleanup (multi=0x2cf45b95a00)
    at multi.c:2758
#22 0x000002ccdcda49c5 in core::CurlStack::~CurlStack (this=0x2cf12c3e640)
    at core/curl_stack.cc:72
#23 0x000002ccdcd9dfec in core::Manager::cleanup (this=<optimized out>)
    at core/manager.cc:199
#24 0x000002ccdce5e284 in Control::cleanup (this=0x2cf45b93600)
    at control.cc:140
#25 0x000002ccdcd825d6 in main (argc=2, argv=0x73be2ad77d38) at main.cc:500


The last problem is that once a torrent has been loaded, it doesn't seem
to actually download (or, presumably, upload). Maybe this is a result of
patching out problem #1. But right now, I'm feeling stuck and not making
more progress, so here's the diff I have so far.


--- net/libtorrent/Makefile
+++ net/libtorrent/Makefile
@@ -6,9 +6,8 @@ BROKEN-sh =		undefined references to __sync atomic ops
 # requires C++ tr1 headers
 NOT_FOR_ARCHS=		${GCC3_ARCHS}
 
-DISTNAME=		libtorrent-0.13.6
+DISTNAME=		libtorrent-0.14.0
 EPOCH=			0
-REVISION=		9
 SHARED_LIBS +=  	torrent 22.1	# .18.0
 CATEGORIES=		net devel
 
@@ -17,16 +16,16 @@ HOMEPAGE=		https://rakshasa.github.io/rtorrent/
 # GPLv2
 PERMIT_PACKAGE=	Yes
 
-SITES=			https://rtorrent.net/downloads/
+SITES=			https://github.com/rakshasa/rtorrent-archive/raw/master/
 
-WANTLIB=		crypto m pthread ${COMPILER_LIBCXX} z
+WANTLIB=		crypto cppunit m pthread ${COMPILER_LIBCXX} z
 
 COMPILER =		base-clang ports-gcc base-gcc
 
-BUILD_DEPENDS=		devel/cppunit
+LIB_DEPENDS=		devel/cppunit
 
 CONFIGURE_STYLE=	autoconf
-AUTOCONF_VERSION=	2.69
+AUTOCONF_VERSION=	2.71
 CONFIGURE_ARGS=		--enable-static \
 			--with-kqueue \
 			--without-epoll \
@@ -36,11 +35,4 @@ CONFIGURE_ARGS=		--enable-static \
 
 DEBUG_PACKAGES =	${BUILD_PACKAGES}
 
-CXXFLAGS +=		-std=c++11
-
-# this patches *only* files containing tr1 to no longer refer to tr1
-# we do it pre-patch, because autoconf passes right after us
-pre-patch:
-	find ${WRKDIST} -type f -exec fgrep -lw tr1 {} + | \
-		xargs sed -i.bak -e 's,<tr1/,<,' -e 's/std::tr1/std/g'
 .include <bsd.port.mk>
blob - f6339dfff0ccd1187874c327e5db0c082ac9ba5b
blob + f1c2cc37bba066850f8faa784ebfc1f147a6629f
--- net/libtorrent/distinfo
+++ net/libtorrent/distinfo
@@ -1,2 +1,2 @@
-SHA256 (libtorrent-0.13.6.tar.gz) = KDigjJbt/ZNq/4+/mey7kwwr/KMzfdFILrX8zbgNWgQ=
-SIZE (libtorrent-0.13.6.tar.gz) = 781253
+SHA256 (libtorrent-0.14.0.tar.gz) = F7gW2lgHx7NFWhpIqujazw9O91saQ3LHWJSHEAZv0+w=
+SIZE (libtorrent-0.14.0.tar.gz) = 809617
blob - 1d794314bb81dca3de70c12d5851fe6f525f48f4 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_data_memory_chunk_cc
+++ /dev/null
@@ -1,14 +0,0 @@
-Index: src/data/memory_chunk.cc
---- src/data/memory_chunk.cc.orig
-+++ src/data/memory_chunk.cc
-@@ -54,6 +54,10 @@ extern "C" int madvise(void *, size_t, int);
- 
- namespace torrent {
- 
-+const int MemoryChunk::sync_sync;
-+const int MemoryChunk::sync_async;
-+const int MemoryChunk::sync_invalidate;
-+
- uint32_t MemoryChunk::m_pagesize = getpagesize();
- 
- inline void
blob - 600a6216dd8a7ff4dfbde7de35fef1544b829372 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_net_socket_set_h
+++ /dev/null
@@ -1,23 +0,0 @@
-clang can't accept a "generic" void* allocator because value_type doesn't
-match.  FreeBSD has the same patch.
-
-
-Index: src/net/socket_set.h
---- src/net/socket_set.h.orig
-+++ src/net/socket_set.h
-@@ -53,12 +53,12 @@ namespace torrent {
- 
- // Propably should rename to EventSet...
- 
--class SocketSet : private std::vector<Event*, rak::cacheline_allocator<> > {
-+class SocketSet : private std::vector<Event*, rak::cacheline_allocator<Event*> > {
- public:
-   typedef uint32_t    size_type;
- 
--  typedef std::vector<Event*, rak::cacheline_allocator<> > base_type;
--  typedef std::vector<size_type, rak::cacheline_allocator<> > Table;
-+  typedef std::vector<Event*, rak::cacheline_allocator<Event*> > base_type;
-+  typedef std::vector<size_type, rak::cacheline_allocator<size_type> > Table;
- 
-   static const size_type npos = static_cast<size_type>(-1);
- 
blob - /dev/null
blob + 38412f6631c20a8c97fd58477f7908ca8ef636aa (mode 644)
--- /dev/null
+++ net/libtorrent/patches/patch-src_torrent_net_socket_address_key_h
@@ -0,0 +1,11 @@
+Index: src/torrent/net/socket_address_key.h
+--- src/torrent/net/socket_address_key.h.orig
++++ src/torrent/net/socket_address_key.h
+@@ -7,6 +7,7 @@
+ #include <cstring>
+ #include <cinttypes>
+ #include <netinet/in.h>
++#include <sys/socket.h>
+ 
+ // Unique key for the socket address, excluding port numbers, etc.
+ 
blob - cb0e9beff860891303fa3ff4e5c8724f95cb76c6 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_protocol_extensions_cc
+++ /dev/null
@@ -1,23 +0,0 @@
-# https://github.com/rakshasa/libtorrent/pull/99/files
-
-Index: src/protocol/extensions.cc
---- src/protocol/extensions.cc.orig	2015-08-08 17:01:32.000000000 +0200
-+++ src/protocol/extensions.cc	2017-12-02 01:46:38.522736000 +0100
-@@ -394,7 +394,7 @@
-   if (m_download->info()->is_meta_download() || piece >= pieceEnd) {
-     // reject: { "msg_type" => 2, "piece" => ... }
-     m_pendingType = UT_METADATA;
--    m_pending = build_bencode(40, "d8:msg_typei2e5:piecei%zuee", piece);
-+    m_pending = build_bencode(sizeof(size_t) + 36, "d8:msg_typei2e5:piecei%zuee", piece);
-     return;
-   }
- 
-@@ -407,7 +407,7 @@
-   // data: { "msg_type" => 1, "piece" => ..., "total_size" => ... } followed by piece data (outside of dictionary)
-   size_t length = piece == pieceEnd - 1 ? m_download->info()->metadata_size() % metadata_piece_size : metadata_piece_size;
-   m_pendingType = UT_METADATA;
--  m_pending = build_bencode(length + 128, "d8:msg_typei1e5:piecei%zue10:total_sizei%zuee", piece, metadataSize);
-+  m_pending = build_bencode((2 * sizeof(size_t)) + length + 120, "d8:msg_typei1e5:piecei%zue10:total_sizei%zuee", piece, metadataSize);
- 
-   memcpy(m_pending.end(), buffer + (piece << metadata_piece_shift), length);
-   m_pending.set(m_pending.data(), m_pending.end() + length, m_pending.owned());
blob - 1233e981fcbb5f72e9eb2955621635e77c489a00 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_protocol_handshake_cc
+++ /dev/null
@@ -1,14 +0,0 @@
-# https://github.com/rakshasa/libtorrent/pull/99/files
-
-Index: src/protocol/handshake.cc
---- src/protocol/handshake.cc.orig	2015-08-08 17:01:49.000000000 +0200
-+++ src/protocol/handshake.cc	2017-12-02 01:46:38.523093000 +0100
-@@ -738,7 +738,7 @@
-         break;
- 
-       if (m_readBuffer.remaining() > m_encryption.length_ia())
--        throw internal_error("Read past initial payload after incoming encrypted handshake.");
-+        throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_value);
- 
-       if (m_encryption.crypto() != HandshakeEncryption::crypto_rc4)
-         m_encryption.info()->set_obfuscated();
blob - 903d95986de957dd463c7ad8ed18050f0c503513 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_protocol_request_list_cc
+++ /dev/null
@@ -1,11 +0,0 @@
-Index: src/protocol/request_list.cc
---- src/protocol/request_list.cc.orig
-+++ src/protocol/request_list.cc
-@@ -52,6 +52,7 @@
- 
- namespace torrent {
- 
-+const int request_list_constants::bucket_count;
- const instrumentation_enum request_list_constants::instrumentation_added[bucket_count] = {
-   INSTRUMENTATION_TRANSFER_REQUESTS_QUEUED_ADDED,
-   INSTRUMENTATION_TRANSFER_REQUESTS_UNORDERED_ADDED,
blob - 74edf78a381012b936625c0e75951331c3632e9a
blob + ee8bcde135a4487f64407af72205ef4b9123647a
--- net/libtorrent/patches/patch-src_torrent_common_h
+++ net/libtorrent/patches/patch-src_torrent_common_h
@@ -3,7 +3,7 @@ comment says it all
 Index: src/torrent/common.h
 --- src/torrent/common.h.orig
 +++ src/torrent/common.h
-@@ -109,4 +109,15 @@ class TransferList;
+@@ -112,4 +112,15 @@ class TransferList;
  
  }
  
blob - b529a5a6e9343f7ed6423b7f6771bcdc4af5df05 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_torrent_data_block_failed_h
+++ /dev/null
@@ -1,16 +0,0 @@
-const reference has no useful semantics, shut up clang warning
-
-Index: src/torrent/data/block_failed.h
---- src/torrent/data/block_failed.h.orig
-+++ src/torrent/data/block_failed.h
-@@ -85,8 +85,8 @@ class BlockFailed : public std::vector<std::pair<char*
-   BlockFailed(const BlockFailed&);
-   void operator = (const BlockFailed&);
- 
--  static void         delete_entry(const reference e)                         { delete [] e.first; }
--  static bool         compare_entries(const reference e1, const reference e2) { return e1.second < e2.second; }
-+  static void         delete_entry(reference e)                         { delete [] e.first; }
-+  static bool         compare_entries(reference e1, reference e2) { return e1.second < e2.second; }
- 
-   size_type           m_current;
- };
blob - 0c6d8582e4d10e9e3307fc58bde972642cd85a82 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_torrent_data_file_cc
+++ /dev/null
@@ -1,19 +0,0 @@
-Index: src/torrent/data/file.cc
---- src/torrent/data/file.cc.orig
-+++ src/torrent/data/file.cc
-@@ -50,6 +50,15 @@
- 
- namespace torrent {
- 
-+const int File::flag_active;
-+const int File::flag_create_queued;
-+const int File::flag_resize_queued;
-+const int File::flag_fallocate;
-+const int File::flag_previously_created;
-+
-+const int File::flag_prioritize_first;
-+const int File::flag_prioritize_last;
-+
- File::File() :
-   m_fd(-1),
-   m_protection(0),
blob - 44a0e6b56a7874edfd7857b80025117e84a38f59 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_torrent_data_transfer_list_cc
+++ /dev/null
@@ -1,12 +0,0 @@
-Index: src/torrent/data/transfer_list.cc
---- src/torrent/data/transfer_list.cc.orig
-+++ src/torrent/data/transfer_list.cc
-@@ -159,7 +159,7 @@ TransferList::hash_succeeded(uint32_t index, Chunk* ch
- struct transfer_list_compare_data {
-   transfer_list_compare_data(Chunk* chunk, const Piece& p) : m_chunk(chunk), m_piece(p) { }
- 
--  bool operator () (const BlockFailed::reference failed) {
-+  bool operator () (BlockFailed::reference failed) {
-     return m_chunk->compare_buffer(failed.first, m_piece.offset(), m_piece.length());
-   }
- 
blob - 8d2d14c06f094f23f46c9cebd7b549de2de04da5 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_torrent_download_cc
+++ /dev/null
@@ -1,24 +0,0 @@
-Index: src/torrent/download.cc
---- src/torrent/download.cc.orig
-+++ src/torrent/download.cc
-@@ -72,6 +72,20 @@
- 
- namespace torrent {
- 
-+const int DownloadInfo::flag_open LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_active LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_compact LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_accepting_new_peers LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_accepting_seeders LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_private LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_meta_download LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_pex_enabled LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_pex_active LIBTORRENT_EXPORT;
-+
-+const int DownloadInfo::public_flags;
-+
-+const uint32_t DownloadInfo::unlimited;
-+
- const DownloadInfo* Download::info() const { return m_ptr->info(); }
- const download_data* Download::data() const { return m_ptr->data(); }
- 
blob - 19bcd8a7f288675939fae3322fb7e2050fdaad6e (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_torrent_object_stream_cc
+++ /dev/null
@@ -1,15 +0,0 @@
-# https://github.com/rakshasa/libtorrent/pull/99/files
-
-Index: src/torrent/object_stream.cc
---- src/torrent/object_stream.cc.orig	2015-08-08 17:01:32.000000000 +0200
-+++ src/torrent/object_stream.cc	2017-12-02 01:46:38.523350000 +0100
-@@ -104,7 +104,8 @@
-   while (first != last && *first >= '0' && *first <= '9')
-     length = length * 10 + (*first++ - '0');
- 
--  if (length + 1 > (unsigned int)std::distance(first, last) || *first++ != ':')
-+  if (length + 1 > (unsigned int)std::distance(first, last) || *first++ != ':'
-+		  || length + 1 == 0)
-     throw torrent::bencode_error("Invalid bencode data.");
-   
-   return raw_string(first, length);
blob - dae8ba4f674cf0b7015210ef363c3f114f8c9936 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_torrent_peer_connection_list_cc
+++ /dev/null
@@ -1,15 +0,0 @@
-Index: src/torrent/peer/connection_list.cc
---- src/torrent/peer/connection_list.cc.orig
-+++ src/torrent/peer/connection_list.cc
-@@ -60,6 +60,11 @@
- 
- namespace torrent {
- 
-+const int ConnectionList::disconnect_available;
-+const int ConnectionList::disconnect_quick;
-+const int ConnectionList::disconnect_unwanted;
-+const int ConnectionList::disconnect_delayed;
-+
- ConnectionList::ConnectionList(DownloadMain* download) :
-   m_download(download), m_minSize(50), m_maxSize(100) {
- }
blob - fd88bd8eef820f1b9e802237fc94b10b477818f8 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_torrent_utils_extents_h
+++ /dev/null
@@ -1,17 +0,0 @@
-assign/fill difference, see header
-
-Index: src/torrent/utils/extents.h
---- src/torrent/utils/extents.h.orig
-+++ src/torrent/utils/extents.h
-@@ -51,9 +51,9 @@ struct extents_base {
-   typedef std::array<mapped_type, TableSize> table_type;
-   
-   extents_base(key_type pos, unsigned int mb, mapped_value_type val) :
--    mask_bits(mb), position(pos) { table.assign(mapped_type(NULL, mapped_value_type())); }
-+    mask_bits(mb), position(pos) { fill_with_value(table, mapped_type(NULL, mapped_value_type())); }
-   extents_base(extents_base* parent, typename table_type::const_iterator itr) :
--    mask_bits(parent->mask_bits - TableBits), position(parent->partition_pos(itr)) { table.assign(mapped_type(NULL, itr->second)); }
-+    mask_bits(parent->mask_bits - TableBits), position(parent->partition_pos(itr)) { fill_with_value(table, mapped_type(NULL, itr->second)); }
-   ~extents_base();
- 
-   bool         is_divisible(key_type key) const { return key % mask_bits == 0; }
blob - 20b02052d2f26422e08320d1c44a37550c32c72f (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_torrent_utils_log_cc
+++ /dev/null
@@ -1,39 +0,0 @@
-can't figure out the functional magic, so just do the algorithm by hand.
-
-Index: src/torrent/utils/log.cc
---- src/torrent/utils/log.cc.orig
-+++ src/torrent/utils/log.cc
-@@ -187,17 +187,14 @@ log_group::internal_print(const HashString* hash, cons
-     return;
- 
-   pthread_mutex_lock(&log_mutex);
--  std::for_each(m_first, m_last, std::bind(&log_slot::operator(),
--                                                std::placeholders::_1,
--                                                buffer,
--                                                std::distance(buffer, first),
--                                                std::distance(log_groups.begin(), this)));
-+
-+  for (log_slot *it = m_first; it != m_last; ++it)
-+  	(*it)(buffer, std::distance(buffer, first),
-+		std::distance(log_groups.begin(), this));
-+
-   if (dump_data != NULL)
--    std::for_each(m_first, m_last, std::bind(&log_slot::operator(),
--                                                  std::placeholders::_1,
--                                                  (const char*)dump_data,
--                                                  dump_size,
--                                                  -1));
-+      for (log_slot *it = m_first; it != m_last; ++it)
-+      	(*it)((const char*)dump_data, dump_size, -1);
-   pthread_mutex_unlock(&log_mutex);
- }
- 
-@@ -250,7 +247,7 @@ void
- log_cleanup() {
-   pthread_mutex_lock(&log_mutex);
- 
--  log_groups.assign(log_group());
-+  fill_with_value(log_groups, log_group());
-   log_outputs.clear();
-   log_children.clear();
- 
blob - acee48b04bf439ee6fa5d291706e13df781f1403 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_torrent_utils_net_h
+++ /dev/null
@@ -1,13 +0,0 @@
-Add missing include.
-
-Index: src/torrent/utils/net.h
---- src/torrent/utils/net.h.orig
-+++ src/torrent/utils/net.h
-@@ -37,6 +37,7 @@
- #ifndef LIBTORRENT_UTILS_NET_H
- #define LIBTORRENT_UTILS_NET_H
- 
-+#include <sys/socket.h>
- #include <netdb.h>
- #include <functional>
- 
blob - e505c6f51aacfa40142b816c987cdef6e1f1cfeb (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_utils_diffie_hellman_cc
+++ /dev/null
@@ -1,39 +0,0 @@
-Fix build with opaque DH in LibreSSL 3.5.
-
-Index: src/utils/diffie_hellman.cc
---- src/utils/diffie_hellman.cc.orig
-+++ src/utils/diffie_hellman.cc
-@@ -53,9 +53,11 @@ DiffieHellman::DiffieHellman(const unsigned char *prim
-   m_secret(NULL), m_size(0) {
- 
- #ifdef USE_OPENSSL
-+  BIGNUM *p, *g;
-   m_dh = DH_new();
--  m_dh->p = BN_bin2bn(prime, primeLength, NULL);
--  m_dh->g = BN_bin2bn(generator, generatorLength, NULL);
-+  p = BN_bin2bn(prime, primeLength, NULL);
-+  g = BN_bin2bn(generator, generatorLength, NULL);
-+  DH_set0_pqg(m_dh, p, NULL, g);
- 
-   DH_generate_key(m_dh);
- #else
-@@ -73,7 +75,7 @@ DiffieHellman::~DiffieHellman() {
- bool
- DiffieHellman::is_valid() const {
- #ifdef USE_OPENSSL
--  return m_dh != NULL && m_dh->pub_key != NULL;
-+  return m_dh != NULL && DH_get0_pub_key(m_dh) != NULL;
- #else
-   return false;
- #endif
-@@ -102,8 +104,8 @@ DiffieHellman::store_pub_key(unsigned char* dest, unsi
- #ifdef USE_OPENSSL
-   std::memset(dest, 0, length);
- 
--  if ((int)length >= BN_num_bytes(m_dh->pub_key))
--    BN_bn2bin(m_dh->pub_key, dest + length - BN_num_bytes(m_dh->pub_key));
-+  if ((int)length >= BN_num_bytes(DH_get0_pub_key(m_dh)))
-+    BN_bn2bin(DH_get0_pub_key(m_dh), dest + length - BN_num_bytes(DH_get0_pub_key(m_dh)));
- #endif
- }
- 
blob - 917a9fd772e90e0a6c4abe1a5fc3416213e543a2 (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_utils_instrumentation_h
+++ /dev/null
@@ -1,14 +0,0 @@
-tr1/std  difference, see header
-
-Index: src/utils/instrumentation.h
---- src/utils/instrumentation.h.orig
-+++ src/utils/instrumentation.h
-@@ -118,7 +118,7 @@ void instrumentation_reset();
- 
- inline void
- instrumentation_initialize() {
--  instrumentation_values.assign(int64_t());
-+  fill_with_value(instrumentation_values, int64_t());
- }
- 
- inline void
blob - 72b23e955f0df995fa0378e208e24f8f00d99e4f (mode 644)
blob + /dev/null
--- net/libtorrent/patches/patch-src_utils_queue_buckets_h
+++ /dev/null
@@ -1,14 +0,0 @@
-proper typing, from FreeBSD
-
-Index: src/utils/queue_buckets.h
---- src/utils/queue_buckets.h.orig
-+++ src/utils/queue_buckets.h
-@@ -251,7 +251,7 @@ queue_buckets<Type, Constants>::destroy(int idx, itera
-   instrumentation_update(constants::instrumentation_total[idx], -difference);
- 
-   // Consider moving these to a temporary dequeue before releasing:
--  std::for_each(begin, end, std::function<void (value_type)>(&constants::template destroy<value_type>));
-+  std::for_each(begin, end, std::function<void (value_type&)>(&constants::template destroy<value_type>));
-   queue_at(idx).erase(begin, end);
- }
- 
blob - 17f0240c04fbf3724158aaceb448d403ff1c4161
blob + 8d8b1a45e1ac7d58ea8722fd142cc4ba0b65558e
--- net/libtorrent/patches/patch-test_Makefile_in
+++ net/libtorrent/patches/patch-test_Makefile_in
@@ -1,11 +1,30 @@
---- test/Makefile.in.orig	Thu Sep 10 20:12:55 2015
-+++ test/Makefile.in	Thu Sep 10 20:13:00 2015
-@@ -644,7 +644,7 @@ LibTorrentTest_SOURCES = \
- 	main.cc
+Index: test/Makefile.in
+--- test/Makefile.in.orig
++++ test/Makefile.in
+@@ -675,19 +675,19 @@ LibTorrent_Test_SOURCES = $(LibTorrent_Test_Common) \
+ 	protocol/test_request_list.h
  
- LibTorrentTest_CXXFLAGS = $(CPPUNIT_CFLAGS)
--LibTorrentTest_LDFLAGS = $(CPPUNIT_LIBS)  -ldl
-+LibTorrentTest_LDFLAGS = $(CPPUNIT_LIBS)
+ LibTorrent_Test_Torrent_Net_CXXFLAGS = $(CPPUNIT_CFLAGS)
+-LibTorrent_Test_Torrent_Net_LDFLAGS = $(CPPUNIT_LIBS) -ldl
++LibTorrent_Test_Torrent_Net_LDFLAGS = $(CPPUNIT_LIBS)
+ LibTorrent_Test_Torrent_Utils_CXXFLAGS = $(CPPUNIT_CFLAGS)
+-LibTorrent_Test_Torrent_Utils_LDFLAGS = $(CPPUNIT_LIBS) -ldl
++LibTorrent_Test_Torrent_Utils_LDFLAGS = $(CPPUNIT_LIBS)
+ LibTorrent_Test_Torrent_CXXFLAGS = $(CPPUNIT_CFLAGS)
+-LibTorrent_Test_Torrent_LDFLAGS = $(CPPUNIT_LIBS) -ldl
++LibTorrent_Test_Torrent_LDFLAGS = $(CPPUNIT_LIBS)
+ LibTorrent_Test_Data_CXXFLAGS = $(CPPUNIT_CFLAGS)
+-LibTorrent_Test_Data_LDFLAGS = $(CPPUNIT_LIBS) -ldl
++LibTorrent_Test_Data_LDFLAGS = $(CPPUNIT_LIBS)
+ LibTorrent_Test_Net_CXXFLAGS = $(CPPUNIT_CFLAGS)
+-LibTorrent_Test_Net_LDFLAGS = $(CPPUNIT_LIBS) -ldl
++LibTorrent_Test_Net_LDFLAGS = $(CPPUNIT_LIBS)
+ LibTorrent_Test_Tracker_CXXFLAGS = $(CPPUNIT_CFLAGS)
+-LibTorrent_Test_Tracker_LDFLAGS = $(CPPUNIT_LIBS) -ldl
++LibTorrent_Test_Tracker_LDFLAGS = $(CPPUNIT_LIBS)
+ LibTorrent_Test_CXXFLAGS = $(CPPUNIT_CFLAGS)
+-LibTorrent_Test_LDFLAGS = $(CPPUNIT_LIBS) -ldl
++LibTorrent_Test_LDFLAGS = $(CPPUNIT_LIBS)
  AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/src
  all: all-am
  
blob - c326932eca398fa673d83184f5abbfc7cc9e2d90
blob + b28873216ae115249103a3af29a6c2e59b72c55b
--- net/libtorrent/pkg/PLIST
+++ net/libtorrent/pkg/PLIST
@@ -30,6 +30,14 @@ include/torrent/event.h
 include/torrent/exceptions.h
 include/torrent/hash_string.h
 include/torrent/http.h
+include/torrent/net/
+include/torrent/net/address_info.h
+include/torrent/net/fd.h
+include/torrent/net/socket_address.h
+include/torrent/net/socket_address_key.h
+include/torrent/net/socket_event.h
+include/torrent/net/types.h
+include/torrent/net/utils.h
 include/torrent/object.h
 include/torrent/object_raw_bencode.h
 include/torrent/object_static_map.h
@@ -54,16 +62,17 @@ include/torrent/tracker.h
 include/torrent/tracker_controller.h
 include/torrent/tracker_list.h
 include/torrent/utils/
+include/torrent/utils/directory_events.h
 include/torrent/utils/extents.h
 include/torrent/utils/log.h
 include/torrent/utils/log_buffer.h
-include/torrent/utils/net.h
 include/torrent/utils/option_strings.h
 include/torrent/utils/ranges.h
 include/torrent/utils/resume.h
 include/torrent/utils/signal_bitfield.h
 include/torrent/utils/thread_base.h
 include/torrent/utils/thread_interrupt.h
+include/torrent/utils/uri_parser.h
 @static-lib lib/libtorrent.a
 lib/libtorrent.la
 @lib lib/libtorrent.so.${LIBtorrent_VERSION}
blob - f27e2bb9ece80c7e3b3a2eaadd868a2bc28ad33e
blob + 78e8d13ec0f245efe9c307e2f110559340a1ddba
--- net/rtorrent/Makefile
+++ net/rtorrent/Makefile
@@ -1,7 +1,6 @@
 COMMENT=		ncurses BitTorrent client based on libTorrent
 
-DISTNAME=		rtorrent-0.9.6
-REVISION=		8
+DISTNAME=		rtorrent-0.10.0
 EPOCH=			0
 CATEGORIES=		net
 
@@ -13,22 +12,23 @@ PERMIT_PACKAGE=	Yes
 WANTLIB += ${COMPILER_LIBCXX} c crypto curl curses m nghttp2 pthread
 WANTLIB += ssl torrent>=21 z
 
-COMPILER =		base-clang ports-gcc base-gcc
+COMPILER =		base-clang ports-gcc
 
-SITES=			https://rtorrent.net/downloads/
+SITES=			https://github.com/rakshasa/rtorrent-archive/raw/master/
 
 BUILD_DEPENDS=		devel/cppunit
 LIB_DEPENDS=		net/libtorrent>=0.13.4 \
 			net/curl
 
 CONFIGURE_STYLE=	autoconf
-AUTOCONF_VERSION=	2.69
-CONFIGURE_ENV +=	LDFLAGS=-pthread
+AUTOCONF_VERSION=	2.71
+CONFIGURE_ENV +=	LDFLAGS="-pthread -lexecinfo"
 CONFIGURE_ARGS=		--disable-debug
 
 DEBUG_PACKAGES =	${BUILD_PACKAGES}
 
-CXXFLAGS +=		-std=c++11
+# uses std::bind2nd which was removed in c++17
+CXXFLAGS +=		-std=c++14
 
 post-install:
 	${INSTALL_DATA_DIR} ${PREFIX}/share/doc/rtorrent
@@ -36,10 +36,4 @@ post-install:
 	${INSTALL_DATA} ${WRKSRC}/doc/rtorrent.rc \
 		${PREFIX}/share/examples/rtorrent/rtorrent.rc
 
-# this patches *only* files containing tr1 to no longer refer to tr1
-# we do it pre-patch, because autoconf passes right after us
-pre-patch:
-	find ${WRKDIST} -type f -exec fgrep -lw tr1 {} + | \
-		xargs sed -i.bak -e 's,<tr1/,<,' -e 's/std::tr1/std/g' -e 's/tr1::placeholders::/std::placeholders::/g' -e 's/tr1::bind/std::bind/g'
-
 .include <bsd.port.mk>
blob - 656bb923ccfe3eab815d525820a8eb10f349b66c
blob + 3877044ee6a2a6f242c83183245b3c58dc1ac9d1
--- net/rtorrent/distinfo
+++ net/rtorrent/distinfo
@@ -1,2 +1,2 @@
-SHA256 (rtorrent-0.9.6.tar.gz) = HmnCTx8m+PB9WNZzSA3Dkr/EMXgYwRFSZbCKeBP/Ww4=
-SIZE (rtorrent-0.9.6.tar.gz) = 610845
+SHA256 (rtorrent-0.10.0.tar.gz) = zGW7p6vq0kFR8QrxFuyiNCsMMg/f88uNYEwK8JIV06o=
+SIZE (rtorrent-0.10.0.tar.gz) = 402931
blob - afcef3329c1734be5c93435557fbfbc4a23a5f75 (mode 644)
blob + /dev/null
--- net/rtorrent/patches/patch-src_core_manager_cc
+++ /dev/null
@@ -1,15 +0,0 @@
-Index: src/core/manager.cc
---- src/core/manager.cc.orig
-+++ src/core/manager.cc
-@@ -74,6 +74,11 @@
- 
- namespace core {
- 
-+const int Manager::create_start;
-+const int Manager::create_tied;
-+const int Manager::create_quiet;
-+const int Manager::create_raw_data;
-+
- void
- Manager::push_log(const char* msg) {
-   m_log_important->lock_and_push_log(msg, strlen(msg), 0);
blob - 3209662dd6bb5093299d0babfc241f3e1242358e
blob + 680d0b60a5c3aa15dd3e044dd377889a708145b7
--- net/rtorrent/patches/patch-src_display_window_file_list_cc
+++ net/rtorrent/patches/patch-src_display_window_file_list_cc
@@ -1,7 +1,7 @@
 Index: src/display/window_file_list.cc
 --- src/display/window_file_list.cc.orig
 +++ src/display/window_file_list.cc
-@@ -41,6 +41,7 @@
+@@ -42,6 +42,7 @@
  #include <torrent/data/file.h>
  #include <torrent/data/file_list.h>
  #include <torrent/data/file_list_iterator.h>
blob - f5a98ad02d7effbdb957252ec242764279007f16 (mode 644)
blob + /dev/null
--- net/rtorrent/patches/patch-src_rpc_exec_file_cc
+++ /dev/null
@@ -1,18 +0,0 @@
-Index: src/rpc/exec_file.cc
---- src/rpc/exec_file.cc.orig
-+++ src/rpc/exec_file.cc
-@@ -52,6 +52,14 @@ namespace rpc {
- 
- // Close m_logFd.
- 
-+const unsigned int ExecFile::max_args;
-+const unsigned int ExecFile::buffer_size;
-+
-+const int ExecFile::flag_expand_tilde;
-+const int ExecFile::flag_throw;
-+const int ExecFile::flag_capture;
-+const int ExecFile::flag_background;
-+
- int
- ExecFile::execute(const char* file, char* const* argv, int flags) {
-   // Write the execued command and its parameters to the log fd.
blob - 35c8ef00f66731bcd2cdec791870fca93580149f (mode 644)
blob + /dev/null
--- net/rtorrent/patches/patch-src_rpc_object_storage_cc
+++ /dev/null
@@ -1,27 +0,0 @@
-Index: src/rpc/object_storage.cc
---- src/rpc/object_storage.cc.orig
-+++ src/rpc/object_storage.cc
-@@ -44,6 +44,23 @@
- 
- namespace rpc {
- 
-+const unsigned int object_storage::flag_generic_type;
-+const unsigned int object_storage::flag_bool_type;
-+const unsigned int object_storage::flag_value_type;
-+const unsigned int object_storage::flag_string_type;
-+const unsigned int object_storage::flag_list_type;
-+const unsigned int object_storage::flag_function_type;
-+const unsigned int object_storage::flag_multi_type;
-+
-+const unsigned int object_storage::mask_type;
-+
-+const unsigned int object_storage::flag_constant;
-+const unsigned int object_storage::flag_static;
-+const unsigned int object_storage::flag_private;
-+const unsigned int object_storage::flag_rlookup;
-+
-+const size_t object_storage::key_size;
-+
- object_storage::local_iterator
- object_storage::find_local(const torrent::raw_string& key) {
-   std::size_t n = hash_fixed_key_type::hash(key.data(), key.size()) % bucket_count();
blob - 5f9dd66d8c5bf5f7231a74f9f355a2ada96991e7 (mode 644)
blob + /dev/null
--- net/rtorrent/patches/patch-src_signal_handler_cc
+++ /dev/null
@@ -1,11 +0,0 @@
-Index: src/signal_handler.cc
---- src/signal_handler.cc.orig
-+++ src/signal_handler.cc
-@@ -38,6 +38,7 @@
- 
- #include <signal.h>
- #include <stdexcept>
-+#include <string>
- #include "rak/error_number.h"
- #include "signal_handler.h"
- 
blob - 57ecaf671f5f67560f8457fdbb8bc196d84389e6
blob + 7f9f8a5d3e4132aed85e18daef13922926596899
--- net/rtorrent/patches/patch-test_Makefile_in
+++ net/rtorrent/patches/patch-test_Makefile_in
@@ -1,8 +1,9 @@
 Unbreak build.
 
---- test/Makefile.in.orig	Thu Sep 10 20:20:28 2015
-+++ test/Makefile.in	Thu Sep 10 20:20:33 2015
-@@ -561,7 +561,7 @@ rtorrentTest_SOURCES = \
+Index: test/Makefile.in
+--- test/Makefile.in.orig
++++ test/Makefile.in
+@@ -582,7 +582,7 @@ rtorrentTest_SOURCES = \
  	main.cc
  
  rtorrentTest_CXXFLAGS = $(CPPUNIT_CFLAGS)
--- /dev/null
+++ net/libtorrent/patches/patch-src_net_socket_fd_cc
@@ -0,0 +1,26 @@
+Index: src/net/socket_fd.cc
+--- src/net/socket_fd.cc.orig
++++ src/net/socket_fd.cc
+@@ -126,21 +126,7 @@ SocketFd::get_error() const {
+ 
+ bool
+ SocketFd::open_stream() {
+-  m_fd = socket(rak::socket_address::pf_inet6, SOCK_STREAM, IPPROTO_TCP);
+-
+-  if (m_fd == -1) {
+-    m_ipv6_socket = false;
+-    return (m_fd = socket(rak::socket_address::pf_inet, SOCK_STREAM, IPPROTO_TCP)) != -1;
+-  }
+-
+-  m_ipv6_socket = true;
+-
+-  if (!set_ipv6_v6only(false)) {
+-    close();
+-    return false;
+-  }
+-
+-  return true;
++  return (m_fd = socket(rak::socket_address::pf_inet, SOCK_STREAM, IPPROTO_TCP)) != -1;
+ }
+ 
+ bool