From 797a194abcc14e2fde353314aacddd6c1fd8ba15 Mon Sep 17 00:00:00 2001 From: Jari Sundell Date: Thu, 14 May 2026 12:24:38 +0200 Subject: [PATCH] Cleaned up torrent header files. --- configure.ac | 2 +- src/command_local.cc | 3 ++- src/command_network.cc | 3 ++- src/control.cc | 2 +- src/core/manager.cc | 14 +++++++++++++- src/core/manager.h | 2 ++ src/display/utils.cc | 3 ++- src/main.cc | 2 +- src/ui/download_list.cc | 3 ++- 9 files changed, 26 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index ee4006ed..f0843960 100644 --- a/configure.ac +++ b/configure.ac @@ -63,7 +63,7 @@ if test ${with_xmlrpc_c+y} && test ${with_xmlrpc_tinyxml2+y}; then AC_MSG_ERROR([--with-xmlrpc-c and --with-xmlrpc-tinyxml2 cannot be used together. Please choose only one]) fi -AC_DEFINE(USER_AGENT, [std::string(PACKAGE "/" VERSION "/") + torrent::version()], Http user agent) +AC_DEFINE(USER_AGENT, [std::string(PACKAGE "/" VERSION)], Http user agent) dnl Only update global build variables immediately before generating the output, dnl to avoid affecting the global build environment for other autoconf checks. diff --git a/src/command_local.cc b/src/command_local.cc index 66f43d46..b421de38 100644 --- a/src/command_local.cc +++ b/src/command_local.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -207,7 +208,7 @@ initialize_command_local() { CMD2_VAR_C_STRING("system.api_version", (int64_t)API_VERSION); CMD2_VAR_C_STRING("system.client_version", PACKAGE_VERSION); - CMD2_VAR_C_STRING("system.library_version", torrent::version()); + CMD2_VAR_C_STRING("system.library_version", torrent::runtime::version()); CMD2_VAR_VALUE ("system.file.allocate", 0); CMD2_VAR_VALUE ("system.file.max_size", (int64_t)512 << 30); diff --git a/src/command_network.cc b/src/command_network.cc index e32b501c..51a3fa09 100644 --- a/src/command_network.cc +++ b/src/command_network.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -288,7 +289,7 @@ initialize_command_network() { CMD2_ANY ("network.open_files", [file_manager](auto, auto) { return file_manager->open_files(); }); CMD2_ANY ("network.max_open_files", [file_manager](auto, auto) { return file_manager->max_open_files(); }); CMD2_ANY_VALUE_V ("network.max_open_files.set", [file_manager](auto, auto& value) { return file_manager->set_max_open_files(value); }); - CMD2_ANY ("network.total_handshakes", [](auto, auto) { return torrent::total_handshakes(); }); + CMD2_ANY ("network.total_handshakes", [](auto, auto) { return torrent::runtime::total_handshakes(); }); CMD2_ANY ("network.open_sockets", [](auto, auto) { return torrent::runtime::socket_manager()->size(); }); CMD2_ANY ("network.max_open_sockets", [](auto, auto) { return torrent::runtime::socket_manager()->max_size(); }); CMD2_ANY_VALUE_V ("network.max_open_sockets.set", [](auto, auto& value) { return torrent::runtime::socket_manager()->set_max_size(value); }); diff --git a/src/control.cc b/src/control.cc index 28e07c90..c415e613 100644 --- a/src/control.cc +++ b/src/control.cc @@ -121,7 +121,7 @@ Control::is_shutdown_completed() { if (torrent::net_thread::http_stack()->size() != 0 || !core()->http_queue()->empty()) return false; - return torrent::is_inactive(); + return core()->is_download_shutdown_completed(); } void diff --git a/src/core/manager.cc b/src/core/manager.cc index 24edbb5d..d9318af4 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -65,6 +64,19 @@ Manager::~Manager() { torrent::Throttle::destroy_throttle(m_throttles["NULL"].first); } +bool +Manager::is_download_shutdown_completed() { + for (const auto& download : *download_list()) { + if (download->tracker_controller().is_active()) + return false; + + if (download->tracker_controller().has_active_trackers_not_dht()) + return false; + } + + return true; +} + void Manager::set_hashing_view(View* v) { if (v == nullptr || m_hashingView != nullptr) diff --git a/src/core/manager.h b/src/core/manager.h index 37e1e0d5..5464000b 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -35,6 +35,8 @@ public: Manager(); ~Manager(); + bool is_download_shutdown_completed(); + DownloadList* download_list() { return m_download_list.get(); } FileStatusCache* file_status_cache() { return m_file_status_cache.get(); } diff --git a/src/display/utils.cc b/src/display/utils.cc index 0ab25913..f39c2d87 100644 --- a/src/display/utils.cc +++ b/src/display/utils.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "control.h" @@ -426,7 +427,7 @@ print_status_extra(char* first, char* last) { torrent::net_thread::http_stack()->max_total_connections()); first = print_buffer(first, last, " [S %i/%i/%i]", - torrent::total_handshakes(), + torrent::runtime::total_handshakes(), torrent::runtime::socket_manager()->size(), torrent::runtime::socket_manager()->max_size()); diff --git a/src/main.cc b/src/main.cc index 8d86e74d..e9130341 100644 --- a/src/main.cc +++ b/src/main.cc @@ -160,7 +160,7 @@ main(int argc, char** argv) { initialize_rpc_slots(); torrent::initialize(); - torrent::set_main_thread_slots(std::bind(&client_perform)); + torrent::main_thread::set_client_callback(&client_perform); scgi::ThreadScgi::create_thread(); session::ThreadSession::create_thread(); diff --git a/src/ui/download_list.cc b/src/ui/download_list.cc index 47ad3666..1ab1eab7 100644 --- a/src/ui/download_list.cc +++ b/src/ui/download_list.cc @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -176,7 +177,7 @@ DownloadList::activate_display(Display displayType) { switch (displayType) { case DISPLAY_DOWNLOAD_LIST: control->ui()->window_title()->set_title("rTorrent " PACKAGE_VERSION "/" + - std::string(torrent::version()) + " - " + + std::string(torrent::runtime::version()) + " - " + rpc::call_command_string("session.name")); break; case DISPLAY_LOG: