mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-15 13:46:17 +00:00
* More fiddling of the throttle code.
* Fixed a bug that caused idle looping due to epoll_wait timeout using msecs rather than usecs resolution. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@590 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -53,7 +53,7 @@ void
|
|||||||
DownloadStore::use(const std::string& path) {
|
DownloadStore::use(const std::string& path) {
|
||||||
m_path = path;
|
m_path = path;
|
||||||
|
|
||||||
if (*m_path.rbegin() != '/')
|
if (!m_path.empty() && *m_path.rbegin() != '/')
|
||||||
m_path += '/';
|
m_path += '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ PollManagerEPoll::~PollManagerEPoll() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
PollManagerEPoll::poll(utils::Timer timeout) {
|
PollManagerEPoll::poll(utils::Timer timeout) {
|
||||||
|
// Add 1ms to ensure we don't idle loop due to the lack of
|
||||||
|
// resolution.
|
||||||
|
torrent::perform();
|
||||||
timeout = std::min(timeout, utils::Timer(torrent::get_next_timeout()));
|
timeout = std::min(timeout, utils::Timer(torrent::get_next_timeout()));
|
||||||
|
|
||||||
if (m_httpStack.is_busy()) {
|
if (m_httpStack.is_busy()) {
|
||||||
@@ -101,13 +104,12 @@ PollManagerEPoll::poll(utils::Timer timeout) {
|
|||||||
|
|
||||||
// Yes, below is how much code really *should* have been in this
|
// Yes, below is how much code really *should* have been in this
|
||||||
// function. ;)
|
// function. ;)
|
||||||
torrent::perform();
|
|
||||||
|
|
||||||
if (static_cast<torrent::PollEPoll*>(m_poll)->poll(timeout.usec() / 1000) == -1)
|
if (static_cast<torrent::PollEPoll*>(m_poll)->poll((timeout.usec() + 999) / 1000) == -1)
|
||||||
return check_error();
|
return check_error();
|
||||||
|
|
||||||
static_cast<torrent::PollEPoll*>(m_poll)->perform();
|
|
||||||
torrent::perform();
|
torrent::perform();
|
||||||
|
static_cast<torrent::PollEPoll*>(m_poll)->perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ PollManagerSelect::~PollManagerSelect() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
PollManagerSelect::poll(utils::Timer timeout) {
|
PollManagerSelect::poll(utils::Timer timeout) {
|
||||||
|
torrent::perform();
|
||||||
timeout = std::min(timeout, utils::Timer(torrent::get_next_timeout()));
|
timeout = std::min(timeout, utils::Timer(torrent::get_next_timeout()));
|
||||||
|
|
||||||
#if defined USE_VARIABLE_FDSET
|
#if defined USE_VARIABLE_FDSET
|
||||||
@@ -89,7 +90,6 @@ PollManagerSelect::poll(utils::Timer timeout) {
|
|||||||
|
|
||||||
torrent::perform();
|
torrent::perform();
|
||||||
static_cast<torrent::PollSelect*>(m_poll)->perform(m_readSet, m_writeSet, m_errorSet);
|
static_cast<torrent::PollSelect*>(m_poll)->perform(m_readSet, m_writeSet, m_errorSet);
|
||||||
torrent::perform();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,8 @@
|
|||||||
#include "canvas.h"
|
#include "canvas.h"
|
||||||
#include "window_statusbar.h"
|
#include "window_statusbar.h"
|
||||||
|
|
||||||
|
extern uint32_t countTicks;
|
||||||
|
|
||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
WindowStatusbar::WindowStatusbar(core::Manager* c) :
|
WindowStatusbar::WindowStatusbar(core::Manager* c) :
|
||||||
@@ -80,7 +82,9 @@ WindowStatusbar::redraw() {
|
|||||||
(int)torrent::get_listen_port(),
|
(int)torrent::get_listen_port(),
|
||||||
!torrent::get_bind_address().empty() ? (" Bind: " + torrent::get_bind_address()).c_str() : "");
|
!torrent::get_bind_address().empty() ? (" Bind: " + torrent::get_bind_address()).c_str() : "");
|
||||||
|
|
||||||
pos = snprintf(buf, 128, "[U %i/%i][S %i/%i/%i][F %i/%i]",
|
// pos = snprintf(buf, 128, "[U %i/%i][S %i/%i/%i][F %i/%i]",
|
||||||
|
pos = snprintf(buf, 128, "%i [U %i/%i][S %i/%i/%i][F %i/%i]",
|
||||||
|
countTicks,
|
||||||
torrent::currently_unchoked(),
|
torrent::currently_unchoked(),
|
||||||
torrent::max_unchoked(),
|
torrent::max_unchoked(),
|
||||||
torrent::get_total_handshakes(),
|
torrent::get_total_handshakes(),
|
||||||
@@ -89,6 +93,8 @@ WindowStatusbar::redraw() {
|
|||||||
torrent::get_open_files(),
|
torrent::get_open_files(),
|
||||||
torrent::get_max_open_files());
|
torrent::get_max_open_files());
|
||||||
|
|
||||||
|
countTicks = 0;
|
||||||
|
|
||||||
m_canvas->print(m_canvas->get_width() - pos, 0, "%s", buf);
|
m_canvas->print(m_canvas->get_width() - pos, 0, "%s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ InputEvent::remove(torrent::Poll* p) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
InputEvent::event_read() {
|
InputEvent::event_read() {
|
||||||
int c = getch();
|
int c;
|
||||||
|
|
||||||
if (c != ERR)
|
while ((c = getch()) != ERR)
|
||||||
m_slotPressed(c);
|
m_slotPressed(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,8 @@
|
|||||||
|
|
||||||
int64_t utils::Timer::m_cache;
|
int64_t utils::Timer::m_cache;
|
||||||
|
|
||||||
|
uint32_t countTicks = 0;
|
||||||
|
|
||||||
void do_panic(int signum);
|
void do_panic(int signum);
|
||||||
void print_help();
|
void print_help();
|
||||||
|
|
||||||
@@ -226,6 +228,8 @@ main(int argc, char** argv) {
|
|||||||
uiControl.display()->adjust_layout();
|
uiControl.display()->adjust_layout();
|
||||||
|
|
||||||
while (!uiControl.is_shutdown_completed()) {
|
while (!uiControl.is_shutdown_completed()) {
|
||||||
|
countTicks++;
|
||||||
|
|
||||||
utils::Timer::update();
|
utils::Timer::update();
|
||||||
utils::taskScheduler.execute(utils::Timer::cache());
|
utils::taskScheduler.execute(utils::Timer::cache());
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ TaskScheduler::erase(TaskItem* task) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
TaskScheduler::execute(Timer time) {
|
TaskScheduler::execute(Timer time) {
|
||||||
m_entry = std::find_if(begin(), end(), rak::less_equal(time, rak::mem_ptr_ref(&value_type::first)));
|
m_entry = std::find_if(begin(), end(), rak::less(time, rak::mem_ptr_ref(&value_type::first)));
|
||||||
|
|
||||||
// Since we are always using the front rather than a splice of the
|
// Since we are always using the front rather than a splice of the
|
||||||
// due tasks, it is safe to erase them from within other tasks.
|
// due tasks, it is safe to erase them from within other tasks.
|
||||||
|
|||||||
Reference in New Issue
Block a user