mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 06:02:31 +00:00
* Changed the API to support different Poll objects and made
PollSelect available. Started work on PollEPoll. * Fixed a bug that caused blank characters to be inserted into the tracker request url. * Added display of the options field in the peer info view. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@508 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -23,7 +23,8 @@ libsub_core_a_SOURCES = \
|
||||
manager.cc \
|
||||
manager.h \
|
||||
poll.cc \
|
||||
poll.h
|
||||
|
||||
poll.h \
|
||||
poll_epoll.cc \
|
||||
poll_epoll.h
|
||||
|
||||
INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
|
||||
@@ -64,6 +64,16 @@ connect_signal_tracker_log(Download* d, torrent::Download::SlotString s) {
|
||||
d->get_download().signal_tracker_failed(s);
|
||||
}
|
||||
|
||||
Manager::Manager() :
|
||||
m_portRandom(false),
|
||||
m_portFirst(6890),
|
||||
m_portLast(6999),
|
||||
m_checkHash(true) {
|
||||
}
|
||||
|
||||
Manager::~Manager() {
|
||||
}
|
||||
|
||||
void
|
||||
Manager::initialize() {
|
||||
torrent::Http::set_factory(m_poll.get_http_factory());
|
||||
|
||||
+2
-1
@@ -58,7 +58,8 @@ public:
|
||||
typedef sigc::slot1<void, DownloadList::iterator> SlotReady;
|
||||
typedef sigc::slot0<void> SlotFailed;
|
||||
|
||||
Manager() : m_portRandom(false), m_portFirst(6890), m_portLast(6999), m_checkHash(true) {}
|
||||
Manager();
|
||||
~Manager();
|
||||
|
||||
DownloadList& get_download_list() { return m_downloadList; }
|
||||
DownloadStore& get_download_store() { return m_downloadStore; }
|
||||
|
||||
+20
-2
@@ -43,12 +43,28 @@
|
||||
#include <ncurses.h>
|
||||
#include <sigc++/bind.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/poll_select.h>
|
||||
|
||||
#include "poll.h"
|
||||
#include "curl_get.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
Poll::Poll() :
|
||||
m_readSet(new fd_set),
|
||||
m_writeSet(new fd_set),
|
||||
m_exceptSet(new fd_set),
|
||||
m_torrentPoll(new torrent::PollSelect)
|
||||
{
|
||||
}
|
||||
|
||||
Poll::~Poll() {
|
||||
delete m_readSet;
|
||||
delete m_writeSet;
|
||||
delete m_exceptSet;
|
||||
delete m_torrentPoll;
|
||||
}
|
||||
|
||||
void
|
||||
Poll::poll(utils::Timer timeout) {
|
||||
// Do we want to clear m_maxFd in torrent::mark?
|
||||
@@ -60,7 +76,7 @@ Poll::poll(utils::Timer timeout) {
|
||||
|
||||
FD_SET(0, m_readSet);
|
||||
|
||||
torrent::mark(m_readSet, m_writeSet, m_exceptSet, &m_maxFd);
|
||||
m_maxFd = m_torrentPoll->mark(m_readSet, m_writeSet, m_exceptSet);
|
||||
|
||||
if (m_curlStack.is_busy()) {
|
||||
int n = 0;
|
||||
@@ -96,7 +112,9 @@ Poll::work() {
|
||||
if (m_curlStack.is_busy())
|
||||
m_curlStack.perform();
|
||||
|
||||
torrent::work(m_readSet, m_writeSet, m_exceptSet, m_maxFd);
|
||||
torrent::perform();
|
||||
m_torrentPoll->work(m_readSet, m_writeSet, m_exceptSet);
|
||||
torrent::perform();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+21
-15
@@ -43,6 +43,10 @@
|
||||
#include "utils/timer.h"
|
||||
#include "curl_stack.h"
|
||||
|
||||
namespace torrent {
|
||||
class PollSelect;
|
||||
}
|
||||
|
||||
namespace core {
|
||||
|
||||
class CurlGet;
|
||||
@@ -53,32 +57,34 @@ public:
|
||||
typedef sigc::slot1<void, int> SlotInt;
|
||||
typedef sigc::slot0<CurlGet*> SlotFactory;
|
||||
|
||||
Poll() : m_readSet(new fd_set), m_writeSet(new fd_set), m_exceptSet(new fd_set) {}
|
||||
~Poll() { delete m_readSet; delete m_writeSet; delete m_exceptSet; }
|
||||
Poll();
|
||||
~Poll();
|
||||
|
||||
void poll(utils::Timer t);
|
||||
void poll(utils::Timer t);
|
||||
|
||||
SlotFactory get_http_factory();
|
||||
SlotFactory get_http_factory();
|
||||
torrent::Poll* get_torrent_poll() { return reinterpret_cast<torrent::Poll*>(m_torrentPoll); }
|
||||
|
||||
void slot_read_stdin(SlotInt s) { m_slotReadStdin = s; }
|
||||
void slot_select_interrupted(Slot s) { m_slotSelectInterrupted = s; }
|
||||
void slot_read_stdin(SlotInt s) { m_slotReadStdin = s; }
|
||||
void slot_select_interrupted(Slot s) { m_slotSelectInterrupted = s; }
|
||||
|
||||
private:
|
||||
Poll(const Poll&);
|
||||
void operator = (const Poll&);
|
||||
|
||||
void work();
|
||||
void work_input();
|
||||
void work();
|
||||
void work_input();
|
||||
|
||||
SlotInt m_slotReadStdin;
|
||||
Slot m_slotSelectInterrupted;
|
||||
SlotInt m_slotReadStdin;
|
||||
Slot m_slotSelectInterrupted;
|
||||
|
||||
int m_maxFd;
|
||||
fd_set* m_readSet;
|
||||
fd_set* m_writeSet;
|
||||
fd_set* m_exceptSet;
|
||||
int m_maxFd;
|
||||
fd_set* m_readSet;
|
||||
fd_set* m_writeSet;
|
||||
fd_set* m_exceptSet;
|
||||
|
||||
CurlStack m_curlStack;
|
||||
CurlStack m_curlStack;
|
||||
torrent::PollSelect* m_torrentPoll;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "poll_epoll.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
PollEPoll::PollEPoll() {
|
||||
}
|
||||
|
||||
PollEPoll::~PollEPoll() {
|
||||
}
|
||||
|
||||
void
|
||||
PollEPoll::open(torrent::Event* event) {
|
||||
}
|
||||
|
||||
void
|
||||
PollEPoll::close(torrent::Event* event) {
|
||||
}
|
||||
|
||||
bool
|
||||
PollEPoll::in_read(torrent::Event* event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
PollEPoll::in_write(torrent::Event* event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
PollEPoll::in_error(torrent::Event* event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
PollEPoll::insert_read(torrent::Event* event) {
|
||||
}
|
||||
|
||||
void
|
||||
PollEPoll::insert_write(torrent::Event* event) {
|
||||
}
|
||||
|
||||
void
|
||||
PollEPoll::insert_error(torrent::Event* event) {
|
||||
}
|
||||
|
||||
void
|
||||
PollEPoll::remove_read(torrent::Event* event) {
|
||||
}
|
||||
|
||||
void
|
||||
PollEPoll::remove_write(torrent::Event* event) {
|
||||
}
|
||||
|
||||
void
|
||||
PollEPoll::remove_error(torrent::Event* event) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#ifndef RTORRENT_CORE_POLL_EPOLL_H
|
||||
#define RTORRENT_CORE_POLL_EPOLL_H
|
||||
|
||||
#include <torrent/poll.h>
|
||||
|
||||
namespace core {
|
||||
|
||||
class PollEPoll : public torrent::Poll {
|
||||
PollEPoll();
|
||||
virtual ~PollEPoll();
|
||||
|
||||
// Add configuration options for doing stuff like setting max open
|
||||
// sockets etc?
|
||||
|
||||
// torrent::Event::get_fd() is guaranteed to be valid and remain constant
|
||||
// from open(...) is called to close(...) returns.
|
||||
virtual void open(torrent::Event* event);
|
||||
virtual void close(torrent::Event* event);
|
||||
|
||||
// Functions for checking whetever the torrent::Event is listening to r/w/e?
|
||||
virtual bool in_read(torrent::Event* event);
|
||||
virtual bool in_write(torrent::Event* event);
|
||||
virtual bool in_error(torrent::Event* event);
|
||||
|
||||
// These functions may be called on 'event's that might, or might
|
||||
// not, already be in the set.
|
||||
virtual void insert_read(torrent::Event* event);
|
||||
virtual void insert_write(torrent::Event* event);
|
||||
virtual void insert_error(torrent::Event* event);
|
||||
|
||||
virtual void remove_read(torrent::Event* event);
|
||||
virtual void remove_write(torrent::Event* event);
|
||||
virtual void remove_error(torrent::Event* event);
|
||||
|
||||
private:
|
||||
int m_fd;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user