added missing asio-debugging mark-up

This commit is contained in:
Arvid Norberg 2013-08-21 15:41:19 +00:00
parent ec7809abb5
commit d5c715bf96
4 changed files with 112 additions and 2 deletions

View File

@ -37,6 +37,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include "libtorrent/proxy_base.hpp"
#if defined TORRENT_ASIO_DEBUGGING
#include "libtorrent/debug.hpp"
#endif
namespace libtorrent {
@ -142,6 +145,9 @@ 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
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

@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include "libtorrent/pch.hpp"
#if TORRENT_USE_I2P
#include "libtorrent/i2p_stream.hpp"
#include "libtorrent/assert.hpp"
@ -38,7 +38,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp>
#if TORRENT_USE_I2P
#if defined TORRENT_ASIO_DEBUGGING
#include "libtorrent/debug.hpp"
#endif
namespace libtorrent
{
@ -105,12 +107,18 @@ 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
m_sam_socket->async_connect(tcp::endpoint()
, boost::bind(&i2p_connection::on_sam_connect, this, _1, handler));
}
void i2p_connection::on_sam_connect(error_code const& ec, i2p_stream::handler_type const& h)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("i2p_stream::on_sam_connect");
#endif
m_state = sam_idle;
do_name_lookup("ME", boost::bind(&i2p_connection::set_local_endpoint, this, _1, _2));
@ -191,17 +199,27 @@ namespace libtorrent
return;
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::connected");
#endif
m_sock.async_connect(i->endpoint(), boost::bind(
&i2p_stream::connected, this, _1, h));
}
void i2p_stream::connected(error_code const& e, boost::shared_ptr<handler_type> h)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("i2p_stream::connected");
#endif
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
async_write(m_sock, asio::buffer(cmd, sizeof(cmd) - 1)
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
// fputs(cmd, stderr);
@ -209,8 +227,14 @@ namespace libtorrent
void i2p_stream::start_read_line(error_code const& e, boost::shared_ptr<handler_type> h)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("i2p_stream::start_read_line");
#endif
if (handle_error(e, h)) return;
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::read_line");
#endif
m_buffer.resize(1);
async_read(m_sock, asio::buffer(m_buffer)
, boost::bind(&i2p_stream::read_line, this, _1, h));
@ -229,6 +253,9 @@ namespace libtorrent
void i2p_stream::read_line(error_code const& e, boost::shared_ptr<handler_type> h)
{
#if defined TORRENT_ASIO_DEBUGGING
complete_async("i2p_stream::read_line");
#endif
if (handle_error(e, h)) return;
int read_pos = m_buffer.size();
@ -237,6 +264,9 @@ 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
// read another byte from the socket
m_buffer.resize(read_pos + 1);
async_read(m_sock, asio::buffer(&m_buffer[read_pos], 1)
@ -379,6 +409,9 @@ 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
async_read(m_sock, asio::buffer(m_buffer)
, boost::bind(&i2p_stream::read_line, this, _1, h));
break;
@ -394,6 +427,9 @@ namespace libtorrent
int size = snprintf(cmd, sizeof(cmd), "STREAM CONNECT ID=%s DESTINATION=%s\n"
, m_id, m_dest.c_str());
// fputs(cmd, stderr);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::start_read_line");
#endif
async_write(m_sock, asio::buffer(cmd, size)
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
}
@ -404,6 +440,9 @@ namespace libtorrent
char cmd[400];
int size = snprintf(cmd, sizeof(cmd), "STREAM ACCEPT ID=%s\n", m_id);
// fputs(cmd, stderr);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::start_read_line");
#endif
async_write(m_sock, asio::buffer(cmd, size)
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
}
@ -415,6 +454,9 @@ namespace libtorrent
int size = snprintf(cmd, sizeof(cmd), "SESSION CREATE STYLE=STREAM ID=%s DESTINATION=TRANSIENT\n"
, m_id);
// fputs(cmd, stderr);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::start_read_line");
#endif
async_write(m_sock, asio::buffer(cmd, size)
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
}
@ -425,6 +467,9 @@ namespace libtorrent
char cmd[1024];
int size = snprintf(cmd, sizeof(cmd), "NAMING LOOKUP NAME=%s\n", m_name_lookup.c_str());
// fputs(cmd, stderr);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("i2p_stream::start_read_line");
#endif
async_write(m_sock, asio::buffer(cmd, size)
, boost::bind(&i2p_stream::start_read_line, this, _1, h));
}

View File

@ -2705,6 +2705,9 @@ retry:
{
// 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
s->get<ssl_stream<stream_socket> >()->async_accept_handshake(
boost::bind(&session_impl::ssl_handshake, this, _1, s));
}
@ -2725,6 +2728,9 @@ retry:
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
error_code e;
tcp::endpoint endp = s->remote_endpoint(e);
if (e) return;

View File

@ -71,6 +71,9 @@ 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
if (e || i == tcp::resolver::iterator())
{
(*h)(e);
@ -93,12 +96,18 @@ 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
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
if (e)
{
(*h)(e);
@ -125,6 +134,9 @@ 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
async_write(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks5_stream::handshake1, this, _1, h));
}
@ -142,6 +154,9 @@ 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
if (e)
{
(*h)(e);
@ -150,6 +165,9 @@ namespace libtorrent
return;
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::handshake2");
#endif
m_buffer.resize(2);
async_read(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks5_stream::handshake2, this, _1, h));
@ -157,6 +175,9 @@ 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
if (e)
{
(*h)(e);
@ -201,6 +222,10 @@ namespace libtorrent
write_string(m_user, p);
write_uint8(m_password.size(), p);
write_string(m_password, p);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::handshake3");
#endif
async_write(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks5_stream::handshake3, this, _1, h));
}
@ -216,6 +241,9 @@ 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
if (e)
{
(*h)(e);
@ -224,6 +252,9 @@ namespace libtorrent
return;
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::handshake4");
#endif
m_buffer.resize(2);
async_read(m_sock, asio::buffer(m_buffer)
, boost::bind(&socks5_stream::handshake4, this, _1, h));
@ -232,6 +263,9 @@ 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
if (e)
{
(*h)(e);
@ -315,12 +349,18 @@ namespace libtorrent
return;
}
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::connect1");
#endif
async_write(m_sock, 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
if (e)
{
(*h)(e);
@ -333,12 +373,19 @@ namespace libtorrent
m_buffer.resize(6 + 4); // assume an IPv4 address
else if (m_version == 4)
m_buffer.resize(8);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::connect2");
#endif
async_read(m_sock, 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
if (e)
{
(*h)(e);
@ -423,6 +470,9 @@ namespace libtorrent
}
m_buffer.resize(m_buffer.size() + extra_bytes);
#if defined TORRENT_ASIO_DEBUGGING
add_outstanding_async("socks5_stream::connect3");
#endif
TORRENT_ASSERT(extra_bytes > 0);
async_read(m_sock, asio::buffer(&m_buffer[m_buffer.size() - extra_bytes], extra_bytes)
, boost::bind(&socks5_stream::connect3, this, _1, h));
@ -476,6 +526,9 @@ 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
using namespace libtorrent::detail;
if (e)