* Finished implementing epoll support in the library. The client side

is abit hacky and normal select based polling is temporarily disabled.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@509 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-07-26 16:38:15 +00:00
parent 424a20b3f5
commit 91f4f022a9
7 changed files with 21 additions and 185 deletions
-1
View File
@@ -18,7 +18,6 @@ AC_SEARCH_LIBS(wbkgdset, ncurses curses,,echo "*** The ncurses library is requir
TORRENT_CHECK_EXECINFO()
TORRENT_CHECK_CURL()
TORRENT_WITHOUT_EPOLL()
TORRENT_OTFD()
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.7.1,
+3 -3
View File
@@ -75,7 +75,7 @@ AC_DEFUN([TORRENT_CHECK_XFS], [
}
]],
[
AC_DEFINE(HAS_XFS, 1, XFS filesystem supported.)
AC_DEFINE(USE_XFS, 1, Use XFS filesystem stuff.)
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
@@ -107,7 +107,7 @@ AC_DEFUN([TORRENT_CHECK_EPOLL], [
}
]],
[
AC_DEFINE(HAS_EPOLL, 1, epoll supported.)
AC_DEFINE(USE_EPOLL, 1, Use epoll.)
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
@@ -139,7 +139,7 @@ AC_DEFUN([TORRENT_CHECK_POSIX_FALLOCATE], [
}
]],
[
AC_DEFINE(HAS_POSIX_FALLOCATE, 1, posix_fallocate supported.)
AC_DEFINE(USE_POSIX_FALLOCATE, 1, posix_fallocate supported.)
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
+1 -3
View File
@@ -23,8 +23,6 @@ libsub_core_a_SOURCES = \
manager.cc \
manager.h \
poll.cc \
poll.h \
poll_epoll.cc \
poll_epoll.h
poll.h
INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
+14 -4
View File
@@ -44,6 +44,7 @@
#include <sigc++/bind.h>
#include <torrent/torrent.h>
#include <torrent/poll_select.h>
#include <torrent/poll_epoll.h>
#include "poll.h"
#include "curl_get.h"
@@ -54,8 +55,11 @@ Poll::Poll() :
m_readSet(new fd_set),
m_writeSet(new fd_set),
m_exceptSet(new fd_set),
m_torrentPoll(new torrent::PollSelect)
// m_torrentPoll(new torrent::PollSelect)
m_torrentPoll(torrent::PollEPoll::create())
{
if (m_torrentPoll == NULL)
throw std::runtime_error("Could not initialize torrent::PollEPoll");
}
Poll::~Poll() {
@@ -76,7 +80,9 @@ Poll::poll(utils::Timer timeout) {
FD_SET(0, m_readSet);
m_maxFd = m_torrentPoll->mark(m_readSet, m_writeSet, m_exceptSet);
FD_SET(m_torrentPoll->get_fd(), m_readSet);
m_maxFd = m_torrentPoll->get_fd();
// m_maxFd = m_torrentPoll->mark(m_readSet, m_writeSet, m_exceptSet);
if (m_curlStack.is_busy()) {
int n = 0;
@@ -113,8 +119,12 @@ Poll::work() {
m_curlStack.perform();
torrent::perform();
m_torrentPoll->work(m_readSet, m_writeSet, m_exceptSet);
torrent::perform();
if (FD_ISSET(m_torrentPoll->get_fd(), m_readSet)) {
// m_torrentPoll->work(m_readSet, m_writeSet, m_exceptSet);
m_torrentPoll->wait(0);
m_torrentPoll->work();
torrent::perform();
}
}
void
+3 -1
View File
@@ -45,6 +45,7 @@
namespace torrent {
class PollSelect;
class PollEPoll;
}
namespace core {
@@ -84,7 +85,8 @@ private:
fd_set* m_exceptSet;
CurlStack m_curlStack;
torrent::PollSelect* m_torrentPoll;
// torrent::PollSelect* m_torrentPoll;
torrent::PollEPoll* m_torrentPoll;
};
}
-96
View File
@@ -1,96 +0,0 @@
// 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) {
}
}
-77
View File
@@ -1,77 +0,0 @@
// 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