* Cleaned up socket read/write error handling.

* Fixed a bug where PeerConnectionSeed was reading the wrong type of
message.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@554 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-09-05 18:50:48 +00:00
parent 3bd99aee50
commit 8732e457fa
6 changed files with 109 additions and 42 deletions
+1
View File
@@ -5,6 +5,7 @@ SUBDIRS = \
EXTRA_DIST= \
autogen.sh \
rak/algorithm.h \
rak/error_number.h \
rak/functional.h \
scripts/checks.m4 \
scripts/common.m4
+2 -2
View File
@@ -1,4 +1,4 @@
AC_INIT(rtorrent, 0.3.3, jaris@ifi.uio.no)
AC_INIT(rtorrent, 0.3.4, jaris@ifi.uio.no)
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)
@@ -22,7 +22,7 @@ TORRENT_OTFD()
TORRENT_WITHOUT_VARIABLE_FDSET()
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.7.3,
PKG_CHECK_MODULES(STUFF, sigc++-2.0 libtorrent >= 0.7.4,
CXXFLAGS="$CXXFLAGS $STUFF_CFLAGS $CURL_CFLAGS";
LIBS="$LIBS $STUFF_LIBS $CURL_LIBS")
+3 -3
View File
@@ -1,4 +1,4 @@
// rTorrent - BitTorrent client
// rak - Rakshasa's toolbox
// Copyright (C) 2005, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
@@ -34,8 +34,8 @@
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#ifndef RTORRENT_UTILS_ALGORITHM_H
#define RTORRENT_UTILS_ALGORITHM_H
#ifndef RAK_ALGORITHM_H
#define RAK_ALGORITHM_H
#include <algorithm>
+66
View File
@@ -0,0 +1,66 @@
// rak - Rakshasa's toolbox
// 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 RAK_ERROR_NUMBER_H
#define RAK_ERROR_NUMBER_H
#include <cerrno>
#include <cstring>
namespace rak {
class error_number {
public:
error_number() : m_errno(0) {}
error_number(int e) : m_errno(e) {}
int value() const { return m_errno; }
const char* c_str() const { return strerror(m_errno); }
bool is_blocked_momentary() const { return m_errno == EAGAIN || m_errno == EINTR; }
bool is_blocked_prolonged() const { return m_errno == EDEADLK; }
bool is_closed() const { return m_errno == ECONNRESET || m_errno == ECONNABORTED; }
static error_number current() { return errno; }
private:
int m_errno;
};
}
#endif
+35 -35
View File
@@ -1,4 +1,4 @@
// rTorrent - BitTorrent client
// rak - Rakshasa's toolbox
// Copyright (C) 2005, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
@@ -34,8 +34,8 @@
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#ifndef RTORRENT_UTILS_FUNCTIONAL_H
#define RTORRENT_UTILS_FUNCTIONAL_H
#ifndef RAK_FUNCTIONAL_H
#define RAK_FUNCTIONAL_H
#include <functional>
@@ -52,8 +52,8 @@ struct reference_fix<Type&> {
};
template <typename Type, typename Ftor>
struct _accumulate {
_accumulate(Type& t, Ftor f) : m_t(t), m_f(f) {}
struct accumulate_t {
accumulate_t(Type& t, Ftor f) : m_t(t), m_f(f) {}
template <typename Arg>
void operator () (Arg& a) { m_t += m_f(a); }
@@ -63,18 +63,18 @@ struct _accumulate {
};
template <typename Type, typename Ftor>
inline _accumulate<Type, Ftor>
inline accumulate_t<Type, Ftor>
accumulate(Type& t, Ftor f) {
return _accumulate<Type, Ftor>(t, f);
return accumulate_t<Type, Ftor>(t, f);
}
// Operators:
template <typename Type, typename Ftor>
struct _equal {
struct equal_t {
typedef bool result_type;
_equal(Type t, Ftor f) : m_t(t), m_f(f) {}
equal_t(Type t, Ftor f) : m_t(t), m_f(f) {}
template <typename Arg>
bool operator () (Arg& a) {
@@ -86,16 +86,16 @@ struct _equal {
};
template <typename Type, typename Ftor>
inline _equal<Type, Ftor>
inline equal_t<Type, Ftor>
equal(Type t, Ftor f) {
return _equal<Type, Ftor>(t, f);
return equal_t<Type, Ftor>(t, f);
}
template <typename Type, typename Ftor>
struct _less {
struct less_t {
typedef bool result_type;
_less(Type t, Ftor f) : m_t(t), m_f(f) {}
less_t(Type t, Ftor f) : m_t(t), m_f(f) {}
template <typename Arg>
bool operator () (Arg& a) {
@@ -107,9 +107,9 @@ struct _less {
};
template <typename Type, typename Ftor>
inline _less<Type, Ftor>
inline less_t<Type, Ftor>
less(Type t, Ftor f) {
return _less<Type, Ftor>(t, f);
return less_t<Type, Ftor>(t, f);
}
template <typename Type, typename Ftor>
@@ -134,10 +134,10 @@ greater(Type t, Ftor f) {
}
template <typename Type, typename Ftor>
struct _less_equal {
struct less_equal_t {
typedef bool result_type;
_less_equal(Type t, Ftor f) : m_t(t), m_f(f) {}
less_equal_t(Type t, Ftor f) : m_t(t), m_f(f) {}
template <typename Arg>
bool operator () (Arg& a) {
@@ -149,16 +149,16 @@ struct _less_equal {
};
template <typename Type, typename Ftor>
inline _less_equal<Type, Ftor>
inline less_equal_t<Type, Ftor>
less_equal(Type t, Ftor f) {
return _less_equal<Type, Ftor>(t, f);
return less_equal_t<Type, Ftor>(t, f);
}
template <typename Type, typename Ftor>
struct _greater_equal {
struct greater_equal_t {
typedef bool result_type;
_greater_equal(Type t, Ftor f) : m_t(t), m_f(f) {}
greater_equal_t(Type t, Ftor f) : m_t(t), m_f(f) {}
template <typename Arg>
bool operator () (Arg& a) {
@@ -170,16 +170,16 @@ struct _greater_equal {
};
template <typename Type, typename Ftor>
inline _greater_equal<Type, Ftor>
inline greater_equal_t<Type, Ftor>
greater_equal(Type t, Ftor f) {
return _greater_equal<Type, Ftor>(t, f);
return greater_equal_t<Type, Ftor>(t, f);
}
template <typename Src, typename Dest>
struct _on : public std::unary_function<typename Src::argument_type, typename Dest::result_type> {
struct on_t : public std::unary_function<typename Src::argument_type, typename Dest::result_type> {
typedef typename Dest::result_type result_type;
_on(Src s, Dest d) : m_dest(d), m_src(s) {}
on_t(Src s, Dest d) : m_dest(d), m_src(s) {}
result_type operator () (typename reference_fix<typename Src::argument_type>::type arg) {
return m_dest(m_src(arg));
@@ -190,15 +190,15 @@ struct _on : public std::unary_function<typename Src::argument_type, typename De
};
template <typename Src, typename Dest>
inline _on<Src, Dest>
inline on_t<Src, Dest>
on(Src s, Dest d) {
return _on<Src, Dest>(s, d);
return on_t<Src, Dest>(s, d);
}
// Creates a functor for accessing a member.
template <typename Class, typename Member>
struct _mem_ptr_ref : public std::unary_function<Class&, Member&> {
_mem_ptr_ref(Member Class::*m) : m_member(m) {}
struct mem_ptr_ref_t : public std::unary_function<Class&, Member&> {
mem_ptr_ref_t(Member Class::*m) : m_member(m) {}
Member& operator () (Class& c) {
return c.*m_member;
@@ -208,14 +208,14 @@ struct _mem_ptr_ref : public std::unary_function<Class&, Member&> {
};
template <typename Class, typename Member>
inline _mem_ptr_ref<Class, Member>
inline mem_ptr_ref_t<Class, Member>
mem_ptr_ref(Member Class::*m) {
return _mem_ptr_ref<Class, Member>(m);
return mem_ptr_ref_t<Class, Member>(m);
}
template <typename Cond, typename Then>
struct _if_then {
_if_then(Cond c, Then t) : m_cond(c), m_then(t) {}
struct if_then_t {
if_then_t(Cond c, Then t) : m_cond(c), m_then(t) {}
template <typename Arg>
void operator () (Arg& a) {
@@ -228,9 +228,9 @@ struct _if_then {
};
template <typename Cond, typename Then>
inline _if_then<Cond, Then>
inline if_then_t<Cond, Then>
if_then(Cond c, Then t) {
return _if_then<Cond, Then>(c, t);
return if_then_t<Cond, Then>(c, t);
}
template <typename T>
+2 -2
View File
@@ -66,8 +66,8 @@ OptionFile::parse_line(const char* line) {
opt[0] = '\0';
// Check for empty lines, and options within "abc".
if ((result = std::sscanf(line, "%64s = \"%512[^\"]s", key, opt)) != 2 &&
(result = std::sscanf(line, "%64s = %512s", key, opt)) != 2 &&
if ((result = std::sscanf(line, "%63s = \"%511[^\"]s", key, opt)) != 2 &&
(result = std::sscanf(line, "%63s = %511s", key, opt)) != 2 &&
result == 1)
throw std::runtime_error("Error parseing option file.");