* 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:
rakshasa
2011-08-06 05:20:18 +00:00
parent 882a64af77
commit ce16621707
3 changed files with 21 additions and 7 deletions
+10 -4
View File
@@ -43,6 +43,7 @@
#include <cstring>
#include <iostream>
#include <signal.h>
#include <unistd.h>
#include <rak/error_number.h>
#include <torrent/exceptions.h>
@@ -201,10 +202,15 @@ ThreadBase::queue_item(thread_base_func newFunc) {
void
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())
return;
pthread_kill(main_thread->m_thread, SIGUSR1);
} while (1);
usleep(sleep_length);
sleep_length = std::min(sleep_length + 50, 1000);
}
}