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:
Arvid Norberg 2016-04-23 17:29:25 -04:00
parent eaf7cb329f
commit c9c6dd2d3b
20 changed files with 157 additions and 470 deletions

View File

@ -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
namespace libtorrent

View File

@ -60,10 +60,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/io_service_fwd.hpp"
#include "libtorrent/receive_buffer.hpp"
#include "libtorrent/aux_/allocating_handler.hpp"
#ifndef TORRENT_DISABLE_LOGGING
#include "libtorrent/debug.hpp"
#endif
#include "libtorrent/aux_/disable_warnings_push.hpp"

View File

@ -53,9 +53,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/ssl_stream.hpp"
#endif
#if defined TORRENT_ASIO_DEBUGGING
#include "libtorrent/debug.hpp"
#endif
#if defined TORRENT_OS2 && defined ioc
#undef ioc

View File

@ -42,9 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/proxy_base.hpp"
#include "libtorrent/assert.hpp"
#if defined TORRENT_ASIO_DEBUGGING
#include "libtorrent/debug.hpp"
#endif
namespace libtorrent {
namespace socks_error {
@ -166,9 +164,7 @@ public:
// store it in a shaed_ptr
boost::shared_ptr<handler_type> h(new handler_type(handler));
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::name_lookup");
#endif
ADD_OUTSTANDING_ASYNC("socks5_stream::name_lookup");
tcp::resolver::query q(m_hostname, to_string(m_port).elems);
m_resolver.async_resolve(q, boost::bind(
&socks5_stream::name_lookup, this, _1, _2, h));

View File

@ -54,10 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/enum_net.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include "libtorrent/assert.hpp"
#if defined TORRENT_ASIO_DEBUGGING
#include "libtorrent/debug.hpp"
#endif
#ifdef TORRENT_DEBUG
#include "libtorrent/socket_io.hpp"
@ -296,9 +293,7 @@ namespace libtorrent
if (ec) return;
m_sockets.push_back(socket_entry(s));
socket_entry& se = m_sockets.back();
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("broadcast_socket::on_receive");
#endif
ADD_OUTSTANDING_ASYNC("broadcast_socket::on_receive");
s->async_receive_from(boost::asio::buffer(se.buffer, sizeof(se.buffer))
, se.remote, boost::bind(&broadcast_socket::on_receive, this, &se, _1, _2));
++m_outstanding_operations;
@ -323,9 +318,7 @@ namespace libtorrent
s->set_option(option, ec);
if (!ec) se.broadcast = true;
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("broadcast_socket::on_receive");
#endif
ADD_OUTSTANDING_ASYNC("broadcast_socket::on_receive");
s->async_receive_from(boost::asio::buffer(se.buffer, sizeof(se.buffer))
, se.remote, boost::bind(&broadcast_socket::on_receive, this, &se, _1, _2));
++m_outstanding_operations;
@ -381,9 +374,7 @@ namespace libtorrent
void broadcast_socket::on_receive(socket_entry* s, error_code const& ec
, std::size_t bytes_transferred)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("broadcast_socket::on_receive");
#endif
COMPLETE_ASYNC("broadcast_socket::on_receive");
TORRENT_ASSERT(m_outstanding_operations > 0);
--m_outstanding_operations;
@ -396,9 +387,7 @@ namespace libtorrent
if (maybe_abort()) return;
if (!s->socket) return;
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("broadcast_socket::on_receive");
#endif
ADD_OUTSTANDING_ASYNC("broadcast_socket::on_receive");
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));
++m_outstanding_operations;

View File

@ -169,9 +169,7 @@ namespace libtorrent
, m_magic(0x1337)
#endif
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("disk_io_thread::work");
#endif
ADD_OUTSTANDING_ASYNC("disk_io_thread::work");
error_code ec;
m_disk_cache.set_settings(m_settings, ec);
TORRENT_ASSERT(!ec);
@ -3282,9 +3280,7 @@ namespace libtorrent
// release the io_service to allow the run() call to return
// we do this once we stop posting new callbacks to it.
#if defined TORRENT_ASIO_DEBUGGING
complete_async("disk_io_thread::work");
#endif
COMPLETE_ASYNC("disk_io_thread::work");
w.reset();
TORRENT_ASSERT(m_magic == 0x1337);

View File

@ -41,10 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/settings_pack.hpp"
#include "libtorrent/aux_/time.hpp"
#include "libtorrent/random.hpp"
#if defined TORRENT_ASIO_DEBUGGING
#include "libtorrent/debug.hpp"
#endif
#include "libtorrent/aux_/disable_warnings_push.hpp"
@ -252,9 +249,7 @@ void http_connection::start(std::string const& hostname, int port
error_code ec;
m_timer.expires_from_now((std::min)(
m_read_timeout, m_completion_timeout), ec);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_timeout");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_timeout");
m_timer.async_wait(boost::bind(&http_connection::on_timeout
, boost::weak_ptr<http_connection>(me), _1));
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
&& m_ssl == ssl && m_bind_addr == bind_addr)
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_write");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_write");
async_write(m_sock, boost::asio::buffer(m_sendbuffer)
, 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 defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_i2p_resolve");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_i2p_resolve");
i2p_conn->async_name_lookup(hostname.c_str(), boost::bind(&http_connection::on_i2p_resolve
, me, _1, _2));
}
@ -411,9 +402,7 @@ void http_connection::start(std::string const& hostname, int port
}
else
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_resolve");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_resolve");
m_resolver.async_resolve(hostname, m_resolve_flags
, boost::bind(&http_connection::on_resolve
, 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
, error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("http_connection::on_timeout");
#endif
COMPLETE_ASYNC("http_connection::on_timeout");
boost::shared_ptr<http_connection> c = p.lock();
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 defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_timeout");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_timeout");
error_code ec;
c->m_timer.expires_at((std::min)(
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_session_id(m_i2p_conn->session_id());
#endif
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_connect");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_connect");
m_sock.async_connect(tcp::endpoint(), boost::bind(&http_connection::on_connect
, 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
, char const* destination)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("http_connection::on_i2p_resolve");
#endif
COMPLETE_ASYNC("http_connection::on_i2p_resolve");
if (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
, std::vector<address> const& addresses)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("http_connection::on_resolve");
#endif
COMPLETE_ASYNC("http_connection::on_resolve");
if (e)
{
callback(e);
@ -614,9 +593,7 @@ void http_connection::connect()
tcp::endpoint target_address = m_endpoints[m_next_ep];
++m_next_ep;
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_connect");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_connect");
TORRENT_ASSERT(!m_connecting);
m_connecting = true;
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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("http_connection::on_connect");
#endif
COMPLETE_ASYNC("http_connection::on_connect");
TORRENT_ASSERT(m_connecting);
m_connecting = false;
@ -636,9 +611,7 @@ void http_connection::on_connect(error_code const& e)
if (!e)
{
if (m_connect_handler) m_connect_handler(*this);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_write");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_write");
async_write(m_sock, boost::asio::buffer(m_sendbuffer)
, 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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("http_connection::on_write");
#endif
COMPLETE_ASYNC("http_connection::on_write");
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 defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_assign_bandwidth");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_assign_bandwidth");
on_assign_bandwidth(error_code());
}
return;
}
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_read");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_read");
m_sock.async_read_some(boost::asio::buffer(&m_recvbuffer[0] + m_read_pos
, amount_to_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
, std::size_t bytes_transferred)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("http_connection::on_read");
#endif
COMPLETE_ASYNC("http_connection::on_read");
if (m_rate_limit)
{
@ -874,17 +839,13 @@ void http_connection::on_read(error_code const& e
{
if (!m_limiter_timer_active)
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_assign_bandwidth");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_assign_bandwidth");
on_assign_bandwidth(error_code());
}
return;
}
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_read");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_read");
m_sock.async_read_some(boost::asio::buffer(&m_recvbuffer[0] + m_read_pos
, amount_to_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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("http_connection::on_assign_bandwidth");
#endif
COMPLETE_ASYNC("http_connection::on_assign_bandwidth");
if ((e == boost::asio::error::operation_aborted
&& m_limiter_timer_active)
|| !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 defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_read");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_read");
m_sock.async_read_some(boost::asio::buffer(&m_recvbuffer[0] + m_read_pos
, amount_to_read)
, boost::bind(&http_connection::on_read
@ -927,9 +884,7 @@ void http_connection::on_assign_bandwidth(error_code const& e)
error_code ec;
m_limiter_timer_active = true;
m_limiter_timer.expires_from_now(milliseconds(250), ec);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_assign_bandwidth");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_assign_bandwidth");
m_limiter_timer.async_wait(boost::bind(&http_connection::on_assign_bandwidth
, shared_from_this(), _1));
}
@ -943,9 +898,7 @@ void http_connection::rate_limit(int limit)
error_code ec;
m_limiter_timer_active = true;
m_limiter_timer.expires_from_now(milliseconds(250), ec);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("http_connection::on_assign_bandwidth");
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_assign_bandwidth");
m_limiter_timer.async_wait(boost::bind(&http_connection::on_assign_bandwidth
, shared_from_this(), _1));
}

View File

@ -42,9 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp>
#if defined TORRENT_ASIO_DEBUGGING
#include "libtorrent/debug.hpp"
#endif
namespace libtorrent
{
@ -140,18 +138,14 @@ namespace libtorrent
m_sam_socket->set_command(i2p_stream::cmd_create_session);
m_sam_socket->set_session_id(m_session_id.c_str());
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::on_sam_connect");
#endif
ADD_OUTSTANDING_ASYNC("i2p_stream::on_sam_connect");
m_sam_socket->async_connect(tcp::endpoint()
, 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>)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("i2p_stream::on_sam_connect");
#endif
COMPLETE_ASYNC("i2p_stream::on_sam_connect");
m_state = sam_idle;
if (ec)
@ -247,9 +241,7 @@ namespace libtorrent
return;
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::connected");
#endif
ADD_OUTSTANDING_ASYNC("i2p_stream::connected");
m_sock.async_connect(i->endpoint(), boost::bind(
&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)
{
TORRENT_ASSERT(m_magic == 0x1337);
#if defined TORRENT_ASIO_DEBUGGING
complete_async("i2p_stream::connected");
#endif
COMPLETE_ASYNC("i2p_stream::connected");
if (handle_error(e, h)) return;
// send hello command
m_state = read_hello_response;
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");
#endif
ADD_OUTSTANDING_ASYNC("i2p_stream::start_read_line");
async_write(m_sock, boost::asio::buffer(cmd, sizeof(cmd) - 1)
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
// 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)
{
TORRENT_ASSERT(m_magic == 0x1337);
#if defined TORRENT_ASIO_DEBUGGING
complete_async("i2p_stream::start_read_line");
#endif
COMPLETE_ASYNC("i2p_stream::start_read_line");
if (handle_error(e, h)) return;
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::read_line");
#endif
ADD_OUTSTANDING_ASYNC("i2p_stream::read_line");
m_buffer.resize(1);
async_read(m_sock, boost::asio::buffer(m_buffer)
, 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)
{
TORRENT_ASSERT(m_magic == 0x1337);
#if defined TORRENT_ASIO_DEBUGGING
complete_async("i2p_stream::read_line");
#endif
COMPLETE_ASYNC("i2p_stream::read_line");
if (handle_error(e, h)) return;
int read_pos = m_buffer.size();
@ -303,9 +285,7 @@ namespace libtorrent
// look for \n which means end of the response
if (m_buffer[read_pos - 1] != '\n')
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::read_line");
#endif
ADD_OUTSTANDING_ASYNC("i2p_stream::read_line");
// read another byte from the socket
m_buffer.resize(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
m_command = cmd_incoming;
m_buffer.resize(1);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::read_line");
#endif
ADD_OUTSTANDING_ASYNC("i2p_stream::read_line");
async_read(m_sock, boost::asio::buffer(m_buffer)
, boost::bind(&i2p_stream::read_line, this, _1, h));
break;
@ -478,9 +456,7 @@ namespace libtorrent
int size = snprintf(cmd, sizeof(cmd), "STREAM CONNECT ID=%s DESTINATION=%s\n"
, m_id, m_dest.c_str());
// fprintf(stderr, ">>> %s", cmd);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::start_read_line");
#endif
ADD_OUTSTANDING_ASYNC("i2p_stream::start_read_line");
async_write(m_sock, boost::asio::buffer(cmd, size)
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
}
@ -492,9 +468,7 @@ namespace libtorrent
char cmd[400];
int size = snprintf(cmd, sizeof(cmd), "STREAM ACCEPT ID=%s\n", m_id);
// fprintf(stderr, ">>> %s", cmd);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::start_read_line");
#endif
ADD_OUTSTANDING_ASYNC("i2p_stream::start_read_line");
async_write(m_sock, boost::asio::buffer(cmd, size)
, 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"
, m_id);
// fprintf(stderr, ">>> %s", cmd);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::start_read_line");
#endif
ADD_OUTSTANDING_ASYNC("i2p_stream::start_read_line");
async_write(m_sock, boost::asio::buffer(cmd, size)
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
}
@ -521,9 +493,7 @@ namespace libtorrent
char cmd[1024];
int size = snprintf(cmd, sizeof(cmd), "NAMING LOOKUP NAME=%s\n", m_name_lookup.c_str());
// fprintf(stderr, ">>> %s", cmd);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::start_read_line");
#endif
ADD_OUTSTANDING_ASYNC("i2p_stream::start_read_line");
async_write(m_sock, boost::asio::buffer(cmd, size)
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
}

View File

@ -37,10 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/random.hpp"
#include "libtorrent/http_parser.hpp"
#include "libtorrent/socket_io.hpp" // for print_address
#if defined TORRENT_ASIO_DEBUGGING
#include "libtorrent/debug.hpp"
#endif
#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;
#endif
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("lsd::resend_announce");
#endif
ADD_OUTSTANDING_ASYNC("lsd::resend_announce");
m_broadcast_timer.expires_from_now(seconds(2 * retry_count), ec);
m_broadcast_timer.async_wait(boost::bind(&lsd::resend_announce, self(), _1
, 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
, int listen_port, int retry_count)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("lsd::resend_announce");
#endif
COMPLETE_ASYNC("lsd::resend_announce");
if (e) return;
announce_impl(info_hash, listen_port, false, retry_count);

View File

@ -39,6 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/version.hpp>
#include <boost/bind.hpp>
#include <boost/asio/ip/host_name.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
@ -49,19 +50,15 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket_io.hpp"
#include "libtorrent/io_service.hpp"
#include "libtorrent/aux_/time.hpp"
#include "libtorrent/debug.hpp"
#include "libtorrent/aux_/escape_string.hpp"
#include <boost/asio/ip/host_name.hpp>
//#define NATPMP_LOG
#ifdef NATPMP_LOG
#include <iostream>
#endif
#if defined TORRENT_ASIO_DEBUGGING
#include "libtorrent/debug.hpp"
#endif
using namespace libtorrent;
@ -124,9 +121,7 @@ void natpmp::start()
return;
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("natpmp::on_reply");
#endif
ADD_OUTSTANDING_ASYNC("natpmp::on_reply");
m_socket.async_receive_from(boost::asio::buffer(&m_response_buffer, 16)
, m_remote, boost::bind(&natpmp::on_reply, self(), _1, _2));
send_get_ip_address_request(l);
@ -376,9 +371,7 @@ void natpmp::send_map_request(int i, mutex::scoped_lock& l)
}
else
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("natpmp::resend_request");
#endif
ADD_OUTSTANDING_ASYNC("natpmp::resend_request");
// linear back-off instead of exponential
++m_retry_count;
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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("natpmp::resend_request");
#endif
COMPLETE_ASYNC("natpmp::resend_request");
if (e) return;
mutex::scoped_lock l(m_mutex);
if (m_currently_mapping != i) return;
@ -414,9 +405,7 @@ void natpmp::on_reply(error_code const& e
{
mutex::scoped_lock l(m_mutex);
#if defined TORRENT_ASIO_DEBUGGING
complete_async("natpmp::on_reply");
#endif
COMPLETE_ASYNC("natpmp::on_reply");
using namespace libtorrent::detail;
if (e)
@ -428,9 +417,7 @@ void natpmp::on_reply(error_code const& e
return;
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("natpmp::on_reply");
#endif
ADD_OUTSTANDING_ASYNC("natpmp::on_reply");
// make a copy of the response packet buffer
// to avoid overwriting it in the next receive call
char msg_buf[16];
@ -645,9 +632,7 @@ void natpmp::update_expiration_timer(mutex::scoped_lock& l)
error_code ec;
if (m_next_refresh >= 0) m_refresh_timer.cancel(ec);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("natpmp::mapping_expired");
#endif
ADD_OUTSTANDING_ASYNC("natpmp::mapping_expired");
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_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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("natpmp::mapping_expired");
#endif
COMPLETE_ASYNC("natpmp::mapping_expired");
if (e) return;
mutex::scoped_lock l(m_mutex);
char msg[200];

View File

@ -400,9 +400,7 @@ namespace libtorrent
peer_log(peer_log_alert::outgoing, "ASYNC_CONNECT", "dst: %s"
, print_endpoint(m_remote).c_str());
#endif
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("peer_connection::on_connection_complete");
#endif
ADD_OUTSTANDING_ASYNC("peer_connection::on_connection_complete");
#ifndef TORRENT_DISABLE_LOGGING
if (t)
@ -5670,9 +5668,7 @@ namespace libtorrent
peer_log(peer_log_alert::outgoing, "ASYNC_WRITE", "bytes: %d", amount_to_send);
#endif
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");
#endif
ADD_OUTSTANDING_ASYNC("peer_connection::on_send_data");
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(!m_socket_is_writing);
@ -5790,9 +5786,7 @@ namespace libtorrent
peer_log(peer_log_alert::incoming, "ASYNC_READ");
#endif
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("peer_connection::on_receive_data_nb");
#endif
ADD_OUTSTANDING_ASYNC("peer_connection::on_receive_data_nb");
m_socket->async_read_some(null_buffers(), make_read_handler(
boost::bind(&peer_connection::on_receive_data_nb, self(), _1, _2)));
return 0;
@ -5822,9 +5816,7 @@ namespace libtorrent
#endif
// utp sockets aren't thread safe...
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("peer_connection::on_receive_data");
#endif
ADD_OUTSTANDING_ASYNC("peer_connection::on_receive_data");
if (is_utp(*m_socket))
{
if (num_bufs == 1)
@ -5977,9 +5969,7 @@ namespace libtorrent
, std::size_t bytes_transferred)
{
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_ASIO_DEBUGGING
complete_async("peer_connection::on_receive_data_nb");
#endif
COMPLETE_ASYNC("peer_connection::on_receive_data_nb");
// 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
@ -6073,9 +6063,7 @@ namespace libtorrent
}
else
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("peer_connection::on_receive_data");
#endif
ADD_OUTSTANDING_ASYNC("peer_connection::on_receive_data");
socket_job j;
j.type = socket_job::read_job;
j.recv_buf = boost::asio::buffer_cast<char*>(buffer);
@ -6103,9 +6091,7 @@ namespace libtorrent
, std::size_t bytes_transferred)
{
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_ASIO_DEBUGGING
complete_async("peer_connection::on_receive_data");
#endif
COMPLETE_ASYNC("peer_connection::on_receive_data");
// 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
@ -6294,9 +6280,7 @@ namespace libtorrent
void peer_connection::on_connection_complete(error_code const& e)
{
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_ASIO_DEBUGGING
complete_async("peer_connection::on_connection_complete");
#endif
COMPLETE_ASYNC("peer_connection::on_connection_complete");
#if !defined TORRENT_DISABLE_LOGGING || defined TORRENT_USE_OPENSSL
time_point completed = clock_type::now();
@ -6471,9 +6455,7 @@ namespace libtorrent
INVARIANT_CHECK;
#if defined TORRENT_ASIO_DEBUGGING
complete_async("peer_connection::on_send_data");
#endif
COMPLETE_ASYNC("peer_connection::on_send_data");
// keep ourselves alive in until this function exits in
// case we disconnect
boost::shared_ptr<peer_connection> me(self());

View File

@ -48,9 +48,7 @@ namespace libtorrent
void resolver::on_lookup(error_code const& ec, tcp::resolver::iterator i
, resolver_interface::callback_t h, std::string hostname)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("resolver::on_lookup");
#endif
COMPLETE_ASYNC("resolver::on_lookup");
if (ec)
{
std::vector<address> empty;
@ -118,9 +116,7 @@ namespace libtorrent
// the port is ignored
tcp::resolver::query q(host, "80");
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("resolver::on_lookup");
#endif
ADD_OUTSTANDING_ASYNC("resolver::on_lookup");
if (flags & resolver_interface::abort_on_shutdown)
{
m_resolver.async_resolve(q, boost::bind(&resolver::on_lookup, this, _1, _2

View File

@ -588,9 +588,7 @@ namespace aux {
error_code 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");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::on_lsd_announce");
int delay = (std::max)(m_settings.get_int(settings_pack::local_service_announce_interval)
/ (std::max)(int(m_torrents.size()), 1), 1);
m_lsd_announce_timer.expires_from_now(seconds(delay), ec);
@ -2204,9 +2202,7 @@ namespace aux {
TORRENT_ASSERT_VAL(ret, ret);
TORRENT_UNUSED(ret);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("session_impl::on_socks_accept");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::on_socks_accept");
socks5_stream& s = *m_socks_listen_socket->get<socks5_stream>();
s.set_command(2); // 2 means BIND (as opposed to CONNECT)
m_socks_listen_port = 2000 + random() % 60000;
@ -2276,9 +2272,7 @@ namespace aux {
TORRENT_ASSERT_VAL(ret, ret);
TORRENT_UNUSED(ret);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("session_impl::on_i2p_accept");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::on_i2p_accept");
i2p_stream& s = *m_i2p_listen_socket->get<i2p_stream>();
s.set_command(i2p_stream::cmd_accept);
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
, error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("session_impl::on_i2p_accept");
#endif
COMPLETE_ASYNC("session_impl::on_i2p_accept");
m_i2p_listen_socket.reset();
if (e == boost::asio::error::operation_aborted) return;
if (e)
@ -2356,9 +2348,7 @@ namespace aux {
str = c->get<tcp::socket>();
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("session_impl::on_accept_connection");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::on_accept_connection");
#ifdef TORRENT_USE_OPENSSL
TORRENT_ASSERT(ssl == is_ssl(*c));
@ -2372,9 +2362,7 @@ namespace aux {
void session_impl::on_accept_connection(shared_ptr<socket_type> const& s
, weak_ptr<tcp::acceptor> listen_socket, error_code const& e, bool ssl)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("session_impl::on_accept_connection");
#endif
COMPLETE_ASYNC("session_impl::on_accept_connection");
m_stats_counters.inc_stats_counter(counters::on_accept_counter);
TORRENT_ASSERT(is_single_thread());
boost::shared_ptr<tcp::acceptor> listener = listen_socket.lock();
@ -2455,9 +2443,7 @@ namespace aux {
// for SSL connections, incoming_connection() is called
// after the handshake is done
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("session_impl::ssl_handshake");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::ssl_handshake");
s->get<ssl_stream<tcp::socket> >()->async_accept_handshake(
boost::bind(&session_impl::ssl_handshake, this, _1, s));
m_incoming_sockets.insert(s);
@ -2477,9 +2463,7 @@ namespace aux {
// for SSL connections, incoming_connection() is called
// after the handshake is done
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("session_impl::ssl_handshake");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::ssl_handshake");
s->get<ssl_stream<utp_stream> >()->async_accept_handshake(
boost::bind(&session_impl::ssl_handshake, this, _1, 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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("session_impl::ssl_handshake");
#endif
COMPLETE_ASYNC("session_impl::ssl_handshake");
TORRENT_ASSERT(is_ssl(*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
, error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("session_impl::on_socks_accept");
#endif
COMPLETE_ASYNC("session_impl::on_socks_accept");
m_socks_listen_socket.reset();
if (e == boost::asio::error::operation_aborted) return;
if (e)
@ -2953,9 +2933,7 @@ namespace aux {
void session_impl::on_tick(error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("session_impl::on_tick");
#endif
COMPLETE_ASYNC("session_impl::on_tick");
m_stats_counters.inc_stats_counter(counters::on_tick_counter);
TORRENT_ASSERT(is_single_thread());
@ -3012,9 +2990,7 @@ namespace aux {
std::abort();
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("session_impl::on_tick");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::on_tick");
error_code 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)));
@ -3495,9 +3471,7 @@ namespace aux {
// timer interval short until all torrents have been announced.
if (m_dht_torrents.size() == 1)
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("session_impl::on_dht_announce");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::on_dht_announce");
error_code ec;
m_dht_announce_timer.expires_from_now(seconds(0), ec);
m_dht_announce_timer.async_wait(
@ -3507,9 +3481,7 @@ namespace aux {
void session_impl::on_dht_announce(error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("session_impl::on_dht_announce");
#endif
COMPLETE_ASYNC("session_impl::on_dht_announce");
TORRENT_ASSERT(is_single_thread());
if (e)
{
@ -3548,9 +3520,7 @@ namespace aux {
delay = (std::min)(4, delay);
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("session_impl::on_dht_announce");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::on_dht_announce");
error_code ec;
m_dht_announce_timer.expires_from_now(seconds(delay), ec);
m_dht_announce_timer.async_wait(
@ -3586,18 +3556,14 @@ namespace aux {
void session_impl::on_lsd_announce(error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("session_impl::on_lsd_announce");
#endif
COMPLETE_ASYNC("session_impl::on_lsd_announce");
m_stats_counters.inc_stats_counter(counters::on_lsd_counter);
TORRENT_ASSERT(is_single_thread());
if (e) return;
if (m_abort) return;
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("session_impl::on_lsd_announce");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::on_lsd_announce");
// announce on local network every 5 minutes
int delay = (std::max)(m_settings.get_int(settings_pack::local_service_announce_interval)
/ (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)
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("session_impl::on_dht_name_lookup");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::on_dht_name_lookup");
m_host_resolver.async_resolve(node.first, resolver_interface::abort_on_shutdown
, boost::bind(&session_impl::on_dht_name_lookup
, this, _1, _2, node.second));
@ -5645,9 +5609,7 @@ namespace aux {
void session_impl::on_dht_name_lookup(error_code const& e
, std::vector<address> const& addresses, int port)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("session_impl::on_dht_name_lookup");
#endif
COMPLETE_ASYNC("session_impl::on_dht_name_lookup");
if (e)
{
@ -5667,9 +5629,7 @@ namespace aux {
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");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::on_dht_router_name_lookup");
++m_outstanding_router_lookups;
m_host_resolver.async_resolve(node.first, resolver_interface::abort_on_shutdown
, 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
, std::vector<address> const& addresses, int port)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("session_impl::on_dht_router_name_lookup");
#endif
COMPLETE_ASYNC("session_impl::on_dht_router_name_lookup");
--m_outstanding_router_lookups;
if (e)
@ -6263,9 +6221,7 @@ namespace aux {
return;
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("session_impl::on_dht_announce");
#endif
ADD_OUTSTANDING_ASYNC("session_impl::on_dht_announce");
error_code ec;
int delay = (std::max)(m_settings.get_int(settings_pack::dht_announce_interval)
/ (std::max)(int(m_torrents.size()), 1), 1);

View File

@ -43,9 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#if defined TORRENT_ASIO_DEBUGGING
#include "libtorrent/debug.hpp"
#endif
namespace libtorrent
{
@ -141,9 +139,7 @@ namespace libtorrent
void on_close_socket(socket_type* s, boost::shared_ptr<void>)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("on_close_socket");
#endif
COMPLETE_ASYNC("on_close_socket");
error_code ec;
s->close(ec);
}

View File

@ -82,9 +82,7 @@ namespace libtorrent
void socks5_stream::name_lookup(error_code const& e, tcp::resolver::iterator i
, boost::shared_ptr<handler_type> h)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("socks5_stream::name_lookup");
#endif
COMPLETE_ASYNC("socks5_stream::name_lookup");
if (handle_error(e, h)) return;
error_code ec;
@ -96,18 +94,14 @@ namespace libtorrent
// TOOD: we could bind the socket here, since we know what the
// target endpoint is of the proxy
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::connected");
#endif
ADD_OUTSTANDING_ASYNC("socks5_stream::connected");
m_sock.async_connect(i->endpoint(), boost::bind(
&socks5_stream::connected, this, _1, 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");
#endif
COMPLETE_ASYNC("socks5_stream::connected");
if (handle_error(e, h)) return;
using namespace libtorrent::detail;
@ -128,9 +122,7 @@ namespace libtorrent
write_uint8(0, p); // no authentication
write_uint8(2, p); // username/password
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::handshake1");
#endif
ADD_OUTSTANDING_ASYNC("socks5_stream::handshake1");
async_write(m_sock, boost::asio::buffer(m_buffer)
, 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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("socks5_stream::handshake1");
#endif
COMPLETE_ASYNC("socks5_stream::handshake1");
if (handle_error(e, h)) return;
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::handshake2");
#endif
ADD_OUTSTANDING_ASYNC("socks5_stream::handshake2");
m_buffer.resize(2);
async_read(m_sock, boost::asio::buffer(m_buffer)
, 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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("socks5_stream::handshake2");
#endif
COMPLETE_ASYNC("socks5_stream::handshake2");
if (handle_error(e, h)) return;
using namespace libtorrent::detail;
@ -201,9 +187,7 @@ namespace libtorrent
write_uint8(uint8_t(m_password.size()), p);
write_string(m_password, p);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::handshake3");
#endif
ADD_OUTSTANDING_ASYNC("socks5_stream::handshake3");
async_write(m_sock, boost::asio::buffer(m_buffer)
, boost::bind(&socks5_stream::handshake3, this, _1, h));
}
@ -217,14 +201,10 @@ namespace libtorrent
void socks5_stream::handshake3(error_code const& e
, boost::shared_ptr<handler_type> h)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("socks5_stream::handshake3");
#endif
COMPLETE_ASYNC("socks5_stream::handshake3");
if (handle_error(e, h)) return;
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::handshake4");
#endif
ADD_OUTSTANDING_ASYNC("socks5_stream::handshake4");
m_buffer.resize(2);
async_read(m_sock, boost::asio::buffer(m_buffer)
, boost::bind(&socks5_stream::handshake4, this, _1, h));
@ -233,9 +213,7 @@ namespace libtorrent
void socks5_stream::handshake4(error_code const& e
, boost::shared_ptr<handler_type> h)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("socks5_stream::handshake4");
#endif
COMPLETE_ASYNC("socks5_stream::handshake4");
if (handle_error(e, h)) return;
using namespace libtorrent::detail;
@ -317,18 +295,14 @@ namespace libtorrent
return;
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::connect1");
#endif
ADD_OUTSTANDING_ASYNC("socks5_stream::connect1");
async_write(m_sock, boost::asio::buffer(m_buffer)
, boost::bind(&socks5_stream::connect1, this, _1, 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");
#endif
COMPLETE_ASYNC("socks5_stream::connect1");
if (handle_error(e, h)) return;
if (m_version == 5)
@ -336,18 +310,14 @@ namespace libtorrent
else if (m_version == 4)
m_buffer.resize(8);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::connect2");
#endif
ADD_OUTSTANDING_ASYNC("socks5_stream::connect2");
async_read(m_sock, boost::asio::buffer(m_buffer)
, boost::bind(&socks5_stream::connect2, this, _1, 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");
#endif
COMPLETE_ASYNC("socks5_stream::connect2");
if (handle_error(e, h)) return;
using namespace libtorrent::detail;
@ -389,9 +359,7 @@ namespace libtorrent
{
if (m_listen == 0)
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::connect1");
#endif
ADD_OUTSTANDING_ASYNC("socks5_stream::connect1");
m_listen = 1;
connect1(e, h);
return;
@ -424,9 +392,7 @@ namespace libtorrent
}
m_buffer.resize(m_buffer.size() + extra_bytes);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::connect3");
#endif
ADD_OUTSTANDING_ASYNC("socks5_stream::connect3");
TORRENT_ASSERT(extra_bytes > 0);
async_read(m_sock, boost::asio::buffer(&m_buffer[m_buffer.size() - extra_bytes], extra_bytes)
, boost::bind(&socks5_stream::connect3, this, _1, h));
@ -446,9 +412,7 @@ namespace libtorrent
{
if (m_listen == 0)
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::connect1");
#endif
ADD_OUTSTANDING_ASYNC("socks5_stream::connect1");
m_listen = 1;
connect1(e, h);
return;
@ -479,9 +443,7 @@ namespace libtorrent
void socks5_stream::connect3(error_code const& e, boost::shared_ptr<handler_type> h)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("socks5_stream::connect3");
#endif
COMPLETE_ASYNC("socks5_stream::connect3");
using namespace libtorrent::detail;
if (handle_error(e, h)) return;
@ -490,9 +452,7 @@ namespace libtorrent
{
if (m_listen == 0)
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::connect1");
#endif
ADD_OUTSTANDING_ASYNC("socks5_stream::connect1");
m_listen = 1;
connect1(e, h);
return;

View File

@ -2702,9 +2702,7 @@ namespace libtorrent
void torrent::on_tracker_announce_disp(boost::weak_ptr<torrent> p
, error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("tracker::on_tracker_announce_disp");
#endif
COMPLETE_ASYNC("tracker::on_tracker_announce_disp");
boost::shared_ptr<torrent> t = p.lock();
if (!t) return;
t->m_waiting_tracker = false;
@ -3324,9 +3322,7 @@ namespace libtorrent
// to do the name lookup
if (boost::algorithm::ends_with(i->hostname, ".b32.i2p"))
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("torrent::on_i2p_resolve");
#endif
ADD_OUTSTANDING_ASYNC("torrent::on_i2p_resolve");
r.i2pconn->async_name_lookup(i->hostname.c_str()
, boost::bind(&torrent::on_i2p_resolve
, shared_from_this(), _1, _2));
@ -3343,9 +3339,7 @@ namespace libtorrent
else
#endif
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("torrent::on_peer_name_lookup");
#endif
ADD_OUTSTANDING_ASYNC("torrent::on_peer_name_lookup");
m_ses.async_resolve(i->hostname, resolver_interface::abort_on_shutdown
, boost::bind(&torrent::on_peer_name_lookup
, shared_from_this(), _1, _2, i->port));
@ -3571,9 +3565,7 @@ namespace libtorrent
INVARIANT_CHECK;
#if defined TORRENT_ASIO_DEBUGGING
complete_async("torrent::on_i2p_resolve");
#endif
COMPLETE_ASYNC("torrent::on_i2p_resolve");
#ifndef TORRENT_DISABLE_LOGGING
if (ec)
debug_log("i2p_resolve error: %s", ec.message().c_str());
@ -3595,9 +3587,7 @@ namespace libtorrent
INVARIANT_CHECK;
#if defined TORRENT_ASIO_DEBUGGING
complete_async("torrent::on_peer_name_lookup");
#endif
COMPLETE_ASYNC("torrent::on_peer_name_lookup");
#ifndef TORRENT_DISABLE_LOGGING
if (e)
@ -9546,9 +9536,7 @@ namespace libtorrent
error_code ec;
boost::weak_ptr<torrent> self(shared_from_this());
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("tracker::on_tracker_announce_disp");
#endif
ADD_OUTSTANDING_ASYNC("tracker::on_tracker_announce_disp");
m_tracker_timer.expires_at(next_announce, ec);
m_tracker_timer.async_wait(boost::bind(&torrent::on_tracker_announce_disp, self, _1));
}

View File

@ -88,9 +88,7 @@ namespace libtorrent
: (std::min)(m_completion_timeout, timeout);
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("timeout_handler::timeout_callback");
#endif
ADD_OUTSTANDING_ASYNC("timeout_handler::timeout_callback");
error_code ec;
m_timeout.expires_at(m_read_time + seconds(timeout), ec);
m_timeout.async_wait(boost::bind(
@ -112,9 +110,7 @@ namespace libtorrent
void timeout_handler::timeout_callback(error_code const& error)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("timeout_handler::timeout_callback");
#endif
COMPLETE_ASYNC("timeout_handler::timeout_callback");
if (m_abort) return;
time_point now = clock_type::now();
@ -139,9 +135,7 @@ namespace libtorrent
? 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);
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("timeout_handler::timeout_callback");
#endif
ADD_OUTSTANDING_ASYNC("timeout_handler::timeout_callback");
error_code ec;
m_timeout.expires_at(m_read_time + seconds(timeout), ec);
m_timeout.async_wait(

View File

@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/settings_pack.hpp"
#include "libtorrent/error.hpp"
#include "libtorrent/aux_/time.hpp" // for aux::time_now()
#include "libtorrent/debug.hpp"
#include <stdlib.h>
#include <boost/bind.hpp>
@ -50,10 +51,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/asio/read.hpp>
#include <boost/asio/ip/v6_only.hpp>
#if defined TORRENT_ASIO_DEBUGGING
#include "libtorrent/debug.hpp"
#endif
using namespace libtorrent;
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
void udp_socket::on_read(error_code const& ec, udp::socket* s)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_read");
#endif
COMPLETE_ASYNC("udp_socket::on_read");
TORRENT_ASSERT(m_magic == 0x1337);
TORRENT_ASSERT(is_single_thread());
@ -553,9 +548,7 @@ void udp_socket::setup_read(udp::socket* s)
++m_v4_outstanding;
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("udp_socket::on_read");
#endif
ADD_OUTSTANDING_ASYNC("udp_socket::on_read");
udp::endpoint ep;
TORRENT_TRY
@ -875,9 +868,7 @@ void udp_socket::set_proxy_settings(aux::proxy_settings const& ps)
#if TORRENT_USE_ASSERTS
++m_outstanding_resolve;
#endif
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("udp_socket::on_name_lookup");
#endif
ADD_OUTSTANDING_ASYNC("udp_socket::on_name_lookup");
m_resolver.async_resolve(q, boost::bind(
&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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_name_lookup");
#endif
COMPLETE_ASYNC("udp_socket::on_name_lookup");
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_resolve > 0);
--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.port(i->endpoint().port());
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("udp_socket::on_connected");
#endif
ADD_OUTSTANDING_ASYNC("udp_socket::on_connected");
error_code 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;
#endif
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("udp_socket::on_connect_timeout");
#endif
ADD_OUTSTANDING_ASYNC("udp_socket::on_connect_timeout");
m_timer.expires_from_now(seconds(10));
m_timer.async_wait(boost::bind(&udp_socket::on_connect_timeout
, 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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_connect_timeout");
#endif
COMPLETE_ASYNC("udp_socket::on_connect_timeout");
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_timeout > 0);
--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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_connected");
#endif
COMPLETE_ASYNC("udp_socket::on_connected");
TORRENT_ASSERT(is_single_thread());
@ -1071,9 +1052,7 @@ void udp_socket::on_connected(error_code const& e)
write_uint8(2, p); // username/password
}
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");
#endif
ADD_OUTSTANDING_ASYNC("udp_socket::on_handshake1");
++m_outstanding_ops;
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
@ -1084,9 +1063,7 @@ void udp_socket::on_connected(error_code const& e)
void udp_socket::handshake1(error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_handshake1");
#endif
COMPLETE_ASYNC("udp_socket::on_handshake1");
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;
@ -1111,9 +1088,7 @@ void udp_socket::handshake1(error_code const& e)
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("udp_socket::on_handshake2");
#endif
ADD_OUTSTANDING_ASYNC("udp_socket::on_handshake2");
++m_outstanding_ops;
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
@ -1124,9 +1099,7 @@ void udp_socket::handshake1(error_code const& e)
void udp_socket::handshake2(error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_handshake2");
#endif
COMPLETE_ASYNC("udp_socket::on_handshake2");
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--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_string(m_proxy_settings.password, p);
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");
#endif
ADD_OUTSTANDING_ASYNC("udp_socket::on_handshake3");
++m_outstanding_ops;
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
@ -1211,9 +1182,7 @@ void udp_socket::handshake2(error_code const& e)
void udp_socket::handshake3(error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_handshake3");
#endif
COMPLETE_ASYNC("udp_socket::on_handshake3");
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;
@ -1238,9 +1207,7 @@ void udp_socket::handshake3(error_code const& e)
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("udp_socket::on_handshake4");
#endif
ADD_OUTSTANDING_ASYNC("udp_socket::on_handshake4");
++m_outstanding_ops;
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
@ -1251,9 +1218,7 @@ void udp_socket::handshake3(error_code const& e)
void udp_socket::handshake4(error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::on_handshake4");
#endif
COMPLETE_ASYNC("udp_socket::on_handshake4");
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;
@ -1308,9 +1273,7 @@ void udp_socket::socks_forward_udp()
write_uint32(0, p); // 0.0.0.0
write_uint16(0, p); // :0
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");
#endif
ADD_OUTSTANDING_ASYNC("udp_socket::connect1");
++m_outstanding_ops;
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
@ -1321,9 +1284,7 @@ void udp_socket::socks_forward_udp()
void udp_socket::connect1(error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::connect1");
#endif
COMPLETE_ASYNC("udp_socket::connect1");
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;
@ -1348,9 +1309,7 @@ void udp_socket::connect1(error_code const& e)
TORRENT_ASSERT(is_single_thread());
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("udp_socket::connect2");
#endif
ADD_OUTSTANDING_ASYNC("udp_socket::connect2");
++m_outstanding_ops;
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
@ -1361,9 +1320,7 @@ void udp_socket::connect1(error_code const& e)
void udp_socket::connect2(error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::connect2");
#endif
COMPLETE_ASYNC("udp_socket::connect2");
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;
@ -1419,9 +1376,7 @@ void udp_socket::connect2(error_code const& e)
m_tunnel_packets = true;
drain_queue();
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("udp_socket::hung_up");
#endif
ADD_OUTSTANDING_ASYNC("udp_socket::hung_up");
++m_outstanding_ops;
#if TORRENT_USE_ASSERTS
++m_outstanding_socks;
@ -1432,9 +1387,7 @@ void udp_socket::connect2(error_code const& e)
void udp_socket::hung_up(error_code const& e)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_socket::hung_up");
#endif
COMPLETE_ASYNC("udp_socket::hung_up");
#if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_outstanding_socks > 0);
--m_outstanding_socks;

View File

@ -109,9 +109,7 @@ namespace libtorrent
}
else
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("udp_tracker_connection::name_lookup");
#endif
ADD_OUTSTANDING_ASYNC("udp_tracker_connection::name_lookup");
// when stopping, pass in the prefer cache flag, because we
// don't want to get stuck on DNS lookups when shutting down
// if we can avoid it
@ -177,9 +175,7 @@ namespace libtorrent
void udp_tracker_connection::name_lookup(error_code const& error
, std::vector<address> const& addresses, int port)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("udp_tracker_connection::name_lookup");
#endif
COMPLETE_ASYNC("udp_tracker_connection::name_lookup");
if (m_abort) return;
if (error == boost::asio::error::operation_aborted) return;
if (error || addresses.empty())

View File

@ -40,10 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/random.hpp"
#include "libtorrent/aux_/time.hpp" // for aux::time_now()
#include "libtorrent/aux_/escape_string.hpp" // for convert_from_native
#if defined TORRENT_ASIO_DEBUGGING
#include "libtorrent/debug.hpp"
#endif
#include "libtorrent/aux_/disable_warnings_push.hpp"
@ -151,9 +148,7 @@ void upnp::discover_device_impl(mutex::scoped_lock& l)
return;
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("upnp::resend_request");
#endif
ADD_OUTSTANDING_ASYNC("upnp::resend_request");
++m_retry_count;
m_broadcast_timer.expires_from_now(seconds(2 * m_retry_count), ec);
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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("upnp::resend_request");
#endif
COMPLETE_ASYNC("upnp::resend_request");
if (ec) return;
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 defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("upnp::map_timer");
#endif
ADD_OUTSTANDING_ASYNC("upnp::map_timer");
// 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
// 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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("upnp::map_timer");
#endif
COMPLETE_ASYNC("upnp::map_timer");
if (ec) 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()
|| next_expire > m.expires)
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("upnp::on_expire");
#endif
ADD_OUTSTANDING_ASYNC("upnp::on_expire");
error_code ec;
m_refresh_timer.expires_at(m.expires, ec);
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)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("upnp::on_expire");
#endif
COMPLETE_ASYNC("upnp::on_expire");
if (ec) return;
time_point now = aux::time_now();
@ -1518,9 +1503,7 @@ void upnp::on_expire(error_code const& ec)
}
if (next_expire != max_time())
{
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("upnp::on_expire");
#endif
ADD_OUTSTANDING_ASYNC("upnp::on_expire");
error_code e;
m_refresh_timer.expires_at(next_expire, e);
m_refresh_timer.async_wait(boost::bind(&upnp::on_expire, self(), _1));