This fixes a reproducible segmentation fault in rtorrent when you're
downloading a large amount of p^Wlinux distros. Can be triggered more
easily by decreasing the file descriptor limit. See description of the
fix in the patch.
Index: Makefile
===================================================================
RCS file: /srv/boron/data/vcs/cvs/openbsd/ports/net/libtorrent/Makefile,v
retrieving revision 1.25
diff -u -p -r1.25 Makefile
--- Makefile 26 Nov 2010 15:00:45 -0000 1.25
+++ Makefile 29 Jan 2011 00:24:49 -0000
@@ -3,6 +3,7 @@
COMMENT= BitTorrent library written in C++
DISTNAME= libtorrent-0.12.6
+REVISION= 0
SHARED_LIBS += torrent 17.0 # .11.6
CATEGORIES= net devel
Index: patches/patch-src_torrent_poll_kqueue_cc
===================================================================
RCS file:
/srv/boron/data/vcs/cvs/openbsd/ports/net/libtorrent/patches/patch-src_torrent_poll_kqueue_cc,v
retrieving revision 1.1
diff -u -p -r1.1 patch-src_torrent_poll_kqueue_cc
--- patches/patch-src_torrent_poll_kqueue_cc 25 Nov 2008 16:21:28 -0000
1.1
+++ patches/patch-src_torrent_poll_kqueue_cc 29 Jan 2011 00:21:01 -0000
@@ -1,6 +1,14 @@
$OpenBSD: patch-src_torrent_poll_kqueue_cc,v 1.1 2008/11/25 16:21:28 naddy Exp
$
---- src/torrent/poll_kqueue.cc.orig Tue Oct 28 04:48:48 2008
-+++ src/torrent/poll_kqueue.cc Sun Nov 23 21:17:59 2008
+
+The number of events is used to index an array of maxOpenSockets
+(file descriptors) elements. If there are less than fds than maxEvents,
+this will cause a segfault.
+
+Limit the number of events to the number of fds with an upper limit of
+maxEvents.
+
+--- src/torrent/poll_kqueue.cc.orig Thu Nov 12 09:03:58 2009
++++ src/torrent/poll_kqueue.cc Sat Jan 29 01:04:59 2011
@@ -37,6 +37,7 @@
#include "config.h"
@@ -9,3 +17,12 @@ $OpenBSD: patch-src_torrent_poll_kqueue_
#include <algorithm>
#include <unistd.h>
+@@ -115,7 +116,7 @@ PollKQueue::create(int maxOpenSockets) {
+
+ PollKQueue::PollKQueue(int fd, int maxEvents, int maxOpenSockets) :
+ m_fd(fd),
+- m_maxEvents(maxEvents),
++ m_maxEvents((maxOpenSockets < maxEvents) ? maxOpenSockets : maxEvents),
+ m_waitingEvents(0),
+ m_changedEvents(0),
+ m_stdinEvent(NULL) {