From 91f4f022a9db49cc9aa09c7729853193982a7dec Mon Sep 17 00:00:00 2001 From: rakshasa Date: Tue, 26 Jul 2005 16:38:15 +0000 Subject: [PATCH] * 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 --- configure.ac | 1 - scripts/checks.m4 | 6 +-- src/core/Makefile.am | 4 +- src/core/poll.cc | 18 ++++++-- src/core/poll.h | 4 +- src/core/poll_epoll.cc | 96 ------------------------------------------ src/core/poll_epoll.h | 77 --------------------------------- 7 files changed, 21 insertions(+), 185 deletions(-) delete mode 100644 src/core/poll_epoll.cc delete mode 100644 src/core/poll_epoll.h diff --git a/configure.ac b/configure.ac index ed685d3a..8a39e264 100644 --- a/configure.ac +++ b/configure.ac @@ -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, diff --git a/scripts/checks.m4 b/scripts/checks.m4 index c750bf78..c4646945 100644 --- a/scripts/checks.m4 +++ b/scripts/checks.m4 @@ -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) diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 69db491d..6c17eefa 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -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) diff --git a/src/core/poll.cc b/src/core/poll.cc index bb5cac21..f8c8dfb5 100644 --- a/src/core/poll.cc +++ b/src/core/poll.cc @@ -44,6 +44,7 @@ #include #include #include +#include #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 diff --git a/src/core/poll.h b/src/core/poll.h index 48444070..489066fa 100644 --- a/src/core/poll.h +++ b/src/core/poll.h @@ -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; }; } diff --git a/src/core/poll_epoll.cc b/src/core/poll_epoll.cc deleted file mode 100644 index d2ff5168..00000000 --- a/src/core/poll_epoll.cc +++ /dev/null @@ -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 -// -// 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) { -} - -} diff --git a/src/core/poll_epoll.h b/src/core/poll_epoll.h deleted file mode 100644 index 7ef062eb..00000000 --- a/src/core/poll_epoll.h +++ /dev/null @@ -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 -// -// Skomakerveien 33 -// 3185 Skoppum, NORWAY - -#ifndef RTORRENT_CORE_POLL_EPOLL_H -#define RTORRENT_CORE_POLL_EPOLL_H - -#include - -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