From 2c97841e92ccf84f609a588f4b346d3e41831860 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Tue, 26 Feb 2013 17:40:41 +0900 Subject: [PATCH 1/4] Removed unused member variables. --- src/core/view_manager.h | 3 --- src/display/window_download_transfer_list.cc | 3 +-- src/display/window_download_transfer_list.h | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/core/view_manager.h b/src/core/view_manager.h index e2ef1ab2..750d210b 100644 --- a/src/core/view_manager.h +++ b/src/core/view_manager.h @@ -97,9 +97,6 @@ public: void set_event_added(const std::string& name, const torrent::Object& cmd) { (*find_throw(name))->set_event_added(cmd); } void set_event_removed(const std::string& name, const torrent::Object& cmd) { (*find_throw(name))->set_event_removed(cmd); } - -private: - DownloadList* m_list; }; } diff --git a/src/display/window_download_transfer_list.cc b/src/display/window_download_transfer_list.cc index 25a59d12..f8d2ff47 100644 --- a/src/display/window_download_transfer_list.cc +++ b/src/display/window_download_transfer_list.cc @@ -50,8 +50,7 @@ namespace display { WindowDownloadTransferList::WindowDownloadTransferList(core::Download* d, unsigned int *focus) : Window(new Canvas, 0, 0, 0, extent_full, extent_full), - m_download(d), - m_focus(focus) { + m_download(d) { } void diff --git a/src/display/window_download_transfer_list.h b/src/display/window_download_transfer_list.h index a61c7009..4e3febb8 100644 --- a/src/display/window_download_transfer_list.h +++ b/src/display/window_download_transfer_list.h @@ -71,8 +71,6 @@ private: char key_id(torrent::BlockTransfer::key_type key); core::Download* m_download; - - unsigned int* m_focus; assigned_vector m_assigned; }; From e28692492b9220ad03e66930229fb32c81d10703 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Tue, 26 Feb 2013 17:44:42 +0900 Subject: [PATCH 2/4] Fixed obsolete macro statements. --- .gitignore | 1 + configure.ac | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cd3dfbbb..a956f2b1 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,4 @@ TAGS ########################### src/rtorrent test/rtorrentTest +test-driver diff --git a/configure.ac b/configure.ac index 9ff7b544..2e6a9eb5 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_INIT(rtorrent, 0.9.3, jaris@ifi.uio.no) AC_DEFINE(API_VERSION, 8, api version) AM_INIT_AUTOMAKE -AM_CONFIG_HEADER(config.h) +AC_CONFIG_HEADERS(config.h) AM_PATH_CPPUNIT(1.9.6) AC_PROG_CXX From 3b2a47a6d08dbb17ddd92d21b0b98c87297d0d7e Mon Sep 17 00:00:00 2001 From: rakshasa Date: Sun, 3 Mar 2013 05:00:31 +0900 Subject: [PATCH 3/4] Use thread_base::interrupt for all SIGUSR1 interrupt signals and don't set a handler if it's not supported. --- src/main.cc | 12 +++++++++--- src/thread_base.cc | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main.cc b/src/main.cc index 843037f6..5221581a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -202,9 +202,15 @@ main(int argc, char** argv) { SignalHandler::set_sigaction_handler(SIGBUS, &handle_sigbus); - // SIGUSR1 is used for interrupting polling, forcing that thread - // to process new non-socket events. - SignalHandler::set_handler(SIGUSR1, sigc::ptr_fun(&do_nothing)); + // SIGUSR1 is used for interrupting polling, forcing the target + // thread to process new non-socket events. + // + // LibTorrent uses sockets for this purpose on Solaris and other + // platforms that do not properly pass signals to the target + // threads. Use '--enable-interrupt-socket' when configuring + // LibTorrent to enable this workaround. + if (torrent::thread_base::should_handle_sigusr1()) + SignalHandler::set_handler(SIGUSR1, sigc::ptr_fun(&do_nothing)); torrent::log_add_group_output(torrent::LOG_NOTICE, "important"); torrent::log_add_group_output(torrent::LOG_INFO, "complete"); diff --git a/src/thread_base.cc b/src/thread_base.cc index 19dab3b0..b4219cf9 100644 --- a/src/thread_base.cc +++ b/src/thread_base.cc @@ -160,7 +160,7 @@ ThreadBase::queue_item(thread_base_func newFunc) { // Make it also restart inactive threads? if (m_state == STATE_ACTIVE) - pthread_kill(m_thread, SIGUSR1); + interrupt(); } void @@ -168,7 +168,7 @@ ThreadBase::interrupt_main_polling() { int sleep_length = 0; while (ThreadBase::is_main_polling()) { - pthread_kill(torrent::main_thread()->pthread(), SIGUSR1); + torrent::main_thread()->interrupt(); if (!ThreadBase::is_main_polling()) return; From 7689059dbc1ee05f855eb28883cbe59d162d4431 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Wed, 3 Apr 2013 21:16:11 +0900 Subject: [PATCH 4/4] Cleaned up thread code. --- src/rpc/scgi.cc | 6 +++--- src/thread_base.cc | 15 --------------- src/thread_base.h | 8 -------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/rpc/scgi.cc b/src/rpc/scgi.cc index 3daa7e57..f992718c 100644 --- a/src/rpc/scgi.cc +++ b/src/rpc/scgi.cc @@ -169,12 +169,12 @@ SCgi::receive_call(SCgiTask* task, const char* buffer, uint32_t length) { slot_write slotWrite; slotWrite.set(rak::mem_fn(task, &SCgiTask::receive_write)); - ThreadBase::acquire_global_lock(); - ThreadBase::interrupt_main_polling(); + torrent::thread_base::acquire_global_lock(); + torrent::main_thread()->interrupt(); bool result = xmlrpc.process(buffer, length, slotWrite); - ThreadBase::release_global_lock(); + torrent::thread_base::release_global_lock(); return result; } diff --git a/src/thread_base.cc b/src/thread_base.cc index b4219cf9..a61a1201 100644 --- a/src/thread_base.cc +++ b/src/thread_base.cc @@ -162,18 +162,3 @@ ThreadBase::queue_item(thread_base_func newFunc) { if (m_state == STATE_ACTIVE) interrupt(); } - -void -ThreadBase::interrupt_main_polling() { - int sleep_length = 0; - - while (ThreadBase::is_main_polling()) { - torrent::main_thread()->interrupt(); - - if (!ThreadBase::is_main_polling()) - return; - - usleep(sleep_length); - sleep_length = std::min(sleep_length + 50, 1000); - } -} diff --git a/src/thread_base.h b/src/thread_base.h index 479e3cdd..b125ea8b 100644 --- a/src/thread_base.h +++ b/src/thread_base.h @@ -66,14 +66,6 @@ public: void queue_item(thread_base_func newFunc); - // Only call this when global lock has been acquired, as it checks - // ThreadBase::is_main_polling() which is only guaranteed to remain - // 'false' if global lock keeps main thread from entering polling - // again. - // - // Move to libtorrent some day. - static void interrupt_main_polling(); - protected: int64_t next_timeout_usec();