* 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:
rakshasa
2005-07-25 15:28:03 +00:00
parent a3521e974d
commit 424a20b3f5
12 changed files with 357 additions and 39 deletions
+1
View File
@@ -18,6 +18,7 @@ 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,
+105 -9
View File
@@ -18,8 +18,8 @@ AC_DEFUN([TORRENT_CHECK_CURL], [
my_cv_curl_vers="$ver"
AC_MSG_RESULT([$my_cv_curl_vers])
CURL_CFLAGS="`curl-config --cflags`"
CURL_LIBS="`curl-config --libs`"
CURL_CFLAGS=`curl-config --cflags`
CURL_LIBS=`curl-config --libs`
else
AC_MSG_RESULT(FAILED)
AC_MSG_ERROR([$ver is too old. Need version $check or higher.])
@@ -36,13 +36,13 @@ AC_DEFUN([TORRENT_CHECK_OPENSSL], [
# first, deal with the user option : set places to be 'search' or the prefix
AC_ARG_WITH(openssl,
[ --with-openssl=PATH Find the OpenSSL header and library in
`PATH/include' and `PATH/lib'. If PATH is of the
form `HEADER:LIB', then search for header files in
HEADER, and the library in LIB. If you omit the
option completely, the configure script will
search for OpenSSL in a number of standard
places.
], [
`PATH/include' and `PATH/lib'. If PATH is of the
form `HEADER:LIB', then search for header files in
HEADER, and the library in LIB. If you omit the
option completely, the configure script will
search for OpenSSL in a number of standard
places.],
[
if test "$withval" = "yes"; then
PKG_CHECK_MODULES(OPENSSL, openssl,
CXXFLAGS="$CXXFLAGS `pkg-config --cflags openssl`";
@@ -60,3 +60,99 @@ AC_DEFUN([TORRENT_CHECK_OPENSSL], [
AC_MSG_ERROR(Could not find openssl's crypto library, try --with-openssl=PATH))
])
])
AC_DEFUN([TORRENT_CHECK_XFS], [
AC_MSG_CHECKING(for XFS support)
AC_COMPILE_IFELSE(
[[#include <xfs/libxfs.h>
#include <sys/ioctl.h>
int main() {
struct xfs_flock64 l;
ioctl(0, XFS_IOC_RESVSP64, &l);
return 0;
}
]],
[
AC_DEFINE(HAS_XFS, 1, XFS filesystem supported.)
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
])
])
AC_DEFUN([TORRENT_WITHOUT_XFS], [
AC_ARG_WITH(xfs,
[ --without-xfs Do not check for XFS filesystem support],
[
if test "$withval" = "yes"; then
TORRENT_CHECK_XFS
fi
], [
TORRENT_CHECK_XFS
])
])
AC_DEFUN([TORRENT_CHECK_EPOLL], [
AC_MSG_CHECKING(for epoll support)
AC_COMPILE_IFELSE(
[[#include <sys/epoll.h>
int main() {
int fd = epoll_create(100);
return 0;
}
]],
[
AC_DEFINE(HAS_EPOLL, 1, epoll supported.)
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
])
])
AC_DEFUN([TORRENT_WITHOUT_EPOLL], [
AC_ARG_WITH(epoll,
[ --without-epoll Do not check for epoll support],
[
if test "$withval" = "yes"; then
TORRENT_CHECK_EPOLL
fi
], [
TORRENT_CHECK_EPOLL
])
])
AC_DEFUN([TORRENT_CHECK_POSIX_FALLOCATE], [
AC_MSG_CHECKING(for posix_fallocate)
AC_COMPILE_IFELSE(
[[#include <fcntl.h>
int main() {
posix_fallocate(0, 0, 0);
return 0;
}
]],
[
AC_DEFINE(HAS_POSIX_FALLOCATE, 1, posix_fallocate supported.)
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
])
])
AC_DEFUN([TORRENT_WITH_POSIX_FALLOCATE], [
AC_ARG_WITH(posix-fallocate,
[ --with-fallocate Check for posix_fallocate],
[
if test "$withval" = "no"; then
TORRENT_CHECK_POSIX_FALLOCATE
fi
])
])
+19 -8
View File
@@ -2,17 +2,16 @@ AC_DEFUN([TORRENT_CHECK_CXXFLAGS], [
AC_MSG_CHECKING([for user-defined CXXFLAGS])
if test !$CXXFLAGS; then
if test $CXXFLAGS; then
AC_MSG_RESULT([user-defined "$CXXFLAGS"])
else
CXXFLAGS="-O3 -Wall"
AC_MSG_RESULT([default "$CXXFLAGS"])
else
AC_MSG_RESULT([user-defined "$CXXFLAGS"])
fi
])
AC_DEFUN([TORRENT_ENABLE_DEBUG], [
AC_ARG_ENABLE(debug,
[ --enable-debug enable debug information [default=yes]],
[
@@ -28,7 +27,6 @@ AC_DEFUN([TORRENT_ENABLE_DEBUG], [
AC_DEFUN([TORRENT_ENABLE_WERROR], [
AC_ARG_ENABLE(werror,
[ --enable-werror enable the -Werror flag [default=no]],
[
@@ -39,8 +37,23 @@ AC_DEFUN([TORRENT_ENABLE_WERROR], [
])
AC_DEFUN([TORRENT_OTFD], [
AC_DEFUN([TORRENT_ENABLE_UNSAFE_OPTIMIZATION], [
AC_ARG_ENABLE(unsafe-optimization,
[ --enable-unsafe-optimization
enable unsafe optimization [default=yes]],
[
if test "$enableval" = "yes"; then
AC_DEFINE(USE_UNSAFE_OPTIMIZATION, 1, Enable possibly unsafe optimization techniques.)
else
AC_DEFINE(USE_UNSAFE_OPTIMIZATION, 0, Disable possibly unsafe optimization techniques.)
fi
],[
AC_DEFINE(USE_UNSAFE_OPTIMIZATION, 0, Disable possibly unsafe optimization techniques.)
])
])
AC_DEFUN([TORRENT_OTFD], [
AC_LANG_PUSH(C++)
AC_MSG_CHECKING(for proper overloaded template function disambiguation)
@@ -61,7 +74,6 @@ AC_DEFUN([TORRENT_OTFD], [
AC_DEFUN([TORRENT_MINCORE_SIGNEDNESS], [
AC_LANG_PUSH(C++)
AC_MSG_CHECKING(signedness of mincore parameter)
@@ -93,7 +105,6 @@ AC_DEFUN([TORRENT_MINCORE_SIGNEDNESS], [
])
AC_DEFUN([TORRENT_CHECK_EXECINFO], [
AC_MSG_CHECKING(for execinfo.h)
AC_COMPILE_IFELSE(
+3 -2
View File
@@ -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)
+10
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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;
};
}
+96
View File
@@ -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) {
}
}
+77
View File
@@ -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
+1
View File
@@ -84,6 +84,7 @@ WindowPeerInfo::redraw() {
m_canvas->print(0, y++, "DNS: %s:%hu", (*m_focus)->get_dns().c_str(), (*m_focus)->get_port());
m_canvas->print(0, y++, "Id: %s" , utils::escape_string((*m_focus)->get_id()).c_str());
m_canvas->print(0, y++, "Options: %s" , utils::string_to_hex(std::string((*m_focus)->get_options(), 8)).c_str());
m_canvas->print(0, y++, "Snubbed: %s", (*m_focus)->get_snubbed() ? "Yes" : "No");
m_canvas->print(0, y++, "Done: %i%", done_percentage(**m_focus));
+2 -2
View File
@@ -223,7 +223,7 @@ main(int argc, char** argv) {
SignalHandler::set_handler(SIGFPE, sigc::bind(sigc::ptr_fun(&do_panic), SIGFPE));
// Need to initialize this before parseing options.
torrent::initialize();
torrent::initialize(uiControl.get_core().get_poll().get_torrent_poll());
if (getenv("HOME"))
load_option_file(getenv("HOME") + std::string("/.rtorrent.rc"), &optionHandler);
@@ -323,7 +323,7 @@ receive_tracker_dump(std::istream* s) {
void
print_help() {
std::cout << "Rakshasa's BitTorrent client " VERSION "." << std::endl;
std::cout << "Rakshasa's BitTorrent client version " VERSION "." << std::endl;
std::cout << std::endl;
std::cout << "All value pairs (f.ex rate and queue size) will be in the UP/DOWN" << std::endl;
std::cout << "order. Use the up/down/left/right arrow keys to move between screens." << std::endl;