mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-21 08:36:18 +00:00
* Fixed a potential issue causing high loads while waiting for main thread to exit polling. #2661
* Added 'strings.choke_heuristics.{upload,download}' and extra dummy upload/download heuristics for testings.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1263 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -296,7 +296,8 @@ Number of unchoked upload / download peers regulated on a group basis.
|
|||||||
(choke_group.down.heuristics.set,<cg_index>,"heuristics")
|
(choke_group.down.heuristics.set,<cg_index>,"heuristics")
|
||||||
|
|
||||||
Heuristics used for deciding what peers to choke and unchoke, see
|
Heuristics used for deciding what peers to choke and unchoke, see
|
||||||
'strings.choke_heuristics' for a list of available options.
|
'strings.choke_heuristics{,_download,_upload}' for a list of available
|
||||||
|
options.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -304,8 +305,10 @@ Heuristics used for deciding what peers to choke and unchoke, see
|
|||||||
void
|
void
|
||||||
initialize_command_groups() {
|
initialize_command_groups() {
|
||||||
// Move somewhere else?
|
// Move somewhere else?
|
||||||
CMD2_ANY ("strings.choke_heuristics", std::bind(&torrent::option_list_strings, torrent::OPTION_CHOKE_HEURISTICS));
|
CMD2_ANY ("strings.choke_heuristics", std::bind(&torrent::option_list_strings, torrent::OPTION_CHOKE_HEURISTICS));
|
||||||
CMD2_ANY ("strings.tracker_mode", std::bind(&torrent::option_list_strings, torrent::OPTION_TRACKER_MODE));
|
CMD2_ANY ("strings.choke_heuristics.uplaod", std::bind(&torrent::option_list_strings, torrent::OPTION_CHOKE_HEURISTICS_UPLOAD));
|
||||||
|
CMD2_ANY ("strings.choke_heuristics.downlaod", std::bind(&torrent::option_list_strings, torrent::OPTION_CHOKE_HEURISTICS_DOWNLOAD));
|
||||||
|
CMD2_ANY ("strings.tracker_mode", std::bind(&torrent::option_list_strings, torrent::OPTION_TRACKER_MODE));
|
||||||
|
|
||||||
CMD2_ANY ("choke_group.list", std::bind(&apply_cg_list));
|
CMD2_ANY ("choke_group.list", std::bind(&apply_cg_list));
|
||||||
CMD2_ANY_STRING ("choke_group.insert", std::bind(&apply_cg_insert, std::placeholders::_2));
|
CMD2_ANY_STRING ("choke_group.insert", std::bind(&apply_cg_insert, std::placeholders::_2));
|
||||||
|
|||||||
+10
-4
@@ -43,6 +43,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <rak/error_number.h>
|
#include <rak/error_number.h>
|
||||||
#include <torrent/exceptions.h>
|
#include <torrent/exceptions.h>
|
||||||
|
|
||||||
@@ -201,10 +202,15 @@ ThreadBase::queue_item(thread_base_func newFunc) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
ThreadBase::interrupt_main_polling() {
|
ThreadBase::interrupt_main_polling() {
|
||||||
do {
|
int sleep_length = 0;
|
||||||
|
|
||||||
|
while (ThreadBase::is_main_polling()) {
|
||||||
|
pthread_kill(main_thread->m_thread, SIGUSR1);
|
||||||
|
|
||||||
if (!ThreadBase::is_main_polling())
|
if (!ThreadBase::is_main_polling())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pthread_kill(main_thread->m_thread, SIGUSR1);
|
usleep(sleep_length);
|
||||||
} while (1);
|
sleep_length = std::min(sleep_length + 50, 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,11 @@ public:
|
|||||||
|
|
||||||
static void* event_loop(ThreadBase* threadBase);
|
static void* event_loop(ThreadBase* threadBase);
|
||||||
|
|
||||||
|
// 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.
|
// Move to libtorrent some day.
|
||||||
static void interrupt_main_polling();
|
static void interrupt_main_polling();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user