mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-11 16:49:22 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9507ac17b3 | |||
| 49d45c1088 | |||
| 5ab973504a | |||
| ebe28e07b1 | |||
| 06a391f9d8 |
@@ -39,7 +39,7 @@ jobs:
|
|||||||
|
|
||||||
# 2. Check for multiple consecutive blank lines
|
# 2. Check for multiple consecutive blank lines
|
||||||
# This regex looks for 2 or more empty lines anywhere in the message
|
# This regex looks for 2 or more empty lines anywhere in the message
|
||||||
if echo "$CLEAN_MSG" | grep -Pz '(\r?\n){3,}'; then
|
if echo "$CLEAN_MSG" | grep -pz '(\r?\n){3,}'; then
|
||||||
echo "❌ Error: Commit message contains multiple consecutive line breaks."
|
echo "❌ Error: Commit message contains multiple consecutive line breaks."
|
||||||
echo " Commit: '$SUBJECT'"
|
echo " Commit: '$SUBJECT'"
|
||||||
FAILED=1
|
FAILED=1
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
m4_pattern_allow([PKG_CHECK_EXISTS])
|
m4_pattern_allow([PKG_CHECK_EXISTS])
|
||||||
|
|
||||||
AC_INIT([rtorrent],[0.16.20],[sundell.software@gmail.com])
|
AC_INIT([rtorrent],[0.16.19],[sundell.software@gmail.com])
|
||||||
|
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
AC_CONFIG_MACRO_DIRS([scripts])
|
AC_CONFIG_MACRO_DIRS([scripts])
|
||||||
@@ -14,7 +14,7 @@ AX_CXX_COMPILE_STDCXX(20, noext, mandatory)
|
|||||||
|
|
||||||
PKG_PROG_PKG_CONFIG
|
PKG_PROG_PKG_CONFIG
|
||||||
|
|
||||||
AC_DEFINE([API_VERSION], [25], [api version])
|
AC_DEFINE([API_VERSION], [24], [api version])
|
||||||
|
|
||||||
RAK_CHECK_CFLAGS
|
RAK_CHECK_CFLAGS
|
||||||
RAK_CHECK_CXXFLAGS
|
RAK_CHECK_CXXFLAGS
|
||||||
@@ -47,7 +47,7 @@ fi
|
|||||||
|
|
||||||
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
|
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
|
||||||
PKG_CHECK_MODULES([ZLIB], [zlib])
|
PKG_CHECK_MODULES([ZLIB], [zlib])
|
||||||
PKG_CHECK_MODULES([DEPENDENCIES], [libtorrent >= 0.16.20])
|
PKG_CHECK_MODULES([DEPENDENCIES], [libtorrent >= 0.16.19])
|
||||||
|
|
||||||
AC_LANG_PUSH(C++)
|
AC_LANG_PUSH(C++)
|
||||||
TORRENT_WITH_XMLRPC_C
|
TORRENT_WITH_XMLRPC_C
|
||||||
|
|||||||
+2
-10
@@ -243,8 +243,6 @@ initialize_command_local() {
|
|||||||
CMD_ANY ("system.sockets.max_size", [](auto, auto) { return torrent::runtime::socket_manager()->max_size(); });
|
CMD_ANY ("system.sockets.max_size", [](auto, auto) { return torrent::runtime::socket_manager()->max_size(); });
|
||||||
CMD_ANY_VALUE_V ("system.sockets.max_size.set", [](auto, auto& value) { return torrent::runtime::socket_manager()->set_max_size_and_adjust(value); });
|
CMD_ANY_VALUE_V ("system.sockets.max_size.set", [](auto, auto& value) { return torrent::runtime::socket_manager()->set_max_size_and_adjust(value); });
|
||||||
CMD_ANY_V ("system.sockets.adjust_alloc", [](auto, auto) { torrent::runtime::socket_manager()->adjust_allocation(); });
|
CMD_ANY_V ("system.sockets.adjust_alloc", [](auto, auto) { torrent::runtime::socket_manager()->adjust_allocation(); });
|
||||||
CMD_ANY ("system.sockets.reserved_alloc", [](auto, auto) { return torrent::runtime::socket_manager()->reserved_allocation(); });
|
|
||||||
CMD_ANY ("system.sockets.available_alloc", [](auto, auto) { return torrent::runtime::socket_manager()->available_allocation(); });
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < torrent::runtime::SocketManager::category_count; ++i) {
|
for (uint32_t i = 0; i < torrent::runtime::SocketManager::category_count; ++i) {
|
||||||
auto category = static_cast<torrent::runtime::socket_manager_category_t>(i);
|
auto category = static_cast<torrent::runtime::socket_manager_category_t>(i);
|
||||||
@@ -253,10 +251,8 @@ initialize_command_local() {
|
|||||||
CMD_ANY (category_name + ".size", [category](auto, auto) { return torrent::runtime::socket_manager()->category_managed_size(category); });
|
CMD_ANY (category_name + ".size", [category](auto, auto) { return torrent::runtime::socket_manager()->category_managed_size(category); });
|
||||||
CMD_ANY (category_name + ".max_size", [category](auto, auto) { return torrent::runtime::socket_manager()->category_max_size(category); });
|
CMD_ANY (category_name + ".max_size", [category](auto, auto) { return torrent::runtime::socket_manager()->category_max_size(category); });
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0)
|
||||||
CMD_ANY (category_name + ".min_alloc", [](auto, auto) { return torrent::runtime::socket_manager()->generic_min_allocation(); });
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
CMD_ANY (category_name + ".min_alloc", [category](auto, auto) { return torrent::runtime::socket_manager()->category_min_allocation(category); });
|
CMD_ANY (category_name + ".min_alloc", [category](auto, auto) { return torrent::runtime::socket_manager()->category_min_allocation(category); });
|
||||||
CMD_ANY (category_name + ".max_alloc", [category](auto, auto) { return torrent::runtime::socket_manager()->category_max_allocation(category); });
|
CMD_ANY (category_name + ".max_alloc", [category](auto, auto) { return torrent::runtime::socket_manager()->category_max_allocation(category); });
|
||||||
@@ -352,8 +348,6 @@ initialize_command_local() {
|
|||||||
|
|
||||||
rpc::rpc.mark_safe("system.sockets.size");
|
rpc::rpc.mark_safe("system.sockets.size");
|
||||||
rpc::rpc.mark_safe("system.sockets.max_size");
|
rpc::rpc.mark_safe("system.sockets.max_size");
|
||||||
rpc::rpc.mark_safe("system.sockets.reserved_alloc");
|
|
||||||
rpc::rpc.mark_safe("system.sockets.available_alloc");
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < torrent::runtime::SocketManager::category_count; ++i) {
|
for (uint32_t i = 0; i < torrent::runtime::SocketManager::category_count; ++i) {
|
||||||
auto category_name = "system.sockets." + torrent::option_to_str_or_throw(torrent::OPTION_SOCKET_CATEGORY, i);
|
auto category_name = "system.sockets." + torrent::option_to_str_or_throw(torrent::OPTION_SOCKET_CATEGORY, i);
|
||||||
@@ -361,10 +355,8 @@ initialize_command_local() {
|
|||||||
rpc::rpc.mark_safe(category_name + ".size");
|
rpc::rpc.mark_safe(category_name + ".size");
|
||||||
rpc::rpc.mark_safe(category_name + ".max_size");
|
rpc::rpc.mark_safe(category_name + ".max_size");
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0)
|
||||||
rpc::rpc.mark_safe(category_name + ".min_alloc");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
rpc::rpc.mark_safe(category_name + ".min_alloc");
|
rpc::rpc.mark_safe(category_name + ".min_alloc");
|
||||||
rpc::rpc.mark_safe(category_name + ".max_alloc");
|
rpc::rpc.mark_safe(category_name + ".max_alloc");
|
||||||
|
|||||||
+3
-3
@@ -6,7 +6,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <torrent/torrent.h>
|
#include <torrent/torrent.h>
|
||||||
#include <torrent/system/scheduler.h>
|
#include <torrent/utils/scheduler.h>
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
class Root;
|
class Root;
|
||||||
@@ -107,8 +107,8 @@ private:
|
|||||||
mode_t m_umask;
|
mode_t m_umask;
|
||||||
std::string m_workingDirectory;
|
std::string m_workingDirectory;
|
||||||
|
|
||||||
torrent::system::SchedulerEntry m_task_shutdown;
|
torrent::utils::SchedulerEntry m_task_shutdown;
|
||||||
torrent::system::SchedulerEntry m_task_shutdown_clear_requests;
|
torrent::utils::SchedulerEntry m_task_shutdown_clear_requests;
|
||||||
|
|
||||||
int m_clear_requests_count{};
|
int m_clear_requests_count{};
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define RTORRENT_CORE_DHT_MANAGER_H
|
#define RTORRENT_CORE_DHT_MANAGER_H
|
||||||
|
|
||||||
#include <torrent/object.h>
|
#include <torrent/object.h>
|
||||||
#include <torrent/system/scheduler.h>
|
#include <torrent/utils/scheduler.h>
|
||||||
|
|
||||||
namespace core {
|
namespace core {
|
||||||
|
|
||||||
@@ -42,8 +42,8 @@ private:
|
|||||||
uint64_t m_dhtPrevBytesUp;
|
uint64_t m_dhtPrevBytesUp;
|
||||||
uint64_t m_dhtPrevBytesDown;
|
uint64_t m_dhtPrevBytesDown;
|
||||||
|
|
||||||
torrent::system::SchedulerEntry m_update_timeout;
|
torrent::utils::SchedulerEntry m_update_timeout;
|
||||||
torrent::system::SchedulerEntry m_stop_timeout;
|
torrent::utils::SchedulerEntry m_stop_timeout;
|
||||||
|
|
||||||
bool m_warned{};
|
bool m_warned{};
|
||||||
bool m_set_by_user{};
|
bool m_set_by_user{};
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
#include <torrent/object.h>
|
#include <torrent/object.h>
|
||||||
#include <torrent/system/scheduler.h>
|
#include <torrent/utils/scheduler.h>
|
||||||
|
|
||||||
#include "http_queue.h"
|
#include "http_queue.h"
|
||||||
|
|
||||||
@@ -79,9 +79,9 @@ private:
|
|||||||
command_list_type m_commands;
|
command_list_type m_commands;
|
||||||
torrent::Object::map_type m_variables;
|
torrent::Object::map_type m_variables;
|
||||||
|
|
||||||
slot_void m_slot_finished;
|
slot_void m_slot_finished;
|
||||||
torrent::system::SchedulerEntry m_task_load;
|
torrent::utils::SchedulerEntry m_task_load;
|
||||||
torrent::system::SchedulerEntry m_task_commit;
|
torrent::utils::SchedulerEntry m_task_commit;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool is_network_uri(const std::string& uri);
|
bool is_network_uri(const std::string& uri);
|
||||||
|
|||||||
+3
-3
@@ -18,7 +18,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <torrent/object.h>
|
#include <torrent/object.h>
|
||||||
#include <torrent/system/scheduler.h>
|
#include <torrent/utils/scheduler.h>
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
@@ -153,8 +153,8 @@ private:
|
|||||||
|
|
||||||
std::chrono::microseconds m_last_changed{};
|
std::chrono::microseconds m_last_changed{};
|
||||||
|
|
||||||
signal_void m_signal_changed;
|
signal_void m_signal_changed;
|
||||||
torrent::system::SchedulerEntry m_delay_changed;
|
torrent::utils::SchedulerEntry m_delay_changed;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace core
|
} // namespace core
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef RTORRENT_DISPLAY_MANAGER_H
|
#ifndef RTORRENT_DISPLAY_MANAGER_H
|
||||||
#define RTORRENT_DISPLAY_MANAGER_H
|
#define RTORRENT_DISPLAY_MANAGER_H
|
||||||
|
|
||||||
#include <torrent/system/scheduler.h>
|
#include <torrent/utils/scheduler.h>
|
||||||
|
|
||||||
#include "display/frame.h"
|
#include "display/frame.h"
|
||||||
|
|
||||||
@@ -31,9 +31,9 @@ private:
|
|||||||
bool m_force_redraw{false};
|
bool m_force_redraw{false};
|
||||||
Frame m_root_frame;
|
Frame m_root_frame;
|
||||||
|
|
||||||
std::chrono::microseconds m_time_last_update{};
|
std::chrono::microseconds m_time_last_update{};
|
||||||
torrent::system::ExternalScheduler m_scheduler;
|
torrent::utils::ExternalScheduler m_scheduler;
|
||||||
torrent::system::SchedulerEntry m_task_update;
|
torrent::utils::SchedulerEntry m_task_update;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define RTORRENT_WINDOW_BASE_H
|
#define RTORRENT_WINDOW_BASE_H
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <torrent/system/scheduler.h>
|
#include <torrent/utils/scheduler.h>
|
||||||
#include <torrent/system/thread.h>
|
#include <torrent/system/thread.h>
|
||||||
|
|
||||||
#include "canvas.h"
|
#include "canvas.h"
|
||||||
@@ -99,7 +99,7 @@ protected:
|
|||||||
extent_type m_max_width;
|
extent_type m_max_width;
|
||||||
extent_type m_max_height;
|
extent_type m_max_height;
|
||||||
|
|
||||||
torrent::system::SchedulerEntry m_task_update;
|
torrent::utils::SchedulerEntry m_task_update;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return a range with a distance of no more than __distance and
|
// Return a range with a distance of no more than __distance and
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ private:
|
|||||||
signal_curl_get::iterator m_conn_insert;
|
signal_curl_get::iterator m_conn_insert;
|
||||||
signal_curl_get::iterator m_conn_erase;
|
signal_curl_get::iterator m_conn_erase;
|
||||||
|
|
||||||
torrent::system::SchedulerEntry m_task_deactivate;
|
torrent::utils::SchedulerEntry m_task_deactivate;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef RTORRENT_DISPLAY_WINDOW_LOG_H
|
#ifndef RTORRENT_DISPLAY_WINDOW_LOG_H
|
||||||
#define RTORRENT_DISPLAY_WINDOW_LOG_H
|
#define RTORRENT_DISPLAY_WINDOW_LOG_H
|
||||||
|
|
||||||
#include <torrent/system/scheduler.h>
|
|
||||||
#include <torrent/utils/log_buffer.h>
|
#include <torrent/utils/log_buffer.h>
|
||||||
|
#include <torrent/utils/scheduler.h>
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
@@ -22,12 +22,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
inline iterator find_older();
|
inline iterator find_older();
|
||||||
|
|
||||||
torrent::log_buffer* m_log;
|
torrent::log_buffer* m_log;
|
||||||
torrent::system::SchedulerEntry m_task_update;
|
torrent::utils::SchedulerEntry m_task_update;
|
||||||
|
|
||||||
align_cacheline
|
align_cacheline std::atomic<bool> m_log_updating{};
|
||||||
|
|
||||||
std::atomic<bool> m_log_updating{};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -392,12 +392,13 @@ main(int argc, char** argv) {
|
|||||||
|
|
||||||
CMD_REDIRECT("bind", "network.bind_address.set");
|
CMD_REDIRECT("bind", "network.bind_address.set");
|
||||||
CMD_REDIRECT("ip", "network.local_address.set");
|
CMD_REDIRECT("ip", "network.local_address.set");
|
||||||
|
CMD_REDIRECT("port_range", "network.port_range.set");
|
||||||
|
|
||||||
// TODO: Check if dht is on by default.
|
// TODO: Check if dht is on by default.
|
||||||
CMD_REDIRECT("dht", "dht.mode.set");
|
CMD_REDIRECT("dht", "dht.mode.set");
|
||||||
|
|
||||||
CMD_REDIRECT("port_random", "network.listen.port.random.set");
|
CMD_REDIRECT("port_random", "network.port_random.set");
|
||||||
CMD_REDIRECT("proxy_address", "network.proxy.http.set");
|
CMD_REDIRECT("proxy_address", "network.proxy_address.set");
|
||||||
|
|
||||||
CMD_REDIRECT("key_layout", "keys.layout.set");
|
CMD_REDIRECT("key_layout", "keys.layout.set");
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <torrent/object.h>
|
#include <torrent/object.h>
|
||||||
#include <torrent/system/scheduler.h>
|
#include <torrent/utils/scheduler.h>
|
||||||
|
|
||||||
namespace rpc {
|
namespace rpc {
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ private:
|
|||||||
uint32_t m_interval{};
|
uint32_t m_interval{};
|
||||||
std::chrono::microseconds m_time_scheduled;
|
std::chrono::microseconds m_time_scheduled;
|
||||||
|
|
||||||
torrent::system::SchedulerEntry m_task;
|
torrent::utils::SchedulerEntry m_task;
|
||||||
|
|
||||||
// Flags for various things.
|
// Flags for various things.
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -76,61 +76,4 @@ ExecFile::execute(const char* file, char* const* argv, int flags) {
|
|||||||
return spawn_process.wait_for_child();
|
return spawn_process.wait_for_child();
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent::Object
|
|
||||||
ExecFile::execute_object(const torrent::Object& rawArgs, int flags) {
|
|
||||||
char* argsBuffer[max_args];
|
|
||||||
char** argsCurrent = argsBuffer;
|
|
||||||
|
|
||||||
// Size of value strings are less than 24.
|
|
||||||
char valueBuffer[buffer_size+1];
|
|
||||||
char* valueCurrent = valueBuffer;
|
|
||||||
|
|
||||||
if (rawArgs.is_list()) {
|
|
||||||
const torrent::Object::list_type& args = rawArgs.as_list();
|
|
||||||
|
|
||||||
if (args.empty())
|
|
||||||
throw torrent::input_error("Too few arguments.");
|
|
||||||
|
|
||||||
for (torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; itr++, argsCurrent++) {
|
|
||||||
if (argsCurrent == argsBuffer + max_args - 1)
|
|
||||||
throw torrent::input_error("Too many arguments.");
|
|
||||||
|
|
||||||
if (itr->is_string() && (!(flags & flag_expand_tilde) || *itr->as_string().c_str() != '~')) {
|
|
||||||
*argsCurrent = const_cast<char*>(itr->as_string().c_str());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
*argsCurrent = valueCurrent;
|
|
||||||
valueCurrent = print_object(valueCurrent, valueBuffer + buffer_size, &*itr, flags) + 1;
|
|
||||||
|
|
||||||
if (valueCurrent >= valueBuffer + buffer_size)
|
|
||||||
throw torrent::input_error("Overflowed execute arg buffer.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
const torrent::Object::string_type& args = rawArgs.as_string();
|
|
||||||
|
|
||||||
if ((flags & flag_expand_tilde) && args.c_str()[0] == '~') {
|
|
||||||
*argsCurrent = valueCurrent;
|
|
||||||
valueCurrent = print_object(valueCurrent, valueBuffer + buffer_size, &rawArgs, flags) + 1;
|
|
||||||
} else {
|
|
||||||
*argsCurrent = const_cast<char*>(args.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
argsCurrent++;
|
|
||||||
}
|
|
||||||
|
|
||||||
*argsCurrent = NULL;
|
|
||||||
|
|
||||||
int status = execute(argsBuffer[0], argsBuffer, flags);
|
|
||||||
|
|
||||||
if ((flags & flag_throw) && status != 0)
|
|
||||||
throw torrent::input_error("Bad return code.");
|
|
||||||
|
|
||||||
if (flags & flag_capture)
|
|
||||||
return m_capture;
|
|
||||||
|
|
||||||
return torrent::Object((int64_t)status);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace rpc
|
} // namespace rpc
|
||||||
|
|||||||
+22
-14
@@ -9,37 +9,38 @@ namespace utils {
|
|||||||
|
|
||||||
WaitpidQueue::WaitpidQueue() {
|
WaitpidQueue::WaitpidQueue() {
|
||||||
m_worker = std::async(std::launch::async, [this]() {
|
m_worker = std::async(std::launch::async, [this]() {
|
||||||
|
bool is_running = true;
|
||||||
auto wait_time = 50ms;
|
auto wait_time = 50ms;
|
||||||
|
|
||||||
while (true) {
|
while (is_running) {
|
||||||
if (!m_queue.empty()) {
|
if (!m_queue.empty()) {
|
||||||
auto start_time = std::chrono::steady_clock::now();
|
auto start_time = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
while (std::chrono::steady_clock::now() - start_time < wait_time) {
|
while (!m_wakeup_worker.load(std::memory_order_acquire) && !m_should_shutdown) {
|
||||||
if (m_should_shutdown.load(std::memory_order_acquire))
|
auto elapsed = std::chrono::steady_clock::now() - start_time;
|
||||||
return;
|
|
||||||
|
if (elapsed >= wait_time)
|
||||||
|
break;
|
||||||
|
|
||||||
std::this_thread::sleep_for(50ms);
|
std::this_thread::sleep_for(50ms);
|
||||||
|
|
||||||
if (m_wakeup_worker.load(std::memory_order_acquire))
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
m_wakeup_worker.wait(false, std::memory_order_acquire);
|
m_wakeup_worker.wait(false, std::memory_order_acquire);
|
||||||
|
std::this_thread::sleep_for(50ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds a small delay to allow new processes to finish if they're quickly spawned and
|
|
||||||
// terminated.
|
|
||||||
std::this_thread::sleep_for(50ms);
|
|
||||||
|
|
||||||
std::set<pid_t> queue;
|
std::set<pid_t> queue;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_mutex);
|
std::lock_guard<std::mutex> guard(m_mutex);
|
||||||
|
|
||||||
if (m_should_shutdown)
|
if (m_should_shutdown) {
|
||||||
return;
|
if (m_queue.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
is_running = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_queue.empty())
|
if (m_queue.empty())
|
||||||
throw torrent::internal_error("WaitpidQueue worker thread woke up but queue is empty.");
|
throw torrent::internal_error("WaitpidQueue worker thread woke up but queue is empty.");
|
||||||
@@ -71,7 +72,6 @@ WaitpidQueue::WaitpidQueue() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't wait for the worker thread to finish as waitpid isn't needed to be called on shutdown.
|
|
||||||
WaitpidQueue::~WaitpidQueue() {
|
WaitpidQueue::~WaitpidQueue() {
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_mutex);
|
std::lock_guard<std::mutex> guard(m_mutex);
|
||||||
@@ -80,6 +80,8 @@ WaitpidQueue::~WaitpidQueue() {
|
|||||||
|
|
||||||
m_wakeup_worker.store(true, std::memory_order_release);
|
m_wakeup_worker.store(true, std::memory_order_release);
|
||||||
m_wakeup_worker.notify_all();
|
m_wakeup_worker.notify_all();
|
||||||
|
|
||||||
|
// m_worker.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -91,6 +93,12 @@ WaitpidQueue::close_pid(pid_t pid) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_mutex);
|
std::lock_guard<std::mutex> guard(m_mutex);
|
||||||
|
|
||||||
|
// if (!m_queue.empty()) {
|
||||||
|
// m_queue.push_back(pid);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
m_queue.insert(pid);
|
m_queue.insert(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ public:
|
|||||||
|
|
||||||
void wait_for(uint32_t max_remaining);
|
void wait_for(uint32_t max_remaining);
|
||||||
|
|
||||||
// TODO: Add a signal handler to tell the worker thread to wake up. Use a counter to batch wakeups.
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WaitpidQueue(const WaitpidQueue&) = delete;
|
WaitpidQueue(const WaitpidQueue&) = delete;
|
||||||
WaitpidQueue& operator=(const WaitpidQueue&) = delete;
|
WaitpidQueue& operator=(const WaitpidQueue&) = delete;
|
||||||
@@ -31,11 +29,11 @@ private:
|
|||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
std::set<pid_t> m_queue;
|
std::set<pid_t> m_queue;
|
||||||
|
|
||||||
|
bool m_should_shutdown{};
|
||||||
|
|
||||||
align_cacheline
|
align_cacheline
|
||||||
|
|
||||||
std::atomic<bool> m_wakeup_worker{};
|
std::atomic<bool> m_wakeup_worker{};
|
||||||
std::atomic<bool> m_should_shutdown{};
|
|
||||||
|
|
||||||
std::atomic<uint32_t> m_remaining{};
|
std::atomic<uint32_t> m_remaining{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <torrent/system/scheduler.h>
|
#include <torrent/utils/scheduler.h>
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
@@ -49,12 +49,10 @@ private:
|
|||||||
void update_status(Entry* entry);
|
void update_status(Entry* entry);
|
||||||
void schedule();
|
void schedule();
|
||||||
|
|
||||||
std::map<std::string, Entry> m_entries;
|
std::map<std::string, Entry> m_entries;
|
||||||
std::vector<Entry*> m_entry_queue;
|
std::vector<Entry*> m_entry_queue;
|
||||||
|
torrent::utils::SchedulerEntry m_task_process;
|
||||||
bool m_active{true};
|
bool m_active{true};
|
||||||
|
|
||||||
torrent::system::SchedulerEntry m_task_process;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "torrent/exceptions.h"
|
#include "torrent/exceptions.h"
|
||||||
#include "torrent/net/resolver.h"
|
#include "torrent/net/resolver.h"
|
||||||
#include "torrent/utils/log.h"
|
#include "torrent/utils/log.h"
|
||||||
|
#include "torrent/utils/scheduler.h"
|
||||||
|
|
||||||
std::unique_ptr<TestMainThread>
|
std::unique_ptr<TestMainThread>
|
||||||
TestMainThread::create() {
|
TestMainThread::create() {
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ TestCommandLocal::test_socket_category_commands() {
|
|||||||
|
|
||||||
CPPUNIT_ASSERT(rpc::commands.has(name + ".size"));
|
CPPUNIT_ASSERT(rpc::commands.has(name + ".size"));
|
||||||
CPPUNIT_ASSERT(rpc::commands.has(name + ".max_size"));
|
CPPUNIT_ASSERT(rpc::commands.has(name + ".max_size"));
|
||||||
CPPUNIT_ASSERT(rpc::commands.has(name + ".min_alloc"));
|
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL(has_allocation, rpc::commands.has(name + ".min_alloc"));
|
||||||
CPPUNIT_ASSERT_EQUAL(has_allocation, rpc::commands.has(name + ".max_alloc"));
|
CPPUNIT_ASSERT_EQUAL(has_allocation, rpc::commands.has(name + ".max_alloc"));
|
||||||
CPPUNIT_ASSERT_EQUAL(has_allocation, rpc::commands.has(name + ".min_alloc.set"));
|
CPPUNIT_ASSERT_EQUAL(has_allocation, rpc::commands.has(name + ".min_alloc.set"));
|
||||||
CPPUNIT_ASSERT_EQUAL(has_allocation, rpc::commands.has(name + ".max_alloc.set"));
|
CPPUNIT_ASSERT_EQUAL(has_allocation, rpc::commands.has(name + ".max_alloc.set"));
|
||||||
|
|||||||
Reference in New Issue
Block a user