improved sun studio support (it seems to lack a lot of stl)
This commit is contained in:
parent
f764227012
commit
1f5a722b01
|
@ -552,7 +552,7 @@ void add_torrent(libtorrent::session& ses
|
||||||
p.auto_managed = true;
|
p.auto_managed = true;
|
||||||
torrent_handle h = ses.add_torrent(p, ec);
|
torrent_handle h = ses.add_torrent(p, ec);
|
||||||
|
|
||||||
handles.insert(std::make_pair(
|
handles.insert(std::pair<const std::string, torrent_handle>(
|
||||||
monitored_dir?std::string(torrent):std::string(), h));
|
monitored_dir?std::string(torrent):std::string(), h));
|
||||||
|
|
||||||
h.set_max_connections(50);
|
h.set_max_connections(50);
|
||||||
|
@ -846,7 +846,7 @@ int main(int argc, char* argv[])
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
handles.insert(std::make_pair(std::string(), h));
|
handles.insert(std::pair<const std::string, torrent_handle>(std::string(), h));
|
||||||
|
|
||||||
h.set_max_connections(50);
|
h.set_max_connections(50);
|
||||||
h.set_max_uploads(-1);
|
h.set_max_uploads(-1);
|
||||||
|
@ -881,7 +881,7 @@ int main(int argc, char* argv[])
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
handles.insert(std::make_pair(std::string(), h));
|
handles.insert(std::pair<const std::string, torrent_handle>(std::string(), h));
|
||||||
|
|
||||||
h.set_max_connections(50);
|
h.set_max_connections(50);
|
||||||
h.set_max_uploads(-1);
|
h.set_max_uploads(-1);
|
||||||
|
|
|
@ -232,7 +232,7 @@ namespace libtorrent
|
||||||
else if (bits > m_size)
|
else if (bits > m_size)
|
||||||
{
|
{
|
||||||
unsigned char* tmp = (unsigned char*)std::malloc(bytes);
|
unsigned char* tmp = (unsigned char*)std::malloc(bytes);
|
||||||
std::memcpy(tmp, m_bytes, (std::min)((m_size + 7)/ 8, bytes));
|
std::memcpy(tmp, m_bytes, (std::min)(int(m_size + 7)/ 8, bytes));
|
||||||
m_bytes = tmp;
|
m_bytes = tmp;
|
||||||
m_own = true;
|
m_own = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,21 +50,43 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
|
||||||
|
|
||||||
#define TORRENT_DEPRECATED __attribute__ ((deprecated))
|
// ======= GCC =========
|
||||||
|
|
||||||
|
#if defined __GNUC__
|
||||||
|
|
||||||
|
# define TORRENT_DEPRECATED __attribute__ ((deprecated))
|
||||||
|
|
||||||
|
// GCC pre 4.0 did not have support for the visibility attribute
|
||||||
|
# if __GNUC__ >= 4
|
||||||
# if defined(TORRENT_BUILDING_SHARED) || defined(TORRENT_LINKING_SHARED)
|
# if defined(TORRENT_BUILDING_SHARED) || defined(TORRENT_LINKING_SHARED)
|
||||||
# define TORRENT_EXPORT __attribute__ ((visibility("default")))
|
# define TORRENT_EXPORT __attribute__ ((visibility("default")))
|
||||||
# else
|
# else
|
||||||
# define TORRENT_EXPORT
|
# define TORRENT_EXPORT
|
||||||
# endif
|
# endif
|
||||||
|
# else
|
||||||
#elif defined(__GNUC__)
|
|
||||||
|
|
||||||
# define TORRENT_EXPORT
|
# define TORRENT_EXPORT
|
||||||
|
# endif
|
||||||
|
|
||||||
#elif defined(BOOST_MSVC)
|
|
||||||
|
// ======= SUNPRO =========
|
||||||
|
|
||||||
|
#elif defined __SUNPRO_CC
|
||||||
|
|
||||||
|
# if __SUNPRO_CC >= 0x550
|
||||||
|
# if defined(TORRENT_BUILDING_SHARED) || defined(TORRENT_LINKING_SHARED)
|
||||||
|
# define TORRENT_EXPORT __global
|
||||||
|
# else
|
||||||
|
# define TORRENT_EXPORT
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define TORRENT_EXPORT
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
// ======= MSVC =========
|
||||||
|
|
||||||
|
#elif defined BOOST_MSVC
|
||||||
|
|
||||||
#pragma warning(disable: 4258)
|
#pragma warning(disable: 4258)
|
||||||
#pragma warning(disable: 4251)
|
#pragma warning(disable: 4251)
|
||||||
|
@ -79,10 +101,16 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#define TORRENT_DEPRECATED_PREFIX __declspec(deprecated("function is deprecated"))
|
#define TORRENT_DEPRECATED_PREFIX __declspec(deprecated("function is deprecated"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ======= GENERIC COMPILER =========
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# define TORRENT_EXPORT
|
# define TORRENT_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef TORRENT_DEPRECATED_PREFIX
|
#ifndef TORRENT_DEPRECATED_PREFIX
|
||||||
#define TORRENT_DEPRECATED_PREFIX
|
#define TORRENT_DEPRECATED_PREFIX
|
||||||
#endif
|
#endif
|
||||||
|
@ -129,14 +157,22 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
// (disables some float-dependent APIs)
|
// (disables some float-dependent APIs)
|
||||||
#define TORRENT_NO_FPU 0
|
#define TORRENT_NO_FPU 0
|
||||||
|
|
||||||
|
// make sure NAME_MAX is defined
|
||||||
|
#ifndef NAME_MAX
|
||||||
|
#ifdef MAXPATH
|
||||||
|
#define NAME_MAX MAXPATH
|
||||||
|
#else
|
||||||
|
// this is the maximum number of characters in a
|
||||||
|
// path element / filename on windows
|
||||||
|
#define NAME_MAX 255
|
||||||
|
#endif // MAXPATH
|
||||||
|
#endif // NAME_MAX
|
||||||
|
|
||||||
#ifdef TORRENT_WINDOWS
|
#ifdef TORRENT_WINDOWS
|
||||||
|
|
||||||
#pragma warning(disable:4251) // class X needs to have dll-interface to be used by clients of class Y
|
#pragma warning(disable:4251) // class X needs to have dll-interface to be used by clients of class Y
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
// this is the maximum number of characters in a
|
|
||||||
// path element / filename on windows
|
|
||||||
#define NAME_MAX 255
|
|
||||||
|
|
||||||
inline int snprintf(char* buf, int len, char const* fmt, ...)
|
inline int snprintf(char* buf, int len, char const* fmt, ...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -191,6 +191,8 @@ namespace libtorrent
|
||||||
reserved8,
|
reserved8,
|
||||||
|
|
||||||
no_i2p_router,
|
no_i2p_router,
|
||||||
|
|
||||||
|
error_code_max
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,14 @@ namespace libtorrent
|
||||||
typedef iovec iovec_t;
|
typedef iovec iovec_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// use a typedef for the type of iovec_t::iov_base
|
||||||
|
// since it may differ
|
||||||
|
#ifdef TORRENT_SOLARIS
|
||||||
|
typedef char* iovec_base_t;
|
||||||
|
#else
|
||||||
|
typedef void* iovec_base_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
file();
|
file();
|
||||||
file(fs::path const& p, int m, error_code& ec);
|
file(fs::path const& p, int m, error_code& ec);
|
||||||
~file();
|
~file();
|
||||||
|
|
|
@ -148,7 +148,7 @@ private:
|
||||||
read_connect_response,
|
read_connect_response,
|
||||||
read_accept_response,
|
read_accept_response,
|
||||||
read_session_create_response,
|
read_session_create_response,
|
||||||
read_name_lookup_response,
|
read_name_lookup_response
|
||||||
};
|
};
|
||||||
|
|
||||||
int m_state;
|
int m_state;
|
||||||
|
|
|
@ -35,6 +35,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/cstdint.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <algorithm> // for copy
|
||||||
|
#include <cstring> // for memcpy
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
@ -137,7 +139,7 @@ namespace libtorrent
|
||||||
|
|
||||||
inline void write_string(std::string const& str, char*& start)
|
inline void write_string(std::string const& str, char*& start)
|
||||||
{
|
{
|
||||||
std::copy(str.begin(), str.end(), start);
|
std::memcpy((void*)start, &str[0], str.size());
|
||||||
start += str.size();
|
start += str.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,16 +87,14 @@ namespace detail
|
||||||
Addr plus_one(Addr const& a)
|
Addr plus_one(Addr const& a)
|
||||||
{
|
{
|
||||||
Addr tmp(a);
|
Addr tmp(a);
|
||||||
typedef typename Addr::reverse_iterator iter;
|
for (int i = tmp.size() - 1; i >= 0; --i)
|
||||||
for (iter i = tmp.rbegin()
|
|
||||||
, end(tmp.rend()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if (*i < (std::numeric_limits<typename iter::value_type>::max)())
|
if (tmp[i] < (std::numeric_limits<typename Addr::value_type>::max)())
|
||||||
{
|
{
|
||||||
*i += 1;
|
tmp[i] += 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*i = 0;
|
tmp[i] = 0;
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
@ -107,16 +105,14 @@ namespace detail
|
||||||
Addr minus_one(Addr const& a)
|
Addr minus_one(Addr const& a)
|
||||||
{
|
{
|
||||||
Addr tmp(a);
|
Addr tmp(a);
|
||||||
typedef typename Addr::reverse_iterator iter;
|
for (int i = tmp.size() - 1; i >= 0; --i)
|
||||||
for (iter i = tmp.rbegin()
|
|
||||||
, end(tmp.rend()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if (*i > 0)
|
if (tmp[i] > 0)
|
||||||
{
|
{
|
||||||
*i -= 1;
|
tmp[i] -= 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*i = (std::numeric_limits<typename iter::value_type>::max)();
|
tmp[i] = (std::numeric_limits<typename Addr::value_type>::max)();
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,12 +55,12 @@ class rpc_manager;
|
||||||
class refresh : public traversal_algorithm
|
class refresh : public traversal_algorithm
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef std::vector<node_entry>::iterator InIt;
|
||||||
typedef boost::function<void()> done_callback;
|
typedef boost::function<void()> done_callback;
|
||||||
|
|
||||||
void ping_reply(node_id id);
|
void ping_reply(node_id id);
|
||||||
void ping_timeout(node_id id, bool prevent_request = false);
|
void ping_timeout(node_id id, bool prevent_request = false);
|
||||||
|
|
||||||
template<class InIt>
|
|
||||||
refresh(node_impl& node, node_id target, InIt first, InIt last
|
refresh(node_impl& node, node_id target, InIt first, InIt last
|
||||||
, done_callback const& callback);
|
, done_callback const& callback);
|
||||||
|
|
||||||
|
@ -131,12 +131,11 @@ private:
|
||||||
boost::intrusive_ptr<refresh> m_algorithm;
|
boost::intrusive_ptr<refresh> m_algorithm;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class InIt>
|
|
||||||
inline refresh::refresh(
|
inline refresh::refresh(
|
||||||
node_impl& node
|
node_impl& node
|
||||||
, node_id target
|
, node_id target
|
||||||
, InIt first
|
, refresh::InIt first
|
||||||
, InIt last
|
, refresh::InIt last
|
||||||
, done_callback const& callback)
|
, done_callback const& callback)
|
||||||
: traversal_algorithm(node, target, first, last)
|
: traversal_algorithm(node, target, first, last)
|
||||||
, m_max_active_pings(10)
|
, m_max_active_pings(10)
|
||||||
|
|
|
@ -86,12 +86,14 @@ namespace libtorrent
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
std::fill(m_number,m_number+number_size,0);
|
std::fill(m_number,m_number+number_size,(const unsigned char)(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_all_zeros() const
|
bool is_all_zeros() const
|
||||||
{
|
{
|
||||||
return std::count(m_number,m_number+number_size,0) == number_size;
|
for (const unsigned char* i = m_number; i < m_number+number_size; ++i)
|
||||||
|
if (*i != 0) return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(big_number const& n) const
|
bool operator==(big_number const& n) const
|
||||||
|
|
|
@ -148,8 +148,13 @@ namespace libtorrent
|
||||||
// we'll have to add thes figures with the
|
// we'll have to add thes figures with the
|
||||||
// statistics from the peer_connection.
|
// statistics from the peer_connection.
|
||||||
// 48 bits can fit 256 Terabytes
|
// 48 bits can fit 256 Terabytes
|
||||||
|
#ifdef __SUNPRO_CC
|
||||||
|
unsigned prev_amount_upload:48;
|
||||||
|
unsigned prev_amount_download:48;
|
||||||
|
#else
|
||||||
boost::uint64_t prev_amount_upload:48;
|
boost::uint64_t prev_amount_upload:48;
|
||||||
boost::uint64_t prev_amount_download:48;
|
boost::uint64_t prev_amount_download:48;
|
||||||
|
#endif
|
||||||
|
|
||||||
// if the peer is connected now, this
|
// if the peer is connected now, this
|
||||||
// will refer to a valid peer_connection
|
// will refer to a valid peer_connection
|
||||||
|
|
|
@ -301,7 +301,12 @@ namespace libtorrent
|
||||||
{ none, requested, writing, finished };
|
{ none, requested, writing, finished };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifdef __SUNPRO_CC
|
||||||
|
// sunpro is strict about POD types in unions
|
||||||
|
struct
|
||||||
|
#else
|
||||||
union
|
union
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
address_v4::bytes_type v4;
|
address_v4::bytes_type v4;
|
||||||
address_v6::bytes_type v6;
|
address_v6::bytes_type v6;
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace libtorrent
|
||||||
internal_port_must_match_external = 724,
|
internal_port_must_match_external = 724,
|
||||||
only_permanent_leases_supported = 725,
|
only_permanent_leases_supported = 725,
|
||||||
remote_host_must_be_wildcard = 726,
|
remote_host_must_be_wildcard = 726,
|
||||||
external_port_must_be_wildcard = 727,
|
external_port_must_be_wildcard = 727
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1233,7 +1233,7 @@ namespace libtorrent
|
||||||
(*m_logger) << " " << e->list_int_value_at(0) << ": "
|
(*m_logger) << " " << e->list_int_value_at(0) << ": "
|
||||||
<< sha1_hash(e->list_at(1)->string_ptr());
|
<< sha1_hash(e->list_at(1)->string_ptr());
|
||||||
#endif
|
#endif
|
||||||
nodes.insert(nodes.begin(), std::make_pair(int(e->list_int_value_at(0))
|
nodes.insert(std::make_pair(int(e->list_int_value_at(0))
|
||||||
, sha1_hash(e->list_at(1)->string_ptr())));
|
, sha1_hash(e->list_at(1)->string_ptr())));
|
||||||
}
|
}
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
|
|
|
@ -85,8 +85,7 @@ namespace libtorrent
|
||||||
dictionary_type::iterator i = dict().find(key);
|
dictionary_type::iterator i = dict().find(key);
|
||||||
if (i != dict().end()) return i->second;
|
if (i != dict().end()) return i->second;
|
||||||
dictionary_type::iterator ret = dict().insert(
|
dictionary_type::iterator ret = dict().insert(
|
||||||
dict().begin()
|
std::pair<const std::string, entry>(key, entry())).first;
|
||||||
, std::make_pair(key, entry()));
|
|
||||||
return ret->second;
|
return ret->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +94,7 @@ namespace libtorrent
|
||||||
dictionary_type::iterator i = dict().find(key);
|
dictionary_type::iterator i = dict().find(key);
|
||||||
if (i != dict().end()) return i->second;
|
if (i != dict().end()) return i->second;
|
||||||
dictionary_type::iterator ret = dict().insert(
|
dictionary_type::iterator ret = dict().insert(
|
||||||
dict().begin()
|
std::make_pair(key, entry())).first;
|
||||||
, std::make_pair(std::string(key), entry()));
|
|
||||||
return ret->second;
|
return ret->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,10 +196,7 @@ namespace libtorrent
|
||||||
std::string ret;
|
std::string ret;
|
||||||
for (int i = 0; i < len; ++i)
|
for (int i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
if (std::count(
|
if (std::strchr(unreserved_chars+offset, *str))
|
||||||
unreserved_chars+offset
|
|
||||||
, unreserved_chars+sizeof(unreserved_chars)-1
|
|
||||||
, *str))
|
|
||||||
{
|
{
|
||||||
ret += *str;
|
ret += *str;
|
||||||
}
|
}
|
||||||
|
@ -228,13 +225,8 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
for (int i = 0; i < len; ++i)
|
for (int i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
if (std::count(
|
if (std::strchr(unreserved_chars, *str) == 0)
|
||||||
unreserved_chars
|
|
||||||
, unreserved_chars+sizeof(unreserved_chars)-1
|
|
||||||
, *str) == 0)
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
++str;
|
++str;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -296,7 +288,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
// available input is 1,2 or 3 bytes
|
// available input is 1,2 or 3 bytes
|
||||||
// since we read 3 bytes at a time at most
|
// since we read 3 bytes at a time at most
|
||||||
int available_input = (std::min)(3, (int)std::distance(i, s.end()));
|
int available_input = (std::min)(3, int(s.end()-i));
|
||||||
|
|
||||||
// clear input buffer
|
// clear input buffer
|
||||||
std::fill(inbuf, inbuf+3, 0);
|
std::fill(inbuf, inbuf+3, 0);
|
||||||
|
@ -344,7 +336,7 @@ namespace libtorrent
|
||||||
std::string ret;
|
std::string ret;
|
||||||
for (std::string::const_iterator i = s.begin(); i != s.end();)
|
for (std::string::const_iterator i = s.begin(); i != s.end();)
|
||||||
{
|
{
|
||||||
int available_input = (std::min)(5, (int)std::distance(i, s.end()));
|
int available_input = (std::min)(5, int(s.end()-i));
|
||||||
|
|
||||||
// clear input buffer
|
// clear input buffer
|
||||||
std::fill(inbuf, inbuf+5, 0);
|
std::fill(inbuf, inbuf+5, 0);
|
||||||
|
@ -387,7 +379,7 @@ namespace libtorrent
|
||||||
std::string ret;
|
std::string ret;
|
||||||
for (std::string::const_iterator i = s.begin(); i != s.end();)
|
for (std::string::const_iterator i = s.begin(); i != s.end();)
|
||||||
{
|
{
|
||||||
int available_input = (std::min)(8, (int)std::distance(i, s.end()));
|
int available_input = (std::min)(8, int(s.end()-i));
|
||||||
|
|
||||||
int pad_start = 0;
|
int pad_start = 0;
|
||||||
if (available_input < 8) pad_start = available_input;
|
if (available_input < 8) pad_start = available_input;
|
||||||
|
|
|
@ -98,7 +98,7 @@ namespace libtorrent
|
||||||
|
|
||||||
char const* line = pos;
|
char const* line = pos;
|
||||||
++newline;
|
++newline;
|
||||||
int incoming = (int)std::distance(pos, newline);
|
int incoming = int(newline - pos);
|
||||||
m_recv_pos += incoming;
|
m_recv_pos += incoming;
|
||||||
boost::get<1>(ret) += newline - (m_recv_buffer.begin + start_pos);
|
boost::get<1>(ret) += newline - (m_recv_buffer.begin + start_pos);
|
||||||
pos = newline;
|
pos = newline;
|
||||||
|
|
|
@ -429,7 +429,7 @@ namespace libtorrent
|
||||||
for (std::string::const_iterator i = peers.begin();
|
for (std::string::const_iterator i = peers.begin();
|
||||||
i != peers.end();)
|
i != peers.end();)
|
||||||
{
|
{
|
||||||
if (std::distance(i, peers.end()) < 6) break;
|
if (peers.end() - i < 6) break;
|
||||||
|
|
||||||
peer_entry p;
|
peer_entry p;
|
||||||
p.pid.clear();
|
p.pid.clear();
|
||||||
|
@ -463,7 +463,7 @@ namespace libtorrent
|
||||||
for (std::string::const_iterator i = peers.begin();
|
for (std::string::const_iterator i = peers.begin();
|
||||||
i != peers.end();)
|
i != peers.end();)
|
||||||
{
|
{
|
||||||
if (std::distance(i, peers.end()) < 18) break;
|
if (peers.end() - i < 18) break;
|
||||||
|
|
||||||
peer_entry p;
|
peer_entry p;
|
||||||
p.pid.clear();
|
p.pid.clear();
|
||||||
|
|
|
@ -349,12 +349,12 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (find_string(PID, "-BOW") && PID[7] == '-')
|
if (find_string(PID, "-BOW") && PID[7] == '-')
|
||||||
return "Bits on Wheels " + std::string(PID + 4, PID + 7);
|
return "Bits on Wheels " + std::string((char const*)PID + 4, (char const*)PID + 7);
|
||||||
|
|
||||||
|
|
||||||
if (find_string(PID, "eX"))
|
if (find_string(PID, "eX"))
|
||||||
{
|
{
|
||||||
std::string user(PID + 2, PID + 14);
|
std::string user((char const*)PID + 2, (char const*)PID + 14);
|
||||||
return std::string("eXeem ('") + user.c_str() + "')";
|
return std::string("eXeem ('") + user.c_str() + "')";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,8 +80,7 @@ namespace
|
||||||
void operator()(std::pair<libtorrent::dht::node_id
|
void operator()(std::pair<libtorrent::dht::node_id
|
||||||
, libtorrent::dht::torrent_entry> const& t)
|
, libtorrent::dht::torrent_entry> const& t)
|
||||||
{
|
{
|
||||||
count += std::distance(t.second.peers.begin()
|
count += t.second.peers.size();
|
||||||
, t.second.peers.end());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1024,7 +1023,7 @@ namespace libtorrent { namespace dht
|
||||||
e["y"] = "r";
|
e["y"] = "r";
|
||||||
e["r"] = entry(entry::dictionary_t);
|
e["r"] = entry(entry::dictionary_t);
|
||||||
entry& r = e["r"];
|
entry& r = e["r"];
|
||||||
r["id"] = std::string(m.id.begin(), m.id.end());
|
r["id"] = std::string((char*)m.id.begin(), (char*)m.id.end());
|
||||||
if (!m.write_token.empty())
|
if (!m.write_token.empty())
|
||||||
{
|
{
|
||||||
r["token"] = m.write_token;
|
r["token"] = m.write_token;
|
||||||
|
@ -1085,7 +1084,7 @@ namespace libtorrent { namespace dht
|
||||||
e["y"] = "q";
|
e["y"] = "q";
|
||||||
e["a"] = entry(entry::dictionary_t);
|
e["a"] = entry(entry::dictionary_t);
|
||||||
entry& a = e["a"];
|
entry& a = e["a"];
|
||||||
a["id"] = std::string(m.id.begin(), m.id.end());
|
a["id"] = std::string((char*)m.id.begin(), (char*)m.id.end());
|
||||||
|
|
||||||
TORRENT_ASSERT(m.message_id <= messages::error);
|
TORRENT_ASSERT(m.message_id <= messages::error);
|
||||||
e["q"] = messages::ids[m.message_id];
|
e["q"] = messages::ids[m.message_id];
|
||||||
|
@ -1100,7 +1099,7 @@ namespace libtorrent { namespace dht
|
||||||
case messages::find_node:
|
case messages::find_node:
|
||||||
{
|
{
|
||||||
send_flags = 1;
|
send_flags = 1;
|
||||||
a["target"] = std::string(m.info_hash.begin(), m.info_hash.end());
|
a["target"] = std::string((char*)m.info_hash.begin(), (char*)m.info_hash.end());
|
||||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||||
log_line << " target: " << boost::lexical_cast<std::string>(m.info_hash);
|
log_line << " target: " << boost::lexical_cast<std::string>(m.info_hash);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1109,7 +1108,7 @@ namespace libtorrent { namespace dht
|
||||||
case messages::get_peers:
|
case messages::get_peers:
|
||||||
{
|
{
|
||||||
send_flags = 1;
|
send_flags = 1;
|
||||||
a["info_hash"] = std::string(m.info_hash.begin(), m.info_hash.end());
|
a["info_hash"] = std::string((char*)m.info_hash.begin(), (char*)m.info_hash.end());
|
||||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||||
log_line << " ih: " << boost::lexical_cast<std::string>(m.info_hash);
|
log_line << " ih: " << boost::lexical_cast<std::string>(m.info_hash);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1118,7 +1117,7 @@ namespace libtorrent { namespace dht
|
||||||
case messages::announce_peer:
|
case messages::announce_peer:
|
||||||
send_flags = 1;
|
send_flags = 1;
|
||||||
a["port"] = m.port;
|
a["port"] = m.port;
|
||||||
a["info_hash"] = std::string(m.info_hash.begin(), m.info_hash.end());
|
a["info_hash"] = std::string((char*)m.info_hash.begin(), (char*)m.info_hash.end());
|
||||||
a["token"] = m.write_token;
|
a["token"] = m.write_token;
|
||||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||||
log_line << " port: " << m.port
|
log_line << " port: " << m.port
|
||||||
|
|
|
@ -106,10 +106,10 @@ namespace libtorrent
|
||||||
i->index = 0;
|
i->index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<piece_pos>::const_iterator i = m_piece_map.begin() + m_cursor
|
for (std::vector<piece_pos>::iterator i = m_piece_map.begin() + m_cursor
|
||||||
, end(m_piece_map.end()); i != end && (i->have() || i->filtered());
|
, end(m_piece_map.end()); i != end && (i->have() || i->filtered());
|
||||||
++i, ++m_cursor);
|
++i, ++m_cursor);
|
||||||
for (std::vector<piece_pos>::const_reverse_iterator i = m_piece_map.rend()
|
for (std::vector<piece_pos>::reverse_iterator i = m_piece_map.rend()
|
||||||
- m_reverse_cursor; m_reverse_cursor > 0 && (i->have() || i->filtered());
|
- m_reverse_cursor; m_reverse_cursor > 0 && (i->have() || i->filtered());
|
||||||
++i, --m_reverse_cursor);
|
++i, --m_reverse_cursor);
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ namespace libtorrent
|
||||||
index = num_pieces;
|
index = num_pieces;
|
||||||
if (num_pieces > 0)
|
if (num_pieces > 0)
|
||||||
{
|
{
|
||||||
for (std::vector<piece_pos>::const_reverse_iterator i = m_piece_map.rend()
|
for (std::vector<piece_pos>::reverse_iterator i = m_piece_map.rend()
|
||||||
- index; index > 0 && (i->have() || i->filtered()); ++i, --index);
|
- index; index > 0 && (i->have() || i->filtered()); ++i, --index);
|
||||||
TORRENT_ASSERT(index == num_pieces
|
TORRENT_ASSERT(index == num_pieces
|
||||||
|| m_piece_map[index].have()
|
|| m_piece_map[index].have()
|
||||||
|
|
|
@ -2992,9 +2992,12 @@ namespace aux {
|
||||||
#ifdef TORRENT_DEBUG
|
#ifdef TORRENT_DEBUG
|
||||||
void session_impl::check_invariant() const
|
void session_impl::check_invariant() const
|
||||||
{
|
{
|
||||||
int num_checking = std::count_if(m_queued_for_checking.begin()
|
int num_checking = 0;
|
||||||
, m_queued_for_checking.end(), boost::bind(&torrent::state, _1)
|
for (check_queue_t::const_iterator i = m_queued_for_checking.begin()
|
||||||
== torrent_status::checking_files);
|
, end(m_queued_for_checking.end()); i != end; ++i)
|
||||||
|
{
|
||||||
|
if ((*i)->state() == torrent_status::checking_files) ++num_checking;
|
||||||
|
}
|
||||||
|
|
||||||
// the queue is either empty, or it has exactly one checking torrent in it
|
// the queue is either empty, or it has exactly one checking torrent in it
|
||||||
TORRENT_ASSERT(m_queued_for_checking.empty() || num_checking == 1);
|
TORRENT_ASSERT(m_queued_for_checking.empty() || num_checking == 1);
|
||||||
|
|
|
@ -226,7 +226,7 @@ namespace libtorrent { namespace
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_block_crc.insert(i, std::make_pair(b, e));
|
m_block_crc.insert(i, std::pair<const piece_block, block_entry>(b, e));
|
||||||
|
|
||||||
#ifdef TORRENT_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
char const* client = "-";
|
char const* client = "-";
|
||||||
|
|
|
@ -1427,7 +1427,7 @@ ret:
|
||||||
, int offset
|
, int offset
|
||||||
, int size)
|
, int size)
|
||||||
{
|
{
|
||||||
file::iovec_t b = { (void*)buf, size };
|
file::iovec_t b = { (file::iovec_base_t)buf, size };
|
||||||
return writev(&b, slot, offset, 1);
|
return writev(&b, slot, offset, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1437,7 +1437,7 @@ ret:
|
||||||
, int offset
|
, int offset
|
||||||
, int size)
|
, int size)
|
||||||
{
|
{
|
||||||
file::iovec_t b = { (void*)buf, size };
|
file::iovec_t b = { (file::iovec_base_t)buf, size };
|
||||||
return readv(&b, slot, offset, 1);
|
return readv(&b, slot, offset, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2526,7 +2526,7 @@ ret:
|
||||||
if (m_hash_to_piece.empty())
|
if (m_hash_to_piece.empty())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_files.num_pieces(); ++i)
|
for (int i = 0; i < m_files.num_pieces(); ++i)
|
||||||
m_hash_to_piece.insert(std::make_pair(m_info->hash_for_piece(i), i));
|
m_hash_to_piece.insert(std::pair<const sha1_hash, int>(m_info->hash_for_piece(i), i));
|
||||||
}
|
}
|
||||||
|
|
||||||
partial_hash ph;
|
partial_hash ph;
|
||||||
|
|
|
@ -185,7 +185,7 @@ namespace
|
||||||
if (p->pid() != pid) return false;
|
if (p->pid() != pid) return false;
|
||||||
// have a special case for all zeros. We can have any number
|
// have a special case for all zeros. We can have any number
|
||||||
// of peers with that pid, since it's used to indicate no pid.
|
// of peers with that pid, since it's used to indicate no pid.
|
||||||
if (std::count(pid.begin(), pid.end(), 0) == 20) return false;
|
if (pid.is_all_zeros()) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5708,7 +5708,7 @@ namespace libtorrent
|
||||||
std::vector<int> pieces;
|
std::vector<int> pieces;
|
||||||
m_picker->piece_priorities(pieces);
|
m_picker->piece_priorities(pieces);
|
||||||
// make sure all pieces have priority 0
|
// make sure all pieces have priority 0
|
||||||
TORRENT_ASSERT(std::count(pieces.begin(), pieces.end(), 0) == int(pieces.size()));
|
TORRENT_ASSERT(std::accumulate(pieces.begin(), pieces.end(), 0) == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s == torrent_status::seeding)
|
if (s == torrent_status::seeding)
|
||||||
|
@ -5906,8 +5906,11 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
return (int)std::count_if(m_connections.begin(), m_connections.end()
|
int ret = 0;
|
||||||
, boost::bind(&peer_connection::is_seed, _1));
|
for (std::set<peer_connection*>::iterator i = m_connections.begin()
|
||||||
|
, end(m_connections.end()); i != end; ++i)
|
||||||
|
if ((*i)->is_seed()) ++ret;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrent::tracker_request_timed_out(
|
void torrent::tracker_request_timed_out(
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace libtorrent
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::distance(i, end) < 2)
|
if (end - i < 2)
|
||||||
{
|
{
|
||||||
convert_to_utf8(tmp_path, *i);
|
convert_to_utf8(tmp_path, *i);
|
||||||
valid_encoding = false;
|
valid_encoding = false;
|
||||||
|
@ -110,7 +110,7 @@ namespace libtorrent
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::distance(i, end) < 3)
|
if (end - i < 3)
|
||||||
{
|
{
|
||||||
convert_to_utf8(tmp_path, *i);
|
convert_to_utf8(tmp_path, *i);
|
||||||
valid_encoding = false;
|
valid_encoding = false;
|
||||||
|
@ -129,7 +129,7 @@ namespace libtorrent
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::distance(i, end) < 4)
|
if (end - i < 4)
|
||||||
{
|
{
|
||||||
convert_to_utf8(tmp_path, *i);
|
convert_to_utf8(tmp_path, *i);
|
||||||
valid_encoding = false;
|
valid_encoding = false;
|
||||||
|
|
Loading…
Reference in New Issue