[csw-devel] SF.net SVN: gar:[9996] csw/mgar/pkg/rtorrent/trunk

dmichelsen at users.sourceforge.net dmichelsen at users.sourceforge.net
Wed May 26 18:01:02 CEST 2010


Revision: 9996
          http://gar.svn.sourceforge.net/gar/?rev=9996&view=rev
Author:   dmichelsen
Date:     2010-05-26 16:01:01 +0000 (Wed, 26 May 2010)

Log Message:
-----------
rtorrent: Add patches from jh

Modified Paths:
--------------
    csw/mgar/pkg/rtorrent/trunk/Makefile
    csw/mgar/pkg/rtorrent/trunk/checksums

Added Paths:
-----------
    csw/mgar/pkg/rtorrent/trunk/files/0001-build-fixes.patch
    csw/mgar/pkg/rtorrent/trunk/files/0001-curl_get.patch
    csw/mgar/pkg/rtorrent/trunk/files/0001-more-build-fixes.patch
    csw/mgar/pkg/rtorrent/trunk/files/0001-more-build-fixes2.patch
    csw/mgar/pkg/rtorrent/trunk/files/0001-scgi_task.cc.patch
    csw/mgar/pkg/rtorrent/trunk/files/rtorrent-01-solaris.diff
    csw/mgar/pkg/rtorrent/trunk/files/rtorrent-02-event-ports.diff
    csw/mgar/pkg/rtorrent/trunk/files/rtorrent-03-curl-event.diff
    csw/mgar/pkg/rtorrent/trunk/files/rtorrent-04-sunpro.diff
    csw/mgar/pkg/rtorrent/trunk/files/rtorrent-05-sunpro-crash.diff
    csw/mgar/pkg/rtorrent/trunk/files/scratch.patch
    csw/mgar/pkg/rtorrent/trunk/files/work-around-UNUSED.patch

Modified: csw/mgar/pkg/rtorrent/trunk/Makefile
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/Makefile	2010-05-26 15:31:17 UTC (rev 9995)
+++ csw/mgar/pkg/rtorrent/trunk/Makefile	2010-05-26 16:01:01 UTC (rev 9996)
@@ -2,26 +2,36 @@
 GARVERSION = 0.8.6
 CATEGORIES = apps
 
-DESCRIPTION = BitTorrent client.
+DESCRIPTION = Client for Unix, based on libtorrent 
 define BLURB
-  BitTorrent library written in C++ for *nix, with a focus on high performance and good code.
-  The library differentiates itself from other implementations by transfering directly from
-  file pages to the network stack. On high-bandwidth connections it is able to seed at 3 times
-  the speed of the official client. 
 endef
 
 MASTER_SITES = http://libtorrent.rakshasa.no/downloads/
 DISTFILES  = $(GARNAME)-$(GARVERSION).tar.gz
 
-RUNTIME_DEP_PKGS = CSWlibtorrent
-
 # We define upstream file regex so we can be notifed of new upstream software release
 UFILES_REGEX = $(GARNAME)-(\d+(?:\.\d+)*).tar.gz
 
-# If the url used to check for software update is different of MASTER_SITES, then 
-# uncomment the next line. Otherwise it is set by default to the value of MASTER_SITES
-# UPSTREAM_MASTER_SITES = 
+# Patches mostly from http://cr.opensolaris.org/~alz/bittorrent/raw_files/new/usr/src/cmd/rtorrent/
+PATCHFILES = rtorrent-01-solaris.diff 0001-curl_get.patch rtorrent-04-sunpro.diff 
+PATCHFILES += 0001-scgi_task.cc.patch rtorrent-05-sunpro-crash.diff work-around-UNUSED.patch 0001-build-fixes.patch
+PATCHFILES += 0001-more-build-fixes.patch 0001-more-build-fixes2.patch
 
-CONFIGURE_ARGS = $(DIRPATHS)
+EXTRA_CXXFLAGS = -D_RWSTD_ALLOCATOR -mt
+EXTRA_LDFLAGS  = -Wl,-zignore -Wl,-zcombreloc -Wl,-Bdirect
 
+CONFIGURE_ARGS = $(DIRPATHS) --disable-debug
+TEST_TARGET = check
+
 include gar/category.mk
+
+pre-configure-modulated:
+	cd $(WORKSRC) && aclocal-1.10 -I scripts && \
+  automake-1.10 --gnu && autoconf
+
+	$(MAKECOOKIE)
+
+
+#post-configure-modulated:
+#	perl -pi -e 's,\|-xarch=,|-norunpath|-xarch=,' $(WORKSRC)/libtool
+#	@$(MAKECOOKIE)

Modified: csw/mgar/pkg/rtorrent/trunk/checksums
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/checksums	2010-05-26 15:31:17 UTC (rev 9995)
+++ csw/mgar/pkg/rtorrent/trunk/checksums	2010-05-26 16:01:01 UTC (rev 9996)
@@ -1 +1,10 @@
+5fc8cb994a9878260814dd91cecb2bc4  0001-build-fixes.patch
+22451ae5516b8a5895152f2bff431879  0001-curl_get.patch
+04aee1b334f244111c1c17a60eda827d  0001-more-build-fixes.patch
+dbff5b0805244cf116e6c8a943e798eb  0001-more-build-fixes2.patch
+7490ec79bf9ab3fbc440af8798813da4  0001-scgi_task.cc.patch
 b804c45c01c40312926bcea6b55bb084  rtorrent-0.8.6.tar.gz
+b6545f8cb3978a2a9c7d08e69c261a2e  rtorrent-01-solaris.diff
+9c15ff7d338b93bb14ceef55e50e35da  rtorrent-04-sunpro.diff
+c9eb081ca192b5c4c222e6f0a6d5b2ae  rtorrent-05-sunpro-crash.diff
+373359da311cec3fe678ea55df5354c3  work-around-UNUSED.patch

Added: csw/mgar/pkg/rtorrent/trunk/files/0001-build-fixes.patch
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/files/0001-build-fixes.patch	                        (rev 0)
+++ csw/mgar/pkg/rtorrent/trunk/files/0001-build-fixes.patch	2010-05-26 16:01:01 UTC (rev 9996)
@@ -0,0 +1,107 @@
+From 425fc5065dd4cc6f0b450ce7864f437eace4e82c Mon Sep 17 00:00:00 2001
+From: Jan Holzhueter <jh at testing9s.bo.opencsw.org>
+Date: Mon, 24 May 2010 13:41:29 +0200
+Subject: [PATCH] build-fixes
+
+---
+ src/core/download_list.cc       |    1 +
+ src/core/poll_manager.cc        |    1 +
+ src/display/attributes.h        |    2 +-
+ src/display/window_file_list.cc |    3 ++-
+ src/input/bindings.h            |    2 +-
+ src/input/input_event.cc        |    2 +-
+ src/rpc/command_function.cc     |    1 +
+ 7 files changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/src/core/download_list.cc b/src/core/download_list.cc
+index 551f873..52bac0e 100644
+--- a/src/core/download_list.cc
++++ b/src/core/download_list.cc
+@@ -37,6 +37,7 @@
+ #include "config.h"
+ 
+ #include <algorithm>
++#include <rak/algorithm.h>
+ #include <iostream>
+ #include <sigc++/adaptors/bind.h>
+ #include <rak/functional.h>
+diff --git a/src/core/poll_manager.cc b/src/core/poll_manager.cc
+index 90df840..458fef5 100644
+--- a/src/core/poll_manager.cc
++++ b/src/core/poll_manager.cc
+@@ -37,6 +37,7 @@
+ #include "config.h"
+ 
+ #include <stdexcept>
++#include <unistd.h>
+ #include <rak/error_number.h>
+ 
+ #include "globals.h"
+diff --git a/src/display/attributes.h b/src/display/attributes.h
+index a4dcfa5..67245af 100644
+--- a/src/display/attributes.h
++++ b/src/display/attributes.h
+@@ -39,7 +39,7 @@
+ 
+ #include <string>
+ #include <vector>
+-#include <ncurses.h>
++#include <ncursesw/ncurses.h>
+ 
+ // Let us hail the creators of curses for being idiots. The only
+ // clever move they made was in the naming.
+diff --git a/src/display/window_file_list.cc b/src/display/window_file_list.cc
+index 540f493..9596f49 100644
+--- a/src/display/window_file_list.cc
++++ b/src/display/window_file_list.cc
+@@ -61,7 +61,8 @@ WindowFileList::WindowFileList(const ui::ElementFileList* element) :
+ // taking into account that some characters may be occupying two screen positions.
+ std::wstring
+ wstring_width(const std::string& i_str, int width) {
+-  wchar_t result[width + 1];
++  //wchar_t result[width + 1];
++  wchar_t* result = new wchar_t[width + 1];
+   size_t length = std::mbstowcs(result, i_str.c_str(), width);
+ 
+   // If not valid UTF-8 encoding, at least copy the printable characters.
+diff --git a/src/input/bindings.h b/src/input/bindings.h
+index 8b200db..657a513 100644
+--- a/src/input/bindings.h
++++ b/src/input/bindings.h
+@@ -38,7 +38,7 @@
+ #define RTORRENT_INPUT_BINDINGS_H
+ 
+ #include <map>
+-#include <ncurses.h>
++#include <ncursesw/ncurses.h>
+ #include <sigc++/functors/slot.h>
+ 
+ namespace input {
+diff --git a/src/input/input_event.cc b/src/input/input_event.cc
+index ce3078a..300269e 100644
+--- a/src/input/input_event.cc
++++ b/src/input/input_event.cc
+@@ -36,7 +36,7 @@
+ 
+ #include "config.h"
+ 
+-#include <ncurses.h>
++#include <ncursesw/ncurses.h>
+ #define NCURSES_ERR -1
+ 
+ #include "input_event.h"
+diff --git a/src/rpc/command_function.cc b/src/rpc/command_function.cc
+index 7f3c331..febca80 100644
+--- a/src/rpc/command_function.cc
++++ b/src/rpc/command_function.cc
+@@ -37,6 +37,7 @@
+ #include "config.h"
+ 
+ #include <algorithm>
++#include <rak/algorithm.h>
+ #include <functional>
+ #include <rak/functional.h>
+ 
+-- 
+1.7.0
+

Added: csw/mgar/pkg/rtorrent/trunk/files/0001-curl_get.patch
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/files/0001-curl_get.patch	                        (rev 0)
+++ csw/mgar/pkg/rtorrent/trunk/files/0001-curl_get.patch	2010-05-26 16:01:01 UTC (rev 9996)
@@ -0,0 +1,25 @@
+From 2f43d953cfe749e381cf0d011d37c7177dc25151 Mon Sep 17 00:00:00 2001
+From: Jan Holzhueter <jh at testing9s.bo.opencsw.org>
+Date: Sun, 23 May 2010 14:10:27 +0200
+Subject: [PATCH] curl_get
+
+---
+ src/core/curl_get.cc |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/src/core/curl_get.cc b/src/core/curl_get.cc
+index f0767b7..5c4b73c 100644
+--- a/src/core/curl_get.cc
++++ b/src/core/curl_get.cc
+@@ -88,7 +88,7 @@ CurlGet::start() {
+   curl_easy_setopt(m_handle, CURLOPT_NOSIGNAL,       (long)1);
+   curl_easy_setopt(m_handle, CURLOPT_FOLLOWLOCATION, (long)1);
+   curl_easy_setopt(m_handle, CURLOPT_MAXREDIRS,      (long)5);
+-  curl_easy_setopt(m_handle, CURLOPT_IPRESOLVE,      CURL_IPRESOLVE_V4);
++  curl_easy_setopt(m_handle, CURLOPT_IPRESOLVE,      CURL_IPRESOLVE_WHATEVER);
+   curl_easy_setopt(m_handle, CURLOPT_ENCODING,       "");
+ 
+   m_stack->add_get(this);
+-- 
+1.7.0
+

Added: csw/mgar/pkg/rtorrent/trunk/files/0001-more-build-fixes.patch
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/files/0001-more-build-fixes.patch	                        (rev 0)
+++ csw/mgar/pkg/rtorrent/trunk/files/0001-more-build-fixes.patch	2010-05-26 16:01:01 UTC (rev 9996)
@@ -0,0 +1,25 @@
+From 73b5cea8f2d71900227058ad3a222c8b98b628bf Mon Sep 17 00:00:00 2001
+From: Jan Holzhueter <jh at testing9s.bo.opencsw.org>
+Date: Mon, 24 May 2010 13:55:39 +0200
+Subject: [PATCH] more-build-fixes
+
+---
+ src/input/text_input.cc |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/src/input/text_input.cc b/src/input/text_input.cc
+index 7e19e86..3e74af8 100644
+--- a/src/input/text_input.cc
++++ b/src/input/text_input.cc
+@@ -36,7 +36,7 @@
+ 
+ #include "config.h"
+ 
+-#include <ncurses.h>
++#include <ncursesw/ncurses.h>
+ 
+ #include "text_input.h"
+ 
+-- 
+1.7.0
+

Added: csw/mgar/pkg/rtorrent/trunk/files/0001-more-build-fixes2.patch
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/files/0001-more-build-fixes2.patch	                        (rev 0)
+++ csw/mgar/pkg/rtorrent/trunk/files/0001-more-build-fixes2.patch	2010-05-26 16:01:01 UTC (rev 9996)
@@ -0,0 +1,25 @@
+From 8be94bd57ea757706b5bf61eb62852a67fe85b52 Mon Sep 17 00:00:00 2001
+From: Jan Holzhueter <jh at testing9s.bo.opencsw.org>
+Date: Mon, 24 May 2010 15:21:55 +0200
+Subject: [PATCH] more-build-fixes2
+
+---
+ src/command_download.cc |    1 +
+ src/rpc/xmlrpc.cc       |    1 +
+ 2 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/src/rpc/xmlrpc.cc b/src/rpc/xmlrpc.cc
+index ba527c6..c81184e 100644
+--- a/src/rpc/xmlrpc.cc
++++ b/src/rpc/xmlrpc.cc
+@@ -46,6 +46,7 @@
+ 
+ #include "xmlrpc.h"
+ #include "parse_commands.h"
++#define __UNUSED
+ 
+ namespace rpc {
+ 
+-- 
+1.7.0
+

Added: csw/mgar/pkg/rtorrent/trunk/files/0001-scgi_task.cc.patch
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/files/0001-scgi_task.cc.patch	                        (rev 0)
+++ csw/mgar/pkg/rtorrent/trunk/files/0001-scgi_task.cc.patch	2010-05-26 16:01:01 UTC (rev 9996)
@@ -0,0 +1,50 @@
+From 3038e30d0be6df9dd3e3afb36220e5ca97e3c7e7 Mon Sep 17 00:00:00 2001
+From: Jan Holzhueter <jh at testing9s.bo.opencsw.org>
+Date: Sun, 23 May 2010 14:31:01 +0200
+Subject: [PATCH] scgi_task.cc
+
+---
+ src/rpc/scgi_task.cc |   12 ++++++------
+ 1 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/src/rpc/scgi_task.cc b/src/rpc/scgi_task.cc
+index 4f78335..bfed679 100644
+--- a/src/rpc/scgi_task.cc
++++ b/src/rpc/scgi_task.cc
+@@ -156,19 +156,19 @@ SCgiTask::event_read() {
+     } else if ((unsigned int)contentSize <= default_buffer_size) {
+       m_bufferSize = contentSize;
+ 
+-      std::memmove(m_buffer, m_body, std::distance(m_body, m_position));
+-      m_position = m_buffer + std::distance(m_body, m_position);
++      std::memmove(m_buffer, m_body, m_position - m_body);
++      m_position = m_buffer + (m_position - m_body);
+       m_body = m_buffer;
+ 
+     } else {
+-      realloc_buffer((m_bufferSize = contentSize) + 1, m_body, std::distance(m_body, m_position));
++      realloc_buffer((m_bufferSize = contentSize) + 1, m_body, m_position - m_body);
+ 
+-      m_position = m_buffer + std::distance(m_body, m_position);
++      m_position = m_buffer + (m_position - m_body);
+       m_body = m_buffer;
+     }
+   }
+ 
+-  if ((unsigned int)std::distance(m_buffer, m_position) != m_bufferSize)
++  if ((unsigned int)(m_position - m_buffer) != m_bufferSize)
+     return;
+ 
+   this_thread->poll()->remove_read(this);
+@@ -182,7 +182,7 @@ SCgiTask::event_read() {
+   }
+ 
+   // Close if the call failed, else stay open to write back data.
+-  if (!m_parent->receive_call(this, m_body, m_bufferSize - std::distance(m_buffer, m_body)))
++  if (!m_parent->receive_call(this, m_body, m_bufferSize - (m_body - m_buffer)))
+     close();
+ 
+   return;
+-- 
+1.7.0
+

Added: csw/mgar/pkg/rtorrent/trunk/files/rtorrent-01-solaris.diff
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/files/rtorrent-01-solaris.diff	                        (rev 0)
+++ csw/mgar/pkg/rtorrent/trunk/files/rtorrent-01-solaris.diff	2010-05-26 16:01:01 UTC (rev 9996)
@@ -0,0 +1,119 @@
+--- rtorrent-0.8.2/src/input/input_event.cc.orig	2008-05-10 18:44:08.970350312 +1200
++++ rtorrent-0.8.2/src/input/input_event.cc	2008-05-10 18:44:41.438283333 +1200
+@@ -37,6 +37,7 @@
+ #include "config.h"
+ 
+ #include <ncurses.h>
++#define NCURSES_ERR -1
+ 
+ #include "input_event.h"
+ 
+@@ -58,7 +59,7 @@
+ InputEvent::event_read() {
+   int c;
+ 
+-  while ((c = getch()) != ERR)
++  while ((c = getch()) != NCURSES_ERR)
+     m_slotPressed(c);
+ }
+ 
+--- rtorrent-0.8.2/src/input/path_input.cc.orig	2008-05-08 00:19:11.000000000 +1200
++++ rtorrent-0.8.2/src/input/path_input.cc	2008-05-10 18:46:38.159258850 +1200
+@@ -42,7 +42,8 @@
+ #include <rak/path.h>
+ 
+ #include <sys/types.h>
+-#include <sys/dir.h>
++#include <sys/dirent.h>
++#include <sys/stat.h>
+ 
+ #include "path_input.h"
+ 
+@@ -71,9 +72,12 @@
+ }
+ 
+ struct _transform_filename {
++  struct stat s;
+   void operator () (utils::directory_entry& entry) {
+-    if (entry.d_type == DT_DIR)
++    stat(entry.d_name.c_str(), &s);
++    if (s.st_mode & S_IFDIR) {
+       entry.d_name += '/';
++    }
+   }
+ };
+ 
+--- rtorrent-0.8.2/src/utils/directory.h.orig	2008-05-08 00:19:11.000000000 +1200
++++ rtorrent-0.8.2/src/utils/directory.h	2008-05-10 18:40:49.485871875 +1200
+@@ -48,9 +48,7 @@
+   bool is_file() const { return true; }
+ 
+   // The name and types should match POSIX.
+-  uint32_t            d_fileno;
+   uint32_t            d_reclen;
+-  uint8_t             d_type;
+ 
+   std::string         d_name;
+ };
+--- rtorrent-0.8.2/src/utils/directory.cc.orig	2008-05-08 00:19:11.000000000 +1200
++++ rtorrent-0.8.2/src/utils/directory.cc	2008-05-10 18:40:49.485525951 +1200
+@@ -76,9 +76,7 @@
+ 
+     iterator itr = base_type::insert(end(), value_type());
+ 
+-    itr->d_fileno = entry->d_fileno;
+     itr->d_reclen = entry->d_reclen;
+-    itr->d_type   = entry->d_type;
+ 
+ #ifdef DIRENT_NAMLEN_EXISTS_FOOBAR
+     itr->d_name   = std::string(entry->d_name, entry->d_name + entry->d_namlen);
+--- rtorrent-0.8.2/src/signal_handler.h.orig	2008-05-08 00:19:11.000000000 +1200
++++ rtorrent-0.8.2/src/signal_handler.h	2008-05-10 18:40:49.485083889 +1200
+@@ -37,7 +37,7 @@
+ #ifndef RTORRENT_SIGNAL_HANDLER_H
+ #define RTORRENT_SIGNAL_HANDLER_H
+ 
+-#include <sys/signal.h>
++#include <signal.h>
+ #include <sigc++/functors/slot.h>
+ 
+ class SignalHandler {
+--- rtorrent-0.8.2/src/rpc/scgi.cc.orig	2008-05-08 00:19:10.000000000 +1200
++++ rtorrent-0.8.2/src/rpc/scgi.cc	2008-05-10 18:40:49.457064063 +1200
+@@ -88,7 +88,7 @@
+   char buffer[sizeof(sockaddr_un) + filename.size()];
+   sockaddr_un* sa = reinterpret_cast<sockaddr_un*>(buffer);
+ 
+-  sa->sun_family = AF_LOCAL;
++  sa->sun_family = AF_UNIX;
+   std::memcpy(sa->sun_path, filename.c_str(), filename.size() + 1);
+ 
+   if (!get_fd().open_local())
+--- rtorrent-0.8.2.orig/src/main.cc	2008-07-01 16:49:14.445080000 -0400
++++ rtorrent-0.8.2/src/main.cc	2008-07-02 10:37:19.052279890 -0400
+@@ -44,7 +44,13 @@
+ #include <torrent/torrent.h>
+ #include <torrent/exceptions.h>
+ #include <rak/functional.h>
++#include <locale.h>
+ 
++#if defined(__sun) && defined(__SVR4)
++#include <stdio.h>
++#include <stdio_ext.h>
++#endif
++
+ #ifdef USE_EXECINFO
+ #include <execinfo.h>
+ #endif
+@@ -165,6 +170,11 @@
+     SignalHandler::set_handler(SIGSEGV,  sigc::bind(sigc::ptr_fun(&do_panic), SIGSEGV));
+     SignalHandler::set_handler(SIGBUS,   sigc::bind(sigc::ptr_fun(&do_panic), SIGBUS));
+     SignalHandler::set_handler(SIGFPE,   sigc::bind(sigc::ptr_fun(&do_panic), SIGFPE));
++    SignalHandler::set_handler(SIGABRT,   sigc::bind(sigc::ptr_fun(&do_panic), SIGABRT));
++
++#if defined(__sun) && defined(__SVR4)
++    enable_extended_FILE_stdio(-1, SIGABRT);
++#endif
+ 
+     control->core()->initialize_first();
+ 

Added: csw/mgar/pkg/rtorrent/trunk/files/rtorrent-02-event-ports.diff
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/files/rtorrent-02-event-ports.diff	                        (rev 0)
+++ csw/mgar/pkg/rtorrent/trunk/files/rtorrent-02-event-ports.diff	2010-05-26 16:01:01 UTC (rev 9996)
@@ -0,0 +1,222 @@
+diff -urN rtorrent-0.8.2.orig/src/core/Makefile.am rtorrent-0.8.2/src/core/Makefile.am
+--- rtorrent-0.8.2.orig/src/core/Makefile.am	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/Makefile.am	2008-05-24 04:58:48.995508910 -0400
+@@ -26,6 +26,8 @@
+ 	poll_manager.h \
+ 	poll_manager_epoll.cc \
+ 	poll_manager_epoll.h \
++	poll_manager_ports.cc \
++	poll_manager_ports.h \
+ 	poll_manager_kqueue.cc \
+ 	poll_manager_kqueue.h \
+ 	poll_manager_select.cc \
+diff -urN rtorrent-0.8.2.orig/src/core/manager.cc rtorrent-0.8.2/src/core/manager.cc
+--- rtorrent-0.8.2.orig/src/core/manager.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/manager.cc	2008-05-24 04:58:48.996596707 -0400
+@@ -69,6 +69,7 @@
+ #include "manager.h"
+ #include "poll_manager_epoll.h"
+ #include "poll_manager_kqueue.h"
++#include "poll_manager_ports.h"
+ #include "poll_manager_select.h"
+ #include "view.h"
+ 
+@@ -189,6 +190,9 @@
+   if ((m_pollManager = PollManagerEPoll::create(sysconf(_SC_OPEN_MAX))) != NULL)
+     m_logImportant.push_front("Using 'epoll' based polling.");
+ 
++  else if ((m_pollManager = PollManagerPorts::create(sysconf(_SC_OPEN_MAX))) != NULL)
++    m_logImportant.push_front("Using 'ports' based polling.");
++
+   else if ((m_pollManager = PollManagerKQueue::create(sysconf(_SC_OPEN_MAX))) != NULL)
+     m_logImportant.push_front("Using 'kqueue' based polling.");
+ 
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_ports.cc rtorrent-0.8.2/src/core/poll_manager_ports.cc
+--- rtorrent-0.8.2.orig/src/core/poll_manager_ports.cc	1969-12-31 19:00:00.000000000 -0500
++++ rtorrent-0.8.2/src/core/poll_manager_ports.cc	2008-05-10 19:04:07.000000000 -0400
+@@ -0,0 +1,118 @@
++// rTorrent - BitTorrent client
++// Copyright (C) 2005-2007, Jari Sundell
++//
++// This program is free software; you can redistribute it and/or modify
++// it under the terms of the GNU General Public License as published by
++// the Free Software Foundation; either version 2 of the License, or
++// (at your option) any later version.
++// 
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++// GNU General Public License for more details.
++// 
++// You should have received a copy of the GNU General Public License
++// along with this program; if not, write to the Free Software
++// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++//
++// In addition, as a special exception, the copyright holders give
++// permission to link the code of portions of this program with the
++// OpenSSL library under certain conditions as described in each
++// individual source file, and distribute linked combinations
++// including the two.
++//
++// You must obey the GNU General Public License in all respects for
++// all of the code used other than OpenSSL.  If you modify file(s)
++// with this exception, you may extend this exception to your version
++// of the file(s), but you are not obligated to do so.  If you do not
++// wish to do so, delete this exception statement from your version.
++// If you delete this exception statement from all source files in the
++// program, then also delete it here.
++//
++// Contact:  Jari Sundell <jaris at ifi.uio.no>
++//
++//           Skomakerveien 33
++//           3185 Skoppum, NORWAY
++
++#include "config.h"
++
++#include <cstring>
++#include <iostream>
++#include <stdexcept>
++#include <unistd.h>
++#include <sys/time.h>
++#include <torrent/poll_ports.h>
++#include <torrent/torrent.h>
++
++#include "poll_manager_ports.h"
++
++namespace core {
++
++PollManagerPorts*
++PollManagerPorts::create(int maxOpenSockets) {
++  torrent::PollPorts* p = torrent::PollPorts::create(maxOpenSockets);
++
++  if (p == NULL)
++    return NULL;
++  else
++    return new PollManagerPorts(p);
++}
++
++PollManagerPorts::~PollManagerPorts() {
++}
++
++void
++PollManagerPorts::poll(rak::timer timeout) {
++  // Add 1ms to ensure we don't idle loop due to the lack of
++  // resolution.
++  torrent::perform();
++  timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
++
++  if (!m_httpStack.empty()) {
++    // When we're using libcurl we need to use select, but as this is
++    // inefficient we try avoiding it whenever possible.
++#if defined USE_VARIABLE_FDSET
++    std::memset(m_readSet, 0, m_setSize);
++    std::memset(m_writeSet, 0, m_setSize);
++    std::memset(m_errorSet, 0, m_setSize);
++#else
++    FD_ZERO(m_readSet);
++    FD_ZERO(m_writeSet);
++    FD_ZERO(m_errorSet);
++#endif    
++    FD_SET(static_cast<torrent::PollPorts*>(m_poll)->file_descriptor(), m_readSet);
++
++    unsigned int maxFd = std::max((unsigned int)static_cast<torrent::PollPorts*>(m_poll)->file_descriptor(),
++                                  m_httpStack.fdset(m_readSet, m_writeSet, m_errorSet));
++
++    timeval t = timeout.tval();
++
++    if (select(maxFd + 1, m_readSet, m_writeSet, m_errorSet, &t) == -1) {
++	    std::cerr << "error from select\n";
++      return check_error();
++    }
++    m_httpStack.perform();
++
++    if (!FD_ISSET(static_cast<torrent::PollPorts*>(m_poll)->file_descriptor(), m_readSet)) {
++      // Need to call perform here so that scheduled task get done
++      // even if there's no socket events outside of the http stuff.
++      torrent::perform();
++      return;
++    }
++
++    // Clear the timeout since we've already used it in the select call.
++    timeout = rak::timer();
++  }
++
++  // Yes, below is how much code really *should* have been in this
++  // function. ;)
++
++  if (static_cast<torrent::PollPorts*>(m_poll)->poll((timeout.usec() + 999) / 1000) == -1) {
++	  std::cerr << "error from ports poll\n";
++    return check_error();
++  }
++  torrent::perform();
++  static_cast<torrent::PollPorts*>(m_poll)->perform();
++}
++
++}
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_ports.h rtorrent-0.8.2/src/core/poll_manager_ports.h
+--- rtorrent-0.8.2.orig/src/core/poll_manager_ports.h	1969-12-31 19:00:00.000000000 -0500
++++ rtorrent-0.8.2/src/core/poll_manager_ports.h	2008-05-10 19:04:07.000000000 -0400
+@@ -0,0 +1,63 @@
++// rTorrent - BitTorrent client
++// Copyright (C) 2005-2007, Jari Sundell
++//
++// This program is free software; you can redistribute it and/or modify
++// it under the terms of the GNU General Public License as published by
++// the Free Software Foundation; either version 2 of the License, or
++// (at your option) any later version.
++// 
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++// GNU General Public License for more details.
++// 
++// You should have received a copy of the GNU General Public License
++// along with this program; if not, write to the Free Software
++// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++//
++// In addition, as a special exception, the copyright holders give
++// permission to link the code of portions of this program with the
++// OpenSSL library under certain conditions as described in each
++// individual source file, and distribute linked combinations
++// including the two.
++//
++// You must obey the GNU General Public License in all respects for
++// all of the code used other than OpenSSL.  If you modify file(s)
++// with this exception, you may extend this exception to your version
++// of the file(s), but you are not obligated to do so.  If you do not
++// wish to do so, delete this exception statement from your version.
++// If you delete this exception statement from all source files in the
++// program, then also delete it here.
++//
++// Contact:  Jari Sundell <jaris at ifi.uio.no>
++//
++//           Skomakerveien 33
++//           3185 Skoppum, NORWAY
++
++#ifndef RTORRENT_CORE_POLL_MANAGER_PORTS_H
++#define RTORRENT_CORE_POLL_MANAGER_PORTS_H
++
++#include "poll_manager.h"
++
++namespace torrent {
++  class PollPorts;
++}
++
++namespace core {
++
++class PollManagerPorts : public PollManager {
++public:
++  static PollManagerPorts* create(int maxOpenSockets);
++  ~PollManagerPorts();
++
++  torrent::Poll*      get_torrent_poll();
++
++  void                poll(rak::timer timeout);
++
++private:
++  PollManagerPorts(torrent::Poll* p) : PollManager(p) {}
++};
++
++}
++
++#endif

Added: csw/mgar/pkg/rtorrent/trunk/files/rtorrent-03-curl-event.diff
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/files/rtorrent-03-curl-event.diff	                        (rev 0)
+++ csw/mgar/pkg/rtorrent/trunk/files/rtorrent-03-curl-event.diff	2010-05-26 16:01:01 UTC (rev 9996)
@@ -0,0 +1,490 @@
+diff -urN rtorrent-0.8.2.orig/src/core/curl_event.cc rtorrent-0.8.2/src/core/curl_event.cc
+--- rtorrent-0.8.2.orig/src/core/curl_event.cc	1969-12-31 19:00:00.000000000 -0500
++++ rtorrent-0.8.2/src/core/curl_event.cc	2008-06-10 14:40:41.403064000 -0400
+@@ -0,0 +1,63 @@
++// libTorrent - BitTorrent library
++// Copyright (C) 2008 Albert Lee
++//
++// This program is free software; you can redistribute it and/or modify
++// it under the terms of the GNU General Public License as published by
++// the Free Software Foundation; either version 2 of the License, or
++// (at your option) any later version.
++// 
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++// GNU General Public License for more details.
++// 
++// You should have received a copy of the GNU General Public License
++// along with this program; if not, write to the Free Software
++// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++//
++// In addition, as a special exception, the copyright holders give
++// permission to link the code of portions of this program with the
++// OpenSSL library under certain conditions as described in each
++// individual source file, and distribute linked combinations
++// including the two.
++//
++// You must obey the GNU General Public License in all respects for
++// all of the code used other than OpenSSL.  If you modify file(s)
++// with this exception, you may extend this exception to your version
++// of the file(s), but you are not obligated to do so.  If you do not
++// wish to do so, delete this exception statement from your version.
++// If you delete this exception statement from all source files in the
++// program, then also delete it here.
++//
++// Contact:  Jari Sundell <jaris at ifi.uio.no>
++//
++//           Skomakerveien 33
++//           3185 Skoppum, NORWAY
++
++#include "config.h"
++
++#include <torrent/exceptions.h>
++
++#include "rak/functional.h"
++
++#include "curl_event.h"
++#include "curl_stack.h"
++
++namespace core {
++
++void
++CurlEvent::event_read() {
++  m_stack->perform(m_fileDesc);
++}
++
++void
++CurlEvent::event_write() {
++  m_stack->perform(m_fileDesc);
++}
++
++void
++CurlEvent::event_error() {
++  m_stack->perform(m_fileDesc);
++}
++
++}
+diff -urN rtorrent-0.8.2.orig/src/core/curl_event.h rtorrent-0.8.2/src/core/curl_event.h
+--- rtorrent-0.8.2.orig/src/core/curl_event.h	1969-12-31 19:00:00.000000000 -0500
++++ rtorrent-0.8.2/src/core/curl_event.h	2008-06-10 14:37:59.758119000 -0400
+@@ -0,0 +1,61 @@
++// libTorrent - BitTorrent library
++// Copyright (C) 2008 Albert Lee
++//
++// This program is free software; you can redistribute it and/or modify
++// it under the terms of the GNU General Public License as published by
++// the Free Software Foundation; either version 2 of the License, or
++// (at your option) any later version.
++// 
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++// GNU General Public License for more details.
++// 
++// You should have received a copy of the GNU General Public License
++// along with this program; if not, write to the Free Software
++// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++//
++// In addition, as a special exception, the copyright holders give
++// permission to link the code of portions of this program with the
++// OpenSSL library under certain conditions as described in each
++// individual source file, and distribute linked combinations
++// including the two.
++//
++// You must obey the GNU General Public License in all respects for
++// all of the code used other than OpenSSL.  If you modify file(s)
++// with this exception, you may extend this exception to your version
++// of the file(s), but you are not obligated to do so.  If you do not
++// wish to do so, delete this exception statement from your version.
++// If you delete this exception statement from all source files in the
++// program, then also delete it here.
++//
++// Contact:  Jari Sundell <jaris at ifi.uio.no>
++//
++//           Skomakerveien 33
++//           3185 Skoppum, NORWAY
++
++#ifndef RTORRENT_CORE_CURL_EVENT_H
++#define RTORRENT_CORE_CURL_EVENT_H
++
++#include <torrent/event.h>
++
++namespace core {
++
++class CurlStack;
++
++class CurlEvent : public torrent::Event {
++public:
++  CurlEvent(CurlStack* s, int fd) : m_stack(s) { m_fileDesc = fd; }
++  virtual ~CurlEvent() {}
++
++  virtual void        event_read();
++  virtual void        event_write();
++  virtual void        event_error();
++
++protected:
++  CurlStack*          m_stack;
++};
++
++}
++
++#endif
+diff -urN rtorrent-0.8.2.orig/src/core/curl_stack.cc rtorrent-0.8.2/src/core/curl_stack.cc
+--- rtorrent-0.8.2.orig/src/core/curl_stack.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/curl_stack.cc	2008-06-10 14:32:12.992249000 -0400
+@@ -44,13 +44,77 @@
+ #include "rak/functional.h"
+ #include "curl_get.h"
+ #include "curl_stack.h"
++#include "curl_event.h"
++
++#include "poll_manager.h"
+ 
+ namespace core {
+ 
+-CurlStack::CurlStack() :
++#if LIBCURL_VERSION_NUM >= 0x071000
++static void timer_callback(curl_socket_t socket, int action, void* event_data)
++{
++  CurlStack* s = static_cast<CurlStack*>(event_data);
++  CURLM* handle = (CURLM*)(s->handle());
++  CURLMcode rc;
++  int count;
++
++  while (CURLM_CALL_MULTI_PERFORM == (rc = curl_multi_socket(handle, CURL_SOCKET_TIMEOUT, &count)));
++}
++#endif
++
++static int socket_callback(CURL *easy, curl_socket_t socket, int action, void* socket_data, void* assign_data)
++{
++  CurlStack* stack = static_cast<CurlStack*>(socket_data);
++  torrent::Event* event = static_cast<torrent::Event*>(assign_data);
++  torrent::Poll* poll = stack->poll();
++
++  if (!event) {
++    event = new CurlEvent(stack, socket);
++    curl_multi_assign((CURLM*)(stack->handle()), socket, event);
++    if (socket > poll->open_max())
++      throw torrent::internal_error("Socket too large for " + poll->open_max());
++    poll->open(event);
++  } else {
++    poll->remove_read(event);
++    poll->remove_write(event);
++    poll->remove_error(event);
++  }
++
++  switch (action) {
++    case CURL_POLL_NONE:
++      break;
++    case CURL_POLL_IN:
++      poll->insert_read(event);
++      break;
++    case CURL_POLL_OUT:
++      poll->insert_write(event);
++      break;
++    case CURL_POLL_INOUT:
++      poll->insert_read(event);
++      poll->insert_write(event);
++      break;
++    case CURL_POLL_REMOVE:
++      poll->close(event);
++      delete event;
++      break;
++    default:
++      throw torrent::internal_error("socket_callback(...) called with unsupported action");
++  }
++
++  return 0;
++}
++
++CurlStack::CurlStack(torrent::Poll* poll) :
+   m_handle((void*)curl_multi_init()),
++  m_poll(poll),
+   m_active(0),
+   m_maxActive(32) {
++  curl_multi_setopt(m_handle, CURLMOPT_SOCKETDATA, this);
++  curl_multi_setopt(m_handle, CURLMOPT_SOCKETFUNCTION, socket_callback);
++#if LIBCURL_VERSION_NUM >= 0x071000
++  curl_multi_setopt(m_handle, CURLMOPT_TIMERDATA, this);
++  curl_multi_setopt(m_handle, CURLMOPT_TIMERFUNCTION, timer_callback);
++#endif
+ }
+ 
+ CurlStack::~CurlStack() {
+@@ -66,35 +130,59 @@
+ }
+ 
+ void
+-CurlStack::perform() {
++CurlStack::process() {
++  int t;
++  CURLMsg* msg;
++
++  while ((msg = curl_multi_info_read((CURLM*)m_handle, &t)) != NULL) {
++    if (msg->msg != CURLMSG_DONE)
++      throw torrent::internal_error("CurlStack::process() msg->msg != CURLMSG_DONE.");
++
++    iterator itr = std::find_if(begin(), end(), rak::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle)));
++
++    if (itr == end())
++      throw torrent::internal_error("Could not find CurlGet with the right easy_handle.");
++        
++    if (msg->data.result == CURLE_OK)
++      (*itr)->signal_done().emit();
++    else
++      (*itr)->signal_failed().emit(curl_easy_strerror(msg->data.result));
++  }
++}
++
++void
++CurlStack::perform(curl_socket_t sockfd) {
+   CURLMcode code;
+ 
+   do {
+     int count;
+-    code = curl_multi_perform((CURLM*)m_handle, &count);
++    code = curl_multi_socket((CURLM*)m_handle, sockfd, &count);
+ 
+     if (code > 0)
+-      throw torrent::internal_error("Error calling curl_multi_perform.");
++      throw torrent::internal_error("Error calling curl_multi_socket.");
+ 
+     if ((unsigned int)count != size()) {
+       // Done with some handles.
+-      int t;
+-      CURLMsg* msg;
++      process();
++    }
+ 
+-      while ((msg = curl_multi_info_read((CURLM*)m_handle, &t)) != NULL) {
+-        if (msg->msg != CURLMSG_DONE)
+-          throw torrent::internal_error("CurlStack::perform() msg->msg != CURLMSG_DONE.");
++  } while (code == CURLM_CALL_MULTI_PERFORM);
++}
+ 
+-        iterator itr = std::find_if(begin(), end(), rak::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle)));
++void
++CurlStack::perform() {
++  CURLMcode code;
+ 
+-        if (itr == end())
+-          throw torrent::internal_error("Could not find CurlGet with the right easy_handle.");
+-        
+-        if (msg->data.result == CURLE_OK)
+-          (*itr)->signal_done().emit();
+-        else
+-          (*itr)->signal_failed().emit(curl_easy_strerror(msg->data.result));
+-      }
++  do {
++    int count;
++    code = curl_multi_perform((CURLM*)m_handle, &count);
++
++    if (code > 0)
++      throw torrent::internal_error("Error calling curl_multi_perform.");
++
++    if ((unsigned int)count != size()) {
++      // Done with some handles.
++      process();
+     }
+ 
+   } while (code == CURLM_CALL_MULTI_PERFORM);
+diff -urN rtorrent-0.8.2.orig/src/core/curl_stack.h rtorrent-0.8.2/src/core/curl_stack.h
+--- rtorrent-0.8.2.orig/src/core/curl_stack.h	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/curl_stack.h	2008-06-10 13:54:21.695024000 -0400
+@@ -40,11 +40,19 @@
+ #include <deque>
+ #include <string>
+ #include <sigc++/functors/slot.h>
++#include <curl/curl.h>
++
++class torrent::Poll;
+ 
+ namespace core {
+ 
+ class CurlGet;
+ 
++#if LIBCURL_VERSION_NUM >= 0x071000
++static void timer_callback(curl_socket_t socket, int action, void* event_data);
++#endif
++static int socket_callback(CURL *easy, curl_socket_t socket, int action, void* socket_data, void* assign_data);
++
+ // By using a deque instead of vector we allow for cheaper removal of
+ // the oldest elements, those that will be first in the in the
+ // deque.
+@@ -76,16 +84,19 @@
+   using base_type::size;
+   using base_type::empty;
+ 
+-  CurlStack();
++  CurlStack(torrent::Poll* poll);
+   ~CurlStack();
+ 
+   CurlGet*            new_object();
+ 
++  void                perform(curl_socket_t sockfd);
+   void                perform();
+ 
+   // TODO: Set fd_set's only once?
+   unsigned int        fdset(fd_set* readfds, fd_set* writefds, fd_set* exceptfds);
+ 
++  void*               handle()                               { return m_handle; }
++  torrent::Poll*      poll()                                 { return m_poll; }         
+   unsigned int        active() const                         { return m_active; }
+   unsigned int        max_active() const                     { return m_maxActive; }
+   void                set_max_active(unsigned int a)         { m_maxActive = a; }
+@@ -111,12 +122,14 @@
+  protected:
+   void                add_get(CurlGet* get);
+   void                remove_get(CurlGet* get);
++  void                process();
+ 
+  private:
+   CurlStack(const CurlStack&);
+   void operator = (const CurlStack&);
+ 
+   void*               m_handle;
++  torrent::Poll*      m_poll;
+ 
+   unsigned int        m_active;
+   unsigned int        m_maxActive;
+diff -urN rtorrent-0.8.2.orig/src/core/Makefile.am rtorrent-0.8.2/src/core/Makefile.am
+--- rtorrent-0.8.2.orig/src/core/Makefile.am	2008-06-10 15:13:49.786345331 -0400
++++ rtorrent-0.8.2/src/core/Makefile.am	2008-06-10 02:25:32.809721000 -0400
+@@ -1,6 +1,8 @@
+ noinst_LIBRARIES = libsub_core.a
+ 
+ libsub_core_a_SOURCES = \
++	curl_event.cc \
++	curl_event.h \
+ 	curl_get.cc \
+ 	curl_get.h \
+ 	curl_stack.cc \
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_epoll.cc rtorrent-0.8.2/src/core/poll_manager_epoll.cc
+--- rtorrent-0.8.2.orig/src/core/poll_manager_epoll.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/poll_manager_epoll.cc	2008-06-10 14:17:27.568558000 -0400
+@@ -67,6 +67,7 @@
+   torrent::perform();
+   timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
+ 
++#if 0
+   if (!m_httpStack.empty()) {
+     // When we're using libcurl we need to use select, but as this is
+     // inefficient we try avoiding it whenever possible.
+@@ -101,6 +102,7 @@
+     // Clear the timeout since we've already used it in the select call.
+     timeout = rak::timer();
+   }
++#endif
+ 
+   // Yes, below is how much code really *should* have been in this
+   // function. ;)
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_kqueue.cc rtorrent-0.8.2/src/core/poll_manager_kqueue.cc
+--- rtorrent-0.8.2.orig/src/core/poll_manager_kqueue.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/poll_manager_kqueue.cc	2008-06-10 14:17:31.672907000 -0400
+@@ -68,6 +68,7 @@
+   torrent::perform();
+   timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
+ 
++#if 0
+   if (!m_httpStack.empty()) {
+     // When we're using libcurl we need to use select, but as this is
+     // inefficient we try avoiding it whenever possible.
+@@ -102,6 +103,7 @@
+     // Clear the timeout since we've already used it in the select call.
+     timeout = rak::timer();
+   }
++#endif
+ 
+   // Yes, below is how much code really *should* have been in this
+   // function. ;)
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_ports.cc rtorrent-0.8.2/src/core/poll_manager_ports.cc
+--- rtorrent-0.8.2.orig/src/core/poll_manager_ports.cc	2008-06-10 15:13:49.790288665 -0400
++++ rtorrent-0.8.2/src/core/poll_manager_ports.cc	2008-06-10 14:31:09.552278000 -0400
+@@ -68,6 +68,7 @@
+   torrent::perform();
+   timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
+ 
++#if 0
+   if (!m_httpStack.empty()) {
+     // When we're using libcurl we need to use select, but as this is
+     // inefficient we try avoiding it whenever possible.
+@@ -103,6 +104,7 @@
+     // Clear the timeout since we've already used it in the select call.
+     timeout = rak::timer();
+   }
++#endif
+ 
+   // Yes, below is how much code really *should* have been in this
+   // function. ;)
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_select.cc rtorrent-0.8.2/src/core/poll_manager_select.cc
+--- rtorrent-0.8.2.orig/src/core/poll_manager_select.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/poll_manager_select.cc	2008-06-10 02:37:17.419878000 -0400
+@@ -77,16 +77,16 @@
+ 
+   unsigned int maxFd = static_cast<torrent::PollSelect*>(m_poll)->fdset(m_readSet, m_writeSet, m_errorSet);
+ 
+-  if (!m_httpStack.empty())
+-    maxFd = std::max(maxFd, m_httpStack.fdset(m_readSet, m_writeSet, m_errorSet));
++  if (!m_httpStack->empty())
++    maxFd = std::max(maxFd, m_httpStack->fdset(m_readSet, m_writeSet, m_errorSet));
+ 
+   timeval t = timeout.tval();
+ 
+   if (select(maxFd + 1, m_readSet, m_writeSet, m_errorSet, &t) == -1)
+     return check_error();
+ 
+-  if (!m_httpStack.empty())
+-    m_httpStack.perform();
++  if (!m_httpStack->empty())
++    m_httpStack->perform();
+ 
+   torrent::perform();
+   static_cast<torrent::PollSelect*>(m_poll)->perform(m_readSet, m_writeSet, m_errorSet);
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager.cc rtorrent-0.8.2/src/core/poll_manager.cc
+--- rtorrent-0.8.2.orig/src/core/poll_manager.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/poll_manager.cc	2008-06-10 02:35:35.523377000 -0400
+@@ -44,7 +44,8 @@
+ namespace core {
+ 
+ PollManager::PollManager(torrent::Poll* poll) :
+-  m_poll(poll) {
++  m_poll(poll),
++  m_httpStack(new CurlStack(poll)) {
+ 
+   if (m_poll == NULL)
+     throw std::logic_error("PollManager::PollManager(...) received poll == NULL");
+@@ -74,10 +75,11 @@
+ 
+   // Call this so curl has valid fd_set pointers if curl_multi_perform
+   // is called before it gets set when polling.
+-  m_httpStack.fdset(m_readSet, m_writeSet, m_errorSet);
++  m_httpStack->fdset(m_readSet, m_writeSet, m_errorSet);
+ }
+ 
+ PollManager::~PollManager() {
++  delete m_httpStack;
+   delete m_poll;
+ 
+ #if defined USE_VARIABLE_FDSET
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager.h rtorrent-0.8.2/src/core/poll_manager.h
+--- rtorrent-0.8.2.orig/src/core/poll_manager.h	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/poll_manager.h	2008-06-10 02:34:57.898088000 -0400
+@@ -58,7 +58,7 @@
+ 
+   unsigned int        get_open_max() const         { return m_poll->open_max(); }
+ 
+-  CurlStack*          get_http_stack()             { return &m_httpStack; }
++  CurlStack*          get_http_stack()             { return m_httpStack; }
+   torrent::Poll*      get_torrent_poll()           { return m_poll; }
+ 
+   virtual void        poll(rak::timer timeout) = 0;
+@@ -70,7 +70,7 @@
+   void                check_error();
+ 
+   torrent::Poll*      m_poll;
+-  CurlStack           m_httpStack;
++  CurlStack*          m_httpStack;
+ 
+   unsigned int        m_setSize;
+   fd_set*             m_readSet;

Added: csw/mgar/pkg/rtorrent/trunk/files/rtorrent-04-sunpro.diff
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/files/rtorrent-04-sunpro.diff	                        (rev 0)
+++ csw/mgar/pkg/rtorrent/trunk/files/rtorrent-04-sunpro.diff	2010-05-26 16:01:01 UTC (rev 9996)
@@ -0,0 +1,652 @@
+--- rtorrent-0.8.2.orig/rak/string_manip.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/string_manip.h	2008-06-25 02:14:10.028329996 -0400
+@@ -62,7 +62,7 @@
+ 
+ template <typename Sequence>
+ Sequence trim_end(const Sequence& seq) {
+-  if (seq.empty() || !std::isspace(*(--seq.end())))
++  if (seq.empty() || !std::isspace(*(seq.end()-1)))
+     return seq;
+ 
+   typename Sequence::size_type pos = seq.size();
+@@ -93,7 +93,7 @@
+ 
+ template <typename Sequence>
+ Sequence trim_end_classic(const Sequence& seq) {
+-  if (seq.empty() || !std::isspace(*(--seq.end()), std::locale::classic()))
++  if (seq.empty() || !std::isspace(*(seq.end()-1), std::locale::classic()))
+     return seq;
+ 
+   typename Sequence::size_type pos = seq.size();
+--- rtorrent-0.8.2.orig/rak/path.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/path.h	2008-06-25 01:57:52.656513911 -0400
+@@ -42,6 +42,7 @@
+ 
+ #include <cstdlib>
+ #include <string>
++#include <algorithm>
+ 
+ namespace rak {
+ 
+@@ -91,7 +92,7 @@
+     if (home == NULL)
+       return first;
+ 
+-    first += strlcpy(first, home, std::distance(first, last));
++    first += strlcpy(first, home, last-first);
+ 
+     if (first > last)
+       return last;
+@@ -99,7 +100,7 @@
+     src++;
+   }
+ 
+-  return std::min(first + strlcpy(first, src, std::distance(first, last)), last);
++  return std::min(first + strlcpy(first, src, last-first), last);
+ }
+ 
+ }
+--- rtorrent-0.8.2.orig/rak/unordered_vector.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/unordered_vector.h	2008-06-25 02:29:35.381434005 -0400
+@@ -90,7 +90,7 @@
+ unordered_vector<_Tp>::insert(iterator position, const value_type& x) {
+   Base::push_back(x);
+ 
+-  return --end();
++  return end()-1;
+ }
+ 
+ template <typename _Tp>
+--- rtorrent-0.8.2.orig/rak/socket_address.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/socket_address.h	2008-06-25 01:58:48.126132462 -0400
+@@ -50,6 +50,7 @@
+ #include <cstring>
+ #include <string>
+ #include <stdexcept>
++#include <algorithm>
+ #include <arpa/inet.h>
+ #include <netinet/in.h>
+ #include <sys/types.h>
+--- rtorrent-0.8.2.orig/rak/regex.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/regex.h	2008-06-25 02:10:05.332867456 -0400
+@@ -75,7 +75,7 @@
+   std::list<unsigned int> paths;
+   paths.push_front(0);
+ 
+-  for (std::string::const_iterator itrText = ++text.begin(), lastText = text.end(); itrText != lastText; ++itrText) {
++  for (std::string::const_iterator itrText = text.begin()+1, lastText = text.end(); itrText != lastText; ++itrText) {
+     
+     for (std::list<unsigned int>::iterator itrPaths = paths.begin(), lastPaths = paths.end(); itrPaths != lastPaths; ) {
+ 
+--- rtorrent-0.8.2.orig/rak/algorithm.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/algorithm.h	2008-06-25 17:27:39.728352000 -0400
+@@ -40,6 +40,63 @@
+ #include <algorithm>
+ #include <functional>
+ 
++#ifdef _RWSTD_NO_CLASS_PARTIAL_SPEC
++namespace std {
++  template <class Iterator> struct iterator_traits
++  {
++    typedef typename Iterator::value_type value_type;
++    typedef typename Iterator::difference_type difference_type;
++    typedef typename Iterator::pointer pointer;
++    typedef typename Iterator::reference reference;
++    typedef typename Iterator::iterator_category iterator_category;
++  };
++  template <class T> struct iterator_traits<T*>
++  {
++    typedef T value_type;
++    typedef ptrdiff_t difference_type;
++    typedef T* pointer;
++    typedef T& reference;
++    typedef random_access_iterator_tag iterator_category;
++  };
++  template <class T> struct iterator_traits<const T*>
++  {
++    typedef T value_type;
++    typedef ptrdiff_t difference_type;
++    typedef const T* pointer;
++    typedef const T& reference;
++    typedef random_access_iterator_tag iterator_category;
++  };
++
++  template <class ForwardIterator>
++  inline typename iterator_traits<ForwardIterator>::difference_type
++  distance (ForwardIterator first, ForwardIterator last)
++  {
++    typename iterator_traits<ForwardIterator>::difference_type n = 0;
++    __distance(first, last, n, 
++               iterator_traits<ForwardIterator>::iterator_category());
++    return n;
++  }
++
++  template <class InputIterator, class T>
++  inline typename iterator_traits<InputIterator>::difference_type
++  count (InputIterator first, InputIterator last, const T& value)
++  {
++    typename iterator_traits<InputIterator>::difference_type n = 0;
++    count(first, last, value, n);
++    return n;
++  }
++
++  template <class InputIterator, class Predicate>
++  inline typename iterator_traits<InputIterator>::difference_type
++  count_if (InputIterator first, InputIterator last, Predicate pred)
++  {
++    typename iterator_traits<InputIterator>::difference_type n = 0;
++    count_if(first, last, pred, n);
++    return n;
++  }
++}
++#endif
++
+ namespace rak {
+ 
+ template <typename _InputIter, typename _Function>
+--- rtorrent-0.8.2.orig/src/command_file.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/command_file.cc	2008-06-25 18:06:51.985365949 -0400
+@@ -64,7 +64,7 @@
+   torrent::Object resultRaw(*file->path()->begin());
+   torrent::Object::string_type& result = resultRaw.as_string();
+ 
+-  for (torrent::Path::const_iterator itr = ++file->path()->begin(), last = file->path()->end(); itr != last; itr++)
++  for (torrent::Path::const_iterator itr = (file->path()->begin())+1, last = file->path()->end(); itr != last; itr++)
+     result += '/' + *itr;
+ 
+   return resultRaw;
+--- rtorrent-0.8.2.orig/src/display/window_download_list.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_download_list.cc	2008-06-25 03:05:03.087916943 -0400
+@@ -90,9 +90,9 @@
+     ++range.second;
+ 
+   int pos = 1;
++  char* buffer = new char[m_canvas->width() + 1];
+ 
+   while (range.first != range.second) {
+-    char buffer[m_canvas->width() + 1];
+     char* position;
+     char* last = buffer + m_canvas->width() - 2 + 1;
+ 
+@@ -107,6 +107,8 @@
+ 
+     ++range.first;
+   }    
++
++  delete buffer;
+ }
+ 
+ }
+--- rtorrent-0.8.2.orig/src/display/window_text.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_text.cc	2008-06-25 03:18:19.930779231 -0400
+@@ -93,8 +93,9 @@
+   if (m_canvas->height() == 0)
+     return;
+ 
++  char* buffer = new char[m_canvas->width() + 1];
++
+   if (m_errorHandler != NULL && m_target.second == NULL) {
+-    char buffer[m_canvas->width() + 1];
+ 
+     Canvas::attributes_list attributes;
+     attributes.push_back(Attributes(buffer, Attributes::a_normal, Attributes::color_default));
+@@ -102,6 +103,9 @@
+     char* last = m_errorHandler->print(buffer, buffer + m_canvas->width(), &attributes, m_target);
+ 
+     m_canvas->print_attributes(0, position, buffer, last, &attributes);
++
++    delete buffer;
++
+     return;
+   }
+ 
+@@ -109,8 +113,6 @@
+     if (*itr == NULL)
+       continue;
+ 
+-    char buffer[m_canvas->width() + 1];
+-
+     Canvas::attributes_list attributes;
+     attributes.push_back(Attributes(buffer, Attributes::a_normal, Attributes::color_default));
+ 
+@@ -118,6 +120,8 @@
+ 
+     m_canvas->print_attributes(0, position, buffer, last, &attributes);
+   }
++
++  delete buffer;
+ }
+ 
+ }
+--- rtorrent-0.8.2.orig/src/display/frame.h	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/frame.h	2008-06-25 02:47:06.518734587 -0400
+@@ -92,9 +92,9 @@
+ 
+   Window*             window() const                    { return m_window; }
+ 
+-  Frame*              frame(size_type idx)              { return m_container[idx]; }
++  Frame*              frame(size_type idx)              { return m_container.frames[idx]; }
+ 
+-  size_type           container_size() const            { return m_containerSize; }
++  size_type           container_size() const            { return m_container.size; }
+   void                set_container_size(size_type size);
+ 
+   void                initialize_window(Window* window);
+@@ -120,13 +120,14 @@
+   uint32_t            m_width;
+   uint32_t            m_height;
+ 
++  typedef struct {
++    size_type           size;
++    Frame*              frames[max_size];
++  } container_t;
++
+   union {
+     Window*             m_window;
+-    
+-    struct {
+-      size_type           m_containerSize;
+-      Frame*              m_container[max_size];
+-    };
++    container_t         m_container;
+   };
+ };
+ 
+--- rtorrent-0.8.2.orig/src/display/text_element_string.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/text_element_string.cc	2008-06-25 02:57:08.521853302 -0400
+@@ -36,6 +36,7 @@
+ 
+ #include "config.h"
+ 
++#include <rak/algorithm.h>
+ #include <rak/string_manip.h>
+ 
+ #include "rpc/parse_commands.h"
+@@ -52,17 +52,21 @@
+     return first;
+ 
+   if (m_flags & flag_escape_hex) {
+-    char buffer[last - first];
++    char* buffer = new char[last - first];
+     char* bufferLast = copy_string(buffer, buffer + (last - first), target);
+ 
+     first = rak::transform_hex(buffer, bufferLast, first, last);
+ 
++    delete buffer;
++
+   } else if (m_flags & flag_escape_html) {
+-    char buffer[last - first];
++    char* buffer = new char[last - first];
+     char* bufferLast = copy_string(buffer, buffer + (last - first), target);
+ 
+     first = rak::copy_escape_html(buffer, bufferLast, first, last);
+ 
++    delete buffer;
++
+   } else {
+     first = copy_string(first, last, target);
+   }  
+--- rtorrent-0.8.2.orig/src/display/window.h	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window.h	2008-06-26 00:42:49.975992333 -0400
+@@ -41,6 +41,7 @@
+ #include <rak/functional.h>
+ 
+ #include "canvas.h"
++#include "manager.h"
+ #include "globals.h"
+ 
+ namespace display {
+--- rtorrent-0.8.2.orig/src/display/window_statusbar.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_statusbar.cc	2008-06-25 03:15:15.445557476 -0400
+@@ -53,7 +53,7 @@
+   m_canvas->erase();
+ 
+   // TODO: Make a buffer with size = get_width?
+-  char buffer[m_canvas->width() + 1];
++  char* buffer = new char[m_canvas->width() + 1];
+   char* position;
+   char* last = buffer + m_canvas->width();
+ 
+@@ -68,6 +68,8 @@
+   }
+ 
+   m_lastTick = control->tick();
++
++  delete buffer;
+ }
+ 
+ }
+--- rtorrent-0.8.2.orig/src/display/window_file_list.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_file_list.cc	2008-06-25 03:08:33.655012018 -0400
+@@ -84,7 +84,7 @@
+   if (fl->size_files() == 0 || m_canvas->height() < 2)
+     return;
+ 
+-  iterator entries[m_canvas->height() - 1];
++  iterator* entries = new iterator[m_canvas->height() - 1];
+ 
+   unsigned int last = 0;
+ 
+@@ -179,6 +181,8 @@
+     pos++;
+     first = (first + 1) % (m_canvas->height() - 1);
+   }
++
++  delete entries;
+ }
+ 
+ int
+--- rtorrent-0.8.2.orig/src/display/window_log.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_log.cc	2008-06-25 03:13:37.195603865 -0400
+@@ -37,6 +37,7 @@
+ #include "config.h"
+ 
+ #include <ctime>
++#include <rak/algorithm.h>
+ 
+ #include "canvas.h"
+ #include "utils.h"
+--- rtorrent-0.8.2.orig/src/display/frame.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/frame.cc	2008-06-25 02:51:41.636803977 -0400
+@@ -41,6 +41,8 @@
+ #include <rak/algorithm.h>
+ #include <torrent/exceptions.h>
+ 
++#include "manager.h"
++
+ #include "frame.h"
+ #include "window.h"
+ 
+@@ -63,8 +65,8 @@
+ 
+   case TYPE_ROW:
+   case TYPE_COLUMN:
+-    for (size_type i = 0; i < m_containerSize; ++i)
+-      if (m_container[i]->is_width_dynamic())
++    for (size_type i = 0; i < m_container.size; ++i)
++      if (m_container.frames[i]->is_width_dynamic())
+         return true;
+ 
+     return false;
+@@ -81,8 +83,8 @@
+ 
+   case TYPE_ROW:
+   case TYPE_COLUMN:
+-    for (size_type i = 0; i < m_containerSize; ++i)
+-      if (m_container[i]->is_height_dynamic())
++    for (size_type i = 0; i < m_container.size; ++i)
++      if (m_container.frames[i]->is_height_dynamic())
+         return true;
+ 
+     return false;
+@@ -99,8 +101,8 @@
+   case TYPE_WINDOW: return m_window->is_active() && m_window->is_left();
+ 
+   case TYPE_COLUMN:
+-    for (size_type i = 0; i < m_containerSize; ++i)
+-      if (m_container[i]->has_left_frame())
++    for (size_type i = 0; i < m_container.size; ++i)
++      if (m_container.frames[i]->has_left_frame())
+         return true;
+ 
+     return false;
+@@ -117,8 +119,8 @@
+   case TYPE_WINDOW: return m_window->is_active() && m_window->is_bottom();
+ 
+   case TYPE_ROW:
+-    for (size_type i = 0; i < m_containerSize; ++i)
+-      if (m_container[i]->has_bottom_frame())
++    for (size_type i = 0; i < m_container.size; ++i)
++      if (m_container.frames[i]->has_bottom_frame())
+         return true;
+ 
+     return false;
+@@ -145,8 +147,8 @@
+     {
+       bounds_type accum(0, 0, 0, 0);
+ 
+-      for (size_type i = 0; i < m_containerSize; ++i) {
+-        bounds_type p = m_container[i]->preferred_size();
++      for (size_type i = 0; i < m_container.size; ++i) {
++        bounds_type p = m_container.frames[i]->preferred_size();
+  
+         accum.minWidth += p.minWidth;
+         accum.minHeight += p.minHeight;
+@@ -174,13 +176,13 @@
+   if ((m_type != TYPE_ROW && m_type != TYPE_COLUMN) || size >= max_size)
+     throw torrent::internal_error("Frame::set_container_size(...) Bad state.");
+ 
+-  while (m_containerSize > size) {
+-    delete m_container[--m_containerSize];
+-    m_container[m_containerSize] = NULL;
++  while (m_container.size > size) {
++    delete m_container.frames[--m_container.size];
++    m_container.frames[m_container.size] = NULL;
+   }
+ 
+-  while (m_containerSize < size) {
+-    m_container[m_containerSize++] = new Frame();
++  while (m_container.size < size) {
++    m_container.frames[m_container.size++] = new Frame();
+   }
+ }
+ 
+@@ -202,10 +204,10 @@
+     throw torrent::internal_error("Frame::initialize_container(...) size >= max_size.");
+ 
+   m_type = TYPE_ROW;
+-  m_containerSize = size;
++  m_container.size = size;
+ 
+-  for (size_type i = 0; i < m_containerSize; ++i)
+-    m_container[i] = new Frame();
++  for (size_type i = 0; i < m_container.size; ++i)
++    m_container.frames[i] = new Frame();
+ }
+ 
+ void
+@@ -217,10 +219,10 @@
+     throw torrent::internal_error("Frame::initialize_container(...) size >= max_size.");
+ 
+   m_type = TYPE_COLUMN;
+-  m_containerSize = size;
++  m_container.size = size;
+ 
+-  for (size_type i = 0; i < m_containerSize; ++i)
+-    m_container[i] = new Frame();
++  for (size_type i = 0; i < m_container.size; ++i)
++    m_container.frames[i] = new Frame();
+ }
+ 
+ void
+@@ -234,9 +236,9 @@
+     
+   case TYPE_ROW:
+   case TYPE_COLUMN:
+-    for (size_type i = 0; i < m_containerSize; ++i) {
+-      m_container[i]->clear();
+-      delete m_container[i];
++    for (size_type i = 0; i < m_container.size; ++i) {
++      m_container.frames[i]->clear();
++      delete m_container.frames[i];
+     }
+     break;
+ 
+@@ -261,7 +263,7 @@
+ 
+   case TYPE_ROW:
+   case TYPE_COLUMN:
+-    for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr)
++    for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr)
+       (*itr)->refresh();
+ 
+     break;
+@@ -282,7 +284,7 @@
+ 
+   case TYPE_ROW:
+   case TYPE_COLUMN:
+-    for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr)
++    for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr)
+       (*itr)->redraw();
+ 
+     break;
+@@ -343,7 +345,7 @@
+ 
+   int remaining = height;
+   
+-  for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
++  for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr) {
+     bounds_type bounds = (*itr)->preferred_size();
+     
+     if ((*itr)->is_height_dynamic()) {
+@@ -391,7 +393,7 @@
+   // the frame is too small, it will set the remaining windows to zero
+   // extent which will flag them as offscreen.
+ 
+-  for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
++  for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr) {
+     // If there is any remaining space, check if we want to shift
+     // the subsequent frames to the other side of this frame.
+     if (remaining > 0 && (*itr)->has_bottom_frame()) {
+@@ -417,7 +419,7 @@
+ 
+   int remaining = width;
+   
+-  for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
++  for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr) {
+     bounds_type bounds = (*itr)->preferred_size();
+     
+     if ((*itr)->is_width_dynamic()) {
+@@ -465,7 +469,7 @@
+   // the frame is too small, it will set the remaining windows to zero
+   // extent which will flag them as offscreen.
+ 
+-  for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
++  for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr) {
+     // If there is any remaining space, check if we want to shift
+     // the subsequent frames to the other side of this frame.
+     if (remaining > 0 && (*itr)->has_left_frame()) {
+--- rtorrent-0.8.2.orig/src/display/window_download_statusbar.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_download_statusbar.cc	2008-06-25 03:05:11.110750771 -0400
+@@ -61,7 +61,7 @@
+ 
+   m_canvas->erase();
+ 
+-  char buffer[m_canvas->width()];
++  char* buffer = new char[m_canvas->width()];
+   char* position;
+   char* last = buffer + m_canvas->width() - 2;
+ 
+@@ -88,6 +88,8 @@
+                   m_download->tracker_list()->has_active() ? 'C' : ' ',
+                   (int)(m_download->download()->tracker_list()->time_next_connection()),
+                   buffer);
++
++  delete buffer;
+ }
+ 
+ }
+ 
+--- rtorrent-0.8.2.orig/src/core/view.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/view.cc	2008-06-25 02:28:36.651635274 -0400
+@@ -38,6 +38,7 @@
+ 
+ #include <algorithm>
+ #include <functional>
++#include <rak/algorithm.h>
+ #include <rak/functional.h>
+ #include <rak/functional_fun.h>
+ #include <rpc/parse_commands.h>
+--- rtorrent-0.8.2.orig/src/core/manager.cc	2008-06-25 01:44:38.134154000 -0400
++++ rtorrent-0.8.2/src/core/manager.cc	2008-06-25 02:08:43.144712661 -0400
+@@ -352,19 +352,25 @@
+   int port;
+   rak::address_info* ai;
+ 
+-  char buf[addr.length() + 1];
++  char* buf = new char[addr.length() + 1];
+ 
+   int err = std::sscanf(addr.c_str(), "%[^:]:%i", buf, &port);
+ 
+-  if (err <= 0)
++  if (err <= 0) {
++    delete buf;
+     throw torrent::input_error("Could not parse proxy address.");
++  }
+ 
+   if (err == 1)
+     port = 80;
+ 
+-  if ((err = rak::address_info::get_address_info(buf, PF_INET, SOCK_STREAM, &ai)) != 0)
++  if ((err = rak::address_info::get_address_info(buf, PF_INET, SOCK_STREAM, &ai)) != 0) {
++    delete buf;
+     throw torrent::input_error("Could not set proxy address: " + std::string(rak::address_info::strerror(err)) + ".");
+-  
++  }
++
++  delete buf;
++
+   try {
+ 
+     ai->address()->set_port(port);
+--- rtorrent-0.8.2.orig/src/rpc/parse.cc	2008-05-07 08:19:10.000000000 -0400
++++ rtorrent-0.8.2/src/rpc/parse.cc	2008-06-25 17:30:55.775246860 -0400
+@@ -37,6 +37,7 @@
+ #include "config.h"
+ 
+ #include <locale>
++#include <rak/algorithm.h>
+ #include <rak/path.h>
+ #include <torrent/exceptions.h>
+ 
+--- rtorrent-0.8.2.orig/src/rpc/xmlrpc.cc	2008-05-07 08:19:10.000000000 -0400
++++ rtorrent-0.8.2/src/rpc/xmlrpc.cc	2008-06-25 17:54:04.404987582 -0400
+@@ -477,7 +477,8 @@
+   xmlrpc_env_init(&localEnv);
+ 
+   xmlrpc_registry_add_method_w_doc(&localEnv, (xmlrpc_registry*)m_registry, NULL, name,
+-                                   &xmlrpc_call_command, const_cast<char*>(name), parm, doc);
++                                   (const xmlrpc_method)(&xmlrpc_call_command),
++				   const_cast<char*>(name), parm, doc);
+ 
+   if (localEnv.fault_occurred)
+     throw torrent::internal_error("Fault occured while inserting xmlrpc call.");
+--- rtorrent-0.8.2.orig/src/rpc/scgi.cc	2008-06-25 01:44:38.128033000 -0400
++++ rtorrent-0.8.2/src/rpc/scgi.cc	2008-06-25 17:32:13.998638901 -0400
+@@ -85,7 +85,7 @@
+   if (filename.empty() || filename.size() > 4096)
+     throw torrent::resource_error("Invalid filename length.");
+ 
+-  char buffer[sizeof(sockaddr_un) + filename.size()];
++  char* buffer = new char[sizeof(sockaddr_un) + filename.size()];
+   sockaddr_un* sa = reinterpret_cast<sockaddr_un*>(buffer);
+ 
+   sa->sun_family = AF_UNIX;
+@@ -96,6 +96,7 @@
+ 
+   open(sa, offsetof(struct sockaddr_un, sun_path) + filename.size() + 1);
+   m_path = filename;
++  delete buffer;
+ }
+ 
+ void
+--- rtorrent-0.8.2.orig/src/rpc/scgi_task.cc	2008-05-07 08:19:10.000000000 -0400
++++ rtorrent-0.8.2/src/rpc/scgi_task.cc	2008-06-25 17:41:41.493886588 -0400
+@@ -134,7 +134,7 @@
+     if (current == m_buffer || *current != ':' || headerSize < 17 || headerSize > max_header_size)
+       goto event_read_failed;
+ 
+-    if (std::distance(++current, m_position) < headerSize + 1)
++    if (m_position - (++current) < headerSize + 1)
+       return;
+ 
+     if (std::memcmp(current, "CONTENT_LENGTH", 15) != 0)
+@@ -147,7 +147,7 @@
+       goto event_read_failed;
+ 
+     m_body = current + headerSize + 1;
+-    headerSize = std::distance(m_buffer, m_body);
++    headerSize = m_body - m_buffer;
+ 
+     if ((unsigned int)(contentSize + headerSize) < m_bufferSize) {
+       m_bufferSize = contentSize + headerSize;

Added: csw/mgar/pkg/rtorrent/trunk/files/rtorrent-05-sunpro-crash.diff
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/files/rtorrent-05-sunpro-crash.diff	                        (rev 0)
+++ csw/mgar/pkg/rtorrent/trunk/files/rtorrent-05-sunpro-crash.diff	2010-05-26 16:01:01 UTC (rev 9996)
@@ -0,0 +1,52 @@
+--- rtorrent-0.8.2.orig/src/ui/download_list.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/ui/download_list.cc	2008-06-27 21:16:40.822674954 -0400
+@@ -234,7 +234,7 @@
+ 
+   input::PathInput* input = new input::PathInput;
+ 
+-  const char* title;
++  std::string title;
+ 
+   switch (type) {
+   case INPUT_LOAD_DEFAULT:
+--- rtorrent-0.8.2.orig/src/display/window_input.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_input.cc	2008-06-27 21:12:27.929764942 -0400
+@@ -43,6 +43,11 @@
+ 
+ namespace display {
+ 
++WindowInput::WindowInput() :
++  Window(new Canvas, 0, 0, 1, extent_full, 1),
++  m_input(NULL),
++  m_focus(false) {}
++
+ void
+ WindowInput::redraw() {
+   m_canvas->erase();
+--- rtorrent-0.8.2.orig/src/display/window_input.h	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_input.h	2008-06-27 20:40:35.526518241 -0400
+@@ -49,10 +49,7 @@
+ 
+ class WindowInput : public Window {
+ public:
+-  WindowInput() :
+-    Window(new Canvas, 0, 0, 1, extent_full, 1),
+-    m_input(NULL),
+-    m_focus(false) {}
++  WindowInput();
+ 
+   input::TextInput*   input()                            { return m_input; }
+   void                set_input(input::TextInput* input) { m_input = input; }
+--- rtorrent-0.8.2.orig/src/core/manager.cc	2008-06-26 00:37:03.743465000 -0400
++++ rtorrent-0.8.2/src/core/manager.cc	2008-06-26 22:13:52.331952728 -0400
+@@ -219,7 +219,9 @@
+   m_downloadList->slot_map_insert()["1_connect_logs"] = "d.initialize_logs=";
+   m_downloadList->slot_map_erase()["9_delete_tied"]   = "d.delete_tied=";
+ 
+-  torrent::connection_manager()->set_signal_handshake_log(sigc::mem_fun(this, &Manager::handshake_log));
++  torrent::ConnectionManager::signal_handshake_type& s = torrent::connection_manager()->signal_handshake_log();
++  s.connect(sigc::mem_fun(this, &Manager::handshake_log));
++  //torrent::connection_manager()->set_signal_handshake_log(sigc::mem_fun(this, &Manager::handshake_log));
+ }
+ 
+ void

Added: csw/mgar/pkg/rtorrent/trunk/files/scratch.patch
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/files/scratch.patch	                        (rev 0)
+++ csw/mgar/pkg/rtorrent/trunk/files/scratch.patch	2010-05-26 16:01:01 UTC (rev 9996)
@@ -0,0 +1,64 @@
+--- rtorrent-0.8.2.orig/src/core/scheduler.cc   2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/scheduler.cc        2008-06-25 02:19:20.043037414 -0400
+@@ -37,6 +37,7 @@
+ #include "config.h"
+
+ #include <algorithm>
++#include <rak/algorithm.h>
+ #include <rak/functional.h>
+ #include <torrent/exceptions.h>
+
+--- rtorrent-0.8.2.orig/src/rpc/scgi_task.cc    2008-05-07 08:19:10.000000000 -0400
++++ rtorrent-0.8.2/src/rpc/scgi_task.cc 2008-06-25 17:41:41.493886588 -0400
+@@ -134,7 +134,7 @@
+     if (current == m_buffer || *current != ':' || headerSize < 17 || headerSize > max_header_size)
+       goto event_read_failed;
+
+-    if (std::distance(++current, m_position) < headerSize + 1)
++    if (m_position - (++current) < headerSize + 1)
+       return;
+
+     if (std::memcmp(current, "CONTENT_LENGTH", 15) != 0)
+@@ -147,7 +147,7 @@
+       goto event_read_failed;
+
+     m_body = current + headerSize + 1;
+-    headerSize = std::distance(m_buffer, m_body);
++    headerSize = m_body - m_buffer;
+
+     if ((unsigned int)(contentSize + headerSize) < m_bufferSize) {
+       m_bufferSize = contentSize + headerSize;
+@@ -155,26 +155,26 @@
+     } else if ((unsigned int)contentSize <= default_buffer_size) {
+       m_bufferSize = contentSize;
+
+-      std::memmove(m_buffer, m_body, std::distance(m_body, m_position));
+-      m_position = m_buffer + std::distance(m_body, m_position);
++      std::memmove(m_buffer, m_body, m_position - m_body);
++      m_position = m_buffer + (m_position - m_body);
+       m_body = m_buffer;
+
+     } else {
+-      realloc_buffer((m_bufferSize = contentSize) + 1, m_body, std::distance(m_body, m_position));
++      realloc_buffer((m_bufferSize = contentSize) + 1, m_body, m_position - m_body);
+
+-      m_position = m_buffer + std::distance(m_body, m_position);
++      m_position = m_buffer + (m_position - m_body);
+       m_body = m_buffer;
+     }
+   }
+
+-  if ((unsigned int)std::distance(m_buffer, m_position) != m_bufferSize)
++  if ((unsigned int)(m_position - m_buffer) != m_bufferSize)
+     return;
+
+   control->poll()->remove_read(this);
+   control->poll()->insert_write(this);
+
+   // Close if the call failed, else stay open to write back data.
+-  if (!m_parent->receive_call(this, m_body, m_bufferSize - std::distance(m_buffer, m_body)))
++  if (!m_parent->receive_call(this, m_body, m_bufferSize - (m_body - m_buffer)))
+     close();
+
+   return;
+

Added: csw/mgar/pkg/rtorrent/trunk/files/work-around-UNUSED.patch
===================================================================
--- csw/mgar/pkg/rtorrent/trunk/files/work-around-UNUSED.patch	                        (rev 0)
+++ csw/mgar/pkg/rtorrent/trunk/files/work-around-UNUSED.patch	2010-05-26 16:01:01 UTC (rev 9996)
@@ -0,0 +1,25 @@
+From 5a6aaf6dd0b924c323d591986117823457bdb387 Mon Sep 17 00:00:00 2001
+From: Jan Holzhueter <jh at current9s.(none)>
+Date: Thu, 20 May 2010 10:59:04 +0200
+Subject: [PATCH] work around __UNUSED
+
+---
+ rak/string_manip.h             |    2 ++
+ 3 files changed, 6 insertions(+), 0 deletions(-)
+
+diff --git a/rak/string_manip.h b/rak/string_manip.h
+index b3f3037..a4f1a6c 100644
+--- a/rak/string_manip.h
++++ b/rak/string_manip.h
+@@ -43,6 +43,8 @@
+ #include <iterator>
+ #include <locale>
+ 
++#define __UNUSED
++
+ namespace rak {
+ 
+ // Use these trim functions until n1872 is widely supported.
+-- 
+1.7.1
+


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list