diff --git a/doc/rtorrent.1 b/doc/rtorrent.1
index dc2ebb01..fa5477f2 100644
--- a/doc/rtorrent.1
+++ b/doc/rtorrent.1
@@ -3,7 +3,7 @@
.\"
.\" Please send any bug reports, improvements, comments, patches,
.\" etc. to Steve Cheng .
-.TH "RTORRENT" "1" "07 May 2008" "BitTorrent client for ncurses" ""
+.TH "RTORRENT" "1" "14 May 2009" "BitTorrent client for ncurses" ""
.SH NAME
rtorrent \- a BitTorrent client for ncurses
@@ -349,6 +349,24 @@ setting \fB0\fR\&.
\fBmax_downloads_global = \fIvalue\fB\fR
Max upload and download slots allowed. Disable by
setting \fB0\fR\&.
+.TP
+\fBthrottle_up = \fIname\fB, \fIupload_rate\fB\fR
+.TP
+\fBthrottle_down = \fIname\fB, \fIdownload_rate\fB\fR
+Define secondary throttle and/or set the given upload or download rate. Attach to a download with the d.set_throttle_name=name command
+or switch throttles with Ctrl-T. Download must be stopped when changing throttles. Note that secondary throttles only work if the
+global upload/download is throttled. Setting a download to use the \fBNULL\fR throttle makes the download unthrottled
+even when there is a global throttle. Note that this special case bypasses the global throttle entirely, and as such its rate and
+transfer amounts are not included in the global statistics.
+.TP
+\fBthrottle_ip = \fIname\fB, \fIhost\fB\fR
+.TP
+\fBthrottle_ip = \fIname\fB, \fInetwork/prefix\fB\fR
+.TP
+\fBthrottle_ip = \fIname\fB, \fIstart\fB, \fIend\fB\fR
+Use the given secondary throttle for a host, CIDR network or IP range. All peers with a matching IP will use this throttle instead
+of the global throttle or a custom download throttle. The name may be \fBNULL\fR to make these peers unthrottled, with
+the same caveats as explained above.
.SH "TRACKER RELATED SETTINGS"
.PP
Tracker related settings.
diff --git a/src/Makefile.am b/src/Makefile.am
index 1936c7d8..f70b0923 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,12 +9,12 @@ SUBDIRS = \
bin_PROGRAMS = rtorrent
rtorrent_LDADD = \
- $(top_srcdir)/src/ui/libsub_ui.a \
- $(top_srcdir)/src/core/libsub_core.a \
- $(top_srcdir)/src/display/libsub_display.a \
- $(top_srcdir)/src/input/libsub_input.a \
- $(top_srcdir)/src/rpc/libsub_rpc.a \
- $(top_srcdir)/src/utils/libsub_utils.a
+ ui/libsub_ui.a \
+ core/libsub_core.a \
+ display/libsub_display.a \
+ input/libsub_input.a \
+ rpc/libsub_rpc.a \
+ utils/libsub_utils.a
rtorrent_SOURCES = \
command_download.cc \
@@ -39,3 +39,5 @@ rtorrent_SOURCES = \
option_parser.h \
signal_handler.cc \
signal_handler.h
+
+INCLUDES = -I$(srcdir) -I$(top_srcdir)
diff --git a/src/command_download.cc b/src/command_download.cc
index de40114d..facc96e0 100644
--- a/src/command_download.cc
+++ b/src/command_download.cc
@@ -38,6 +38,7 @@
#include
#include
+#include
#include
#include
#include
@@ -289,6 +290,13 @@ retrieve_d_custom_throw(core::Download* download, const std::string& key) {
}
}
+torrent::Object
+retrieve_d_bitfield(core::Download* download) {
+ const torrent::Bitfield* bitField = download->download()->file_list()->bitfield();
+
+ return torrent::Object(rak::transform_hex(bitField->begin(), bitField->end()));
+}
+
// Just a helper function atm.
torrent::Object
cmd_d_initialize_logs(core::Download* download) {
@@ -552,6 +560,7 @@ initialize_command_download() {
ADD_CD_VOID("hash", &retrieve_d_hash);
ADD_CD_VOID("local_id", &retrieve_d_local_id);
ADD_CD_VOID("local_id_html", &retrieve_d_local_id_html);
+ ADD_CD_VOID("bitfield", &retrieve_d_bitfield);
ADD_CD_VOID("base_path", &retrieve_d_base_path);
ADD_CD_VOID("base_filename", &retrieve_d_base_filename);
ADD_CD_STRING_UNI("name", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::name)));
diff --git a/src/command_events.cc b/src/command_events.cc
index c3974fc6..b25dfbc2 100644
--- a/src/command_events.cc
+++ b/src/command_events.cc
@@ -37,6 +37,7 @@
#include "config.h"
#include
+#include
#include
#include
#include
diff --git a/src/command_network.cc b/src/command_network.cc
index cce13d36..d5992efd 100644
--- a/src/command_network.cc
+++ b/src/command_network.cc
@@ -37,6 +37,7 @@
#include "config.h"
#include
+#include
#include
#include
#include
diff --git a/src/core/download.cc b/src/core/download.cc
index 0e2185b0..1f6947a4 100644
--- a/src/core/download.cc
+++ b/src/core/download.cc
@@ -131,7 +131,7 @@ Download::receive_storage_error(std::string msg) {
float
Download::distributed_copies() const {
const uint8_t* avail = m_download.chunks_seen();
- const uint8_t* end = avail + m_download.file_list()->size_chunks();
+ const torrent::Bitfield* bitfield = m_download.file_list()->bitfield();
if (avail == NULL)
return 0;
@@ -139,15 +139,17 @@ Download::distributed_copies() const {
int minAvail = std::numeric_limits::max();
int num = 0;
- for (; avail < end; ++avail)
- if (*avail == minAvail) {
+ for (uint32_t i = m_download.file_list()->size_chunks(); i-- > 0; ) {
+ int totAvail = (int)avail[i] + bitfield->get(i);
+ if (totAvail == minAvail) {
num++;
- } else if (*avail < minAvail) {
- minAvail = *avail;
+ } else if (totAvail < minAvail) {
+ minAvail = totAvail;
num = 1;
}
+ }
- return minAvail + 1 - (float)num / m_download.file_list()->size_chunks();
+ return minAvail + 1 - bitfield->is_all_set() - (float)num / m_download.file_list()->size_chunks();
}
void
diff --git a/src/display/utils.cc b/src/display/utils.cc
index af24fa1b..d2f1af47 100644
--- a/src/display/utils.cc
+++ b/src/display/utils.cc
@@ -37,6 +37,7 @@
#include "config.h"
#include
+#include
#include
#include
#include
diff --git a/src/display/utils.h b/src/display/utils.h
index aeec90a9..48637e64 100644
--- a/src/display/utils.h
+++ b/src/display/utils.h
@@ -38,6 +38,7 @@
#define RTORRENT_DISPLAY_UTILS_H
#include
+#include
#include
namespace core {
diff --git a/src/display/window_download_chunks_seen.cc b/src/display/window_download_chunks_seen.cc
index e318e53c..15b37b5e 100644
--- a/src/display/window_download_chunks_seen.cc
+++ b/src/display/window_download_chunks_seen.cc
@@ -67,7 +67,7 @@ WindowDownloadChunksSeen::redraw() {
return;
m_canvas->print(2, 0, "Chunks seen: [C/A/D %i/%i/%.2f]",
- (int)m_download->download()->peers_complete(),
+ (int)m_download->download()->peers_complete() + m_download->download()->file_list()->is_done(),
(int)m_download->download()->peers_accounted(),
std::floor(m_download->distributed_copies() * 100.0f) / 100.0f);
diff --git a/src/rpc/parse.cc b/src/rpc/parse.cc
index 10abe425..55c67a4f 100644
--- a/src/rpc/parse.cc
+++ b/src/rpc/parse.cc
@@ -37,6 +37,7 @@
#include "config.h"
#include
+#include
#include
#include
#include
diff --git a/src/rpc/scgi_task.cc b/src/rpc/scgi_task.cc
index 46d37f85..ed058c36 100644
--- a/src/rpc/scgi_task.cc
+++ b/src/rpc/scgi_task.cc
@@ -37,6 +37,7 @@
#include "config.h"
#include
+#include
#include
#include
#include
diff --git a/src/rpc/xmlrpc.cc b/src/rpc/xmlrpc.cc
index f57c5436..aac87a58 100644
--- a/src/rpc/xmlrpc.cc
+++ b/src/rpc/xmlrpc.cc
@@ -98,7 +98,7 @@ xmlrpc_list_entry_to_value(xmlrpc_env* env, xmlrpc_value* src, int index) {
#ifdef XMLRPC_HAVE_I8
case XMLRPC_TYPE_I8:
- long long v2;
+ int64_t v2;
xmlrpc_read_i8(env, tmp, &v2);
xmlrpc_DECREF(tmp);
return v2;
@@ -244,7 +244,7 @@ xmlrpc_to_object(xmlrpc_env* env, xmlrpc_value* value, int callType, rpc::target
#ifdef XMLRPC_HAVE_I8
case XMLRPC_TYPE_I8:
- long long v2;
+ int64_t v2;
xmlrpc_read_i8(env, value, &v2);
return torrent::Object((int64_t)v2);
diff --git a/src/utils/lockfile.cc b/src/utils/lockfile.cc
index 33a60299..d81c71fb 100644
--- a/src/utils/lockfile.cc
+++ b/src/utils/lockfile.cc
@@ -40,6 +40,7 @@
#include
#include
#include
+#include
#include
#include
#include