clean up the annotations used for asio debugging (#639)
clean up the annotations used for asio debugging (tracking outstanding async operations)
This commit is contained in:
parent
eaf7cb329f
commit
c9c6dd2d3b
|
@ -164,6 +164,14 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ADD_OUTSTANDING_ASYNC(x) add_outstanding_async(x)
|
||||||
|
#define COMPLETE_ASYNC(x) complete_async(x)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define ADD_OUTSTANDING_ASYNC(x) do {} while(0)
|
||||||
|
#define COMPLETE_ASYNC(x) do {} while(0)
|
||||||
|
|
||||||
#endif // TORRENT_ASIO_DEBUGGING
|
#endif // TORRENT_ASIO_DEBUGGING
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
|
|
|
@ -60,10 +60,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/io_service_fwd.hpp"
|
#include "libtorrent/io_service_fwd.hpp"
|
||||||
#include "libtorrent/receive_buffer.hpp"
|
#include "libtorrent/receive_buffer.hpp"
|
||||||
#include "libtorrent/aux_/allocating_handler.hpp"
|
#include "libtorrent/aux_/allocating_handler.hpp"
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/ssl_stream.hpp"
|
#include "libtorrent/ssl_stream.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined TORRENT_OS2 && defined ioc
|
#if defined TORRENT_OS2 && defined ioc
|
||||||
#undef ioc
|
#undef ioc
|
||||||
|
|
|
@ -42,9 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "libtorrent/proxy_base.hpp"
|
#include "libtorrent/proxy_base.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
namespace socks_error {
|
namespace socks_error {
|
||||||
|
@ -166,9 +164,7 @@ public:
|
||||||
// store it in a shaed_ptr
|
// store it in a shaed_ptr
|
||||||
boost::shared_ptr<handler_type> h(new handler_type(handler));
|
boost::shared_ptr<handler_type> h(new handler_type(handler));
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("socks5_stream::name_lookup");
|
||||||
add_outstanding_async("socks5_stream::name_lookup");
|
|
||||||
#endif
|
|
||||||
tcp::resolver::query q(m_hostname, to_string(m_port).elems);
|
tcp::resolver::query q(m_hostname, to_string(m_port).elems);
|
||||||
m_resolver.async_resolve(q, boost::bind(
|
m_resolver.async_resolve(q, boost::bind(
|
||||||
&socks5_stream::name_lookup, this, _1, _2, h));
|
&socks5_stream::name_lookup, this, _1, _2, h));
|
||||||
|
|
|
@ -54,10 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/enum_net.hpp"
|
#include "libtorrent/enum_net.hpp"
|
||||||
#include "libtorrent/broadcast_socket.hpp"
|
#include "libtorrent/broadcast_socket.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TORRENT_DEBUG
|
#ifdef TORRENT_DEBUG
|
||||||
#include "libtorrent/socket_io.hpp"
|
#include "libtorrent/socket_io.hpp"
|
||||||
|
@ -296,9 +293,7 @@ namespace libtorrent
|
||||||
if (ec) return;
|
if (ec) return;
|
||||||
m_sockets.push_back(socket_entry(s));
|
m_sockets.push_back(socket_entry(s));
|
||||||
socket_entry& se = m_sockets.back();
|
socket_entry& se = m_sockets.back();
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("broadcast_socket::on_receive");
|
||||||
add_outstanding_async("broadcast_socket::on_receive");
|
|
||||||
#endif
|
|
||||||
s->async_receive_from(boost::asio::buffer(se.buffer, sizeof(se.buffer))
|
s->async_receive_from(boost::asio::buffer(se.buffer, sizeof(se.buffer))
|
||||||
, se.remote, boost::bind(&broadcast_socket::on_receive, this, &se, _1, _2));
|
, se.remote, boost::bind(&broadcast_socket::on_receive, this, &se, _1, _2));
|
||||||
++m_outstanding_operations;
|
++m_outstanding_operations;
|
||||||
|
@ -323,9 +318,7 @@ namespace libtorrent
|
||||||
s->set_option(option, ec);
|
s->set_option(option, ec);
|
||||||
if (!ec) se.broadcast = true;
|
if (!ec) se.broadcast = true;
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("broadcast_socket::on_receive");
|
||||||
add_outstanding_async("broadcast_socket::on_receive");
|
|
||||||
#endif
|
|
||||||
s->async_receive_from(boost::asio::buffer(se.buffer, sizeof(se.buffer))
|
s->async_receive_from(boost::asio::buffer(se.buffer, sizeof(se.buffer))
|
||||||
, se.remote, boost::bind(&broadcast_socket::on_receive, this, &se, _1, _2));
|
, se.remote, boost::bind(&broadcast_socket::on_receive, this, &se, _1, _2));
|
||||||
++m_outstanding_operations;
|
++m_outstanding_operations;
|
||||||
|
@ -381,9 +374,7 @@ namespace libtorrent
|
||||||
void broadcast_socket::on_receive(socket_entry* s, error_code const& ec
|
void broadcast_socket::on_receive(socket_entry* s, error_code const& ec
|
||||||
, std::size_t bytes_transferred)
|
, std::size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("broadcast_socket::on_receive");
|
||||||
complete_async("broadcast_socket::on_receive");
|
|
||||||
#endif
|
|
||||||
TORRENT_ASSERT(m_outstanding_operations > 0);
|
TORRENT_ASSERT(m_outstanding_operations > 0);
|
||||||
--m_outstanding_operations;
|
--m_outstanding_operations;
|
||||||
|
|
||||||
|
@ -396,9 +387,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (maybe_abort()) return;
|
if (maybe_abort()) return;
|
||||||
if (!s->socket) return;
|
if (!s->socket) return;
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("broadcast_socket::on_receive");
|
||||||
add_outstanding_async("broadcast_socket::on_receive");
|
|
||||||
#endif
|
|
||||||
s->socket->async_receive_from(boost::asio::buffer(s->buffer, sizeof(s->buffer))
|
s->socket->async_receive_from(boost::asio::buffer(s->buffer, sizeof(s->buffer))
|
||||||
, s->remote, boost::bind(&broadcast_socket::on_receive, this, s, _1, _2));
|
, s->remote, boost::bind(&broadcast_socket::on_receive, this, s, _1, _2));
|
||||||
++m_outstanding_operations;
|
++m_outstanding_operations;
|
||||||
|
|
|
@ -169,9 +169,7 @@ namespace libtorrent
|
||||||
, m_magic(0x1337)
|
, m_magic(0x1337)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("disk_io_thread::work");
|
||||||
add_outstanding_async("disk_io_thread::work");
|
|
||||||
#endif
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_disk_cache.set_settings(m_settings, ec);
|
m_disk_cache.set_settings(m_settings, ec);
|
||||||
TORRENT_ASSERT(!ec);
|
TORRENT_ASSERT(!ec);
|
||||||
|
@ -3282,9 +3280,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// release the io_service to allow the run() call to return
|
// release the io_service to allow the run() call to return
|
||||||
// we do this once we stop posting new callbacks to it.
|
// we do this once we stop posting new callbacks to it.
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("disk_io_thread::work");
|
||||||
complete_async("disk_io_thread::work");
|
|
||||||
#endif
|
|
||||||
w.reset();
|
w.reset();
|
||||||
|
|
||||||
TORRENT_ASSERT(m_magic == 0x1337);
|
TORRENT_ASSERT(m_magic == 0x1337);
|
||||||
|
|
|
@ -41,10 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/settings_pack.hpp"
|
#include "libtorrent/settings_pack.hpp"
|
||||||
#include "libtorrent/aux_/time.hpp"
|
#include "libtorrent/aux_/time.hpp"
|
||||||
#include "libtorrent/random.hpp"
|
#include "libtorrent/random.hpp"
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
|
@ -252,9 +249,7 @@ void http_connection::start(std::string const& hostname, int port
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_timer.expires_from_now((std::min)(
|
m_timer.expires_from_now((std::min)(
|
||||||
m_read_timeout, m_completion_timeout), ec);
|
m_read_timeout, m_completion_timeout), ec);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_timeout");
|
||||||
add_outstanding_async("http_connection::on_timeout");
|
|
||||||
#endif
|
|
||||||
m_timer.async_wait(boost::bind(&http_connection::on_timeout
|
m_timer.async_wait(boost::bind(&http_connection::on_timeout
|
||||||
, boost::weak_ptr<http_connection>(me), _1));
|
, boost::weak_ptr<http_connection>(me), _1));
|
||||||
m_called = false;
|
m_called = false;
|
||||||
|
@ -273,9 +268,7 @@ void http_connection::start(std::string const& hostname, int port
|
||||||
if (m_sock.is_open() && m_hostname == hostname && m_port == port
|
if (m_sock.is_open() && m_hostname == hostname && m_port == port
|
||||||
&& m_ssl == ssl && m_bind_addr == bind_addr)
|
&& m_ssl == ssl && m_bind_addr == bind_addr)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_write");
|
||||||
add_outstanding_async("http_connection::on_write");
|
|
||||||
#endif
|
|
||||||
async_write(m_sock, boost::asio::buffer(m_sendbuffer)
|
async_write(m_sock, boost::asio::buffer(m_sendbuffer)
|
||||||
, boost::bind(&http_connection::on_write, me, _1));
|
, boost::bind(&http_connection::on_write, me, _1));
|
||||||
}
|
}
|
||||||
|
@ -389,9 +382,7 @@ void http_connection::start(std::string const& hostname, int port
|
||||||
{
|
{
|
||||||
if (hostname.length() < 516) // Base64 encoded destination with optional .i2p
|
if (hostname.length() < 516) // Base64 encoded destination with optional .i2p
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_i2p_resolve");
|
||||||
add_outstanding_async("http_connection::on_i2p_resolve");
|
|
||||||
#endif
|
|
||||||
i2p_conn->async_name_lookup(hostname.c_str(), boost::bind(&http_connection::on_i2p_resolve
|
i2p_conn->async_name_lookup(hostname.c_str(), boost::bind(&http_connection::on_i2p_resolve
|
||||||
, me, _1, _2));
|
, me, _1, _2));
|
||||||
}
|
}
|
||||||
|
@ -411,9 +402,7 @@ void http_connection::start(std::string const& hostname, int port
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_resolve");
|
||||||
add_outstanding_async("http_connection::on_resolve");
|
|
||||||
#endif
|
|
||||||
m_resolver.async_resolve(hostname, m_resolve_flags
|
m_resolver.async_resolve(hostname, m_resolve_flags
|
||||||
, boost::bind(&http_connection::on_resolve
|
, boost::bind(&http_connection::on_resolve
|
||||||
, me, _1, _2));
|
, me, _1, _2));
|
||||||
|
@ -426,9 +415,7 @@ void http_connection::start(std::string const& hostname, int port
|
||||||
void http_connection::on_timeout(boost::weak_ptr<http_connection> p
|
void http_connection::on_timeout(boost::weak_ptr<http_connection> p
|
||||||
, error_code const& e)
|
, error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("http_connection::on_timeout");
|
||||||
complete_async("http_connection::on_timeout");
|
|
||||||
#endif
|
|
||||||
boost::shared_ptr<http_connection> c = p.lock();
|
boost::shared_ptr<http_connection> c = p.lock();
|
||||||
if (!c) return;
|
if (!c) return;
|
||||||
|
|
||||||
|
@ -461,9 +448,7 @@ void http_connection::on_timeout(boost::weak_ptr<http_connection> p
|
||||||
if (!c->m_sock.is_open()) return;
|
if (!c->m_sock.is_open()) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_timeout");
|
||||||
add_outstanding_async("http_connection::on_timeout");
|
|
||||||
#endif
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
c->m_timer.expires_at((std::min)(
|
c->m_timer.expires_at((std::min)(
|
||||||
c->m_last_receive + c->m_read_timeout
|
c->m_last_receive + c->m_read_timeout
|
||||||
|
@ -505,9 +490,7 @@ void http_connection::connect_i2p_tracker(char const* destination)
|
||||||
m_sock.get<i2p_stream>()->set_command(i2p_stream::cmd_connect);
|
m_sock.get<i2p_stream>()->set_command(i2p_stream::cmd_connect);
|
||||||
m_sock.get<i2p_stream>()->set_session_id(m_i2p_conn->session_id());
|
m_sock.get<i2p_stream>()->set_session_id(m_i2p_conn->session_id());
|
||||||
#endif
|
#endif
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_connect");
|
||||||
add_outstanding_async("http_connection::on_connect");
|
|
||||||
#endif
|
|
||||||
m_sock.async_connect(tcp::endpoint(), boost::bind(&http_connection::on_connect
|
m_sock.async_connect(tcp::endpoint(), boost::bind(&http_connection::on_connect
|
||||||
, shared_from_this(), _1));
|
, shared_from_this(), _1));
|
||||||
}
|
}
|
||||||
|
@ -515,9 +498,7 @@ void http_connection::connect_i2p_tracker(char const* destination)
|
||||||
void http_connection::on_i2p_resolve(error_code const& e
|
void http_connection::on_i2p_resolve(error_code const& e
|
||||||
, char const* destination)
|
, char const* destination)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("http_connection::on_i2p_resolve");
|
||||||
complete_async("http_connection::on_i2p_resolve");
|
|
||||||
#endif
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
callback(e);
|
callback(e);
|
||||||
|
@ -530,9 +511,7 @@ void http_connection::on_i2p_resolve(error_code const& e
|
||||||
void http_connection::on_resolve(error_code const& e
|
void http_connection::on_resolve(error_code const& e
|
||||||
, std::vector<address> const& addresses)
|
, std::vector<address> const& addresses)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("http_connection::on_resolve");
|
||||||
complete_async("http_connection::on_resolve");
|
|
||||||
#endif
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
callback(e);
|
callback(e);
|
||||||
|
@ -614,9 +593,7 @@ void http_connection::connect()
|
||||||
tcp::endpoint target_address = m_endpoints[m_next_ep];
|
tcp::endpoint target_address = m_endpoints[m_next_ep];
|
||||||
++m_next_ep;
|
++m_next_ep;
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_connect");
|
||||||
add_outstanding_async("http_connection::on_connect");
|
|
||||||
#endif
|
|
||||||
TORRENT_ASSERT(!m_connecting);
|
TORRENT_ASSERT(!m_connecting);
|
||||||
m_connecting = true;
|
m_connecting = true;
|
||||||
m_sock.async_connect(target_address, boost::bind(&http_connection::on_connect
|
m_sock.async_connect(target_address, boost::bind(&http_connection::on_connect
|
||||||
|
@ -625,9 +602,7 @@ void http_connection::connect()
|
||||||
|
|
||||||
void http_connection::on_connect(error_code const& e)
|
void http_connection::on_connect(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("http_connection::on_connect");
|
||||||
complete_async("http_connection::on_connect");
|
|
||||||
#endif
|
|
||||||
TORRENT_ASSERT(m_connecting);
|
TORRENT_ASSERT(m_connecting);
|
||||||
m_connecting = false;
|
m_connecting = false;
|
||||||
|
|
||||||
|
@ -636,9 +611,7 @@ void http_connection::on_connect(error_code const& e)
|
||||||
if (!e)
|
if (!e)
|
||||||
{
|
{
|
||||||
if (m_connect_handler) m_connect_handler(*this);
|
if (m_connect_handler) m_connect_handler(*this);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_write");
|
||||||
add_outstanding_async("http_connection::on_write");
|
|
||||||
#endif
|
|
||||||
async_write(m_sock, boost::asio::buffer(m_sendbuffer)
|
async_write(m_sock, boost::asio::buffer(m_sendbuffer)
|
||||||
, boost::bind(&http_connection::on_write, shared_from_this(), _1));
|
, boost::bind(&http_connection::on_write, shared_from_this(), _1));
|
||||||
}
|
}
|
||||||
|
@ -692,9 +665,7 @@ void http_connection::callback(error_code e, char* data, int size)
|
||||||
|
|
||||||
void http_connection::on_write(error_code const& e)
|
void http_connection::on_write(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("http_connection::on_write");
|
||||||
complete_async("http_connection::on_write");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (e == boost::asio::error::operation_aborted) return;
|
if (e == boost::asio::error::operation_aborted) return;
|
||||||
|
|
||||||
|
@ -717,17 +688,13 @@ void http_connection::on_write(error_code const& e)
|
||||||
{
|
{
|
||||||
if (!m_limiter_timer_active)
|
if (!m_limiter_timer_active)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_assign_bandwidth");
|
||||||
add_outstanding_async("http_connection::on_assign_bandwidth");
|
|
||||||
#endif
|
|
||||||
on_assign_bandwidth(error_code());
|
on_assign_bandwidth(error_code());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_read");
|
||||||
add_outstanding_async("http_connection::on_read");
|
|
||||||
#endif
|
|
||||||
m_sock.async_read_some(boost::asio::buffer(&m_recvbuffer[0] + m_read_pos
|
m_sock.async_read_some(boost::asio::buffer(&m_recvbuffer[0] + m_read_pos
|
||||||
, amount_to_read)
|
, amount_to_read)
|
||||||
, boost::bind(&http_connection::on_read
|
, boost::bind(&http_connection::on_read
|
||||||
|
@ -737,9 +704,7 @@ void http_connection::on_write(error_code const& e)
|
||||||
void http_connection::on_read(error_code const& e
|
void http_connection::on_read(error_code const& e
|
||||||
, std::size_t bytes_transferred)
|
, std::size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("http_connection::on_read");
|
||||||
complete_async("http_connection::on_read");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (m_rate_limit)
|
if (m_rate_limit)
|
||||||
{
|
{
|
||||||
|
@ -874,17 +839,13 @@ void http_connection::on_read(error_code const& e
|
||||||
{
|
{
|
||||||
if (!m_limiter_timer_active)
|
if (!m_limiter_timer_active)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_assign_bandwidth");
|
||||||
add_outstanding_async("http_connection::on_assign_bandwidth");
|
|
||||||
#endif
|
|
||||||
on_assign_bandwidth(error_code());
|
on_assign_bandwidth(error_code());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_read");
|
||||||
add_outstanding_async("http_connection::on_read");
|
|
||||||
#endif
|
|
||||||
m_sock.async_read_some(boost::asio::buffer(&m_recvbuffer[0] + m_read_pos
|
m_sock.async_read_some(boost::asio::buffer(&m_recvbuffer[0] + m_read_pos
|
||||||
, amount_to_read)
|
, amount_to_read)
|
||||||
, boost::bind(&http_connection::on_read
|
, boost::bind(&http_connection::on_read
|
||||||
|
@ -893,9 +854,7 @@ void http_connection::on_read(error_code const& e
|
||||||
|
|
||||||
void http_connection::on_assign_bandwidth(error_code const& e)
|
void http_connection::on_assign_bandwidth(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("http_connection::on_assign_bandwidth");
|
||||||
complete_async("http_connection::on_assign_bandwidth");
|
|
||||||
#endif
|
|
||||||
if ((e == boost::asio::error::operation_aborted
|
if ((e == boost::asio::error::operation_aborted
|
||||||
&& m_limiter_timer_active)
|
&& m_limiter_timer_active)
|
||||||
|| !m_sock.is_open())
|
|| !m_sock.is_open())
|
||||||
|
@ -916,9 +875,7 @@ void http_connection::on_assign_bandwidth(error_code const& e)
|
||||||
|
|
||||||
if (!m_sock.is_open()) return;
|
if (!m_sock.is_open()) return;
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_read");
|
||||||
add_outstanding_async("http_connection::on_read");
|
|
||||||
#endif
|
|
||||||
m_sock.async_read_some(boost::asio::buffer(&m_recvbuffer[0] + m_read_pos
|
m_sock.async_read_some(boost::asio::buffer(&m_recvbuffer[0] + m_read_pos
|
||||||
, amount_to_read)
|
, amount_to_read)
|
||||||
, boost::bind(&http_connection::on_read
|
, boost::bind(&http_connection::on_read
|
||||||
|
@ -927,9 +884,7 @@ void http_connection::on_assign_bandwidth(error_code const& e)
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_limiter_timer_active = true;
|
m_limiter_timer_active = true;
|
||||||
m_limiter_timer.expires_from_now(milliseconds(250), ec);
|
m_limiter_timer.expires_from_now(milliseconds(250), ec);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_assign_bandwidth");
|
||||||
add_outstanding_async("http_connection::on_assign_bandwidth");
|
|
||||||
#endif
|
|
||||||
m_limiter_timer.async_wait(boost::bind(&http_connection::on_assign_bandwidth
|
m_limiter_timer.async_wait(boost::bind(&http_connection::on_assign_bandwidth
|
||||||
, shared_from_this(), _1));
|
, shared_from_this(), _1));
|
||||||
}
|
}
|
||||||
|
@ -943,9 +898,7 @@ void http_connection::rate_limit(int limit)
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_limiter_timer_active = true;
|
m_limiter_timer_active = true;
|
||||||
m_limiter_timer.expires_from_now(milliseconds(250), ec);
|
m_limiter_timer.expires_from_now(milliseconds(250), ec);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("http_connection::on_assign_bandwidth");
|
||||||
add_outstanding_async("http_connection::on_assign_bandwidth");
|
|
||||||
#endif
|
|
||||||
m_limiter_timer.async_wait(boost::bind(&http_connection::on_assign_bandwidth
|
m_limiter_timer.async_wait(boost::bind(&http_connection::on_assign_bandwidth
|
||||||
, shared_from_this(), _1));
|
, shared_from_this(), _1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,9 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
@ -140,18 +138,14 @@ namespace libtorrent
|
||||||
m_sam_socket->set_command(i2p_stream::cmd_create_session);
|
m_sam_socket->set_command(i2p_stream::cmd_create_session);
|
||||||
m_sam_socket->set_session_id(m_session_id.c_str());
|
m_sam_socket->set_session_id(m_session_id.c_str());
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("i2p_stream::on_sam_connect");
|
||||||
add_outstanding_async("i2p_stream::on_sam_connect");
|
|
||||||
#endif
|
|
||||||
m_sam_socket->async_connect(tcp::endpoint()
|
m_sam_socket->async_connect(tcp::endpoint()
|
||||||
, boost::bind(&i2p_connection::on_sam_connect, this, _1, handler, m_sam_socket));
|
, boost::bind(&i2p_connection::on_sam_connect, this, _1, handler, m_sam_socket));
|
||||||
}
|
}
|
||||||
|
|
||||||
void i2p_connection::on_sam_connect(error_code const& ec, i2p_stream::handler_type const& h, boost::shared_ptr<i2p_stream>)
|
void i2p_connection::on_sam_connect(error_code const& ec, i2p_stream::handler_type const& h, boost::shared_ptr<i2p_stream>)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("i2p_stream::on_sam_connect");
|
||||||
complete_async("i2p_stream::on_sam_connect");
|
|
||||||
#endif
|
|
||||||
m_state = sam_idle;
|
m_state = sam_idle;
|
||||||
|
|
||||||
if (ec)
|
if (ec)
|
||||||
|
@ -247,9 +241,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("i2p_stream::connected");
|
||||||
add_outstanding_async("i2p_stream::connected");
|
|
||||||
#endif
|
|
||||||
m_sock.async_connect(i->endpoint(), boost::bind(
|
m_sock.async_connect(i->endpoint(), boost::bind(
|
||||||
&i2p_stream::connected, this, _1, h));
|
&i2p_stream::connected, this, _1, h));
|
||||||
}
|
}
|
||||||
|
@ -257,18 +249,14 @@ namespace libtorrent
|
||||||
void i2p_stream::connected(error_code const& e, boost::shared_ptr<handler_type> h)
|
void i2p_stream::connected(error_code const& e, boost::shared_ptr<handler_type> h)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_magic == 0x1337);
|
TORRENT_ASSERT(m_magic == 0x1337);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("i2p_stream::connected");
|
||||||
complete_async("i2p_stream::connected");
|
|
||||||
#endif
|
|
||||||
if (handle_error(e, h)) return;
|
if (handle_error(e, h)) return;
|
||||||
|
|
||||||
// send hello command
|
// send hello command
|
||||||
m_state = read_hello_response;
|
m_state = read_hello_response;
|
||||||
static const char cmd[] = "HELLO VERSION MIN=3.0 MAX=3.0\n";
|
static const char cmd[] = "HELLO VERSION MIN=3.0 MAX=3.0\n";
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("i2p_stream::start_read_line");
|
||||||
add_outstanding_async("i2p_stream::start_read_line");
|
|
||||||
#endif
|
|
||||||
async_write(m_sock, boost::asio::buffer(cmd, sizeof(cmd) - 1)
|
async_write(m_sock, boost::asio::buffer(cmd, sizeof(cmd) - 1)
|
||||||
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
|
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
|
||||||
// fprintf(stderr, ">>> %s", cmd);
|
// fprintf(stderr, ">>> %s", cmd);
|
||||||
|
@ -277,14 +265,10 @@ namespace libtorrent
|
||||||
void i2p_stream::start_read_line(error_code const& e, boost::shared_ptr<handler_type> h)
|
void i2p_stream::start_read_line(error_code const& e, boost::shared_ptr<handler_type> h)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_magic == 0x1337);
|
TORRENT_ASSERT(m_magic == 0x1337);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("i2p_stream::start_read_line");
|
||||||
complete_async("i2p_stream::start_read_line");
|
|
||||||
#endif
|
|
||||||
if (handle_error(e, h)) return;
|
if (handle_error(e, h)) return;
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("i2p_stream::read_line");
|
||||||
add_outstanding_async("i2p_stream::read_line");
|
|
||||||
#endif
|
|
||||||
m_buffer.resize(1);
|
m_buffer.resize(1);
|
||||||
async_read(m_sock, boost::asio::buffer(m_buffer)
|
async_read(m_sock, boost::asio::buffer(m_buffer)
|
||||||
, boost::bind(&i2p_stream::read_line, this, _1, h));
|
, boost::bind(&i2p_stream::read_line, this, _1, h));
|
||||||
|
@ -293,9 +277,7 @@ namespace libtorrent
|
||||||
void i2p_stream::read_line(error_code const& e, boost::shared_ptr<handler_type> h)
|
void i2p_stream::read_line(error_code const& e, boost::shared_ptr<handler_type> h)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_magic == 0x1337);
|
TORRENT_ASSERT(m_magic == 0x1337);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("i2p_stream::read_line");
|
||||||
complete_async("i2p_stream::read_line");
|
|
||||||
#endif
|
|
||||||
if (handle_error(e, h)) return;
|
if (handle_error(e, h)) return;
|
||||||
|
|
||||||
int read_pos = m_buffer.size();
|
int read_pos = m_buffer.size();
|
||||||
|
@ -303,9 +285,7 @@ namespace libtorrent
|
||||||
// look for \n which means end of the response
|
// look for \n which means end of the response
|
||||||
if (m_buffer[read_pos - 1] != '\n')
|
if (m_buffer[read_pos - 1] != '\n')
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("i2p_stream::read_line");
|
||||||
add_outstanding_async("i2p_stream::read_line");
|
|
||||||
#endif
|
|
||||||
// read another byte from the socket
|
// read another byte from the socket
|
||||||
m_buffer.resize(read_pos + 1);
|
m_buffer.resize(read_pos + 1);
|
||||||
async_read(m_sock, boost::asio::buffer(&m_buffer[read_pos], 1)
|
async_read(m_sock, boost::asio::buffer(&m_buffer[read_pos], 1)
|
||||||
|
@ -459,9 +439,7 @@ namespace libtorrent
|
||||||
// the destination of the remote peer
|
// the destination of the remote peer
|
||||||
m_command = cmd_incoming;
|
m_command = cmd_incoming;
|
||||||
m_buffer.resize(1);
|
m_buffer.resize(1);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("i2p_stream::read_line");
|
||||||
add_outstanding_async("i2p_stream::read_line");
|
|
||||||
#endif
|
|
||||||
async_read(m_sock, boost::asio::buffer(m_buffer)
|
async_read(m_sock, boost::asio::buffer(m_buffer)
|
||||||
, boost::bind(&i2p_stream::read_line, this, _1, h));
|
, boost::bind(&i2p_stream::read_line, this, _1, h));
|
||||||
break;
|
break;
|
||||||
|
@ -478,9 +456,7 @@ namespace libtorrent
|
||||||
int size = snprintf(cmd, sizeof(cmd), "STREAM CONNECT ID=%s DESTINATION=%s\n"
|
int size = snprintf(cmd, sizeof(cmd), "STREAM CONNECT ID=%s DESTINATION=%s\n"
|
||||||
, m_id, m_dest.c_str());
|
, m_id, m_dest.c_str());
|
||||||
// fprintf(stderr, ">>> %s", cmd);
|
// fprintf(stderr, ">>> %s", cmd);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("i2p_stream::start_read_line");
|
||||||
add_outstanding_async("i2p_stream::start_read_line");
|
|
||||||
#endif
|
|
||||||
async_write(m_sock, boost::asio::buffer(cmd, size)
|
async_write(m_sock, boost::asio::buffer(cmd, size)
|
||||||
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
|
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
|
||||||
}
|
}
|
||||||
|
@ -492,9 +468,7 @@ namespace libtorrent
|
||||||
char cmd[400];
|
char cmd[400];
|
||||||
int size = snprintf(cmd, sizeof(cmd), "STREAM ACCEPT ID=%s\n", m_id);
|
int size = snprintf(cmd, sizeof(cmd), "STREAM ACCEPT ID=%s\n", m_id);
|
||||||
// fprintf(stderr, ">>> %s", cmd);
|
// fprintf(stderr, ">>> %s", cmd);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("i2p_stream::start_read_line");
|
||||||
add_outstanding_async("i2p_stream::start_read_line");
|
|
||||||
#endif
|
|
||||||
async_write(m_sock, boost::asio::buffer(cmd, size)
|
async_write(m_sock, boost::asio::buffer(cmd, size)
|
||||||
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
|
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
|
||||||
}
|
}
|
||||||
|
@ -507,9 +481,7 @@ namespace libtorrent
|
||||||
int size = snprintf(cmd, sizeof(cmd), "SESSION CREATE STYLE=STREAM ID=%s DESTINATION=TRANSIENT\n"
|
int size = snprintf(cmd, sizeof(cmd), "SESSION CREATE STYLE=STREAM ID=%s DESTINATION=TRANSIENT\n"
|
||||||
, m_id);
|
, m_id);
|
||||||
// fprintf(stderr, ">>> %s", cmd);
|
// fprintf(stderr, ">>> %s", cmd);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("i2p_stream::start_read_line");
|
||||||
add_outstanding_async("i2p_stream::start_read_line");
|
|
||||||
#endif
|
|
||||||
async_write(m_sock, boost::asio::buffer(cmd, size)
|
async_write(m_sock, boost::asio::buffer(cmd, size)
|
||||||
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
|
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
|
||||||
}
|
}
|
||||||
|
@ -521,9 +493,7 @@ namespace libtorrent
|
||||||
char cmd[1024];
|
char cmd[1024];
|
||||||
int size = snprintf(cmd, sizeof(cmd), "NAMING LOOKUP NAME=%s\n", m_name_lookup.c_str());
|
int size = snprintf(cmd, sizeof(cmd), "NAMING LOOKUP NAME=%s\n", m_name_lookup.c_str());
|
||||||
// fprintf(stderr, ">>> %s", cmd);
|
// fprintf(stderr, ">>> %s", cmd);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("i2p_stream::start_read_line");
|
||||||
add_outstanding_async("i2p_stream::start_read_line");
|
|
||||||
#endif
|
|
||||||
async_write(m_sock, boost::asio::buffer(cmd, size)
|
async_write(m_sock, boost::asio::buffer(cmd, size)
|
||||||
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
|
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
|
||||||
}
|
}
|
||||||
|
|
11
src/lsd.cpp
11
src/lsd.cpp
|
@ -37,10 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/random.hpp"
|
#include "libtorrent/random.hpp"
|
||||||
#include "libtorrent/http_parser.hpp"
|
#include "libtorrent/http_parser.hpp"
|
||||||
#include "libtorrent/socket_io.hpp" // for print_address
|
#include "libtorrent/socket_io.hpp" // for print_address
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
|
@ -187,9 +184,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast
|
||||||
if (m_disabled) return;
|
if (m_disabled) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("lsd::resend_announce");
|
||||||
add_outstanding_async("lsd::resend_announce");
|
|
||||||
#endif
|
|
||||||
m_broadcast_timer.expires_from_now(seconds(2 * retry_count), ec);
|
m_broadcast_timer.expires_from_now(seconds(2 * retry_count), ec);
|
||||||
m_broadcast_timer.async_wait(boost::bind(&lsd::resend_announce, self(), _1
|
m_broadcast_timer.async_wait(boost::bind(&lsd::resend_announce, self(), _1
|
||||||
, ih, listen_port, retry_count));
|
, ih, listen_port, retry_count));
|
||||||
|
@ -198,9 +193,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast
|
||||||
void lsd::resend_announce(error_code const& e, sha1_hash const& info_hash
|
void lsd::resend_announce(error_code const& e, sha1_hash const& info_hash
|
||||||
, int listen_port, int retry_count)
|
, int listen_port, int retry_count)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("lsd::resend_announce");
|
||||||
complete_async("lsd::resend_announce");
|
|
||||||
#endif
|
|
||||||
if (e) return;
|
if (e) return;
|
||||||
|
|
||||||
announce_impl(info_hash, listen_port, false, retry_count);
|
announce_impl(info_hash, listen_port, false, retry_count);
|
||||||
|
|
|
@ -39,6 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
#include <boost/asio/ip/host_name.hpp>
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
|
||||||
|
@ -49,19 +50,15 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/socket_io.hpp"
|
#include "libtorrent/socket_io.hpp"
|
||||||
#include "libtorrent/io_service.hpp"
|
#include "libtorrent/io_service.hpp"
|
||||||
#include "libtorrent/aux_/time.hpp"
|
#include "libtorrent/aux_/time.hpp"
|
||||||
|
#include "libtorrent/debug.hpp"
|
||||||
#include "libtorrent/aux_/escape_string.hpp"
|
#include "libtorrent/aux_/escape_string.hpp"
|
||||||
|
|
||||||
#include <boost/asio/ip/host_name.hpp>
|
|
||||||
|
|
||||||
//#define NATPMP_LOG
|
//#define NATPMP_LOG
|
||||||
|
|
||||||
#ifdef NATPMP_LOG
|
#ifdef NATPMP_LOG
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
|
||||||
#include "libtorrent/debug.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
|
@ -124,9 +121,7 @@ void natpmp::start()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("natpmp::on_reply");
|
||||||
add_outstanding_async("natpmp::on_reply");
|
|
||||||
#endif
|
|
||||||
m_socket.async_receive_from(boost::asio::buffer(&m_response_buffer, 16)
|
m_socket.async_receive_from(boost::asio::buffer(&m_response_buffer, 16)
|
||||||
, m_remote, boost::bind(&natpmp::on_reply, self(), _1, _2));
|
, m_remote, boost::bind(&natpmp::on_reply, self(), _1, _2));
|
||||||
send_get_ip_address_request(l);
|
send_get_ip_address_request(l);
|
||||||
|
@ -376,9 +371,7 @@ void natpmp::send_map_request(int i, mutex::scoped_lock& l)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("natpmp::resend_request");
|
||||||
add_outstanding_async("natpmp::resend_request");
|
|
||||||
#endif
|
|
||||||
// linear back-off instead of exponential
|
// linear back-off instead of exponential
|
||||||
++m_retry_count;
|
++m_retry_count;
|
||||||
m_send_timer.expires_from_now(milliseconds(250 * m_retry_count), ec);
|
m_send_timer.expires_from_now(milliseconds(250 * m_retry_count), ec);
|
||||||
|
@ -388,9 +381,7 @@ void natpmp::send_map_request(int i, mutex::scoped_lock& l)
|
||||||
|
|
||||||
void natpmp::resend_request(int i, error_code const& e)
|
void natpmp::resend_request(int i, error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("natpmp::resend_request");
|
||||||
complete_async("natpmp::resend_request");
|
|
||||||
#endif
|
|
||||||
if (e) return;
|
if (e) return;
|
||||||
mutex::scoped_lock l(m_mutex);
|
mutex::scoped_lock l(m_mutex);
|
||||||
if (m_currently_mapping != i) return;
|
if (m_currently_mapping != i) return;
|
||||||
|
@ -414,9 +405,7 @@ void natpmp::on_reply(error_code const& e
|
||||||
{
|
{
|
||||||
mutex::scoped_lock l(m_mutex);
|
mutex::scoped_lock l(m_mutex);
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("natpmp::on_reply");
|
||||||
complete_async("natpmp::on_reply");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace libtorrent::detail;
|
using namespace libtorrent::detail;
|
||||||
if (e)
|
if (e)
|
||||||
|
@ -428,9 +417,7 @@ void natpmp::on_reply(error_code const& e
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("natpmp::on_reply");
|
||||||
add_outstanding_async("natpmp::on_reply");
|
|
||||||
#endif
|
|
||||||
// make a copy of the response packet buffer
|
// make a copy of the response packet buffer
|
||||||
// to avoid overwriting it in the next receive call
|
// to avoid overwriting it in the next receive call
|
||||||
char msg_buf[16];
|
char msg_buf[16];
|
||||||
|
@ -645,9 +632,7 @@ void natpmp::update_expiration_timer(mutex::scoped_lock& l)
|
||||||
error_code ec;
|
error_code ec;
|
||||||
if (m_next_refresh >= 0) m_refresh_timer.cancel(ec);
|
if (m_next_refresh >= 0) m_refresh_timer.cancel(ec);
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("natpmp::mapping_expired");
|
||||||
add_outstanding_async("natpmp::mapping_expired");
|
|
||||||
#endif
|
|
||||||
m_refresh_timer.expires_from_now(min_expire - now, ec);
|
m_refresh_timer.expires_from_now(min_expire - now, ec);
|
||||||
m_refresh_timer.async_wait(boost::bind(&natpmp::mapping_expired, self(), _1, min_index));
|
m_refresh_timer.async_wait(boost::bind(&natpmp::mapping_expired, self(), _1, min_index));
|
||||||
m_next_refresh = min_index;
|
m_next_refresh = min_index;
|
||||||
|
@ -656,9 +641,7 @@ void natpmp::update_expiration_timer(mutex::scoped_lock& l)
|
||||||
|
|
||||||
void natpmp::mapping_expired(error_code const& e, int i)
|
void natpmp::mapping_expired(error_code const& e, int i)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("natpmp::mapping_expired");
|
||||||
complete_async("natpmp::mapping_expired");
|
|
||||||
#endif
|
|
||||||
if (e) return;
|
if (e) return;
|
||||||
mutex::scoped_lock l(m_mutex);
|
mutex::scoped_lock l(m_mutex);
|
||||||
char msg[200];
|
char msg[200];
|
||||||
|
|
|
@ -400,9 +400,7 @@ namespace libtorrent
|
||||||
peer_log(peer_log_alert::outgoing, "ASYNC_CONNECT", "dst: %s"
|
peer_log(peer_log_alert::outgoing, "ASYNC_CONNECT", "dst: %s"
|
||||||
, print_endpoint(m_remote).c_str());
|
, print_endpoint(m_remote).c_str());
|
||||||
#endif
|
#endif
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("peer_connection::on_connection_complete");
|
||||||
add_outstanding_async("peer_connection::on_connection_complete");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
if (t)
|
if (t)
|
||||||
|
@ -5670,9 +5668,7 @@ namespace libtorrent
|
||||||
peer_log(peer_log_alert::outgoing, "ASYNC_WRITE", "bytes: %d", amount_to_send);
|
peer_log(peer_log_alert::outgoing, "ASYNC_WRITE", "bytes: %d", amount_to_send);
|
||||||
#endif
|
#endif
|
||||||
std::vector<boost::asio::const_buffer> const& vec = m_send_buffer.build_iovec(amount_to_send);
|
std::vector<boost::asio::const_buffer> const& vec = m_send_buffer.build_iovec(amount_to_send);
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("peer_connection::on_send_data");
|
||||||
add_outstanding_async("peer_connection::on_send_data");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
TORRENT_ASSERT(!m_socket_is_writing);
|
TORRENT_ASSERT(!m_socket_is_writing);
|
||||||
|
@ -5790,9 +5786,7 @@ namespace libtorrent
|
||||||
peer_log(peer_log_alert::incoming, "ASYNC_READ");
|
peer_log(peer_log_alert::incoming, "ASYNC_READ");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("peer_connection::on_receive_data_nb");
|
||||||
add_outstanding_async("peer_connection::on_receive_data_nb");
|
|
||||||
#endif
|
|
||||||
m_socket->async_read_some(null_buffers(), make_read_handler(
|
m_socket->async_read_some(null_buffers(), make_read_handler(
|
||||||
boost::bind(&peer_connection::on_receive_data_nb, self(), _1, _2)));
|
boost::bind(&peer_connection::on_receive_data_nb, self(), _1, _2)));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -5822,9 +5816,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// utp sockets aren't thread safe...
|
// utp sockets aren't thread safe...
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("peer_connection::on_receive_data");
|
||||||
add_outstanding_async("peer_connection::on_receive_data");
|
|
||||||
#endif
|
|
||||||
if (is_utp(*m_socket))
|
if (is_utp(*m_socket))
|
||||||
{
|
{
|
||||||
if (num_bufs == 1)
|
if (num_bufs == 1)
|
||||||
|
@ -5977,9 +5969,7 @@ namespace libtorrent
|
||||||
, std::size_t bytes_transferred)
|
, std::size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("peer_connection::on_receive_data_nb");
|
||||||
complete_async("peer_connection::on_receive_data_nb");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// leave this bit set until we're done looping, reading from the socket.
|
// leave this bit set until we're done looping, reading from the socket.
|
||||||
// that way we don't trigger any async read calls until the end of this
|
// that way we don't trigger any async read calls until the end of this
|
||||||
|
@ -6073,9 +6063,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("peer_connection::on_receive_data");
|
||||||
add_outstanding_async("peer_connection::on_receive_data");
|
|
||||||
#endif
|
|
||||||
socket_job j;
|
socket_job j;
|
||||||
j.type = socket_job::read_job;
|
j.type = socket_job::read_job;
|
||||||
j.recv_buf = boost::asio::buffer_cast<char*>(buffer);
|
j.recv_buf = boost::asio::buffer_cast<char*>(buffer);
|
||||||
|
@ -6103,9 +6091,7 @@ namespace libtorrent
|
||||||
, std::size_t bytes_transferred)
|
, std::size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("peer_connection::on_receive_data");
|
||||||
complete_async("peer_connection::on_receive_data");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// leave this bit set until we're done looping, reading from the socket.
|
// leave this bit set until we're done looping, reading from the socket.
|
||||||
// that way we don't trigger any async read calls until the end of this
|
// that way we don't trigger any async read calls until the end of this
|
||||||
|
@ -6294,9 +6280,7 @@ namespace libtorrent
|
||||||
void peer_connection::on_connection_complete(error_code const& e)
|
void peer_connection::on_connection_complete(error_code const& e)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("peer_connection::on_connection_complete");
|
||||||
complete_async("peer_connection::on_connection_complete");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined TORRENT_DISABLE_LOGGING || defined TORRENT_USE_OPENSSL
|
#if !defined TORRENT_DISABLE_LOGGING || defined TORRENT_USE_OPENSSL
|
||||||
time_point completed = clock_type::now();
|
time_point completed = clock_type::now();
|
||||||
|
@ -6471,9 +6455,7 @@ namespace libtorrent
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("peer_connection::on_send_data");
|
||||||
complete_async("peer_connection::on_send_data");
|
|
||||||
#endif
|
|
||||||
// keep ourselves alive in until this function exits in
|
// keep ourselves alive in until this function exits in
|
||||||
// case we disconnect
|
// case we disconnect
|
||||||
boost::shared_ptr<peer_connection> me(self());
|
boost::shared_ptr<peer_connection> me(self());
|
||||||
|
|
|
@ -48,9 +48,7 @@ namespace libtorrent
|
||||||
void resolver::on_lookup(error_code const& ec, tcp::resolver::iterator i
|
void resolver::on_lookup(error_code const& ec, tcp::resolver::iterator i
|
||||||
, resolver_interface::callback_t h, std::string hostname)
|
, resolver_interface::callback_t h, std::string hostname)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("resolver::on_lookup");
|
||||||
complete_async("resolver::on_lookup");
|
|
||||||
#endif
|
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
std::vector<address> empty;
|
std::vector<address> empty;
|
||||||
|
@ -118,9 +116,7 @@ namespace libtorrent
|
||||||
// the port is ignored
|
// the port is ignored
|
||||||
tcp::resolver::query q(host, "80");
|
tcp::resolver::query q(host, "80");
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("resolver::on_lookup");
|
||||||
add_outstanding_async("resolver::on_lookup");
|
|
||||||
#endif
|
|
||||||
if (flags & resolver_interface::abort_on_shutdown)
|
if (flags & resolver_interface::abort_on_shutdown)
|
||||||
{
|
{
|
||||||
m_resolver.async_resolve(q, boost::bind(&resolver::on_lookup, this, _1, _2
|
m_resolver.async_resolve(q, boost::bind(&resolver::on_lookup, this, _1, _2
|
||||||
|
|
|
@ -588,9 +588,7 @@ namespace aux {
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_io_service.post(boost::bind(&session_impl::on_tick, this, ec));
|
m_io_service.post(boost::bind(&session_impl::on_tick, this, ec));
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::on_lsd_announce");
|
||||||
add_outstanding_async("session_impl::on_lsd_announce");
|
|
||||||
#endif
|
|
||||||
int delay = (std::max)(m_settings.get_int(settings_pack::local_service_announce_interval)
|
int delay = (std::max)(m_settings.get_int(settings_pack::local_service_announce_interval)
|
||||||
/ (std::max)(int(m_torrents.size()), 1), 1);
|
/ (std::max)(int(m_torrents.size()), 1), 1);
|
||||||
m_lsd_announce_timer.expires_from_now(seconds(delay), ec);
|
m_lsd_announce_timer.expires_from_now(seconds(delay), ec);
|
||||||
|
@ -2204,9 +2202,7 @@ namespace aux {
|
||||||
TORRENT_ASSERT_VAL(ret, ret);
|
TORRENT_ASSERT_VAL(ret, ret);
|
||||||
TORRENT_UNUSED(ret);
|
TORRENT_UNUSED(ret);
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::on_socks_accept");
|
||||||
add_outstanding_async("session_impl::on_socks_accept");
|
|
||||||
#endif
|
|
||||||
socks5_stream& s = *m_socks_listen_socket->get<socks5_stream>();
|
socks5_stream& s = *m_socks_listen_socket->get<socks5_stream>();
|
||||||
s.set_command(2); // 2 means BIND (as opposed to CONNECT)
|
s.set_command(2); // 2 means BIND (as opposed to CONNECT)
|
||||||
m_socks_listen_port = 2000 + random() % 60000;
|
m_socks_listen_port = 2000 + random() % 60000;
|
||||||
|
@ -2276,9 +2272,7 @@ namespace aux {
|
||||||
TORRENT_ASSERT_VAL(ret, ret);
|
TORRENT_ASSERT_VAL(ret, ret);
|
||||||
TORRENT_UNUSED(ret);
|
TORRENT_UNUSED(ret);
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::on_i2p_accept");
|
||||||
add_outstanding_async("session_impl::on_i2p_accept");
|
|
||||||
#endif
|
|
||||||
i2p_stream& s = *m_i2p_listen_socket->get<i2p_stream>();
|
i2p_stream& s = *m_i2p_listen_socket->get<i2p_stream>();
|
||||||
s.set_command(i2p_stream::cmd_accept);
|
s.set_command(i2p_stream::cmd_accept);
|
||||||
s.set_session_id(m_i2p_conn.session_id());
|
s.set_session_id(m_i2p_conn.session_id());
|
||||||
|
@ -2290,9 +2284,7 @@ namespace aux {
|
||||||
void session_impl::on_i2p_accept(boost::shared_ptr<socket_type> const& s
|
void session_impl::on_i2p_accept(boost::shared_ptr<socket_type> const& s
|
||||||
, error_code const& e)
|
, error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("session_impl::on_i2p_accept");
|
||||||
complete_async("session_impl::on_i2p_accept");
|
|
||||||
#endif
|
|
||||||
m_i2p_listen_socket.reset();
|
m_i2p_listen_socket.reset();
|
||||||
if (e == boost::asio::error::operation_aborted) return;
|
if (e == boost::asio::error::operation_aborted) return;
|
||||||
if (e)
|
if (e)
|
||||||
|
@ -2356,9 +2348,7 @@ namespace aux {
|
||||||
str = c->get<tcp::socket>();
|
str = c->get<tcp::socket>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::on_accept_connection");
|
||||||
add_outstanding_async("session_impl::on_accept_connection");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TORRENT_USE_OPENSSL
|
#ifdef TORRENT_USE_OPENSSL
|
||||||
TORRENT_ASSERT(ssl == is_ssl(*c));
|
TORRENT_ASSERT(ssl == is_ssl(*c));
|
||||||
|
@ -2372,9 +2362,7 @@ namespace aux {
|
||||||
void session_impl::on_accept_connection(shared_ptr<socket_type> const& s
|
void session_impl::on_accept_connection(shared_ptr<socket_type> const& s
|
||||||
, weak_ptr<tcp::acceptor> listen_socket, error_code const& e, bool ssl)
|
, weak_ptr<tcp::acceptor> listen_socket, error_code const& e, bool ssl)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("session_impl::on_accept_connection");
|
||||||
complete_async("session_impl::on_accept_connection");
|
|
||||||
#endif
|
|
||||||
m_stats_counters.inc_stats_counter(counters::on_accept_counter);
|
m_stats_counters.inc_stats_counter(counters::on_accept_counter);
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
boost::shared_ptr<tcp::acceptor> listener = listen_socket.lock();
|
boost::shared_ptr<tcp::acceptor> listener = listen_socket.lock();
|
||||||
|
@ -2455,9 +2443,7 @@ namespace aux {
|
||||||
|
|
||||||
// for SSL connections, incoming_connection() is called
|
// for SSL connections, incoming_connection() is called
|
||||||
// after the handshake is done
|
// after the handshake is done
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::ssl_handshake");
|
||||||
add_outstanding_async("session_impl::ssl_handshake");
|
|
||||||
#endif
|
|
||||||
s->get<ssl_stream<tcp::socket> >()->async_accept_handshake(
|
s->get<ssl_stream<tcp::socket> >()->async_accept_handshake(
|
||||||
boost::bind(&session_impl::ssl_handshake, this, _1, s));
|
boost::bind(&session_impl::ssl_handshake, this, _1, s));
|
||||||
m_incoming_sockets.insert(s);
|
m_incoming_sockets.insert(s);
|
||||||
|
@ -2477,9 +2463,7 @@ namespace aux {
|
||||||
|
|
||||||
// for SSL connections, incoming_connection() is called
|
// for SSL connections, incoming_connection() is called
|
||||||
// after the handshake is done
|
// after the handshake is done
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::ssl_handshake");
|
||||||
add_outstanding_async("session_impl::ssl_handshake");
|
|
||||||
#endif
|
|
||||||
s->get<ssl_stream<utp_stream> >()->async_accept_handshake(
|
s->get<ssl_stream<utp_stream> >()->async_accept_handshake(
|
||||||
boost::bind(&session_impl::ssl_handshake, this, _1, s));
|
boost::bind(&session_impl::ssl_handshake, this, _1, s));
|
||||||
m_incoming_sockets.insert(s);
|
m_incoming_sockets.insert(s);
|
||||||
|
@ -2493,9 +2477,7 @@ namespace aux {
|
||||||
|
|
||||||
void session_impl::ssl_handshake(error_code const& ec, boost::shared_ptr<socket_type> s)
|
void session_impl::ssl_handshake(error_code const& ec, boost::shared_ptr<socket_type> s)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("session_impl::ssl_handshake");
|
||||||
complete_async("session_impl::ssl_handshake");
|
|
||||||
#endif
|
|
||||||
TORRENT_ASSERT(is_ssl(*s));
|
TORRENT_ASSERT(is_ssl(*s));
|
||||||
|
|
||||||
m_incoming_sockets.erase(s);
|
m_incoming_sockets.erase(s);
|
||||||
|
@ -2769,9 +2751,7 @@ namespace aux {
|
||||||
void session_impl::on_socks_accept(boost::shared_ptr<socket_type> const& s
|
void session_impl::on_socks_accept(boost::shared_ptr<socket_type> const& s
|
||||||
, error_code const& e)
|
, error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("session_impl::on_socks_accept");
|
||||||
complete_async("session_impl::on_socks_accept");
|
|
||||||
#endif
|
|
||||||
m_socks_listen_socket.reset();
|
m_socks_listen_socket.reset();
|
||||||
if (e == boost::asio::error::operation_aborted) return;
|
if (e == boost::asio::error::operation_aborted) return;
|
||||||
if (e)
|
if (e)
|
||||||
|
@ -2953,9 +2933,7 @@ namespace aux {
|
||||||
|
|
||||||
void session_impl::on_tick(error_code const& e)
|
void session_impl::on_tick(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("session_impl::on_tick");
|
||||||
complete_async("session_impl::on_tick");
|
|
||||||
#endif
|
|
||||||
m_stats_counters.inc_stats_counter(counters::on_tick_counter);
|
m_stats_counters.inc_stats_counter(counters::on_tick_counter);
|
||||||
|
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
@ -3012,9 +2990,7 @@ namespace aux {
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::on_tick");
|
||||||
add_outstanding_async("session_impl::on_tick");
|
|
||||||
#endif
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_timer.expires_at(now + milliseconds(m_settings.get_int(settings_pack::tick_interval)), ec);
|
m_timer.expires_at(now + milliseconds(m_settings.get_int(settings_pack::tick_interval)), ec);
|
||||||
m_timer.async_wait(make_tick_handler(boost::bind(&session_impl::on_tick, this, _1)));
|
m_timer.async_wait(make_tick_handler(boost::bind(&session_impl::on_tick, this, _1)));
|
||||||
|
@ -3495,9 +3471,7 @@ namespace aux {
|
||||||
// timer interval short until all torrents have been announced.
|
// timer interval short until all torrents have been announced.
|
||||||
if (m_dht_torrents.size() == 1)
|
if (m_dht_torrents.size() == 1)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::on_dht_announce");
|
||||||
add_outstanding_async("session_impl::on_dht_announce");
|
|
||||||
#endif
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_dht_announce_timer.expires_from_now(seconds(0), ec);
|
m_dht_announce_timer.expires_from_now(seconds(0), ec);
|
||||||
m_dht_announce_timer.async_wait(
|
m_dht_announce_timer.async_wait(
|
||||||
|
@ -3507,9 +3481,7 @@ namespace aux {
|
||||||
|
|
||||||
void session_impl::on_dht_announce(error_code const& e)
|
void session_impl::on_dht_announce(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("session_impl::on_dht_announce");
|
||||||
complete_async("session_impl::on_dht_announce");
|
|
||||||
#endif
|
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
|
@ -3548,9 +3520,7 @@ namespace aux {
|
||||||
delay = (std::min)(4, delay);
|
delay = (std::min)(4, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::on_dht_announce");
|
||||||
add_outstanding_async("session_impl::on_dht_announce");
|
|
||||||
#endif
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_dht_announce_timer.expires_from_now(seconds(delay), ec);
|
m_dht_announce_timer.expires_from_now(seconds(delay), ec);
|
||||||
m_dht_announce_timer.async_wait(
|
m_dht_announce_timer.async_wait(
|
||||||
|
@ -3586,18 +3556,14 @@ namespace aux {
|
||||||
|
|
||||||
void session_impl::on_lsd_announce(error_code const& e)
|
void session_impl::on_lsd_announce(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("session_impl::on_lsd_announce");
|
||||||
complete_async("session_impl::on_lsd_announce");
|
|
||||||
#endif
|
|
||||||
m_stats_counters.inc_stats_counter(counters::on_lsd_counter);
|
m_stats_counters.inc_stats_counter(counters::on_lsd_counter);
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
if (e) return;
|
if (e) return;
|
||||||
|
|
||||||
if (m_abort) return;
|
if (m_abort) return;
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::on_lsd_announce");
|
||||||
add_outstanding_async("session_impl::on_lsd_announce");
|
|
||||||
#endif
|
|
||||||
// announce on local network every 5 minutes
|
// announce on local network every 5 minutes
|
||||||
int delay = (std::max)(m_settings.get_int(settings_pack::local_service_announce_interval)
|
int delay = (std::max)(m_settings.get_int(settings_pack::local_service_announce_interval)
|
||||||
/ (std::max)(int(m_torrents.size()), 1), 1);
|
/ (std::max)(int(m_torrents.size()), 1), 1);
|
||||||
|
@ -5634,9 +5600,7 @@ namespace aux {
|
||||||
|
|
||||||
void session_impl::add_dht_node_name(std::pair<std::string, int> const& node)
|
void session_impl::add_dht_node_name(std::pair<std::string, int> const& node)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::on_dht_name_lookup");
|
||||||
add_outstanding_async("session_impl::on_dht_name_lookup");
|
|
||||||
#endif
|
|
||||||
m_host_resolver.async_resolve(node.first, resolver_interface::abort_on_shutdown
|
m_host_resolver.async_resolve(node.first, resolver_interface::abort_on_shutdown
|
||||||
, boost::bind(&session_impl::on_dht_name_lookup
|
, boost::bind(&session_impl::on_dht_name_lookup
|
||||||
, this, _1, _2, node.second));
|
, this, _1, _2, node.second));
|
||||||
|
@ -5645,9 +5609,7 @@ namespace aux {
|
||||||
void session_impl::on_dht_name_lookup(error_code const& e
|
void session_impl::on_dht_name_lookup(error_code const& e
|
||||||
, std::vector<address> const& addresses, int port)
|
, std::vector<address> const& addresses, int port)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("session_impl::on_dht_name_lookup");
|
||||||
complete_async("session_impl::on_dht_name_lookup");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
|
@ -5667,9 +5629,7 @@ namespace aux {
|
||||||
|
|
||||||
void session_impl::add_dht_router(std::pair<std::string, int> const& node)
|
void session_impl::add_dht_router(std::pair<std::string, int> const& node)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::on_dht_router_name_lookup");
|
||||||
add_outstanding_async("session_impl::on_dht_router_name_lookup");
|
|
||||||
#endif
|
|
||||||
++m_outstanding_router_lookups;
|
++m_outstanding_router_lookups;
|
||||||
m_host_resolver.async_resolve(node.first, resolver_interface::abort_on_shutdown
|
m_host_resolver.async_resolve(node.first, resolver_interface::abort_on_shutdown
|
||||||
, boost::bind(&session_impl::on_dht_router_name_lookup
|
, boost::bind(&session_impl::on_dht_router_name_lookup
|
||||||
|
@ -5679,9 +5639,7 @@ namespace aux {
|
||||||
void session_impl::on_dht_router_name_lookup(error_code const& e
|
void session_impl::on_dht_router_name_lookup(error_code const& e
|
||||||
, std::vector<address> const& addresses, int port)
|
, std::vector<address> const& addresses, int port)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("session_impl::on_dht_router_name_lookup");
|
||||||
complete_async("session_impl::on_dht_router_name_lookup");
|
|
||||||
#endif
|
|
||||||
--m_outstanding_router_lookups;
|
--m_outstanding_router_lookups;
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
|
@ -6263,9 +6221,7 @@ namespace aux {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("session_impl::on_dht_announce");
|
||||||
add_outstanding_async("session_impl::on_dht_announce");
|
|
||||||
#endif
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
int delay = (std::max)(m_settings.get_int(settings_pack::dht_announce_interval)
|
int delay = (std::max)(m_settings.get_int(settings_pack::dht_announce_interval)
|
||||||
/ (std::max)(int(m_torrents.size()), 1), 1);
|
/ (std::max)(int(m_torrents.size()), 1), 1);
|
||||||
|
|
|
@ -43,9 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
@ -141,9 +139,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void on_close_socket(socket_type* s, boost::shared_ptr<void>)
|
void on_close_socket(socket_type* s, boost::shared_ptr<void>)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("on_close_socket");
|
||||||
complete_async("on_close_socket");
|
|
||||||
#endif
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
s->close(ec);
|
s->close(ec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,9 +82,7 @@ namespace libtorrent
|
||||||
void socks5_stream::name_lookup(error_code const& e, tcp::resolver::iterator i
|
void socks5_stream::name_lookup(error_code const& e, tcp::resolver::iterator i
|
||||||
, boost::shared_ptr<handler_type> h)
|
, boost::shared_ptr<handler_type> h)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("socks5_stream::name_lookup");
|
||||||
complete_async("socks5_stream::name_lookup");
|
|
||||||
#endif
|
|
||||||
if (handle_error(e, h)) return;
|
if (handle_error(e, h)) return;
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
|
@ -96,18 +94,14 @@ namespace libtorrent
|
||||||
|
|
||||||
// TOOD: we could bind the socket here, since we know what the
|
// TOOD: we could bind the socket here, since we know what the
|
||||||
// target endpoint is of the proxy
|
// target endpoint is of the proxy
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("socks5_stream::connected");
|
||||||
add_outstanding_async("socks5_stream::connected");
|
|
||||||
#endif
|
|
||||||
m_sock.async_connect(i->endpoint(), boost::bind(
|
m_sock.async_connect(i->endpoint(), boost::bind(
|
||||||
&socks5_stream::connected, this, _1, h));
|
&socks5_stream::connected, this, _1, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
void socks5_stream::connected(error_code const& e, boost::shared_ptr<handler_type> h)
|
void socks5_stream::connected(error_code const& e, boost::shared_ptr<handler_type> h)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("socks5_stream::connected");
|
||||||
complete_async("socks5_stream::connected");
|
|
||||||
#endif
|
|
||||||
if (handle_error(e, h)) return;
|
if (handle_error(e, h)) return;
|
||||||
|
|
||||||
using namespace libtorrent::detail;
|
using namespace libtorrent::detail;
|
||||||
|
@ -128,9 +122,7 @@ namespace libtorrent
|
||||||
write_uint8(0, p); // no authentication
|
write_uint8(0, p); // no authentication
|
||||||
write_uint8(2, p); // username/password
|
write_uint8(2, p); // username/password
|
||||||
}
|
}
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("socks5_stream::handshake1");
|
||||||
add_outstanding_async("socks5_stream::handshake1");
|
|
||||||
#endif
|
|
||||||
async_write(m_sock, boost::asio::buffer(m_buffer)
|
async_write(m_sock, boost::asio::buffer(m_buffer)
|
||||||
, boost::bind(&socks5_stream::handshake1, this, _1, h));
|
, boost::bind(&socks5_stream::handshake1, this, _1, h));
|
||||||
}
|
}
|
||||||
|
@ -146,14 +138,10 @@ namespace libtorrent
|
||||||
|
|
||||||
void socks5_stream::handshake1(error_code const& e, boost::shared_ptr<handler_type> h)
|
void socks5_stream::handshake1(error_code const& e, boost::shared_ptr<handler_type> h)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("socks5_stream::handshake1");
|
||||||
complete_async("socks5_stream::handshake1");
|
|
||||||
#endif
|
|
||||||
if (handle_error(e, h)) return;
|
if (handle_error(e, h)) return;
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("socks5_stream::handshake2");
|
||||||
add_outstanding_async("socks5_stream::handshake2");
|
|
||||||
#endif
|
|
||||||
m_buffer.resize(2);
|
m_buffer.resize(2);
|
||||||
async_read(m_sock, boost::asio::buffer(m_buffer)
|
async_read(m_sock, boost::asio::buffer(m_buffer)
|
||||||
, boost::bind(&socks5_stream::handshake2, this, _1, h));
|
, boost::bind(&socks5_stream::handshake2, this, _1, h));
|
||||||
|
@ -161,9 +149,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void socks5_stream::handshake2(error_code const& e, boost::shared_ptr<handler_type> h)
|
void socks5_stream::handshake2(error_code const& e, boost::shared_ptr<handler_type> h)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("socks5_stream::handshake2");
|
||||||
complete_async("socks5_stream::handshake2");
|
|
||||||
#endif
|
|
||||||
if (handle_error(e, h)) return;
|
if (handle_error(e, h)) return;
|
||||||
|
|
||||||
using namespace libtorrent::detail;
|
using namespace libtorrent::detail;
|
||||||
|
@ -201,9 +187,7 @@ namespace libtorrent
|
||||||
write_uint8(uint8_t(m_password.size()), p);
|
write_uint8(uint8_t(m_password.size()), p);
|
||||||
write_string(m_password, p);
|
write_string(m_password, p);
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("socks5_stream::handshake3");
|
||||||
add_outstanding_async("socks5_stream::handshake3");
|
|
||||||
#endif
|
|
||||||
async_write(m_sock, boost::asio::buffer(m_buffer)
|
async_write(m_sock, boost::asio::buffer(m_buffer)
|
||||||
, boost::bind(&socks5_stream::handshake3, this, _1, h));
|
, boost::bind(&socks5_stream::handshake3, this, _1, h));
|
||||||
}
|
}
|
||||||
|
@ -217,14 +201,10 @@ namespace libtorrent
|
||||||
void socks5_stream::handshake3(error_code const& e
|
void socks5_stream::handshake3(error_code const& e
|
||||||
, boost::shared_ptr<handler_type> h)
|
, boost::shared_ptr<handler_type> h)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("socks5_stream::handshake3");
|
||||||
complete_async("socks5_stream::handshake3");
|
|
||||||
#endif
|
|
||||||
if (handle_error(e, h)) return;
|
if (handle_error(e, h)) return;
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("socks5_stream::handshake4");
|
||||||
add_outstanding_async("socks5_stream::handshake4");
|
|
||||||
#endif
|
|
||||||
m_buffer.resize(2);
|
m_buffer.resize(2);
|
||||||
async_read(m_sock, boost::asio::buffer(m_buffer)
|
async_read(m_sock, boost::asio::buffer(m_buffer)
|
||||||
, boost::bind(&socks5_stream::handshake4, this, _1, h));
|
, boost::bind(&socks5_stream::handshake4, this, _1, h));
|
||||||
|
@ -233,9 +213,7 @@ namespace libtorrent
|
||||||
void socks5_stream::handshake4(error_code const& e
|
void socks5_stream::handshake4(error_code const& e
|
||||||
, boost::shared_ptr<handler_type> h)
|
, boost::shared_ptr<handler_type> h)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("socks5_stream::handshake4");
|
||||||
complete_async("socks5_stream::handshake4");
|
|
||||||
#endif
|
|
||||||
if (handle_error(e, h)) return;
|
if (handle_error(e, h)) return;
|
||||||
|
|
||||||
using namespace libtorrent::detail;
|
using namespace libtorrent::detail;
|
||||||
|
@ -317,18 +295,14 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("socks5_stream::connect1");
|
||||||
add_outstanding_async("socks5_stream::connect1");
|
|
||||||
#endif
|
|
||||||
async_write(m_sock, boost::asio::buffer(m_buffer)
|
async_write(m_sock, boost::asio::buffer(m_buffer)
|
||||||
, boost::bind(&socks5_stream::connect1, this, _1, h));
|
, boost::bind(&socks5_stream::connect1, this, _1, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
void socks5_stream::connect1(error_code const& e, boost::shared_ptr<handler_type> h)
|
void socks5_stream::connect1(error_code const& e, boost::shared_ptr<handler_type> h)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("socks5_stream::connect1");
|
||||||
complete_async("socks5_stream::connect1");
|
|
||||||
#endif
|
|
||||||
if (handle_error(e, h)) return;
|
if (handle_error(e, h)) return;
|
||||||
|
|
||||||
if (m_version == 5)
|
if (m_version == 5)
|
||||||
|
@ -336,18 +310,14 @@ namespace libtorrent
|
||||||
else if (m_version == 4)
|
else if (m_version == 4)
|
||||||
m_buffer.resize(8);
|
m_buffer.resize(8);
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("socks5_stream::connect2");
|
||||||
add_outstanding_async("socks5_stream::connect2");
|
|
||||||
#endif
|
|
||||||
async_read(m_sock, boost::asio::buffer(m_buffer)
|
async_read(m_sock, boost::asio::buffer(m_buffer)
|
||||||
, boost::bind(&socks5_stream::connect2, this, _1, h));
|
, boost::bind(&socks5_stream::connect2, this, _1, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
void socks5_stream::connect2(error_code const& e, boost::shared_ptr<handler_type> h)
|
void socks5_stream::connect2(error_code const& e, boost::shared_ptr<handler_type> h)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("socks5_stream::connect2");
|
||||||
complete_async("socks5_stream::connect2");
|
|
||||||
#endif
|
|
||||||
if (handle_error(e, h)) return;
|
if (handle_error(e, h)) return;
|
||||||
|
|
||||||
using namespace libtorrent::detail;
|
using namespace libtorrent::detail;
|
||||||
|
@ -389,9 +359,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
if (m_listen == 0)
|
if (m_listen == 0)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("socks5_stream::connect1");
|
||||||
add_outstanding_async("socks5_stream::connect1");
|
|
||||||
#endif
|
|
||||||
m_listen = 1;
|
m_listen = 1;
|
||||||
connect1(e, h);
|
connect1(e, h);
|
||||||
return;
|
return;
|
||||||
|
@ -424,9 +392,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
m_buffer.resize(m_buffer.size() + extra_bytes);
|
m_buffer.resize(m_buffer.size() + extra_bytes);
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("socks5_stream::connect3");
|
||||||
add_outstanding_async("socks5_stream::connect3");
|
|
||||||
#endif
|
|
||||||
TORRENT_ASSERT(extra_bytes > 0);
|
TORRENT_ASSERT(extra_bytes > 0);
|
||||||
async_read(m_sock, boost::asio::buffer(&m_buffer[m_buffer.size() - extra_bytes], extra_bytes)
|
async_read(m_sock, boost::asio::buffer(&m_buffer[m_buffer.size() - extra_bytes], extra_bytes)
|
||||||
, boost::bind(&socks5_stream::connect3, this, _1, h));
|
, boost::bind(&socks5_stream::connect3, this, _1, h));
|
||||||
|
@ -446,9 +412,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
if (m_listen == 0)
|
if (m_listen == 0)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("socks5_stream::connect1");
|
||||||
add_outstanding_async("socks5_stream::connect1");
|
|
||||||
#endif
|
|
||||||
m_listen = 1;
|
m_listen = 1;
|
||||||
connect1(e, h);
|
connect1(e, h);
|
||||||
return;
|
return;
|
||||||
|
@ -479,9 +443,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void socks5_stream::connect3(error_code const& e, boost::shared_ptr<handler_type> h)
|
void socks5_stream::connect3(error_code const& e, boost::shared_ptr<handler_type> h)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("socks5_stream::connect3");
|
||||||
complete_async("socks5_stream::connect3");
|
|
||||||
#endif
|
|
||||||
using namespace libtorrent::detail;
|
using namespace libtorrent::detail;
|
||||||
|
|
||||||
if (handle_error(e, h)) return;
|
if (handle_error(e, h)) return;
|
||||||
|
@ -490,9 +452,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
if (m_listen == 0)
|
if (m_listen == 0)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("socks5_stream::connect1");
|
||||||
add_outstanding_async("socks5_stream::connect1");
|
|
||||||
#endif
|
|
||||||
m_listen = 1;
|
m_listen = 1;
|
||||||
connect1(e, h);
|
connect1(e, h);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2702,9 +2702,7 @@ namespace libtorrent
|
||||||
void torrent::on_tracker_announce_disp(boost::weak_ptr<torrent> p
|
void torrent::on_tracker_announce_disp(boost::weak_ptr<torrent> p
|
||||||
, error_code const& e)
|
, error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("tracker::on_tracker_announce_disp");
|
||||||
complete_async("tracker::on_tracker_announce_disp");
|
|
||||||
#endif
|
|
||||||
boost::shared_ptr<torrent> t = p.lock();
|
boost::shared_ptr<torrent> t = p.lock();
|
||||||
if (!t) return;
|
if (!t) return;
|
||||||
t->m_waiting_tracker = false;
|
t->m_waiting_tracker = false;
|
||||||
|
@ -3324,9 +3322,7 @@ namespace libtorrent
|
||||||
// to do the name lookup
|
// to do the name lookup
|
||||||
if (boost::algorithm::ends_with(i->hostname, ".b32.i2p"))
|
if (boost::algorithm::ends_with(i->hostname, ".b32.i2p"))
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("torrent::on_i2p_resolve");
|
||||||
add_outstanding_async("torrent::on_i2p_resolve");
|
|
||||||
#endif
|
|
||||||
r.i2pconn->async_name_lookup(i->hostname.c_str()
|
r.i2pconn->async_name_lookup(i->hostname.c_str()
|
||||||
, boost::bind(&torrent::on_i2p_resolve
|
, boost::bind(&torrent::on_i2p_resolve
|
||||||
, shared_from_this(), _1, _2));
|
, shared_from_this(), _1, _2));
|
||||||
|
@ -3343,9 +3339,7 @@ namespace libtorrent
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("torrent::on_peer_name_lookup");
|
||||||
add_outstanding_async("torrent::on_peer_name_lookup");
|
|
||||||
#endif
|
|
||||||
m_ses.async_resolve(i->hostname, resolver_interface::abort_on_shutdown
|
m_ses.async_resolve(i->hostname, resolver_interface::abort_on_shutdown
|
||||||
, boost::bind(&torrent::on_peer_name_lookup
|
, boost::bind(&torrent::on_peer_name_lookup
|
||||||
, shared_from_this(), _1, _2, i->port));
|
, shared_from_this(), _1, _2, i->port));
|
||||||
|
@ -3571,9 +3565,7 @@ namespace libtorrent
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("torrent::on_i2p_resolve");
|
||||||
complete_async("torrent::on_i2p_resolve");
|
|
||||||
#endif
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
if (ec)
|
if (ec)
|
||||||
debug_log("i2p_resolve error: %s", ec.message().c_str());
|
debug_log("i2p_resolve error: %s", ec.message().c_str());
|
||||||
|
@ -3595,9 +3587,7 @@ namespace libtorrent
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("torrent::on_peer_name_lookup");
|
||||||
complete_async("torrent::on_peer_name_lookup");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
if (e)
|
if (e)
|
||||||
|
@ -9546,9 +9536,7 @@ namespace libtorrent
|
||||||
error_code ec;
|
error_code ec;
|
||||||
boost::weak_ptr<torrent> self(shared_from_this());
|
boost::weak_ptr<torrent> self(shared_from_this());
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("tracker::on_tracker_announce_disp");
|
||||||
add_outstanding_async("tracker::on_tracker_announce_disp");
|
|
||||||
#endif
|
|
||||||
m_tracker_timer.expires_at(next_announce, ec);
|
m_tracker_timer.expires_at(next_announce, ec);
|
||||||
m_tracker_timer.async_wait(boost::bind(&torrent::on_tracker_announce_disp, self, _1));
|
m_tracker_timer.async_wait(boost::bind(&torrent::on_tracker_announce_disp, self, _1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,9 +88,7 @@ namespace libtorrent
|
||||||
: (std::min)(m_completion_timeout, timeout);
|
: (std::min)(m_completion_timeout, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("timeout_handler::timeout_callback");
|
||||||
add_outstanding_async("timeout_handler::timeout_callback");
|
|
||||||
#endif
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_timeout.expires_at(m_read_time + seconds(timeout), ec);
|
m_timeout.expires_at(m_read_time + seconds(timeout), ec);
|
||||||
m_timeout.async_wait(boost::bind(
|
m_timeout.async_wait(boost::bind(
|
||||||
|
@ -112,9 +110,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void timeout_handler::timeout_callback(error_code const& error)
|
void timeout_handler::timeout_callback(error_code const& error)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("timeout_handler::timeout_callback");
|
||||||
complete_async("timeout_handler::timeout_callback");
|
|
||||||
#endif
|
|
||||||
if (m_abort) return;
|
if (m_abort) return;
|
||||||
|
|
||||||
time_point now = clock_type::now();
|
time_point now = clock_type::now();
|
||||||
|
@ -139,9 +135,7 @@ namespace libtorrent
|
||||||
? int(m_completion_timeout - total_seconds(m_read_time - m_start_time))
|
? int(m_completion_timeout - total_seconds(m_read_time - m_start_time))
|
||||||
: (std::min)(int(m_completion_timeout - total_seconds(m_read_time - m_start_time)), timeout);
|
: (std::min)(int(m_completion_timeout - total_seconds(m_read_time - m_start_time)), timeout);
|
||||||
}
|
}
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("timeout_handler::timeout_callback");
|
||||||
add_outstanding_async("timeout_handler::timeout_callback");
|
|
||||||
#endif
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_timeout.expires_at(m_read_time + seconds(timeout), ec);
|
m_timeout.expires_at(m_read_time + seconds(timeout), ec);
|
||||||
m_timeout.async_wait(
|
m_timeout.async_wait(
|
||||||
|
|
|
@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/settings_pack.hpp"
|
#include "libtorrent/settings_pack.hpp"
|
||||||
#include "libtorrent/error.hpp"
|
#include "libtorrent/error.hpp"
|
||||||
#include "libtorrent/aux_/time.hpp" // for aux::time_now()
|
#include "libtorrent/aux_/time.hpp" // for aux::time_now()
|
||||||
|
#include "libtorrent/debug.hpp"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
@ -50,10 +51,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/asio/read.hpp>
|
#include <boost/asio/read.hpp>
|
||||||
#include <boost/asio/ip/v6_only.hpp>
|
#include <boost/asio/ip/v6_only.hpp>
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
|
||||||
#include "libtorrent/debug.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
udp_socket::udp_socket(io_service& ios)
|
udp_socket::udp_socket(io_service& ios)
|
||||||
|
@ -265,9 +262,7 @@ void udp_socket::on_writable(error_code const& ec, udp::socket* s)
|
||||||
// called whenever the socket is readable
|
// called whenever the socket is readable
|
||||||
void udp_socket::on_read(error_code const& ec, udp::socket* s)
|
void udp_socket::on_read(error_code const& ec, udp::socket* s)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("udp_socket::on_read");
|
||||||
complete_async("udp_socket::on_read");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TORRENT_ASSERT(m_magic == 0x1337);
|
TORRENT_ASSERT(m_magic == 0x1337);
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
@ -553,9 +548,7 @@ void udp_socket::setup_read(udp::socket* s)
|
||||||
++m_v4_outstanding;
|
++m_v4_outstanding;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("udp_socket::on_read");
|
||||||
add_outstanding_async("udp_socket::on_read");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
udp::endpoint ep;
|
udp::endpoint ep;
|
||||||
TORRENT_TRY
|
TORRENT_TRY
|
||||||
|
@ -875,9 +868,7 @@ void udp_socket::set_proxy_settings(aux::proxy_settings const& ps)
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
++m_outstanding_resolve;
|
++m_outstanding_resolve;
|
||||||
#endif
|
#endif
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("udp_socket::on_name_lookup");
|
||||||
add_outstanding_async("udp_socket::on_name_lookup");
|
|
||||||
#endif
|
|
||||||
m_resolver.async_resolve(q, boost::bind(
|
m_resolver.async_resolve(q, boost::bind(
|
||||||
&udp_socket::on_name_lookup, this, _1, _2));
|
&udp_socket::on_name_lookup, this, _1, _2));
|
||||||
}
|
}
|
||||||
|
@ -898,9 +889,7 @@ void udp_socket::close_impl()
|
||||||
|
|
||||||
void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
|
void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("udp_socket::on_name_lookup");
|
||||||
complete_async("udp_socket::on_name_lookup");
|
|
||||||
#endif
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
TORRENT_ASSERT(m_outstanding_resolve > 0);
|
TORRENT_ASSERT(m_outstanding_resolve > 0);
|
||||||
--m_outstanding_resolve;
|
--m_outstanding_resolve;
|
||||||
|
@ -947,9 +936,7 @@ void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
|
||||||
m_proxy_addr.address(i->endpoint().address());
|
m_proxy_addr.address(i->endpoint().address());
|
||||||
m_proxy_addr.port(i->endpoint().port());
|
m_proxy_addr.port(i->endpoint().port());
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("udp_socket::on_connected");
|
||||||
add_outstanding_async("udp_socket::on_connected");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_socks5_sock.open(m_proxy_addr.address().is_v4()?tcp::v4():tcp::v6(), ec);
|
m_socks5_sock.open(m_proxy_addr.address().is_v4()?tcp::v4():tcp::v6(), ec);
|
||||||
|
@ -969,9 +956,7 @@ void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
|
||||||
++m_outstanding_timeout;
|
++m_outstanding_timeout;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("udp_socket::on_connect_timeout");
|
||||||
add_outstanding_async("udp_socket::on_connect_timeout");
|
|
||||||
#endif
|
|
||||||
m_timer.expires_from_now(seconds(10));
|
m_timer.expires_from_now(seconds(10));
|
||||||
m_timer.async_wait(boost::bind(&udp_socket::on_connect_timeout
|
m_timer.async_wait(boost::bind(&udp_socket::on_connect_timeout
|
||||||
, this, _1));
|
, this, _1));
|
||||||
|
@ -979,9 +964,7 @@ void udp_socket::on_name_lookup(error_code const& e, tcp::resolver::iterator i)
|
||||||
|
|
||||||
void udp_socket::on_connect_timeout(error_code const& ec)
|
void udp_socket::on_connect_timeout(error_code const& ec)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("udp_socket::on_connect_timeout");
|
||||||
complete_async("udp_socket::on_connect_timeout");
|
|
||||||
#endif
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
TORRENT_ASSERT(m_outstanding_timeout > 0);
|
TORRENT_ASSERT(m_outstanding_timeout > 0);
|
||||||
--m_outstanding_timeout;
|
--m_outstanding_timeout;
|
||||||
|
@ -1012,9 +995,7 @@ void udp_socket::on_connect_timeout(error_code const& ec)
|
||||||
|
|
||||||
void udp_socket::on_connected(error_code const& e)
|
void udp_socket::on_connected(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("udp_socket::on_connected");
|
||||||
complete_async("udp_socket::on_connected");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
|
||||||
|
@ -1071,9 +1052,7 @@ void udp_socket::on_connected(error_code const& e)
|
||||||
write_uint8(2, p); // username/password
|
write_uint8(2, p); // username/password
|
||||||
}
|
}
|
||||||
TORRENT_ASSERT_VAL(p - m_tmp_buf < int(sizeof(m_tmp_buf)), (p - m_tmp_buf));
|
TORRENT_ASSERT_VAL(p - m_tmp_buf < int(sizeof(m_tmp_buf)), (p - m_tmp_buf));
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("udp_socket::on_handshake1");
|
||||||
add_outstanding_async("udp_socket::on_handshake1");
|
|
||||||
#endif
|
|
||||||
++m_outstanding_ops;
|
++m_outstanding_ops;
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
++m_outstanding_socks;
|
++m_outstanding_socks;
|
||||||
|
@ -1084,9 +1063,7 @@ void udp_socket::on_connected(error_code const& e)
|
||||||
|
|
||||||
void udp_socket::handshake1(error_code const& e)
|
void udp_socket::handshake1(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("udp_socket::on_handshake1");
|
||||||
complete_async("udp_socket::on_handshake1");
|
|
||||||
#endif
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
TORRENT_ASSERT(m_outstanding_socks > 0);
|
TORRENT_ASSERT(m_outstanding_socks > 0);
|
||||||
--m_outstanding_socks;
|
--m_outstanding_socks;
|
||||||
|
@ -1111,9 +1088,7 @@ void udp_socket::handshake1(error_code const& e)
|
||||||
|
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("udp_socket::on_handshake2");
|
||||||
add_outstanding_async("udp_socket::on_handshake2");
|
|
||||||
#endif
|
|
||||||
++m_outstanding_ops;
|
++m_outstanding_ops;
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
++m_outstanding_socks;
|
++m_outstanding_socks;
|
||||||
|
@ -1124,9 +1099,7 @@ void udp_socket::handshake1(error_code const& e)
|
||||||
|
|
||||||
void udp_socket::handshake2(error_code const& e)
|
void udp_socket::handshake2(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("udp_socket::on_handshake2");
|
||||||
complete_async("udp_socket::on_handshake2");
|
|
||||||
#endif
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
TORRENT_ASSERT(m_outstanding_socks > 0);
|
TORRENT_ASSERT(m_outstanding_socks > 0);
|
||||||
--m_outstanding_socks;
|
--m_outstanding_socks;
|
||||||
|
@ -1190,9 +1163,7 @@ void udp_socket::handshake2(error_code const& e)
|
||||||
write_uint8(uint8_t(m_proxy_settings.password.size()), p);
|
write_uint8(uint8_t(m_proxy_settings.password.size()), p);
|
||||||
write_string(m_proxy_settings.password, p);
|
write_string(m_proxy_settings.password, p);
|
||||||
TORRENT_ASSERT_VAL(p - m_tmp_buf < int(sizeof(m_tmp_buf)), (p - m_tmp_buf));
|
TORRENT_ASSERT_VAL(p - m_tmp_buf < int(sizeof(m_tmp_buf)), (p - m_tmp_buf));
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("udp_socket::on_handshake3");
|
||||||
add_outstanding_async("udp_socket::on_handshake3");
|
|
||||||
#endif
|
|
||||||
++m_outstanding_ops;
|
++m_outstanding_ops;
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
++m_outstanding_socks;
|
++m_outstanding_socks;
|
||||||
|
@ -1211,9 +1182,7 @@ void udp_socket::handshake2(error_code const& e)
|
||||||
|
|
||||||
void udp_socket::handshake3(error_code const& e)
|
void udp_socket::handshake3(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("udp_socket::on_handshake3");
|
||||||
complete_async("udp_socket::on_handshake3");
|
|
||||||
#endif
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
TORRENT_ASSERT(m_outstanding_socks > 0);
|
TORRENT_ASSERT(m_outstanding_socks > 0);
|
||||||
--m_outstanding_socks;
|
--m_outstanding_socks;
|
||||||
|
@ -1238,9 +1207,7 @@ void udp_socket::handshake3(error_code const& e)
|
||||||
|
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("udp_socket::on_handshake4");
|
||||||
add_outstanding_async("udp_socket::on_handshake4");
|
|
||||||
#endif
|
|
||||||
++m_outstanding_ops;
|
++m_outstanding_ops;
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
++m_outstanding_socks;
|
++m_outstanding_socks;
|
||||||
|
@ -1251,9 +1218,7 @@ void udp_socket::handshake3(error_code const& e)
|
||||||
|
|
||||||
void udp_socket::handshake4(error_code const& e)
|
void udp_socket::handshake4(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("udp_socket::on_handshake4");
|
||||||
complete_async("udp_socket::on_handshake4");
|
|
||||||
#endif
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
TORRENT_ASSERT(m_outstanding_socks > 0);
|
TORRENT_ASSERT(m_outstanding_socks > 0);
|
||||||
--m_outstanding_socks;
|
--m_outstanding_socks;
|
||||||
|
@ -1308,9 +1273,7 @@ void udp_socket::socks_forward_udp()
|
||||||
write_uint32(0, p); // 0.0.0.0
|
write_uint32(0, p); // 0.0.0.0
|
||||||
write_uint16(0, p); // :0
|
write_uint16(0, p); // :0
|
||||||
TORRENT_ASSERT_VAL(p - m_tmp_buf < int(sizeof(m_tmp_buf)), (p - m_tmp_buf));
|
TORRENT_ASSERT_VAL(p - m_tmp_buf < int(sizeof(m_tmp_buf)), (p - m_tmp_buf));
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("udp_socket::connect1");
|
||||||
add_outstanding_async("udp_socket::connect1");
|
|
||||||
#endif
|
|
||||||
++m_outstanding_ops;
|
++m_outstanding_ops;
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
++m_outstanding_socks;
|
++m_outstanding_socks;
|
||||||
|
@ -1321,9 +1284,7 @@ void udp_socket::socks_forward_udp()
|
||||||
|
|
||||||
void udp_socket::connect1(error_code const& e)
|
void udp_socket::connect1(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("udp_socket::connect1");
|
||||||
complete_async("udp_socket::connect1");
|
|
||||||
#endif
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
TORRENT_ASSERT(m_outstanding_socks > 0);
|
TORRENT_ASSERT(m_outstanding_socks > 0);
|
||||||
--m_outstanding_socks;
|
--m_outstanding_socks;
|
||||||
|
@ -1348,9 +1309,7 @@ void udp_socket::connect1(error_code const& e)
|
||||||
|
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("udp_socket::connect2");
|
||||||
add_outstanding_async("udp_socket::connect2");
|
|
||||||
#endif
|
|
||||||
++m_outstanding_ops;
|
++m_outstanding_ops;
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
++m_outstanding_socks;
|
++m_outstanding_socks;
|
||||||
|
@ -1361,9 +1320,7 @@ void udp_socket::connect1(error_code const& e)
|
||||||
|
|
||||||
void udp_socket::connect2(error_code const& e)
|
void udp_socket::connect2(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("udp_socket::connect2");
|
||||||
complete_async("udp_socket::connect2");
|
|
||||||
#endif
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
TORRENT_ASSERT(m_outstanding_socks > 0);
|
TORRENT_ASSERT(m_outstanding_socks > 0);
|
||||||
--m_outstanding_socks;
|
--m_outstanding_socks;
|
||||||
|
@ -1419,9 +1376,7 @@ void udp_socket::connect2(error_code const& e)
|
||||||
m_tunnel_packets = true;
|
m_tunnel_packets = true;
|
||||||
drain_queue();
|
drain_queue();
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("udp_socket::hung_up");
|
||||||
add_outstanding_async("udp_socket::hung_up");
|
|
||||||
#endif
|
|
||||||
++m_outstanding_ops;
|
++m_outstanding_ops;
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
++m_outstanding_socks;
|
++m_outstanding_socks;
|
||||||
|
@ -1432,9 +1387,7 @@ void udp_socket::connect2(error_code const& e)
|
||||||
|
|
||||||
void udp_socket::hung_up(error_code const& e)
|
void udp_socket::hung_up(error_code const& e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("udp_socket::hung_up");
|
||||||
complete_async("udp_socket::hung_up");
|
|
||||||
#endif
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
TORRENT_ASSERT(m_outstanding_socks > 0);
|
TORRENT_ASSERT(m_outstanding_socks > 0);
|
||||||
--m_outstanding_socks;
|
--m_outstanding_socks;
|
||||||
|
|
|
@ -109,9 +109,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("udp_tracker_connection::name_lookup");
|
||||||
add_outstanding_async("udp_tracker_connection::name_lookup");
|
|
||||||
#endif
|
|
||||||
// when stopping, pass in the prefer cache flag, because we
|
// when stopping, pass in the prefer cache flag, because we
|
||||||
// don't want to get stuck on DNS lookups when shutting down
|
// don't want to get stuck on DNS lookups when shutting down
|
||||||
// if we can avoid it
|
// if we can avoid it
|
||||||
|
@ -177,9 +175,7 @@ namespace libtorrent
|
||||||
void udp_tracker_connection::name_lookup(error_code const& error
|
void udp_tracker_connection::name_lookup(error_code const& error
|
||||||
, std::vector<address> const& addresses, int port)
|
, std::vector<address> const& addresses, int port)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("udp_tracker_connection::name_lookup");
|
||||||
complete_async("udp_tracker_connection::name_lookup");
|
|
||||||
#endif
|
|
||||||
if (m_abort) return;
|
if (m_abort) return;
|
||||||
if (error == boost::asio::error::operation_aborted) return;
|
if (error == boost::asio::error::operation_aborted) return;
|
||||||
if (error || addresses.empty())
|
if (error || addresses.empty())
|
||||||
|
|
31
src/upnp.cpp
31
src/upnp.cpp
|
@ -40,10 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/random.hpp"
|
#include "libtorrent/random.hpp"
|
||||||
#include "libtorrent/aux_/time.hpp" // for aux::time_now()
|
#include "libtorrent/aux_/time.hpp" // for aux::time_now()
|
||||||
#include "libtorrent/aux_/escape_string.hpp" // for convert_from_native
|
#include "libtorrent/aux_/escape_string.hpp" // for convert_from_native
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
|
@ -151,9 +148,7 @@ void upnp::discover_device_impl(mutex::scoped_lock& l)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("upnp::resend_request");
|
||||||
add_outstanding_async("upnp::resend_request");
|
|
||||||
#endif
|
|
||||||
++m_retry_count;
|
++m_retry_count;
|
||||||
m_broadcast_timer.expires_from_now(seconds(2 * m_retry_count), ec);
|
m_broadcast_timer.expires_from_now(seconds(2 * m_retry_count), ec);
|
||||||
m_broadcast_timer.async_wait(boost::bind(&upnp::resend_request
|
m_broadcast_timer.async_wait(boost::bind(&upnp::resend_request
|
||||||
|
@ -257,9 +252,7 @@ bool upnp::get_mapping(int index, int& local_port, int& external_port, int& prot
|
||||||
|
|
||||||
void upnp::resend_request(error_code const& ec)
|
void upnp::resend_request(error_code const& ec)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("upnp::resend_request");
|
||||||
complete_async("upnp::resend_request");
|
|
||||||
#endif
|
|
||||||
if (ec) return;
|
if (ec) return;
|
||||||
|
|
||||||
boost::shared_ptr<upnp> me(self());
|
boost::shared_ptr<upnp> me(self());
|
||||||
|
@ -548,9 +541,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
|
||||||
|
|
||||||
if (m_ignore_non_routers)
|
if (m_ignore_non_routers)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("upnp::map_timer");
|
||||||
add_outstanding_async("upnp::map_timer");
|
|
||||||
#endif
|
|
||||||
// check back in in a little bit to see if we have seen any
|
// check back in in a little bit to see if we have seen any
|
||||||
// devices at one of our default routes. If not, we want to override
|
// devices at one of our default routes. If not, we want to override
|
||||||
// ignoring them and use them instead (better than not working).
|
// ignoring them and use them instead (better than not working).
|
||||||
|
@ -562,9 +553,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
|
||||||
|
|
||||||
void upnp::map_timer(error_code const& ec)
|
void upnp::map_timer(error_code const& ec)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("upnp::map_timer");
|
||||||
complete_async("upnp::map_timer");
|
|
||||||
#endif
|
|
||||||
if (ec) return;
|
if (ec) return;
|
||||||
if (m_closing) return;
|
if (m_closing) return;
|
||||||
|
|
||||||
|
@ -1383,9 +1372,7 @@ void upnp::on_upnp_map_response(error_code const& e
|
||||||
if (next_expire < aux::time_now()
|
if (next_expire < aux::time_now()
|
||||||
|| next_expire > m.expires)
|
|| next_expire > m.expires)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("upnp::on_expire");
|
||||||
add_outstanding_async("upnp::on_expire");
|
|
||||||
#endif
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_refresh_timer.expires_at(m.expires, ec);
|
m_refresh_timer.expires_at(m.expires, ec);
|
||||||
m_refresh_timer.async_wait(boost::bind(&upnp::on_expire, self(), _1));
|
m_refresh_timer.async_wait(boost::bind(&upnp::on_expire, self(), _1));
|
||||||
|
@ -1485,9 +1472,7 @@ void upnp::on_upnp_unmap_response(error_code const& e
|
||||||
|
|
||||||
void upnp::on_expire(error_code const& ec)
|
void upnp::on_expire(error_code const& ec)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
COMPLETE_ASYNC("upnp::on_expire");
|
||||||
complete_async("upnp::on_expire");
|
|
||||||
#endif
|
|
||||||
if (ec) return;
|
if (ec) return;
|
||||||
|
|
||||||
time_point now = aux::time_now();
|
time_point now = aux::time_now();
|
||||||
|
@ -1518,9 +1503,7 @@ void upnp::on_expire(error_code const& ec)
|
||||||
}
|
}
|
||||||
if (next_expire != max_time())
|
if (next_expire != max_time())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
ADD_OUTSTANDING_ASYNC("upnp::on_expire");
|
||||||
add_outstanding_async("upnp::on_expire");
|
|
||||||
#endif
|
|
||||||
error_code e;
|
error_code e;
|
||||||
m_refresh_timer.expires_at(next_expire, e);
|
m_refresh_timer.expires_at(next_expire, e);
|
||||||
m_refresh_timer.async_wait(boost::bind(&upnp::on_expire, self(), _1));
|
m_refresh_timer.async_wait(boost::bind(&upnp::on_expire, self(), _1));
|
||||||
|
|
Loading…
Reference in New Issue