mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-06 02:02:30 +00:00
* Initial work on a global chunk manager for controlling memory usage,
and checking if enough disk space is available for MS_ASYNC to be safe. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@743 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+2
-2
@@ -1,4 +1,4 @@
|
||||
AC_INIT(rtorrent, 0.6.0, jaris@ifi.uio.no)
|
||||
AC_INIT(rtorrent, 0.6.1, jaris@ifi.uio.no)
|
||||
|
||||
AM_INIT_AUTOMAKE
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
@@ -23,7 +23,7 @@ TORRENT_WITHOUT_NCURSESW()
|
||||
TORRENT_WITHOUT_STATVFS()
|
||||
TORRENT_WITHOUT_STATFS()
|
||||
|
||||
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.10.0,
|
||||
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.10.1,
|
||||
CXXFLAGS="$CXXFLAGS $STUFF_CFLAGS $CURL_CFLAGS";
|
||||
LIBS="$LIBS $STUFF_LIBS $CURL_LIBS")
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
static const int e_deadlk = EDEADLK;
|
||||
|
||||
static const int e_noent = ENOENT;
|
||||
static const int e_nomem = ENOMEM;
|
||||
static const int e_notdir = ENOTDIR;
|
||||
|
||||
static const int e_intr = EINTR;
|
||||
|
||||
+2
-2
@@ -71,9 +71,9 @@ public:
|
||||
bool update(const char* fn) { return FS_STAT_FN; }
|
||||
bool update(const std::string& filename) { return update(filename.c_str()); }
|
||||
|
||||
blocksize_type blocksize() { return m_stat.f_bsize; }
|
||||
blocksize_type blocksize() { return FS_STAT_BLOCK_SIZE; }
|
||||
blockcount_type blocks_avail() { return m_stat.f_bavail; }
|
||||
int64_t bytes_avail() { return (int64_t) m_stat.f_bsize * m_stat.f_bavail; }
|
||||
int64_t bytes_avail() { return (int64_t) blocksize() * m_stat.f_bavail; }
|
||||
|
||||
private:
|
||||
fs_stat_type m_stat;
|
||||
|
||||
@@ -229,6 +229,7 @@ AC_DEFUN([TORRENT_CHECK_STATVFS], [
|
||||
AC_DEFINE(FS_STAT_STRUCT, [struct statvfs], Type of second argument to statfs function)
|
||||
AC_DEFINE(FS_STAT_SIZE_TYPE, [unsigned long], Type of block size member in stat struct)
|
||||
AC_DEFINE(FS_STAT_COUNT_TYPE, [fsblkcnt_t], Type of block count member in stat struct)
|
||||
AC_DEFINE(FS_STAT_BLOCK_SIZE, [(m_stat.f_frsize)], Determine the block size)
|
||||
AC_MSG_RESULT(ok)
|
||||
have_stat_vfs=yes
|
||||
],
|
||||
@@ -265,6 +266,7 @@ AC_DEFUN([TORRENT_CHECK_STATFS], [
|
||||
AC_DEFINE(FS_STAT_STRUCT, [struct statfs], Type of second argument to statfs function)
|
||||
AC_DEFINE(FS_STAT_SIZE_TYPE, [long], Type of block size member in stat struct)
|
||||
AC_DEFINE(FS_STAT_COUNT_TYPE, [long], Type of block count member in stat struct)
|
||||
AC_DEFINE(FS_STAT_BLOCK_SIZE, [(m_stat.f_bsize)], Determine the block size)
|
||||
AC_MSG_RESULT(ok)
|
||||
],
|
||||
[
|
||||
@@ -278,6 +280,7 @@ AC_DEFUN([TORRENT_DISABLED_STATFS], [
|
||||
AC_DEFINE(FS_STAT_STRUCT, [struct {blocksize_type f_bsize; blockcount_type f_bavail;}], Type of second argument to statfs function)
|
||||
AC_DEFINE(FS_STAT_SIZE_TYPE, [int], Type of block size member in stat struct)
|
||||
AC_DEFINE(FS_STAT_COUNT_TYPE, [int], Type of block count member in stat struct)
|
||||
AC_DEFINE(FS_STAT_BLOCK_SIZE, [(4096)], Determine the block size)
|
||||
AC_MSG_RESULT(No filesystem stats available)
|
||||
])
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ ClientInfo::ClientInfo() {
|
||||
insert(TYPE_AZUREUS, "CT", "CTorrent");
|
||||
insert(TYPE_AZUREUS, "MT", "MoonlightTorrent");
|
||||
insert(TYPE_AZUREUS, "LT", "libtorrent");
|
||||
insert(TYPE_AZUREUS, "LP", "Lphant");
|
||||
insert(TYPE_AZUREUS, "KT", "KTorrent");
|
||||
insert(TYPE_AZUREUS, "BX", "Bittorrent X");
|
||||
insert(TYPE_AZUREUS, "TS", "Torrentstorm");
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <rak/socket_address.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/connection_manager.h>
|
||||
#include <torrent/chunk_manager.h>
|
||||
|
||||
#include "core/download.h"
|
||||
|
||||
@@ -73,10 +73,7 @@ WindowPeerInfo::redraw() {
|
||||
|
||||
m_canvas->print(0, y++, "Hash: %s", rak::transform_hex(d->info_hash()).c_str());
|
||||
m_canvas->print(0, y++, "Id: %s", rak::copy_escape_html(d->local_id()).c_str());
|
||||
m_canvas->print(0, y++, "Chunks: %u / %u * %u",
|
||||
d->chunks_done(),
|
||||
d->chunks_total(),
|
||||
d->chunks_size());
|
||||
m_canvas->print(0, y++, "Chunks: %u / %u * %u", d->chunks_done(), d->chunks_total(), d->chunks_size());
|
||||
|
||||
y++;
|
||||
|
||||
@@ -89,9 +86,9 @@ WindowPeerInfo::redraw() {
|
||||
y++;
|
||||
|
||||
m_canvas->print(0, y++, "Connection Type: %s ( %s / %s )",
|
||||
m_download->variable()->get("connection_current").as_string().c_str(),
|
||||
m_download->variable()->get("connection_seed").as_string().c_str(),
|
||||
m_download->variable()->get("connection_leech").as_string().c_str());
|
||||
m_download->variable()->get("connection_current").as_string().c_str(),
|
||||
m_download->variable()->get("connection_seed").as_string().c_str(),
|
||||
m_download->variable()->get("connection_leech").as_string().c_str());
|
||||
m_canvas->print(0, y++, "Priority: %u", torrent::download_priority(*m_download->download()));
|
||||
|
||||
m_canvas->print(0, y++, "Directory: %s", m_download->variable_string("directory").c_str());
|
||||
@@ -103,7 +100,10 @@ WindowPeerInfo::redraw() {
|
||||
// m_canvas->print(0, y++, "SndBuf: %u", torrent::connection_manager()->send_buffer_size());
|
||||
// m_canvas->print(0, y++, "RcvBuf: %u", torrent::connection_manager()->receive_buffer_size());
|
||||
|
||||
// y++;
|
||||
m_canvas->print(0, y++, "MemUsage: %llu", torrent::chunk_manager()->memory_usage());
|
||||
m_canvas->print(0, y++, "MaxMemUsage: %llu", torrent::chunk_manager()->max_memory_usage());
|
||||
|
||||
y++;
|
||||
|
||||
if (*m_focus == m_list->end()) {
|
||||
m_canvas->print(0, y++, "No peer in focus");
|
||||
@@ -114,8 +114,8 @@ WindowPeerInfo::redraw() {
|
||||
m_canvas->print(0, y++, "*** Peer Info ***");
|
||||
|
||||
m_canvas->print(0, y++, "IP: %s:%hu",
|
||||
rak::socket_address::cast_from((*m_focus)->address())->address_str().c_str(),
|
||||
rak::socket_address::cast_from((*m_focus)->address())->port());
|
||||
rak::socket_address::cast_from((*m_focus)->address())->address_str().c_str(),
|
||||
rak::socket_address::cast_from((*m_focus)->address())->port());
|
||||
|
||||
m_canvas->print(0, y++, "ID: %s" , rak::copy_escape_html((*m_focus)->id()).c_str());
|
||||
|
||||
@@ -131,10 +131,10 @@ WindowPeerInfo::redraw() {
|
||||
m_canvas->print(0, y++, "Done: %i%", done_percentage(**m_focus));
|
||||
|
||||
m_canvas->print(0, y++, "Rate: %5.1f/%5.1f KB Total: %.1f/%.1f MB",
|
||||
(double)(*m_focus)->up_rate()->rate() / (double)(1 << 10),
|
||||
(double)(*m_focus)->down_rate()->rate() / (double)(1 << 10),
|
||||
(double)(*m_focus)->up_rate()->total() / (double)(1 << 20),
|
||||
(double)(*m_focus)->down_rate()->total() / (double)(1 << 20));
|
||||
(double)(*m_focus)->up_rate()->rate() / (double)(1 << 10),
|
||||
(double)(*m_focus)->down_rate()->rate() / (double)(1 << 10),
|
||||
(double)(*m_focus)->up_rate()->total() / (double)(1 << 20),
|
||||
(double)(*m_focus)->down_rate()->total() / (double)(1 << 20));
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/chunk_manager.h>
|
||||
#include <torrent/connection_manager.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/file.h>
|
||||
@@ -213,8 +214,10 @@ apply_stop_on_ratio(Control* m, const std::string& arg) {
|
||||
int64_t totalUpload = (*itr)->download()->up_rate()->total();
|
||||
int64_t totalDone = (*itr)->download()->bytes_done();
|
||||
|
||||
if ((totalUpload >= minUpload && totalUpload * 100 >= totalDone * minRatio) || (maxRatio > 0 && totalUpload * 100 > totalDone * maxRatio))
|
||||
m->core()->download_list()->stop_try(*itr);
|
||||
if ((totalUpload >= minUpload && totalUpload * 100 >= totalDone * minRatio) || (maxRatio > 0 && totalUpload * 100 > totalDone * maxRatio)) {
|
||||
m->core()->download_list()->stop_try(*itr);
|
||||
(*itr)->variable()->set("ignore_commands", (int64_t)1);
|
||||
}
|
||||
|
||||
++itr;
|
||||
}
|
||||
@@ -463,6 +466,9 @@ initialize_option_handler(Control* c) {
|
||||
variables->insert("receive_buffer_size", new utils::VariableValueSlot(rak::mem_fn(torrent::connection_manager(), &torrent::ConnectionManager::receive_buffer_size),
|
||||
rak::mem_fn(torrent::connection_manager(), &torrent::ConnectionManager::set_receive_buffer_size)));
|
||||
|
||||
variables->insert("max_memory_usage", new utils::VariableValueSlot(rak::mem_fn(torrent::chunk_manager(), &torrent::ChunkManager::max_memory_usage),
|
||||
rak::mem_fn(torrent::chunk_manager(), &torrent::ChunkManager::set_max_memory_usage)));
|
||||
|
||||
variables->insert("port_range", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::bind_ptr_fn(&apply_port_range, c)));
|
||||
|
||||
variables->insert("hash_read_ahead", new utils::VariableValueSlot(rak::ptr_fn(torrent::hash_read_ahead), rak::bind_ptr_fn(&apply_hash_read_ahead, c)));
|
||||
|
||||
Reference in New Issue
Block a user