* Include locally available chunks in the "chunks seen" statistics for completed/distributed copies. Patch by Josef Drexler.

* Added 'd.get_bitfield' command for retrieving the bitfield in hex format. Patch by Thomas Rosner. (PD)

* Fixed include headers for gcc-4.4.0. Patch by 'kloeri'.

* Switched a 'long long' with 'int64_t' in xmlrpc.cc to avoid incompatible types for some systems.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1092 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2009-05-14 13:07:47 +00:00
parent 855bf9a781
commit 63af7078a3
13 changed files with 54 additions and 16 deletions
+8 -6
View File
@@ -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)
+9
View File
@@ -38,6 +38,7 @@
#include <functional>
#include <unistd.h>
#include <cstdio>
#include <rak/file_stat.h>
#include <rak/error_number.h>
#include <rak/path.h>
@@ -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)));
+1
View File
@@ -37,6 +37,7 @@
#include "config.h"
#include <functional>
#include <cstdio>
#include <rak/file_stat.h>
#include <rak/path.h>
#include <rak/string_manip.h>
+1
View File
@@ -37,6 +37,7 @@
#include "config.h"
#include <functional>
#include <cstdio>
#include <rak/address_info.h>
#include <rak/path.h>
#include <torrent/connection_manager.h>
+8 -6
View File
@@ -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<uint8_t>::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
+1
View File
@@ -37,6 +37,7 @@
#include "config.h"
#include <cstring>
#include <cstdio>
#include <sstream>
#include <iomanip>
#include <rak/socket_address.h>
+1
View File
@@ -38,6 +38,7 @@
#define RTORRENT_DISPLAY_UTILS_H
#include <ctime>
#include <cstdio>
#include <string>
namespace core {
+1 -1
View File
@@ -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);
+1
View File
@@ -37,6 +37,7 @@
#include "config.h"
#include <cstring>
#include <cstdio>
#include <locale>
#include <rak/path.h>
#include <torrent/exceptions.h>
+1
View File
@@ -37,6 +37,7 @@
#include "config.h"
#include <rak/error_number.h>
#include <cstdio>
#include <sys/types.h>
#include <sys/socket.h>
#include <torrent/exceptions.h>
+2 -2
View File
@@ -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);
+1
View File
@@ -40,6 +40,7 @@
#include <cctype>
#include <cerrno>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <fcntl.h>
#include <signal.h>