From 7ff232848aadcc8307cac8fddf9eb8f3fa6b6468 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Fri, 29 Jul 2011 12:09:29 +0000 Subject: [PATCH] * Minor fixes to the choke group implementation. * Added some documentation. * Fixed a compiler bug on gcc-4.6.1. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1255 e378c898-3ddf-0310-93e7-cc216c733640 --- src/command_groups.cc | 67 +++++++++++++++++++++++++++++++++++++++---- src/main.cc | 2 +- 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/src/command_groups.cc b/src/command_groups.cc index 43a1536c..d1184343 100644 --- a/src/command_groups.cc +++ b/src/command_groups.cc @@ -113,11 +113,6 @@ std::vector cg_list_hack; int64_t cg_get_index(const torrent::Object& raw_args) { - if (cg_list_hack.empty()) { - cg_list_hack.push_back(new torrent::choke_group()); - cg_list_hack.back()->set_name("default"); - } - const torrent::Object& arg = (raw_args.is_list() && !raw_args.as_list().empty()) ? raw_args.as_list().front() : raw_args; int64_t index = 0; @@ -247,6 +242,65 @@ apply_cg_tracker_mode_set(const torrent::Object::list_type& args) { #define CG_GROUP_AT() std::bind(&cg_get_group, std::placeholders::_2) #define CHOKE_GROUP(direction) std::bind(direction, CG_GROUP_AT()) +/* + + -> '0'..'(choke_group.size)' + -> '-1'..'-(choke_group.size)' + -> '' + +(choke_group.list) -> List of group names. +(choke_group.size) -> Number of groups. + +(choke_group.insert,"group_name") + +Adds a new group with default settings, use index '-1' to accessing it +immediately afterwards. + +(choke_group.index_of,"group_name") -> + +Throws if the group name was not found. + +(choke_group.general.size,) -> + +Number of torrents in this group. + +(choke_group.tracker.mode,) -> "tracker_mode" +(choke_group.tracker.mode.set,,"tracker_mode") + +Decide on how aggressive a tracker should be, see +'strings.tracker_mode' for list of available options + +(choke_group.up.rate,) -> +(choke_group.down.rate,) -> + +Upload / download rate for the aggregate of all torrents in this +particular group. + +(choke_group.up.max,) -> +(choke_group.up.max.set,, ) +(choke_group.down.max,) -> +(choke_group.down.max.set,, ) -> +(choke_group.up.queued,) -> +(choke_group.up.unchoked,) -> +(choke_group.down.total,) -> +(choke_group.down.queued,) -> +(choke_group.down.unchoked,) -> + +(choke_group.up.heuristics,) -> "heuristics" +(choke_group.up.heuristics.set,,"heuristics") +(choke_group.down.heuristics,) -> "heuristics" +(choke_group.down.heuristics.set,,"heuristics") + +Heuristics used for deciding what peers to choke and unchoke, see +'strings.choke_heuristics' for a list of available options. + + */ + + void initialize_command_groups() { // Move somewhere else? @@ -260,6 +314,9 @@ initialize_command_groups() { CMD2_ANY ("choke_group.size", std::bind(&torrent::ResourceManager::group_size, torrent::resource_manager())); CMD2_ANY_STRING ("choke_group.index_of", std::bind(&torrent::ResourceManager::group_index_of, torrent::resource_manager(), std::placeholders::_2)); #else + cg_list_hack.push_back(new torrent::choke_group()); + cg_list_hack.back()->set_name("default"); + CMD2_ANY ("choke_group.size", std::bind(&std::vector::size, cg_list_hack)); CMD2_ANY_STRING ("choke_group.index_of", std::bind(&apply_cg_index_of, std::placeholders::_2)); #endif diff --git a/src/main.cc b/src/main.cc index e3485f0f..42dbf73a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -907,7 +907,7 @@ handle_sigbus(int signum, siginfo_t* sa, void* ptr) { printf("Stack dump not enabled.\n"); #endif - printf("\nError: %s\n", rak::error_number::error_number(sa->si_errno).c_str()); + printf("\nError: %s\n", rak::error_number(sa->si_errno).c_str()); const char* signal_reason;