mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-10 04:02:30 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 877e5f6ed3 | |||
| ee64f8ea50 | |||
| bf1265d954 | |||
| 6c3c77a2b7 | |||
| 120fcb0273 | |||
| c36956813d | |||
| 05563b4c9b | |||
| a544f8ad68 | |||
| b35413ea71 | |||
| f9f19fb041 |
@@ -11,8 +11,7 @@ namespace input {
|
|||||||
|
|
||||||
void
|
void
|
||||||
InputEvent::insert() {
|
InputEvent::insert() {
|
||||||
torrent::this_thread::poll()->open(this);
|
torrent::this_thread::poll()->open_and_insert_read(this);
|
||||||
torrent::this_thread::poll()->insert_read(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+16
-15
@@ -112,8 +112,9 @@ main(int argc, char** argv) {
|
|||||||
|
|
||||||
torrent::log_initialize();
|
torrent::log_initialize();
|
||||||
|
|
||||||
// TODO: Create a fake thread object for initializing other processes and enabling logging.
|
torrent::runtime::initialize_worker_process_and_main_thread([argc, argv]() {
|
||||||
torrent::initialize_main_thread();
|
parse_config_file(argc, argv, [](auto& path) { parse_config_file_comments("worker", path); });
|
||||||
|
});
|
||||||
|
|
||||||
// Block SIGCHLD until all threads are created, then unblock on main-thread, to avoid SIGCHLD
|
// Block SIGCHLD until all threads are created, then unblock on main-thread, to avoid SIGCHLD
|
||||||
// interrupting other threads.
|
// interrupting other threads.
|
||||||
@@ -125,9 +126,9 @@ main(int argc, char** argv) {
|
|||||||
SignalHandler::set_block(SIGCHLD);
|
SignalHandler::set_block(SIGCHLD);
|
||||||
|
|
||||||
// All signal handlers must restore errno if they return.
|
// All signal handlers must restore errno if they return.
|
||||||
SignalHandler::set_handler(SIGSEGV, std::bind(&do_panic, SIGSEGV));
|
SignalHandler::set_handler(SIGSEGV, []() { do_panic(SIGSEGV); });
|
||||||
SignalHandler::set_handler(SIGILL, std::bind(&do_panic, SIGILL));
|
SignalHandler::set_handler(SIGILL, []() { do_panic(SIGILL); });
|
||||||
SignalHandler::set_handler(SIGFPE, std::bind(&do_panic, SIGFPE));
|
SignalHandler::set_handler(SIGFPE, []() { do_panic(SIGFPE); });
|
||||||
|
|
||||||
// Limited list of commands with the following format:
|
// Limited list of commands with the following format:
|
||||||
//
|
//
|
||||||
@@ -136,19 +137,17 @@ main(int argc, char** argv) {
|
|||||||
// # do:log.open_file=system,/usr/rakshasa/system.log
|
// # do:log.open_file=system,/usr/rakshasa/system.log
|
||||||
// # do:log.add_output=system,system
|
// # do:log.add_output=system,system
|
||||||
//
|
//
|
||||||
parse_config_file(argc, argv, [](auto& path) {
|
// # do-worker:log.open_file=system,/usr/rakshasa/system-worker.log
|
||||||
if (path.empty())
|
// # do-worker:log.add_output=system,system
|
||||||
return;
|
//
|
||||||
|
parse_config_file(argc, argv, [](auto& path) { parse_config_file_comments("", path); });
|
||||||
parse_config_file_comments(path);
|
|
||||||
});
|
|
||||||
|
|
||||||
control = new Control;
|
control = new Control;
|
||||||
|
|
||||||
SignalHandler::set_handler(SIGINT, std::bind(&Control::receive_normal_shutdown, control));
|
SignalHandler::set_handler(SIGINT, []() { control->receive_normal_shutdown(); });
|
||||||
SignalHandler::set_handler(SIGHUP, std::bind(&Control::receive_normal_shutdown, control));
|
SignalHandler::set_handler(SIGHUP, []() { control->receive_normal_shutdown(); });
|
||||||
SignalHandler::set_handler(SIGTERM, std::bind(&Control::receive_quick_shutdown, control));
|
SignalHandler::set_handler(SIGTERM, []() { control->receive_quick_shutdown(); });
|
||||||
SignalHandler::set_handler(SIGWINCH, std::bind(&display::Manager::force_redraw, control->display()));
|
SignalHandler::set_handler(SIGWINCH, []() { control->display()->force_redraw(); });
|
||||||
|
|
||||||
SignalHandler::set_sigaction_handler(SIGBUS, &handle_sigbus);
|
SignalHandler::set_sigaction_handler(SIGBUS, &handle_sigbus);
|
||||||
|
|
||||||
@@ -463,6 +462,8 @@ main(int argc, char** argv) {
|
|||||||
control->ui()->load_input_history();
|
control->ui()->load_input_history();
|
||||||
|
|
||||||
torrent::net_thread::http_stack()->set_user_agent(USER_AGENT);
|
torrent::net_thread::http_stack()->set_user_agent(USER_AGENT);
|
||||||
|
|
||||||
|
torrent::runtime::initialize_worker_process();
|
||||||
torrent::runtime::initialize_network();
|
torrent::runtime::initialize_network();
|
||||||
|
|
||||||
// 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
|
||||||
|
|||||||
+1
-2
@@ -109,8 +109,7 @@ void
|
|||||||
SCgi::activate() {
|
SCgi::activate() {
|
||||||
assert(torrent::this_thread::thread() == scgi_thread::thread());
|
assert(torrent::this_thread::thread() == scgi_thread::thread());
|
||||||
|
|
||||||
torrent::this_thread::poll()->open(this);
|
torrent::this_thread::poll()->open_and_insert_read(this);
|
||||||
torrent::this_thread::poll()->insert_read(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This should close the fd to avoid reuse.
|
// TODO: This should close the fd to avoid reuse.
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ SCgiTask::open(SCgi* parent, int fd) {
|
|||||||
// m_trusted=false into the next reuse, given that the
|
// m_trusted=false into the next reuse, given that the
|
||||||
// UNTRUSTED_CONNECTION=0 parse branch is a no-op.
|
// UNTRUSTED_CONNECTION=0 parse branch is a no-op.
|
||||||
|
|
||||||
torrent::this_thread::poll()->open(this);
|
torrent::this_thread::poll()->open_and_insert_read(this);
|
||||||
torrent::this_thread::poll()->insert_read(this);
|
|
||||||
|
|
||||||
auto lock = std::lock_guard<std::mutex>(m_result_mutex);
|
auto lock = std::lock_guard<std::mutex>(m_result_mutex);
|
||||||
|
|
||||||
|
|||||||
+9
-5
@@ -108,18 +108,22 @@ config_comment_log(const std::string& command, const std::string& raw_args) {
|
|||||||
throw torrent::input_error("Unknown log command: " + command);
|
throw torrent::input_error("Unknown log command: " + command);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call special commands in the format "# do:command=args" in the config file.
|
// Call special commands in the format "# do:command=args" or "# do-<category>:command=args" in the config file.
|
||||||
void
|
void
|
||||||
parse_config_file_comments(const std::string& path) {
|
parse_config_file_comments(const std::string& category, const std::string& path) {
|
||||||
|
if (path.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
std::fstream file(path, std::ios::in);
|
std::fstream file(path, std::ios::in);
|
||||||
|
|
||||||
if (!file.is_open())
|
if (!file.is_open())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
|
std::string prefix = category.empty() ? "# do:" : "# do-" + category + ":";
|
||||||
|
|
||||||
while (std::getline(file, line)) {
|
while (std::getline(file, line)) {
|
||||||
if (line.size() <= 5 || line.compare(0, 5, "# do:") != 0)
|
if (line.size() <= prefix.size() || line.compare(0, prefix.size(), prefix) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto equal_pos = line.find('=');
|
auto equal_pos = line.find('=');
|
||||||
@@ -127,8 +131,8 @@ parse_config_file_comments(const std::string& path) {
|
|||||||
if (equal_pos == std::string::npos)
|
if (equal_pos == std::string::npos)
|
||||||
throw torrent::input_error("Invalid command in config file comment: " + line);
|
throw torrent::input_error("Invalid command in config file comment: " + line);
|
||||||
|
|
||||||
std::string command = line.substr(5, equal_pos - 5);
|
auto command = line.substr(prefix.size(), equal_pos - prefix.size());
|
||||||
std::string args = line.substr(equal_pos + 1);
|
auto args = line.substr(equal_pos + 1);
|
||||||
|
|
||||||
if (command.empty())
|
if (command.empty())
|
||||||
throw torrent::input_error("Invalid command in config file comment: " + line);
|
throw torrent::input_error("Invalid command in config file comment: " + line);
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
int parse_main_options(int argc, char** argv);
|
int parse_main_options(int argc, char** argv);
|
||||||
void parse_config_file(int argc, char** argv, std::function<void (const std::string&)> parse_fn);
|
void parse_config_file(int argc, char** argv, std::function<void (const std::string&)> parse_fn);
|
||||||
void parse_config_file_comments(const std::string& path);
|
void parse_config_file_comments(const std::string& category, const std::string& path);
|
||||||
|
|
||||||
void load_session_torrents(const std::string& path);
|
void load_session_torrents(const std::string& path);
|
||||||
void load_arg_torrents(char** first, char** last);
|
void load_arg_torrents(char** first, char** last);
|
||||||
|
|||||||
Reference in New Issue
Block a user