mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-20 16:16:17 +00:00
Compare commits
7 Commits
v0.16.17
...
4980283f38
| Author | SHA1 | Date | |
|---|---|---|---|
| 4980283f38 | |||
| 2354c9cdb5 | |||
| 1b25bc7f56 | |||
| c6bde213b4 | |||
| 959448acda | |||
| 3b6da6feac | |||
| ea2d22cb87 |
+25
-24
@@ -8,10 +8,10 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <torrent/torrent.h>
|
#include <torrent/torrent.h>
|
||||||
#include <torrent/chunk_manager.h>
|
|
||||||
#include <torrent/data/file_manager.h>
|
#include <torrent/data/file_manager.h>
|
||||||
#include <torrent/data/chunk_utils.h>
|
#include <torrent/data/chunk_utils.h>
|
||||||
#include <torrent/runtime/runtime.h>
|
#include <torrent/runtime/runtime.h>
|
||||||
|
#include <torrent/runtime/memory_manager.h>
|
||||||
#include <torrent/runtime/socket_manager.h>
|
#include <torrent/runtime/socket_manager.h>
|
||||||
#include <torrent/utils/chrono.h>
|
#include <torrent/utils/chrono.h>
|
||||||
#include <torrent/utils/option_strings.h>
|
#include <torrent/utils/option_strings.h>
|
||||||
@@ -188,7 +188,6 @@ cmd_file_append(const torrent::Object::list_type& args) {
|
|||||||
void
|
void
|
||||||
initialize_command_local() {
|
initialize_command_local() {
|
||||||
core::DownloadList* dList = control->core()->download_list();
|
core::DownloadList* dList = control->core()->download_list();
|
||||||
torrent::ChunkManager* chunkManager = torrent::chunk_manager();
|
|
||||||
torrent::FileManager* fileManager = torrent::file_manager();
|
torrent::FileManager* fileManager = torrent::file_manager();
|
||||||
|
|
||||||
if (rpc::call_command_value("method.use_deprecated") == 1) {
|
if (rpc::call_command_value("method.use_deprecated") == 1) {
|
||||||
@@ -265,32 +264,34 @@ initialize_command_local() {
|
|||||||
CMD_ANY_VALUE_V(category_name + ".max_alloc.set", [category](auto, auto& value) { torrent::runtime::socket_manager()->set_category_max_allocation(category, value); });
|
CMD_ANY_VALUE_V(category_name + ".max_alloc.set", [category](auto, auto& value) { torrent::runtime::socket_manager()->set_category_max_allocation(category, value); });
|
||||||
}
|
}
|
||||||
|
|
||||||
CMD_ANY ("pieces.sync.always_safe", std::bind(&CM_t::safe_sync, chunkManager));
|
CMD_ANY ("pieces.sync.always_safe", [](auto, auto) { return torrent::runtime::memory_manager()->safe_sync(); });
|
||||||
CMD_ANY_VALUE_V ("pieces.sync.always_safe.set", std::bind(&CM_t::set_safe_sync, chunkManager, std::placeholders::_2));
|
CMD_ANY_VALUE_V ("pieces.sync.always_safe.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_safe_sync(value); });
|
||||||
CMD_ANY ("pieces.sync.safe_free_diskspace", std::bind(&CM_t::safe_free_diskspace, chunkManager));
|
CMD_ANY ("pieces.sync.safe_free_diskspace", [](auto, auto) { return torrent::runtime::memory_manager()->sync_safe_free_diskspace(); });
|
||||||
CMD_ANY ("pieces.sync.timeout", std::bind(&CM_t::timeout_sync, chunkManager));
|
CMD_ANY ("pieces.sync.timeout", [](auto, auto) { return torrent::runtime::memory_manager()->timeout_sync().count(); });
|
||||||
CMD_ANY_VALUE_V ("pieces.sync.timeout.set", std::bind(&CM_t::set_timeout_sync, chunkManager, std::placeholders::_2));
|
CMD_ANY_VALUE_V ("pieces.sync.timeout.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_timeout_sync(value); });
|
||||||
CMD_ANY ("pieces.sync.timeout_safe", std::bind(&CM_t::timeout_safe_sync, chunkManager));
|
// CMD_ANY ("pieces.sync.timeout_safe", [](auto, auto) { return torrent::runtime::memory_manager()->timeout_safe_sync(); });
|
||||||
CMD_ANY_VALUE_V ("pieces.sync.timeout_safe.set", std::bind(&CM_t::set_timeout_safe_sync, chunkManager, std::placeholders::_2));
|
// CMD_ANY_VALUE_V ("pieces.sync.timeout_safe.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_timeout_safe_sync(value); });
|
||||||
CMD_ANY ("pieces.sync.queue_size", std::bind(&CM_t::sync_queue_size, chunkManager));
|
CMD_ANY ("pieces.sync.timeout_safe", [](auto, auto) { return 0; });
|
||||||
|
CMD_ANY_VALUE_V ("pieces.sync.timeout_safe.set", [](auto, auto) { });
|
||||||
|
CMD_ANY ("pieces.sync.queue_size", [](auto, auto) { return torrent::runtime::memory_manager()->sync_queue_block_count(); });
|
||||||
|
|
||||||
CMD_ANY ("pieces.preload.type", std::bind(&CM_t::preload_type, chunkManager));
|
CMD_ANY ("pieces.preload.type", [](auto, auto) { return torrent::runtime::memory_manager()->preload_type(); });
|
||||||
CMD_ANY_VALUE_V ("pieces.preload.type.set", std::bind(&CM_t::set_preload_type, chunkManager, std::placeholders::_2));
|
CMD_ANY_VALUE_V ("pieces.preload.type.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_preload_type(value); });
|
||||||
CMD_ANY ("pieces.preload.min_size", std::bind(&CM_t::preload_min_size, chunkManager));
|
CMD_ANY ("pieces.preload.min_size", [](auto, auto) { return torrent::runtime::memory_manager()->preload_min_size(); });
|
||||||
CMD_ANY_VALUE_V ("pieces.preload.min_size.set", std::bind(&CM_t::set_preload_min_size, chunkManager, std::placeholders::_2));
|
CMD_ANY_VALUE_V ("pieces.preload.min_size.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_preload_min_size(value); });
|
||||||
CMD_ANY ("pieces.preload.min_rate", std::bind(&CM_t::preload_required_rate, chunkManager));
|
CMD_ANY ("pieces.preload.min_rate", [](auto, auto) { return torrent::runtime::memory_manager()->preload_required_rate(); });
|
||||||
CMD_ANY_VALUE_V ("pieces.preload.min_rate.set", std::bind(&CM_t::set_preload_required_rate, chunkManager, std::placeholders::_2));
|
CMD_ANY_VALUE_V ("pieces.preload.min_rate.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_preload_required_rate(value); });
|
||||||
|
|
||||||
CMD_ANY ("pieces.memory.current", std::bind(&CM_t::memory_usage, chunkManager));
|
|
||||||
CMD_ANY ("pieces.memory.sync_queue", std::bind(&CM_t::sync_queue_memory_usage, chunkManager));
|
|
||||||
CMD_ANY ("pieces.memory.block_count", std::bind(&CM_t::memory_block_count, chunkManager));
|
|
||||||
CMD_ANY ("pieces.memory.max", std::bind(&CM_t::max_memory_usage, chunkManager));
|
|
||||||
CMD_ANY_VALUE_V ("pieces.memory.max.set", std::bind(&CM_t::set_max_memory_usage, chunkManager, std::placeholders::_2));
|
|
||||||
CMD_ANY ("pieces.stats_preloaded", std::bind(&CM_t::stats_preloaded, chunkManager));
|
|
||||||
CMD_ANY ("pieces.stats_not_preloaded", std::bind(&CM_t::stats_not_preloaded, chunkManager));
|
|
||||||
|
|
||||||
|
CMD_ANY ("pieces.stats_preloaded", [](auto, auto) { return torrent::runtime::memory_manager()->stats_preloaded(); });
|
||||||
|
CMD_ANY ("pieces.stats_not_preloaded", [](auto, auto) { return torrent::runtime::memory_manager()->stats_not_preloaded(); });
|
||||||
CMD_ANY ("pieces.stats.total_size", std::bind(&apply_pieces_stats_total_size));
|
CMD_ANY ("pieces.stats.total_size", std::bind(&apply_pieces_stats_total_size));
|
||||||
|
|
||||||
|
CMD_ANY ("pieces.memory.current", [](auto, auto) { return torrent::runtime::memory_manager()->memory_usage(); });
|
||||||
|
CMD_ANY ("pieces.memory.sync_queue", [](auto, auto) { return torrent::runtime::memory_manager()->sync_queue_memory_usage(); });
|
||||||
|
CMD_ANY ("pieces.memory.block_count", [](auto, auto) { return torrent::runtime::memory_manager()->memory_block_count(); });
|
||||||
|
CMD_ANY ("pieces.memory.max", [](auto, auto) { return torrent::runtime::memory_manager()->max_memory_usage(); });
|
||||||
|
CMD_ANY_VALUE_V ("pieces.memory.max.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_max_memory_usage(value); });
|
||||||
|
|
||||||
CMD_ANY ("pieces.hash.queue_size", std::bind(&torrent::main_thread::hash_queue_size));
|
CMD_ANY ("pieces.hash.queue_size", std::bind(&torrent::main_thread::hash_queue_size));
|
||||||
CMD_VAR_BOOL ("pieces.hash.on_completion", true);
|
CMD_VAR_BOOL ("pieces.hash.on_completion", true);
|
||||||
|
|
||||||
|
|||||||
@@ -70,9 +70,6 @@ Control::initialize() {
|
|||||||
display::Window::slot_unschedule([this](display::Window* w) { m_display->unschedule(w); });
|
display::Window::slot_unschedule([this](display::Window* w) { m_display->unschedule(w); });
|
||||||
display::Window::slot_adjust([this]() { m_display->adjust_layout(); });
|
display::Window::slot_adjust([this]() { m_display->adjust_layout(); });
|
||||||
|
|
||||||
torrent::net_thread::http_stack()->set_user_agent(USER_AGENT);
|
|
||||||
|
|
||||||
m_core->listen_open();
|
|
||||||
m_core->set_hashing_view(*m_view_manager->find_throw("hashing"));
|
m_core->set_hashing_view(*m_view_manager->find_throw("hashing"));
|
||||||
|
|
||||||
m_ui->init(this);
|
m_ui->init(this);
|
||||||
|
|||||||
+21
-7
@@ -8,6 +8,7 @@
|
|||||||
#include <torrent/object_stream.h>
|
#include <torrent/object_stream.h>
|
||||||
#include <torrent/rate.h>
|
#include <torrent/rate.h>
|
||||||
#include <torrent/runtime/network_manager.h>
|
#include <torrent/runtime/network_manager.h>
|
||||||
|
#include <torrent/runtime/runtime.h>
|
||||||
#include <torrent/tracker/dht_controller.h>
|
#include <torrent/tracker/dht_controller.h>
|
||||||
#include <torrent/utils/log.h>
|
#include <torrent/utils/log.h>
|
||||||
|
|
||||||
@@ -141,18 +142,29 @@ DhtManager::save_dht_cache() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DhtManager::set_mode_by_user(const std::string& arg) {
|
DhtManager::set_mode_by_user(const std::string& arg) {
|
||||||
for (int i = 0; i < dht_settings_num; i++) {
|
unsigned int mode = [arg]() {
|
||||||
if (arg == dht_settings[i]) {
|
for (int i = 0; i < dht_settings_num; i++) {
|
||||||
m_set_by_user = true;
|
if (arg == dht_settings[i])
|
||||||
return set_mode_directly(i);
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw torrent::input_error("Invalid dht mode: " + arg);
|
||||||
|
}();
|
||||||
|
|
||||||
|
m_set_by_user = true;
|
||||||
|
|
||||||
|
if (!torrent::runtime::is_network_initialized()) {
|
||||||
|
m_start = mode;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_mode_directly(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DhtManager::set_mode_directly(unsigned int mode) {
|
DhtManager::set_mode_directly(unsigned int mode) {
|
||||||
if (mode >= dht_settings_num)
|
if (mode >= dht_settings_num)
|
||||||
throw torrent::input_error("Invalid argument.");
|
throw torrent::input_error("Invalid dht mode.");
|
||||||
|
|
||||||
m_start = mode;
|
m_start = mode;
|
||||||
|
|
||||||
@@ -164,8 +176,10 @@ DhtManager::set_mode_directly(unsigned int mode) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DhtManager::set_auto_if_untouched_and_has_session() {
|
DhtManager::set_auto_if_untouched_and_has_session() {
|
||||||
if (m_set_by_user)
|
if (m_set_by_user) {
|
||||||
|
set_mode_directly(m_start);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (rpc::call_command_string("session.path").empty()) {
|
if (rpc::call_command_string("session.path").empty()) {
|
||||||
LT_LOG("DHT auto-start disabled, session path not set.", 0);
|
LT_LOG("DHT auto-start disabled, session path not set.", 0);
|
||||||
|
|||||||
@@ -104,40 +104,42 @@ DownloadFactory::receive_load() {
|
|||||||
throw torrent::internal_error("DownloadFactory::load*() called on an object with m_stream != NULL");
|
throw torrent::internal_error("DownloadFactory::load*() called on an object with m_stream != NULL");
|
||||||
|
|
||||||
if (is_network_uri(m_uri)) {
|
if (is_network_uri(m_uri)) {
|
||||||
// Http handling here.
|
|
||||||
m_stream.reset(new std::stringstream);
|
m_stream.reset(new std::stringstream);
|
||||||
|
|
||||||
m_manager->http_queue()->insert(m_uri, m_stream,
|
auto done_fn = [this]() { receive_loaded(); };
|
||||||
[this]() { receive_loaded(); },
|
auto failed_fn = [this](const std::string& error) { receive_failed(error); };
|
||||||
[this](const std::string& error) { receive_failed(error); }
|
|
||||||
);
|
m_manager->http_queue()->insert(m_uri, m_stream, done_fn, failed_fn);
|
||||||
|
|
||||||
m_variables["tied_to_file"] = (int64_t)false;
|
m_variables["tied_to_file"] = (int64_t)false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (is_magnet_uri(m_uri)) {
|
if (is_magnet_uri(m_uri)) {
|
||||||
// DEBUG: Use m_object.
|
// DEBUG: Use m_object.
|
||||||
m_stream.reset(new std::stringstream());
|
m_stream.reset(new std::stringstream());
|
||||||
*m_stream << "d10:magnet-uri" << m_uri.length() << ":" << m_uri << "e";
|
*m_stream << "d10:magnet-uri" << m_uri.length() << ":" << m_uri << "e";
|
||||||
|
|
||||||
m_variables["tied_to_file"] = (int64_t)false;
|
m_variables["tied_to_file"] = (int64_t)false;
|
||||||
receive_loaded();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
std::fstream stream(expand_path(m_uri).c_str(), std::ios::in | std::ios::binary);
|
|
||||||
|
|
||||||
if (!stream.is_open())
|
|
||||||
return receive_failed("Could not open file");
|
|
||||||
|
|
||||||
m_object = new torrent::Object;
|
|
||||||
stream >> *m_object;
|
|
||||||
|
|
||||||
if (!stream.good())
|
|
||||||
return receive_failed("Reading torrent file failed");
|
|
||||||
|
|
||||||
m_isFile = true;
|
|
||||||
|
|
||||||
receive_loaded();
|
receive_loaded();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::fstream stream(expand_path(m_uri).c_str(), std::ios::in | std::ios::binary);
|
||||||
|
|
||||||
|
if (!stream.is_open())
|
||||||
|
return receive_failed("Could not open file");
|
||||||
|
|
||||||
|
m_object = new torrent::Object;
|
||||||
|
stream >> *m_object;
|
||||||
|
|
||||||
|
if (!stream.good())
|
||||||
|
return receive_failed("Reading torrent file failed");
|
||||||
|
|
||||||
|
m_isFile = true;
|
||||||
|
|
||||||
|
receive_loaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -19,14 +19,11 @@ HttpQueue::insert(const std::string& url, std::shared_ptr<std::ostream> stream,
|
|||||||
for (auto& slot : m_signal_insert)
|
for (auto& slot : m_signal_insert)
|
||||||
slot(*itr);
|
slot(*itr);
|
||||||
|
|
||||||
itr->add_done_slot(torrent::this_thread::thread(), [this, itr]() { erase(itr); });
|
|
||||||
itr->add_failed_slot(torrent::this_thread::thread(), [this, itr](auto) { erase(itr); });
|
|
||||||
|
|
||||||
itr->add_done_slot(torrent::this_thread::thread(), std::move(done_fn));
|
itr->add_done_slot(torrent::this_thread::thread(), std::move(done_fn));
|
||||||
itr->add_failed_slot(torrent::this_thread::thread(), std::move(failed_fn));
|
itr->add_done_slot(torrent::this_thread::thread(), [this, itr]() { erase(itr); });
|
||||||
|
|
||||||
// TODO: Downloading http torrents doesn't seem to work.
|
itr->add_failed_slot(torrent::this_thread::thread(), std::move(failed_fn));
|
||||||
// TODO: Quitting no longer works.
|
itr->add_failed_slot(torrent::this_thread::thread(), [this, itr](auto) { erase(itr); });
|
||||||
|
|
||||||
torrent::net_thread::http_stack()->start_get(*itr);
|
torrent::net_thread::http_stack()->start_get(*itr);
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ void
|
|||||||
InputEvent::insert() {
|
InputEvent::insert() {
|
||||||
torrent::this_thread::poll()->open(this);
|
torrent::this_thread::poll()->open(this);
|
||||||
torrent::this_thread::poll()->insert_read(this);
|
torrent::this_thread::poll()->insert_read(this);
|
||||||
torrent::this_thread::poll()->insert_error(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class InputEvent : public torrent::Event {
|
|||||||
public:
|
public:
|
||||||
typedef std::function<void (int)> slot_int;
|
typedef std::function<void (int)> slot_int;
|
||||||
|
|
||||||
InputEvent(int fd) { m_fileDesc = fd; }
|
InputEvent(int fd) { set_file_descriptor(fd); }
|
||||||
|
|
||||||
const char* type_name() const override { return "input"; }
|
const char* type_name() const override { return "input"; }
|
||||||
|
|
||||||
|
|||||||
+11
-2
@@ -11,6 +11,9 @@
|
|||||||
#include <torrent/exceptions.h>
|
#include <torrent/exceptions.h>
|
||||||
#include <torrent/data/chunk_utils.h>
|
#include <torrent/data/chunk_utils.h>
|
||||||
#include <torrent/net/fd.h>
|
#include <torrent/net/fd.h>
|
||||||
|
#include <torrent/net/http_stack.h>
|
||||||
|
#include <torrent/runtime/memory_manager.h>
|
||||||
|
#include <torrent/runtime/runtime.h>
|
||||||
#include <torrent/utils/chrono.h>
|
#include <torrent/utils/chrono.h>
|
||||||
#include <torrent/utils/log.h>
|
#include <torrent/utils/log.h>
|
||||||
|
|
||||||
@@ -149,8 +152,8 @@ main(int argc, char** argv) {
|
|||||||
|
|
||||||
SignalHandler::set_sigaction_handler(SIGBUS, &handle_sigbus);
|
SignalHandler::set_sigaction_handler(SIGBUS, &handle_sigbus);
|
||||||
|
|
||||||
torrent::log_add_group_output(torrent::LOG_NOTICE, "important");
|
torrent::log_add_group_output(torrent::LOG_NOTICE, "important");
|
||||||
torrent::log_add_group_output(torrent::LOG_DHT_ERROR, "important");
|
torrent::log_add_group_output(torrent::LOG_DHT_ERROR, "important");
|
||||||
|
|
||||||
torrent::log_add_group_output(torrent::LOG_INFO, "complete");
|
torrent::log_add_group_output(torrent::LOG_INFO, "complete");
|
||||||
torrent::log_add_group_output(torrent::LOG_DHT_ERROR, "complete");
|
torrent::log_add_group_output(torrent::LOG_DHT_ERROR, "complete");
|
||||||
@@ -444,10 +447,16 @@ main(int argc, char** argv) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
LT_LOG("seeded srandom and srand48 (seed:%u)", random_seed);
|
LT_LOG("seeded srandom and srand48 (seed:%u)", random_seed);
|
||||||
|
LT_LOG("max memory usage: %" PRIu64, torrent::runtime::memory_manager()->max_memory_usage());
|
||||||
|
|
||||||
control->initialize();
|
control->initialize();
|
||||||
control->ui()->load_input_history();
|
control->ui()->load_input_history();
|
||||||
|
|
||||||
|
torrent::net_thread::http_stack()->set_user_agent(USER_AGENT);
|
||||||
|
torrent::runtime::initialize_network();
|
||||||
|
|
||||||
|
control->core()->listen_open();
|
||||||
|
|
||||||
// Load session torrents and perform scheduled tasks to ensure session torrents are loaded
|
// Load session torrents and perform scheduled tasks to ensure session torrents are loaded
|
||||||
// before arg torrents.
|
// before arg torrents.
|
||||||
control->dht_manager()->set_auto_if_untouched_and_has_session();
|
control->dht_manager()->set_auto_if_untouched_and_has_session();
|
||||||
|
|||||||
+15
-16
@@ -55,12 +55,11 @@ struct rt_triple : private std::pair<T1, T2> {
|
|||||||
base_type(src.first, src.second), third(src.third) {}
|
base_type(src.first, src.second), third(src.third) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef rt_triple<int, void*, void*> target_type;
|
|
||||||
|
|
||||||
class command_base;
|
class command_base;
|
||||||
|
|
||||||
typedef const torrent::Object (*command_base_call_type)(command_base*, target_type, const torrent::Object&);
|
using target_type = rt_triple<int, void*, void*>;
|
||||||
typedef std::function<torrent::Object (target_type, const torrent::Object&)> base_function;
|
using base_function = std::function<torrent::Object (target_type, const torrent::Object&)>;
|
||||||
|
using command_base_call_type = const torrent::Object (command_base*, target_type, const torrent::Object&);
|
||||||
|
|
||||||
template <typename tmpl> struct command_base_is_valid {};
|
template <typename tmpl> struct command_base_is_valid {};
|
||||||
template <command_base_call_type tmpl_func> struct command_base_is_type {};
|
template <command_base_call_type tmpl_func> struct command_base_is_type {};
|
||||||
@@ -84,17 +83,18 @@ public:
|
|||||||
|
|
||||||
typedef const torrent::Object (*download_pair_slot) (command_base*, core::Download*, core::Download*, const torrent::Object&);
|
typedef const torrent::Object (*download_pair_slot) (command_base*, core::Download*, core::Download*, const torrent::Object&);
|
||||||
|
|
||||||
static const int target_generic = 0;
|
static constexpr int target_generic = 0;
|
||||||
static const int target_any = 1;
|
static constexpr int target_any = 1;
|
||||||
static const int target_download = 2;
|
static constexpr int target_download = 2;
|
||||||
static const int target_peer = 3;
|
static constexpr int target_peer = 3;
|
||||||
static const int target_tracker = 4;
|
static constexpr int target_tracker = 4;
|
||||||
static const int target_file = 5;
|
static constexpr int target_file = 5;
|
||||||
static const int target_file_itr = 6;
|
static constexpr int target_file_itr = 6;
|
||||||
|
static constexpr int target_download_pair = 7;
|
||||||
|
|
||||||
static const int target_download_pair = 7;
|
static constexpr unsigned int max_arguments = 10;
|
||||||
|
|
||||||
static const unsigned int max_arguments = 10;
|
static constexpr std::size_t optimal_alignment = std::max(alignof(std::max_align_t), alignof(base_function));
|
||||||
|
|
||||||
struct stack_type {
|
struct stack_type {
|
||||||
torrent::Object* begin() { return reinterpret_cast<torrent::Object*>(buffer); }
|
torrent::Object* begin() { return reinterpret_cast<torrent::Object*>(buffer); }
|
||||||
@@ -169,8 +169,7 @@ public:
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void set_function(T s, [[maybe_unused]] int value = command_base_is_valid<T>::value) {
|
void set_function(T s, [[maybe_unused]] int value = command_base_is_valid<T>::value) {
|
||||||
static_assert(sizeof(T) <= sizeof(t_pod), "t_pod storage overflow");
|
static_assert(sizeof(T) <= sizeof(t_pod), "t_pod storage overflow");
|
||||||
static_assert(alignof(std::max_align_t) % alignof(T) == 0, "t_pod alignment insufficient for type");
|
static_assert(optimal_alignment >= alignof(T), "t_pod alignment insufficient for type");
|
||||||
static_assert(alignof(std::max_align_t) >= alignof(T), "t_pod structural capacity mismatch");
|
|
||||||
|
|
||||||
if (m_dest_helper)
|
if (m_dest_helper)
|
||||||
m_dest_helper(t_pod);
|
m_dest_helper(t_pod);
|
||||||
@@ -200,7 +199,7 @@ protected:
|
|||||||
using copy_fn_t = void (*)(void* dest, const void* src);
|
using copy_fn_t = void (*)(void* dest, const void* src);
|
||||||
using dest_fn_t = void (*)(void* ptr);
|
using dest_fn_t = void (*)(void* ptr);
|
||||||
|
|
||||||
alignas(std::max_align_t) char t_pod[sizeof(base_function)];
|
alignas(optimal_alignment) char t_pod[sizeof(base_function)];
|
||||||
|
|
||||||
copy_fn_t m_copy_helper;
|
copy_fn_t m_copy_helper;
|
||||||
dest_fn_t m_dest_helper;
|
dest_fn_t m_dest_helper;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -9,8 +10,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <torrent/net/fd.h>
|
#include <torrent/net/fd.h>
|
||||||
#include <torrent/system/system.h>
|
|
||||||
#include <torrent/system/thread.h>
|
#include <torrent/system/thread.h>
|
||||||
|
#include <torrent/system/types.h>
|
||||||
|
|
||||||
#include "exec_file.h"
|
#include "exec_file.h"
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
@@ -24,6 +25,8 @@ namespace rpc {
|
|||||||
|
|
||||||
int
|
int
|
||||||
ExecFile::execute(const char* file, char* const* argv, int flags) {
|
ExecFile::execute(const char* file, char* const* argv, int flags) {
|
||||||
|
assert(!((flags & flag_capture) && (flags & flag_background)));
|
||||||
|
|
||||||
// Write the executed command and its parameters to the log fd.
|
// Write the executed command and its parameters to the log fd.
|
||||||
[[maybe_unused]] int result;
|
[[maybe_unused]] int result;
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ SCgi::activate() {
|
|||||||
|
|
||||||
torrent::this_thread::poll()->open(this);
|
torrent::this_thread::poll()->open(this);
|
||||||
torrent::this_thread::poll()->insert_read(this);
|
torrent::this_thread::poll()->insert_read(this);
|
||||||
torrent::this_thread::poll()->insert_error(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This should close the fd to avoid reuse.
|
// TODO: This should close the fd to avoid reuse.
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace rpc {
|
|||||||
SCgiTask::SCgiTask()
|
SCgiTask::SCgiTask()
|
||||||
: m_callback_id(torrent::system::make_callback_id()) {
|
: m_callback_id(torrent::system::make_callback_id()) {
|
||||||
|
|
||||||
set_file_descriptor(-1);
|
reset_file_descriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -49,7 +49,6 @@ SCgiTask::open(SCgi* parent, int fd) {
|
|||||||
|
|
||||||
torrent::this_thread::poll()->open(this);
|
torrent::this_thread::poll()->open(this);
|
||||||
torrent::this_thread::poll()->insert_read(this);
|
torrent::this_thread::poll()->insert_read(this);
|
||||||
torrent::this_thread::poll()->insert_error(this);
|
|
||||||
|
|
||||||
auto lock = std::lock_guard<std::mutex>(m_result_mutex);
|
auto lock = std::lock_guard<std::mutex>(m_result_mutex);
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ SCgiTask::cancel_open() {
|
|||||||
torrent::this_thread::poll()->remove_and_close(this);
|
torrent::this_thread::poll()->remove_and_close(this);
|
||||||
|
|
||||||
torrent::fd_close(file_descriptor());
|
torrent::fd_close(file_descriptor());
|
||||||
set_file_descriptor(-1);
|
reset_file_descriptor();
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -79,7 +78,7 @@ SCgiTask::close() {
|
|||||||
torrent::this_thread::poll()->remove_and_close(this);
|
torrent::this_thread::poll()->remove_and_close(this);
|
||||||
|
|
||||||
torrent::fd_close(file_descriptor());
|
torrent::fd_close(file_descriptor());
|
||||||
set_file_descriptor(-1);
|
reset_file_descriptor();
|
||||||
});
|
});
|
||||||
|
|
||||||
// The callbacks are guaranteed to be finished/canceled at this point.
|
// The callbacks are guaranteed to be finished/canceled at this point.
|
||||||
@@ -98,7 +97,7 @@ SCgiTask::event_read() {
|
|||||||
if (read_length <= 0)
|
if (read_length <= 0)
|
||||||
throw torrent::internal_error("SCgiTask::event_read() no space in buffer for event_read.");
|
throw torrent::internal_error("SCgiTask::event_read() no space in buffer for event_read.");
|
||||||
|
|
||||||
int bytes = ::recv(m_fileDesc, m_buffer.data() + m_position, read_length, 0);
|
int bytes = ::recv(file_descriptor(), m_buffer.data() + m_position, read_length, 0);
|
||||||
|
|
||||||
if (bytes <= 0) {
|
if (bytes <= 0) {
|
||||||
if (bytes == 0 || !(errno == EAGAIN || errno == EINTR))
|
if (bytes == 0 || !(errno == EAGAIN || errno == EINTR))
|
||||||
@@ -181,7 +180,7 @@ event_read_failed:
|
|||||||
|
|
||||||
void
|
void
|
||||||
SCgiTask::event_write() {
|
SCgiTask::event_write() {
|
||||||
int bytes = ::send(m_fileDesc, m_buffer.data() + m_position, m_buffer.size() - m_position, 0);
|
int bytes = ::send(file_descriptor(), m_buffer.data() + m_position, m_buffer.size() - m_position, 0);
|
||||||
|
|
||||||
if (bytes == -1) {
|
if (bytes == -1) {
|
||||||
if (!(errno == EAGAIN || errno == EINTR))
|
if (!(errno == EAGAIN || errno == EINTR))
|
||||||
|
|||||||
+2
-2
@@ -22,8 +22,8 @@ public:
|
|||||||
|
|
||||||
const char* type_name() const override { return "scgi-task"; }
|
const char* type_name() const override { return "scgi-task"; }
|
||||||
|
|
||||||
bool is_open() const { return m_fileDesc != -1; }
|
bool is_open() const { return file_descriptor() != -1; }
|
||||||
bool is_available() const { return m_fileDesc == -1; }
|
bool is_available() const { return file_descriptor() == -1; }
|
||||||
|
|
||||||
void open(SCgi* parent, int fd);
|
void open(SCgi* parent, int fd);
|
||||||
void cancel_open();
|
void cancel_open();
|
||||||
|
|||||||
+4
-7
@@ -3,7 +3,6 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include <torrent/exceptions.h>
|
#include <torrent/exceptions.h>
|
||||||
#include <torrent/chunk_manager.h>
|
|
||||||
#include <torrent/throttle.h>
|
#include <torrent/throttle.h>
|
||||||
#include <torrent/torrent.h>
|
#include <torrent/torrent.h>
|
||||||
#include <torrent/data/file_list.h>
|
#include <torrent/data/file_list.h>
|
||||||
@@ -31,10 +30,10 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
Download::Download(core::Download* d) :
|
Download::Download(core::Download* d)
|
||||||
m_download(d) {
|
: m_download(d) {
|
||||||
|
|
||||||
m_windowDownloadStatus = new WDownloadStatus(d);
|
m_windowDownloadStatus = std::make_unique<WDownloadStatus>(d);
|
||||||
m_windowDownloadStatus->set_bottom(true);
|
m_windowDownloadStatus->set_bottom(true);
|
||||||
|
|
||||||
m_uiArray[DISPLAY_MENU] = create_menu();
|
m_uiArray[DISPLAY_MENU] = create_menu();
|
||||||
@@ -60,8 +59,6 @@ Download::~Download() {
|
|||||||
assert(!is_active() && "ui::Download::~Download() called on an active object.");
|
assert(!is_active() && "ui::Download::~Download() called on an active object.");
|
||||||
|
|
||||||
std::for_each(m_uiArray, m_uiArray + DISPLAY_MAX_SIZE, [](ElementBase* eb) { delete eb; });
|
std::for_each(m_uiArray, m_uiArray + DISPLAY_MAX_SIZE, [](ElementBase* eb) { delete eb; });
|
||||||
|
|
||||||
delete m_windowDownloadStatus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ElementBase*
|
inline ElementBase*
|
||||||
@@ -171,7 +168,7 @@ Download::activate(display::Frame* frame, [[maybe_unused]] bool focus) {
|
|||||||
m_frame = frame;
|
m_frame = frame;
|
||||||
m_frame->initialize_row(2);
|
m_frame->initialize_row(2);
|
||||||
|
|
||||||
m_frame->frame(1)->initialize_window(m_windowDownloadStatus);
|
m_frame->frame(1)->initialize_window(m_windowDownloadStatus.get());
|
||||||
m_windowDownloadStatus->set_active(true);
|
m_windowDownloadStatus->set_active(true);
|
||||||
|
|
||||||
activate_display_menu(DISPLAY_PEER_LIST);
|
activate_display_menu(DISPLAY_PEER_LIST);
|
||||||
|
|||||||
+1
-35
@@ -1,37 +1,3 @@
|
|||||||
// rTorrent - BitTorrent client
|
|
||||||
// Copyright (C) 2005-2011, Jari Sundell
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation; either version 2 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
//
|
|
||||||
// In addition, as a special exception, the copyright holders give
|
|
||||||
// permission to link the code of portions of this program with the
|
|
||||||
// OpenSSL library under certain conditions as described in each
|
|
||||||
// individual source file, and distribute linked combinations
|
|
||||||
// including the two.
|
|
||||||
//
|
|
||||||
// You must obey the GNU General Public License in all respects for
|
|
||||||
// all of the code used other than OpenSSL. If you modify file(s)
|
|
||||||
// with this exception, you may extend this exception to your version
|
|
||||||
// of the file(s), but you are not obligated to do so. If you do not
|
|
||||||
// wish to do so, delete this exception statement from your version.
|
|
||||||
// If you delete this exception statement from all source files in the
|
|
||||||
// program, then also delete it here.
|
|
||||||
//
|
|
||||||
// Contact: Jari Sundell <sundell.software@gmail.com>
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef RTORRENT_UI_DOWNLOAD_H
|
#ifndef RTORRENT_UI_DOWNLOAD_H
|
||||||
#define RTORRENT_UI_DOWNLOAD_H
|
#define RTORRENT_UI_DOWNLOAD_H
|
||||||
|
|
||||||
@@ -113,7 +79,7 @@ private:
|
|||||||
|
|
||||||
bool m_focusDisplay{};
|
bool m_focusDisplay{};
|
||||||
|
|
||||||
WDownloadStatus* m_windowDownloadStatus;
|
std::unique_ptr<WDownloadStatus> m_windowDownloadStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ namespace ui {
|
|||||||
|
|
||||||
class ElementLogComplete : public ElementBase {
|
class ElementLogComplete : public ElementBase {
|
||||||
public:
|
public:
|
||||||
typedef display::WindowLogComplete WLogComplete;
|
using WLogComplete = display::WindowLogComplete;
|
||||||
|
|
||||||
ElementLogComplete(torrent::log_buffer* l);
|
ElementLogComplete(torrent::log_buffer* l);
|
||||||
~ElementLogComplete() override;
|
~ElementLogComplete() override;
|
||||||
|
|
||||||
void activate(display::Frame* frame, bool focus = true);
|
void activate(display::Frame* frame, bool focus = true) override;
|
||||||
void disable();
|
void disable() override;
|
||||||
|
|
||||||
display::Window* window();
|
display::Window* window();
|
||||||
|
|
||||||
@@ -32,7 +32,9 @@ private:
|
|||||||
|
|
||||||
torrent::log_buffer* m_log;
|
torrent::log_buffer* m_log;
|
||||||
|
|
||||||
align_cacheline std::atomic<bool> m_log_updating{};
|
align_cacheline
|
||||||
|
|
||||||
|
std::atomic<bool> m_log_updating{};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user