mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-17 07:32:32 +00:00
* Created ThreadBase holding poll manager, etc, and added a this_thread global object.
* Cleaned up main initialization, SCGI and polling code. * Fixed a bug that would cause reading of a piece to hang if the incoming data contains only data up to the file boundary, but not the next file's data. The bug did not trigger if the file boundary and piece boundaries were the same. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1101 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -39,7 +39,13 @@
|
||||
#include <stdexcept>
|
||||
#include <rak/error_number.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "control.h"
|
||||
#include "manager.h"
|
||||
#include "poll_manager.h"
|
||||
#include "poll_manager_epoll.h"
|
||||
#include "poll_manager_kqueue.h"
|
||||
#include "poll_manager_select.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
@@ -54,6 +60,45 @@ PollManager::~PollManager() {
|
||||
delete m_poll;
|
||||
}
|
||||
|
||||
PollManager*
|
||||
PollManager::create_poll_manager() {
|
||||
PollManager* pollManager = NULL;
|
||||
Log* log = &control->core()->get_log_important();
|
||||
|
||||
const char* poll = getenv("RTORRENT_POLL");
|
||||
|
||||
int maxOpen = sysconf(_SC_OPEN_MAX);
|
||||
|
||||
if (poll != NULL) {
|
||||
if (!strcmp(poll, "epoll"))
|
||||
pollManager = PollManagerEPoll::create(maxOpen);
|
||||
else if (!strcmp(poll, "kqueue"))
|
||||
pollManager = PollManagerKQueue::create(maxOpen);
|
||||
else if (!strcmp(poll, "select"))
|
||||
pollManager = PollManagerSelect::create(maxOpen);
|
||||
|
||||
if (pollManager == NULL)
|
||||
log->push_front(std::string("Cannot enable '") + poll + "' based polling.");
|
||||
}
|
||||
|
||||
if (pollManager != NULL)
|
||||
log->push_front(std::string("Using '") + poll + "' based polling.");
|
||||
|
||||
else if ((pollManager = PollManagerEPoll::create(maxOpen)) != NULL)
|
||||
log->push_front("Using 'epoll' based polling.");
|
||||
|
||||
else if ((pollManager = PollManagerKQueue::create(maxOpen)) != NULL)
|
||||
log->push_front("Using 'kqueue' based polling.");
|
||||
|
||||
else if ((pollManager = PollManagerSelect::create(maxOpen)) != NULL)
|
||||
log->push_front("Using 'select' based polling.");
|
||||
|
||||
else
|
||||
throw std::runtime_error("Could not create any PollManager.");
|
||||
|
||||
return pollManager;
|
||||
}
|
||||
|
||||
void
|
||||
PollManager::check_error() {
|
||||
if (rak::error_number::current().value() != rak::error_number::e_intr)
|
||||
|
||||
Reference in New Issue
Block a user