sync with asio 1.0 release and update lt 2147
This commit is contained in:
parent
642569f4bc
commit
fecd9132ce
|
@ -698,40 +698,40 @@ inline const char* inet_ntop(int af, const void* src, char* dest, size_t length,
|
|||
return 0;
|
||||
}
|
||||
|
||||
sockaddr_storage_type address;
|
||||
union
|
||||
{
|
||||
socket_addr_type base;
|
||||
sockaddr_storage_type storage;
|
||||
sockaddr_in4_type v4;
|
||||
sockaddr_in6_type v6;
|
||||
} address;
|
||||
DWORD address_length;
|
||||
if (af == AF_INET)
|
||||
{
|
||||
address_length = sizeof(sockaddr_in4_type);
|
||||
sockaddr_in4_type* ipv4_address =
|
||||
reinterpret_cast<sockaddr_in4_type*>(&address);
|
||||
ipv4_address->sin_family = AF_INET;
|
||||
ipv4_address->sin_port = 0;
|
||||
memcpy(&ipv4_address->sin_addr, src, sizeof(in4_addr_type));
|
||||
address.v4.sin_family = AF_INET;
|
||||
address.v4.sin_port = 0;
|
||||
memcpy(&address.v4.sin_addr, src, sizeof(in4_addr_type));
|
||||
}
|
||||
else // AF_INET6
|
||||
{
|
||||
address_length = sizeof(sockaddr_in6_type);
|
||||
sockaddr_in6_type* ipv6_address =
|
||||
reinterpret_cast<sockaddr_in6_type*>(&address);
|
||||
ipv6_address->sin6_family = AF_INET6;
|
||||
ipv6_address->sin6_port = 0;
|
||||
ipv6_address->sin6_flowinfo = 0;
|
||||
ipv6_address->sin6_scope_id = scope_id;
|
||||
memcpy(&ipv6_address->sin6_addr, src, sizeof(in6_addr_type));
|
||||
address.v6.sin6_family = AF_INET6;
|
||||
address.v6.sin6_port = 0;
|
||||
address.v6.sin6_flowinfo = 0;
|
||||
address.v6.sin6_scope_id = scope_id;
|
||||
memcpy(&address.v6.sin6_addr, src, sizeof(in6_addr_type));
|
||||
}
|
||||
|
||||
DWORD string_length = static_cast<DWORD>(length);
|
||||
#if defined(BOOST_NO_ANSI_APIS)
|
||||
LPWSTR string_buffer = (LPWSTR)_alloca(length * sizeof(WCHAR));
|
||||
int result = error_wrapper(::WSAAddressToStringW(
|
||||
reinterpret_cast<sockaddr*>(&address),
|
||||
int result = error_wrapper(::WSAAddressToStringW(&address.base,
|
||||
address_length, 0, string_buffer, &string_length), ec);
|
||||
::WideCharToMultiByte(CP_ACP, 0, string_buffer, -1, dest, length, 0, 0);
|
||||
#else
|
||||
int result = error_wrapper(::WSAAddressToStringA(
|
||||
reinterpret_cast<sockaddr*>(&address),
|
||||
address_length, 0, dest, &string_length), ec);
|
||||
&address.base, address_length, 0, dest, &string_length), ec);
|
||||
#endif
|
||||
|
||||
// Windows may set error code on success.
|
||||
|
@ -774,30 +774,30 @@ inline int inet_pton(int af, const char* src, void* dest,
|
|||
return -1;
|
||||
}
|
||||
|
||||
sockaddr_storage_type address;
|
||||
union
|
||||
{
|
||||
socket_addr_type base;
|
||||
sockaddr_storage_type storage;
|
||||
sockaddr_in4_type v4;
|
||||
sockaddr_in6_type v6;
|
||||
} address;
|
||||
int address_length = sizeof(sockaddr_storage_type);
|
||||
#if defined(BOOST_NO_ANSI_APIS)
|
||||
int num_wide_chars = strlen(src) + 1;
|
||||
LPWSTR wide_buffer = (LPWSTR)_alloca(num_wide_chars * sizeof(WCHAR));
|
||||
::MultiByteToWideChar(CP_ACP, 0, src, -1, wide_buffer, num_wide_chars);
|
||||
int result = error_wrapper(::WSAStringToAddressW(
|
||||
wide_buffer, af, 0,
|
||||
reinterpret_cast<sockaddr*>(&address),
|
||||
&address_length), ec);
|
||||
wide_buffer, af, 0, &address.base, &address_length), ec);
|
||||
#else
|
||||
int result = error_wrapper(::WSAStringToAddressA(
|
||||
const_cast<char*>(src), af, 0,
|
||||
reinterpret_cast<sockaddr*>(&address),
|
||||
&address_length), ec);
|
||||
const_cast<char*>(src), af, 0, &address.base, &address_length), ec);
|
||||
#endif
|
||||
|
||||
if (af == AF_INET)
|
||||
{
|
||||
if (result != socket_error_retval)
|
||||
{
|
||||
sockaddr_in4_type* ipv4_address =
|
||||
reinterpret_cast<sockaddr_in4_type*>(&address);
|
||||
memcpy(dest, &ipv4_address->sin_addr, sizeof(in4_addr_type));
|
||||
memcpy(dest, &address.v4.sin_addr, sizeof(in4_addr_type));
|
||||
clear_error(ec);
|
||||
}
|
||||
else if (strcmp(src, "255.255.255.255") == 0)
|
||||
|
@ -810,11 +810,9 @@ inline int inet_pton(int af, const char* src, void* dest,
|
|||
{
|
||||
if (result != socket_error_retval)
|
||||
{
|
||||
sockaddr_in6_type* ipv6_address =
|
||||
reinterpret_cast<sockaddr_in6_type*>(&address);
|
||||
memcpy(dest, &ipv6_address->sin6_addr, sizeof(in6_addr_type));
|
||||
memcpy(dest, &address.v6.sin6_addr, sizeof(in6_addr_type));
|
||||
if (scope_id)
|
||||
*scope_id = ipv6_address->sin6_scope_id;
|
||||
*scope_id = address.v6.sin6_scope_id;
|
||||
clear_error(ec);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -427,10 +427,9 @@ public:
|
|||
if (impl->current_handler_ == 0)
|
||||
{
|
||||
// This handler now has the lock, so can be dispatched immediately.
|
||||
impl->current_handler_ = ptr.get();
|
||||
impl->current_handler_ = ptr.release();
|
||||
lock.unlock();
|
||||
this->get_io_service().dispatch(invoke_current_handler(*this, impl));
|
||||
ptr.release();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -467,10 +466,9 @@ public:
|
|||
if (impl->current_handler_ == 0)
|
||||
{
|
||||
// This handler now has the lock, so can be dispatched immediately.
|
||||
impl->current_handler_ = ptr.get();
|
||||
impl->current_handler_ = ptr.release();
|
||||
lock.unlock();
|
||||
this->get_io_service().post(invoke_current_handler(*this, impl));
|
||||
ptr.release();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -392,7 +392,7 @@ private:
|
|||
&timer_thread_, this_thread_id, 0) == 0);
|
||||
|
||||
// Calculate timeout for GetQueuedCompletionStatus call.
|
||||
DWORD timeout = INFINITE;
|
||||
DWORD timeout = max_timeout;
|
||||
if (dispatching_timers)
|
||||
{
|
||||
asio::detail::mutex::scoped_lock lock(timer_mutex_);
|
||||
|
|
|
@ -65,11 +65,9 @@ public:
|
|||
basic_endpoint()
|
||||
: data_()
|
||||
{
|
||||
asio::detail::sockaddr_in4_type& data
|
||||
= reinterpret_cast<asio::detail::sockaddr_in4_type&>(data_);
|
||||
data.sin_family = AF_INET;
|
||||
data.sin_port = 0;
|
||||
data.sin_addr.s_addr = INADDR_ANY;
|
||||
data_.v4.sin_family = AF_INET;
|
||||
data_.v4.sin_port = 0;
|
||||
data_.v4.sin_addr.s_addr = INADDR_ANY;
|
||||
}
|
||||
|
||||
/// Construct an endpoint using a port number, specified in the host's byte
|
||||
|
@ -94,24 +92,20 @@ public:
|
|||
using namespace std; // For memcpy.
|
||||
if (protocol.family() == PF_INET)
|
||||
{
|
||||
asio::detail::sockaddr_in4_type& data
|
||||
= reinterpret_cast<asio::detail::sockaddr_in4_type&>(data_);
|
||||
data.sin_family = AF_INET;
|
||||
data.sin_port =
|
||||
data_.v4.sin_family = AF_INET;
|
||||
data_.v4.sin_port =
|
||||
asio::detail::socket_ops::host_to_network_short(port_num);
|
||||
data.sin_addr.s_addr = INADDR_ANY;
|
||||
data_.v4.sin_addr.s_addr = INADDR_ANY;
|
||||
}
|
||||
else
|
||||
{
|
||||
asio::detail::sockaddr_in6_type& data
|
||||
= reinterpret_cast<asio::detail::sockaddr_in6_type&>(data_);
|
||||
data.sin6_family = AF_INET6;
|
||||
data.sin6_port =
|
||||
data_.v6.sin6_family = AF_INET6;
|
||||
data_.v6.sin6_port =
|
||||
asio::detail::socket_ops::host_to_network_short(port_num);
|
||||
data.sin6_flowinfo = 0;
|
||||
data_.v6.sin6_flowinfo = 0;
|
||||
asio::detail::in6_addr_type tmp_addr = IN6ADDR_ANY_INIT;
|
||||
data.sin6_addr = tmp_addr;
|
||||
data.sin6_scope_id = 0;
|
||||
data_.v6.sin6_addr = tmp_addr;
|
||||
data_.v6.sin6_scope_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,27 +118,23 @@ public:
|
|||
using namespace std; // For memcpy.
|
||||
if (addr.is_v4())
|
||||
{
|
||||
asio::detail::sockaddr_in4_type& data
|
||||
= reinterpret_cast<asio::detail::sockaddr_in4_type&>(data_);
|
||||
data.sin_family = AF_INET;
|
||||
data.sin_port =
|
||||
data_.v4.sin_family = AF_INET;
|
||||
data_.v4.sin_port =
|
||||
asio::detail::socket_ops::host_to_network_short(port_num);
|
||||
data.sin_addr.s_addr =
|
||||
data_.v4.sin_addr.s_addr =
|
||||
asio::detail::socket_ops::host_to_network_long(
|
||||
addr.to_v4().to_ulong());
|
||||
}
|
||||
else
|
||||
{
|
||||
asio::detail::sockaddr_in6_type& data
|
||||
= reinterpret_cast<asio::detail::sockaddr_in6_type&>(data_);
|
||||
data.sin6_family = AF_INET6;
|
||||
data.sin6_port =
|
||||
data_.v6.sin6_family = AF_INET6;
|
||||
data_.v6.sin6_port =
|
||||
asio::detail::socket_ops::host_to_network_short(port_num);
|
||||
data.sin6_flowinfo = 0;
|
||||
data_.v6.sin6_flowinfo = 0;
|
||||
asio::ip::address_v6 v6_addr = addr.to_v6();
|
||||
asio::ip::address_v6::bytes_type bytes = v6_addr.to_bytes();
|
||||
memcpy(data.sin6_addr.s6_addr, bytes.elems, 16);
|
||||
data.sin6_scope_id = v6_addr.scope_id();
|
||||
memcpy(data_.v6.sin6_addr.s6_addr, bytes.elems, 16);
|
||||
data_.v6.sin6_scope_id = v6_addr.scope_id();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,7 +154,7 @@ public:
|
|||
/// The protocol associated with the endpoint.
|
||||
protocol_type protocol() const
|
||||
{
|
||||
if (is_v4(data_))
|
||||
if (is_v4())
|
||||
return InternetProtocol::v4();
|
||||
return InternetProtocol::v6();
|
||||
}
|
||||
|
@ -172,19 +162,19 @@ public:
|
|||
/// Get the underlying endpoint in the native type.
|
||||
data_type* data()
|
||||
{
|
||||
return reinterpret_cast<data_type*>(&data_);
|
||||
return &data_.base;
|
||||
}
|
||||
|
||||
/// Get the underlying endpoint in the native type.
|
||||
const data_type* data() const
|
||||
{
|
||||
return reinterpret_cast<const data_type*>(&data_);
|
||||
return &data_.base;
|
||||
}
|
||||
|
||||
/// Get the underlying size of the endpoint in the native type.
|
||||
std::size_t size() const
|
||||
{
|
||||
if (is_v4(data_))
|
||||
if (is_v4())
|
||||
return sizeof(asio::detail::sockaddr_in4_type);
|
||||
else
|
||||
return sizeof(asio::detail::sockaddr_in6_type);
|
||||
|
@ -193,7 +183,7 @@ public:
|
|||
/// Set the underlying size of the endpoint in the native type.
|
||||
void resize(std::size_t size)
|
||||
{
|
||||
if (size > sizeof(data_))
|
||||
if (size > sizeof(asio::detail::sockaddr_storage_type))
|
||||
{
|
||||
asio::system_error e(asio::error::invalid_argument);
|
||||
boost::throw_exception(e);
|
||||
|
@ -203,24 +193,22 @@ public:
|
|||
/// Get the capacity of the endpoint in the native type.
|
||||
std::size_t capacity() const
|
||||
{
|
||||
return sizeof(data_);
|
||||
return sizeof(asio::detail::sockaddr_storage_type);
|
||||
}
|
||||
|
||||
/// Get the port associated with the endpoint. The port number is always in
|
||||
/// the host's byte order.
|
||||
unsigned short port() const
|
||||
{
|
||||
if (is_v4(data_))
|
||||
if (is_v4())
|
||||
{
|
||||
return asio::detail::socket_ops::network_to_host_short(
|
||||
reinterpret_cast<const asio::detail::sockaddr_in4_type&>(
|
||||
data_).sin_port);
|
||||
data_.v4.sin_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
return asio::detail::socket_ops::network_to_host_short(
|
||||
reinterpret_cast<const asio::detail::sockaddr_in6_type&>(
|
||||
data_).sin6_port);
|
||||
data_.v6.sin6_port);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,14 +216,14 @@ public:
|
|||
/// the host's byte order.
|
||||
void port(unsigned short port_num)
|
||||
{
|
||||
if (is_v4(data_))
|
||||
if (is_v4())
|
||||
{
|
||||
reinterpret_cast<asio::detail::sockaddr_in4_type&>(data_).sin_port
|
||||
data_.v4.sin_port
|
||||
= asio::detail::socket_ops::host_to_network_short(port_num);
|
||||
}
|
||||
else
|
||||
{
|
||||
reinterpret_cast<asio::detail::sockaddr_in6_type&>(data_).sin6_port
|
||||
data_.v6.sin6_port
|
||||
= asio::detail::socket_ops::host_to_network_short(port_num);
|
||||
}
|
||||
}
|
||||
|
@ -244,23 +232,17 @@ public:
|
|||
asio::ip::address address() const
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
if (is_v4(data_))
|
||||
if (is_v4())
|
||||
{
|
||||
const asio::detail::sockaddr_in4_type& data
|
||||
= reinterpret_cast<const asio::detail::sockaddr_in4_type&>(
|
||||
data_);
|
||||
return asio::ip::address_v4(
|
||||
asio::detail::socket_ops::network_to_host_long(
|
||||
data.sin_addr.s_addr));
|
||||
data_.v4.sin_addr.s_addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
const asio::detail::sockaddr_in6_type& data
|
||||
= reinterpret_cast<const asio::detail::sockaddr_in6_type&>(
|
||||
data_);
|
||||
asio::ip::address_v6::bytes_type bytes;
|
||||
memcpy(bytes.elems, data.sin6_addr.s6_addr, 16);
|
||||
return asio::ip::address_v6(bytes, data.sin6_scope_id);
|
||||
memcpy(bytes.elems, data_.v6.sin6_addr.s6_addr, 16);
|
||||
return asio::ip::address_v6(bytes, data_.v6.sin6_scope_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -298,29 +280,19 @@ public:
|
|||
|
||||
private:
|
||||
// Helper function to determine whether the endpoint is IPv4.
|
||||
#if defined(_AIX)
|
||||
template <typename T, unsigned char (T::*)> struct is_v4_helper {};
|
||||
|
||||
template <typename T>
|
||||
static bool is_v4(const T& ss, is_v4_helper<T, &T::ss_family>* = 0)
|
||||
bool is_v4() const
|
||||
{
|
||||
return ss.ss_family == AF_INET;
|
||||
return data_.base.sa_family == AF_INET;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static bool is_v4(const T& ss, is_v4_helper<T, &T::__ss_family>* = 0)
|
||||
{
|
||||
return ss.__ss_family == AF_INET;
|
||||
}
|
||||
#else
|
||||
static bool is_v4(const asio::detail::sockaddr_storage_type& ss)
|
||||
{
|
||||
return ss.ss_family == AF_INET;
|
||||
}
|
||||
#endif
|
||||
|
||||
// The underlying IP socket address.
|
||||
asio::detail::sockaddr_storage_type data_;
|
||||
union data_union
|
||||
{
|
||||
asio::detail::socket_addr_type base;
|
||||
asio::detail::sockaddr_storage_type storage;
|
||||
asio::detail::sockaddr_in4_type v4;
|
||||
asio::detail::sockaddr_in6_type v6;
|
||||
} data_;
|
||||
};
|
||||
|
||||
/// Output an endpoint as a string.
|
||||
|
|
|
@ -18,6 +18,6 @@
|
|||
// ASIO_VERSION % 100 is the sub-minor version
|
||||
// ASIO_VERSION / 100 % 1000 is the minor version
|
||||
// ASIO_VERSION / 100000 is the major version
|
||||
#define ASIO_VERSION 309 // 0.3.9
|
||||
#define ASIO_VERSION 100000 // 1.0.0
|
||||
|
||||
#endif // ASIO_VERSION_HPP
|
||||
|
|
|
@ -158,7 +158,6 @@ struct bandwidth_manager
|
|||
INVARIANT_CHECK;
|
||||
if (m_abort) return;
|
||||
TORRENT_ASSERT(blk > 0);
|
||||
TORRENT_ASSERT(!peer->ignore_bandwidth_limits());
|
||||
|
||||
// make sure this peer isn't already in line
|
||||
// waiting for bandwidth
|
||||
|
@ -264,7 +263,7 @@ private:
|
|||
catch (std::exception&) {}
|
||||
}
|
||||
|
||||
void hand_out_bandwidth(boost::mutex::scoped_lock& l) throw()
|
||||
void hand_out_bandwidth(boost::mutex::scoped_lock& l)
|
||||
{
|
||||
TORRENT_ASSERT(l.locked());
|
||||
// if we're already handing out bandwidth, just return back
|
||||
|
@ -380,7 +379,7 @@ private:
|
|||
}
|
||||
if (!tmp.empty()) m_queue.insert(m_queue.begin(), tmp.begin(), tmp.end());
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (std::exception&)
|
||||
{
|
||||
m_in_hand_out_bandwidth = false;
|
||||
throw;
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace libtorrent
|
|||
action_t action;
|
||||
|
||||
char* buffer;
|
||||
size_type buffer_size;
|
||||
int buffer_size;
|
||||
boost::intrusive_ptr<piece_manager> storage;
|
||||
// arguments used for read and write
|
||||
int piece, offset;
|
||||
|
|
|
@ -293,13 +293,13 @@ namespace libtorrent
|
|||
|
||||
inline int total_seconds(time_duration td)
|
||||
{
|
||||
return aux::performance_counter_to_microseconds(td.diff)
|
||||
/ 1000000;
|
||||
return int(aux::performance_counter_to_microseconds(td.diff)
|
||||
/ 1000000);
|
||||
}
|
||||
inline int total_milliseconds(time_duration td)
|
||||
{
|
||||
return aux::performance_counter_to_microseconds(td.diff)
|
||||
/ 1000;
|
||||
return int(aux::performance_counter_to_microseconds(td.diff)
|
||||
/ 1000);
|
||||
}
|
||||
inline boost::int64_t total_microseconds(time_duration td)
|
||||
{
|
||||
|
|
|
@ -281,7 +281,6 @@ namespace libtorrent
|
|||
torrent_handle(): m_ses(0), m_chk(0), m_info_hash(0) {}
|
||||
|
||||
void get_peer_info(std::vector<peer_info>& v) const;
|
||||
bool send_chat_message(tcp::endpoint ip, std::string message) const;
|
||||
torrent_status status() const;
|
||||
void get_download_queue(std::vector<partial_piece_info>& queue) const;
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ namespace libtorrent
|
|||
const std::vector<announce_entry>& trackers() const { return m_urls; }
|
||||
|
||||
size_type total_size() const { TORRENT_ASSERT(m_piece_length > 0); return m_total_size; }
|
||||
size_type piece_length() const { TORRENT_ASSERT(m_piece_length > 0); return m_piece_length; }
|
||||
int piece_length() const { TORRENT_ASSERT(m_piece_length > 0); return m_piece_length; }
|
||||
int num_pieces() const { TORRENT_ASSERT(m_piece_length > 0); return m_num_pieces; }
|
||||
const sha1_hash& info_hash() const { return m_info_hash; }
|
||||
const std::string& name() const { TORRENT_ASSERT(m_piece_length > 0); return m_name; }
|
||||
|
@ -215,7 +215,7 @@ namespace libtorrent
|
|||
|
||||
void convert_file_names();
|
||||
|
||||
size_type piece_size(int index) const;
|
||||
int piece_size(int index) const;
|
||||
|
||||
const sha1_hash& hash_for_piece(int index) const
|
||||
{
|
||||
|
@ -267,7 +267,7 @@ namespace libtorrent
|
|||
// the length of one piece
|
||||
// if this is 0, the torrent_info is
|
||||
// in an uninitialized state
|
||||
size_type m_piece_length;
|
||||
int m_piece_length;
|
||||
|
||||
// the sha-1 hashes of each piece
|
||||
std::vector<sha1_hash> m_piece_hash;
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace libtorrent {
|
|||
nsec -= 1000000000;
|
||||
xt.sec += 1;
|
||||
}
|
||||
xt.nsec = nsec;
|
||||
xt.nsec = boost::xtime::xtime_nsec_t(nsec);
|
||||
if (!m_condition.timed_wait(lock, xt)) return 0;
|
||||
TORRENT_ASSERT(!m_alerts.empty());
|
||||
if (m_alerts.empty()) return 0;
|
||||
|
|
|
@ -1177,6 +1177,7 @@ namespace libtorrent
|
|||
}
|
||||
catch (std::exception& exc)
|
||||
{
|
||||
(void)exc;
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << "invalid extended handshake: " << exc.what() << "\n";
|
||||
#endif
|
||||
|
@ -1208,7 +1209,7 @@ namespace libtorrent
|
|||
if (listen_port->type() == entry::int_t
|
||||
&& peer_info_struct() != 0)
|
||||
{
|
||||
t->get_policy().update_peer_port(listen_port->integer()
|
||||
t->get_policy().update_peer_port(int(listen_port->integer())
|
||||
, peer_info_struct(), peer_info::incoming);
|
||||
}
|
||||
}
|
||||
|
@ -1224,7 +1225,7 @@ namespace libtorrent
|
|||
if (entry* reqq = root.find_key("reqq"))
|
||||
{
|
||||
if (reqq->type() == entry::int_t)
|
||||
m_max_out_request_queue = reqq->integer();
|
||||
m_max_out_request_queue = int(reqq->integer());
|
||||
if (m_max_out_request_queue < 1)
|
||||
m_max_out_request_queue = 1;
|
||||
}
|
||||
|
|
|
@ -281,8 +281,8 @@ namespace libtorrent
|
|||
break;
|
||||
}
|
||||
}
|
||||
ret = j.storage->read_impl(j.buffer, j.piece, j.offset
|
||||
, j.buffer_size);
|
||||
ret = int(j.storage->read_impl(j.buffer, j.piece, j.offset
|
||||
, j.buffer_size));
|
||||
|
||||
// simulates slow drives
|
||||
// usleep(300);
|
||||
|
|
|
@ -266,7 +266,7 @@ void http_connection::on_read(asio::error_code const& e
|
|||
{
|
||||
m_parser.incoming(rcv_buf);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (std::exception&)
|
||||
{
|
||||
m_timer.cancel();
|
||||
m_handler(asio::error::fault, m_parser, 0, 0);
|
||||
|
|
|
@ -222,12 +222,13 @@ namespace libtorrent
|
|||
if (value.find(' ') != std::string::npos)
|
||||
range_str >> bytes;
|
||||
range_str >> range_start >> dummy >> range_end;
|
||||
if (!range_str || range_end < range_start)
|
||||
if (!range_str || range_end < range_start
|
||||
|| range_end - range_start + 1 >= (std::numeric_limits<int>::max)())
|
||||
{
|
||||
throw std::runtime_error("invalid content-range in HTTP response: " + range_str.str());
|
||||
}
|
||||
// the http range is inclusive
|
||||
m_content_length = range_end - range_start + 1;
|
||||
m_content_length = int(range_end - range_start + 1);
|
||||
}
|
||||
|
||||
TORRENT_ASSERT(m_recv_pos <= (int)recv_buffer.left());
|
||||
|
@ -914,15 +915,15 @@ namespace libtorrent
|
|||
|
||||
entry const* complete_ent = scrape_data.find_key("complete");
|
||||
if (complete_ent && complete_ent->type() == entry::int_t)
|
||||
complete = complete_ent->integer();
|
||||
complete = int(complete_ent->integer());
|
||||
|
||||
entry const* incomplete_ent = scrape_data.find_key("incomplete");
|
||||
if (incomplete_ent && incomplete_ent->type() == entry::int_t)
|
||||
incomplete = incomplete_ent->integer();
|
||||
incomplete = int(incomplete_ent->integer());
|
||||
|
||||
entry const* downloaded_ent = scrape_data.find_key("downloaded");
|
||||
if (downloaded_ent && downloaded_ent->type() == entry::int_t)
|
||||
downloaded = downloaded_ent->integer();
|
||||
downloaded = int(downloaded_ent->integer());
|
||||
|
||||
cb->tracker_scrape_response(tracker_req(), complete
|
||||
, incomplete, downloaded);
|
||||
|
@ -977,10 +978,10 @@ namespace libtorrent
|
|||
int complete = -1;
|
||||
int incomplete = -1;
|
||||
|
||||
try { complete = e["complete"].integer(); }
|
||||
try { complete = int(e["complete"].integer()); }
|
||||
catch(type_error&) {}
|
||||
|
||||
try { incomplete = e["incomplete"].integer(); }
|
||||
try { incomplete = int(e["incomplete"].integer()); }
|
||||
catch(type_error&) {}
|
||||
|
||||
cb->tracker_response(tracker_req(), peer_list, interval, complete
|
||||
|
|
|
@ -112,7 +112,7 @@ void closest_nodes::done()
|
|||
std::vector<node_entry> results;
|
||||
int num_results = m_max_results;
|
||||
for (std::vector<result>::iterator i = m_results.begin()
|
||||
, end(m_results.end()); i != end && num_results >= 0; ++i)
|
||||
, end(m_results.end()); i != end && num_results > 0; ++i)
|
||||
{
|
||||
if (i->flags & result::no_id) continue;
|
||||
if ((i->flags & result::queried) == 0) continue;
|
||||
|
|
|
@ -88,7 +88,9 @@ boost::pool<>& traversal_algorithm::allocator() const
|
|||
|
||||
void traversal_algorithm::traverse(node_id const& id, udp::endpoint addr)
|
||||
{
|
||||
TORRENT_ASSERT(!id.is_all_zeros());
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_LOG(traversal) << "node returned a list which included a node with id 0";
|
||||
#endif
|
||||
add_entry(id, addr, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ namespace libtorrent { namespace
|
|||
entry const& messages = h["m"];
|
||||
if (entry const* index = messages.find_key("LT_metadata"))
|
||||
{
|
||||
m_message_index = index->integer();
|
||||
m_message_index = int(index->integer());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -245,7 +245,7 @@ namespace libtorrent
|
|||
t->get_policy().peer_is_interesting(*this);
|
||||
}
|
||||
// may throw an asio error if socket has disconnected
|
||||
catch (std::exception& e) {}
|
||||
catch (std::exception&) {}
|
||||
|
||||
TORRENT_ASSERT(is_interesting() == interested);
|
||||
}
|
||||
|
@ -1107,7 +1107,7 @@ namespace libtorrent
|
|||
"s: " << r.start << " | "
|
||||
"l: " << r.length << " | "
|
||||
"i: " << m_peer_interested << " | "
|
||||
"t: " << (int)t->torrent_file().piece_size(r.piece) << " | "
|
||||
"t: " << t->torrent_file().piece_size(r.piece) << " | "
|
||||
"n: " << t->torrent_file().num_pieces() << " ]\n";
|
||||
#endif
|
||||
write_reject_request(r);
|
||||
|
@ -1127,7 +1127,7 @@ namespace libtorrent
|
|||
"s: " << r.start << " | "
|
||||
"l: " << r.length << " | "
|
||||
"i: " << m_peer_interested << " | "
|
||||
"t: " << (int)t->torrent_file().piece_size(r.piece) << " | "
|
||||
"t: " << t->torrent_file().piece_size(r.piece) << " | "
|
||||
"n: " << t->torrent_file().num_pieces() << " ]\n";
|
||||
|
||||
(*m_logger) << time_now_string()
|
||||
|
@ -1194,7 +1194,7 @@ namespace libtorrent
|
|||
"s: " << r.start << " | "
|
||||
"l: " << r.length << " | "
|
||||
"i: " << m_peer_interested << " | "
|
||||
"t: " << (int)t->torrent_file().piece_size(r.piece) << " | "
|
||||
"t: " << t->torrent_file().piece_size(r.piece) << " | "
|
||||
"n: " << t->torrent_file().num_pieces() << " | "
|
||||
"h: " << t->have_piece(r.piece) << " | "
|
||||
"block_limit: " << t->block_size() << " ]\n";
|
||||
|
@ -1785,7 +1785,7 @@ namespace libtorrent
|
|||
|
||||
int block_offset = block.block_index * t->block_size();
|
||||
int block_size
|
||||
= (std::min)((int)t->torrent_file().piece_size(block.piece_index)-block_offset,
|
||||
= (std::min)(t->torrent_file().piece_size(block.piece_index)-block_offset,
|
||||
t->block_size());
|
||||
TORRENT_ASSERT(block_size > 0);
|
||||
TORRENT_ASSERT(block_size <= t->block_size());
|
||||
|
@ -1897,7 +1897,7 @@ namespace libtorrent
|
|||
piece_block block = m_request_queue.front();
|
||||
|
||||
int block_offset = block.block_index * t->block_size();
|
||||
int block_size = (std::min)((int)t->torrent_file().piece_size(
|
||||
int block_size = (std::min)(t->torrent_file().piece_size(
|
||||
block.piece_index) - block_offset, t->block_size());
|
||||
TORRENT_ASSERT(block_size > 0);
|
||||
TORRENT_ASSERT(block_size <= t->block_size());
|
||||
|
@ -1943,7 +1943,7 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
block_offset = block.block_index * t->block_size();
|
||||
block_size = (std::min)((int)t->torrent_file().piece_size(
|
||||
block_size = (std::min)(t->torrent_file().piece_size(
|
||||
block.piece_index) - block_offset, t->block_size());
|
||||
TORRENT_ASSERT(block_size > 0);
|
||||
TORRENT_ASSERT(block_size <= t->block_size());
|
||||
|
@ -1988,7 +1988,7 @@ namespace libtorrent
|
|||
|
||||
void close_socket_ignore_error(boost::shared_ptr<socket_type> s)
|
||||
{
|
||||
try { s->close(); } catch (std::exception& e) {}
|
||||
try { s->close(); } catch (std::exception&) {}
|
||||
}
|
||||
|
||||
void peer_connection::timed_out()
|
||||
|
|
|
@ -1111,15 +1111,6 @@ namespace libtorrent
|
|||
if (flags & 0x01) i->second.pe_support = true;
|
||||
#endif
|
||||
if (flags & 0x02) i->second.seed = true;
|
||||
|
||||
// try to send a DHT ping to this peer
|
||||
// as well, to figure out if it supports
|
||||
// DHT (uTorrent and BitComet doesn't
|
||||
// advertise support)
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
udp::endpoint node(remote.address(), remote.port());
|
||||
m_torrent->session().add_dht_node(node);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1024,6 +1024,15 @@ namespace detail
|
|||
async_accept(listener);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifdef TORRENT_BSD
|
||||
// Leopard sometimes generates an "invalid argument" error. It seems to be
|
||||
// non-fatal and we have to do another async_accept.
|
||||
if (e.value() == EINVAL)
|
||||
{
|
||||
async_accept(listener);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (m_alerts.should_post(alert::fatal))
|
||||
{
|
||||
|
@ -1603,7 +1612,7 @@ namespace detail
|
|||
nsec -= 1000000000;
|
||||
xt.sec += 1;
|
||||
}
|
||||
xt.nsec = nsec;
|
||||
xt.nsec = boost::xtime::xtime_nsec_t(nsec);
|
||||
boost::thread::sleep(xt);
|
||||
}
|
||||
|
||||
|
|
|
@ -541,9 +541,9 @@ namespace libtorrent
|
|||
for (entry::list_type::iterator i = l.begin();
|
||||
i != l.end(); ++i)
|
||||
{
|
||||
file_sizes.push_back(std::pair<size_type, std::time_t>(
|
||||
file_sizes.push_back(std::make_pair(
|
||||
i->list().front().integer()
|
||||
, i->list().back().integer()));
|
||||
, std::time_t(i->list().back().integer())));
|
||||
}
|
||||
|
||||
if (file_sizes.empty())
|
||||
|
@ -818,7 +818,7 @@ namespace libtorrent
|
|||
== file_iter->path);
|
||||
#endif
|
||||
|
||||
size_type actual_read = in->read(buf + buf_pos, read_bytes);
|
||||
int actual_read = int(in->read(buf + buf_pos, read_bytes));
|
||||
|
||||
if (read_bytes != actual_read)
|
||||
{
|
||||
|
@ -1702,8 +1702,8 @@ namespace libtorrent
|
|||
|
||||
m_piece_data.resize(int(m_info->piece_length()));
|
||||
int piece_size = int(m_info->piece_size(m_current_slot));
|
||||
int num_read = m_storage->read(&m_piece_data[0]
|
||||
, m_current_slot, 0, piece_size);
|
||||
int num_read = int(m_storage->read(&m_piece_data[0]
|
||||
, m_current_slot, 0, piece_size));
|
||||
|
||||
// if the file is incomplete, skip the rest of it
|
||||
if (num_read != piece_size)
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace
|
|||
// if pieces are too small, adjust the block size
|
||||
if (i.piece_length() < default_block_size)
|
||||
{
|
||||
return static_cast<int>(i.piece_length());
|
||||
return i.piece_length();
|
||||
}
|
||||
|
||||
// otherwise, go with the default
|
||||
|
@ -337,7 +337,7 @@ namespace libtorrent
|
|||
peer_request torrent::to_req(piece_block const& p)
|
||||
{
|
||||
int block_offset = p.block_index * m_block_size;
|
||||
int block_size = (std::min)((int)torrent_file().piece_size(
|
||||
int block_size = (std::min)(torrent_file().piece_size(
|
||||
p.piece_index) - block_offset, m_block_size);
|
||||
TORRENT_ASSERT(block_size > 0);
|
||||
TORRENT_ASSERT(block_size <= m_block_size);
|
||||
|
@ -403,8 +403,8 @@ namespace libtorrent
|
|||
m_storage = m_owning_storage.get();
|
||||
m_block_size = calculate_block_size(*m_torrent_file, m_default_block_size);
|
||||
m_picker.reset(new piece_picker(
|
||||
static_cast<int>(m_torrent_file->piece_length() / m_block_size)
|
||||
, static_cast<int>((m_torrent_file->total_size()+m_block_size-1)/m_block_size)));
|
||||
m_torrent_file->piece_length() / m_block_size
|
||||
, int((m_torrent_file->total_size()+m_block_size-1)/m_block_size)));
|
||||
|
||||
std::vector<std::string> const& url_seeds = m_torrent_file->url_seeds();
|
||||
std::copy(url_seeds.begin(), url_seeds.end(), std::inserter(m_web_seeds
|
||||
|
@ -775,8 +775,7 @@ namespace libtorrent
|
|||
const std::vector<piece_picker::downloading_piece>& dl_queue
|
||||
= m_picker->get_download_queue();
|
||||
|
||||
const int blocks_per_piece = static_cast<int>(
|
||||
piece_size / m_block_size);
|
||||
const int blocks_per_piece = piece_size / m_block_size;
|
||||
|
||||
for (std::vector<piece_picker::downloading_piece>::const_iterator i =
|
||||
dl_queue.begin(); i != dl_queue.end(); ++i)
|
||||
|
@ -1702,7 +1701,7 @@ namespace libtorrent
|
|||
m_host_resolver.async_resolve(q, m_ses.m_strand.wrap(
|
||||
bind(&torrent::on_name_lookup, shared_from_this(), _1, _2, url, a)));
|
||||
}
|
||||
catch (std::exception& exc)
|
||||
catch (std::exception&)
|
||||
{
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
|
@ -1987,7 +1986,7 @@ namespace libtorrent
|
|||
pi.finished = (int)i->finished;
|
||||
pi.writing = (int)i->writing;
|
||||
pi.requested = (int)i->requested;
|
||||
int piece_size = torrent_file().piece_size(i->index);
|
||||
int piece_size = int(torrent_file().piece_size(i->index));
|
||||
for (int j = 0; j < pi.blocks_in_piece; ++j)
|
||||
{
|
||||
block_info& bi = pi.blocks[j];
|
||||
|
@ -2178,7 +2177,7 @@ namespace libtorrent
|
|||
#endif
|
||||
m_policy.new_connection(*p);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (std::exception&)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
@ -2864,6 +2863,13 @@ namespace libtorrent
|
|||
m_storage->async_release_files(
|
||||
bind(&torrent::on_torrent_paused, shared_from_this(), _1, _2));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (alerts().should_post(alert::warning))
|
||||
{
|
||||
alerts().post_alert(torrent_paused_alert(get_handle(), "torrent paused"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void torrent::resume()
|
||||
|
@ -2967,6 +2973,7 @@ namespace libtorrent
|
|||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
(void)e;
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*p->m_logger) << "**ERROR**: " << e.what() << "\n";
|
||||
#endif
|
||||
|
@ -3053,8 +3060,8 @@ namespace libtorrent
|
|||
size_type done = 0;
|
||||
while (size > 0)
|
||||
{
|
||||
size_type bytes_step = (std::min)(m_torrent_file->piece_size(ret.piece)
|
||||
- ret.start, size);
|
||||
size_type bytes_step = (std::min)(size_type(m_torrent_file->piece_size(ret.piece)
|
||||
- ret.start), size);
|
||||
if (m_have_pieces[ret.piece]) done += bytes_step;
|
||||
++ret.piece;
|
||||
ret.start = 0;
|
||||
|
@ -3177,7 +3184,7 @@ namespace libtorrent
|
|||
|
||||
if (st.total_wanted == 0) st.progress = 1.f;
|
||||
else st.progress = st.total_wanted_done
|
||||
/ static_cast<double>(st.total_wanted);
|
||||
/ static_cast<float>(st.total_wanted);
|
||||
|
||||
st.pieces = &m_have_pieces;
|
||||
st.num_pieces = m_num_pieces;
|
||||
|
|
|
@ -485,7 +485,7 @@ namespace libtorrent
|
|||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
torrent* t = find_torrent(m_ses, m_chk, m_info_hash);
|
||||
return t;
|
||||
return t != 0;
|
||||
}
|
||||
|
||||
entry torrent_handle::write_resume_data() const
|
||||
|
|
|
@ -340,7 +340,7 @@ namespace libtorrent
|
|||
m_info_hash = h.final();
|
||||
|
||||
// extract piece length
|
||||
m_piece_length = (int)info["piece length"].integer();
|
||||
m_piece_length = int(info["piece length"].integer());
|
||||
if (m_piece_length <= 0) throw std::runtime_error("invalid torrent. piece length <= 0");
|
||||
|
||||
// extract file name (or the directory name if it's a multifile libtorrent)
|
||||
|
@ -497,7 +497,7 @@ namespace libtorrent
|
|||
std::string const& hostname = iter->string();
|
||||
++iter;
|
||||
int port = 6881;
|
||||
if (l.end() != iter) port = iter->integer();
|
||||
if (l.end() != iter) port = int(iter->integer());
|
||||
m_nodes.push_back(std::make_pair(hostname, port));
|
||||
}
|
||||
}
|
||||
|
@ -817,7 +817,7 @@ namespace libtorrent
|
|||
|
||||
// ------- end deprecation -------
|
||||
|
||||
size_type torrent_info::piece_size(int index) const
|
||||
int torrent_info::piece_size(int index) const
|
||||
{
|
||||
TORRENT_ASSERT(index >= 0 && index < num_pieces());
|
||||
if (index == num_pieces()-1)
|
||||
|
@ -826,7 +826,7 @@ namespace libtorrent
|
|||
- (num_pieces() - 1) * piece_length();
|
||||
TORRENT_ASSERT(size > 0);
|
||||
TORRENT_ASSERT(size <= piece_length());
|
||||
return size;
|
||||
return int(size);
|
||||
}
|
||||
else
|
||||
return piece_length();
|
||||
|
@ -882,12 +882,13 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
std::vector<file_slice> torrent_info::map_block(int piece, size_type offset
|
||||
, int size, bool storage) const
|
||||
, int size_, bool storage) const
|
||||
{
|
||||
TORRENT_ASSERT(num_files() > 0);
|
||||
std::vector<file_slice> ret;
|
||||
|
||||
size_type start = piece * (size_type)m_piece_length + offset;
|
||||
size_type size = size_;
|
||||
TORRENT_ASSERT(start + size <= m_total_size);
|
||||
|
||||
// find the file iterator and file offset
|
||||
|
@ -926,8 +927,8 @@ namespace libtorrent
|
|||
size_type offset = file_offset + file_at(file_index, storage).offset;
|
||||
|
||||
peer_request ret;
|
||||
ret.piece = offset / piece_length();
|
||||
ret.start = offset - ret.piece * piece_length();
|
||||
ret.piece = int(offset / piece_length());
|
||||
ret.start = int(offset - ret.piece * piece_length());
|
||||
ret.length = size;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -352,7 +352,7 @@ namespace libtorrent
|
|||
m_timeout.async_wait(m_strand.wrap(
|
||||
bind(&timeout_handler::timeout_callback, self(), _1)));
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (std::exception&)
|
||||
{
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
|
|
@ -216,6 +216,7 @@ try
|
|||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
(void)e;
|
||||
#ifdef TORRENT_UPNP_LOGGING
|
||||
m_log << time_now_string()
|
||||
<< " *** Connection failed to: " << d.url
|
||||
|
@ -302,6 +303,7 @@ try
|
|||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
(void)e;
|
||||
#ifdef TORRENT_UPNP_LOGGING
|
||||
m_log << time_now_string()
|
||||
<< " <== (" << from << ") Rootdevice responded with incorrect HTTP packet. Ignoring device (" << e.what() << ")" << std::endl;
|
||||
|
@ -449,6 +451,7 @@ try
|
|||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
(void)e;
|
||||
#ifdef TORRENT_UPNP_LOGGING
|
||||
m_log << time_now_string()
|
||||
<< " *** Connection failed to: " << d.url
|
||||
|
|
|
@ -202,7 +202,7 @@ namespace libtorrent { namespace
|
|||
|
||||
if (entry const* index = messages.find_key(extension_name))
|
||||
{
|
||||
m_message_index = index->integer();
|
||||
m_message_index = int(index->integer());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -486,7 +486,7 @@ namespace libtorrent
|
|||
|
||||
int file_index = m_file_requests.front();
|
||||
peer_request in_range = info.map_file(file_index, range_start
|
||||
, range_end - range_start);
|
||||
, int(range_end - range_start));
|
||||
|
||||
peer_request front_request = m_requests.front();
|
||||
|
||||
|
|
Loading…
Reference in New Issue