* More work on cleaning up code.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1198 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2011-03-31 11:25:31 +00:00
parent 386250bc87
commit 86c508e212
2 changed files with 42 additions and 15 deletions
+8 -6
View File
@@ -108,8 +108,10 @@ DownloadFactory::DownloadFactory(Manager* m) :
m_taskLoad.set_slot(rak::mem_fn(this, &DownloadFactory::receive_load));
m_taskCommit.set_slot(rak::mem_fn(this, &DownloadFactory::receive_commit));
m_variables["connection_leech"] = rpc::call_command_void("protocol.connection.leech");
m_variables["connection_seed"] = rpc::call_command_void("protocol.connection.seed");
// m_variables["connection_leech"] = rpc::call_command_void("protocol.connection.leech");
// m_variables["connection_seed"] = rpc::call_command_void("protocol.connection.seed");
m_variables["connection_leech"] = std::string();
m_variables["connection_seed"] = std::string();
m_variables["directory"] = rpc::call_command_void("directory.default");
m_variables["tied_to_file"] = torrent::Object((int64_t)false);
}
@@ -399,10 +401,10 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre
rtorrent->insert_preserve_type("connection_leech", m_variables["connection_leech"]);
rtorrent->insert_preserve_type("connection_seed", m_variables["connection_seed"]);
rtorrent->insert_preserve_copy("choke_heuristics.up.leech", rpc::call_command_void("protocol.choke_heuristics.up.leech"));
rtorrent->insert_preserve_copy("choke_heuristics.up.seed", rpc::call_command_void("protocol.choke_heuristics.up.seed"));
rtorrent->insert_preserve_copy("choke_heuristics.down.leech", rpc::call_command_void("protocol.choke_heuristics.down.leech"));
rtorrent->insert_preserve_copy("choke_heuristics.down.seed", rpc::call_command_void("protocol.choke_heuristics.down.seed"));
rtorrent->insert_preserve_copy("choke_heuristics.up.leech", std::string());
rtorrent->insert_preserve_copy("choke_heuristics.up.seed", std::string());
rtorrent->insert_preserve_copy("choke_heuristics.down.leech", std::string());
rtorrent->insert_preserve_copy("choke_heuristics.down.seed", std::string());
}
}
+34 -9
View File
@@ -357,14 +357,30 @@ DownloadList::resume(Download* download, int flags) {
rpc::call_command("d.state_counter.set", rpc::call_command_value("d.state_counter", rpc::make_target(download)) + 1, rpc::make_target(download));
if (download->is_done()) {
rpc::call_command("d.connection_current.set", rpc::call_command_void("d.connection_seed", rpc::make_target(download)), rpc::make_target(download));
rpc::call_command("d.up.choke_heuristics.set", rpc::call_command_void("d.up.choke_heuristics.seed", rpc::make_target(download)), rpc::make_target(download));
rpc::call_command("d.down.choke_heuristics.set", rpc::call_command_void("d.down.choke_heuristics.seed", rpc::make_target(download)), rpc::make_target(download));
torrent::Object conn_current = rpc::call_command_void("d.connection_seed", rpc::make_target(download));
torrent::Object choke_up = rpc::call_command_void("d.up.choke_heuristics.seed", rpc::make_target(download));
torrent::Object choke_down = rpc::call_command_void("d.down.choke_heuristics.seed", rpc::make_target(download));
if (conn_current.is_string_empty()) conn_current = rpc::call_command_void("protocol.connection.seed", rpc::make_target(download));
if (choke_up.is_string_empty()) choke_up = rpc::call_command_void("protocol.choke_heuristics.up.seed", rpc::make_target(download));
if (choke_down.is_string_empty()) choke_down = rpc::call_command_void("protocol.choke_heuristics.down.seed", rpc::make_target(download));
rpc::call_command("d.connection_current.set", conn_current, rpc::make_target(download));
rpc::call_command("d.up.choke_heuristics.set", choke_up, rpc::make_target(download));
rpc::call_command("d.down.choke_heuristics.set", choke_down, rpc::make_target(download));
} else {
rpc::call_command("d.connection_current.set", rpc::call_command_void("d.connection_leech", rpc::make_target(download)), rpc::make_target(download));
rpc::call_command("d.up.choke_heuristics.set", rpc::call_command_void("d.up.choke_heuristics.leech", rpc::make_target(download)), rpc::make_target(download));
rpc::call_command("d.down.choke_heuristics.set", rpc::call_command_void("d.down.choke_heuristics.leech", rpc::make_target(download)), rpc::make_target(download));
torrent::Object conn_current = rpc::call_command_void("d.connection_leech", rpc::make_target(download));
torrent::Object choke_up = rpc::call_command_void("d.up.choke_heuristics.leech", rpc::make_target(download));
torrent::Object choke_down = rpc::call_command_void("d.down.choke_heuristics.leech", rpc::make_target(download));
if (conn_current.is_string_empty()) conn_current = rpc::call_command_void("protocol.connection.leech", rpc::make_target(download));
if (choke_up.is_string_empty()) choke_up = rpc::call_command_void("protocol.choke_heuristics.up.leech", rpc::make_target(download));
if (choke_down.is_string_empty()) choke_down = rpc::call_command_void("protocol.choke_heuristics.down.leech", rpc::make_target(download));
rpc::call_command("d.connection_current.set", conn_current, rpc::make_target(download));
rpc::call_command("d.up.choke_heuristics.set", choke_up, rpc::make_target(download));
rpc::call_command("d.down.choke_heuristics.set", choke_down, rpc::make_target(download));
// For the moment, clear the resume data so we force hash-check
// on non-complete downloads after a crash. This shouldn't be
@@ -581,9 +597,18 @@ DownloadList::confirm_finished(Download* download) {
rpc::call_command("d.complete.set", (int64_t)1, rpc::make_target(download));
rpc::call_command("d.connection_current.set", rpc::call_command_void("d.connection_seed", rpc::make_target(download)), rpc::make_target(download));
rpc::call_command("d.up.choke_heuristics.set", rpc::call_command_void("d.up.choke_heuristics.seed", rpc::make_target(download)), rpc::make_target(download));
rpc::call_command("d.down.choke_heuristics.set", rpc::call_command_void("d.down.choke_heuristics.seed", rpc::make_target(download)), rpc::make_target(download));
// Clean up these settings:
torrent::Object conn_current = rpc::call_command_void("d.connection_seed", rpc::make_target(download));
torrent::Object choke_up = rpc::call_command_void("d.up.choke_heuristics.seed", rpc::make_target(download));
torrent::Object choke_down = rpc::call_command_void("d.down.choke_heuristics.seed", rpc::make_target(download));
if (conn_current.is_string_empty()) conn_current = rpc::call_command_void("protocol.connection.seed", rpc::make_target(download));
if (choke_up.is_string_empty()) choke_up = rpc::call_command_void("protocol.choke_heuristics.up.seed", rpc::make_target(download));
if (choke_down.is_string_empty()) choke_down = rpc::call_command_void("protocol.choke_heuristics.down.seed", rpc::make_target(download));
rpc::call_command("d.connection_current.set", conn_current, rpc::make_target(download));
rpc::call_command("d.up.choke_heuristics.set", choke_up, rpc::make_target(download));
rpc::call_command("d.down.choke_heuristics.set", choke_down, rpc::make_target(download));
download->set_priority(download->priority());