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

@@ -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));
}