improve some uTP logging

This commit is contained in:
Arvid Norberg 2012-06-25 05:57:59 +00:00
parent c24b372191
commit 6be3357759
1 changed files with 13 additions and 9 deletions

View File

@ -387,6 +387,8 @@ struct utp_socket_impl
// write callbacks (unless the buffers fill up
// before)
ptime m_read_timeout;
// TODO: remove the write timeout concept, and maybe even the read timeout
ptime m_write_timeout;
// the time when the last packet we sent times out. Including re-sends.
@ -985,8 +987,8 @@ size_t utp_stream::read_some(bool clear_buffers)
TORRENT_ASSERT(m_impl->m_receive_buffer_size == 0
|| m_impl->m_read_buffer.empty());
UTP_LOGV("%8p: %d packets moved from buffer to user space\n"
, m_impl, pop_packets);
UTP_LOGV("%8p: %d packets moved from buffer to user space (%d bytes)\n"
, m_impl, pop_packets, int(ret));
if (clear_buffers)
{
@ -1327,8 +1329,9 @@ void utp_socket_impl::parse_sack(boost::uint16_t packet_ack, char const* ptr
// this is the sequence number the current bit represents
int ack_nr = (packet_ack + 2) & ACK_MASK;
#if TORRENT_UTP_LOG
#if TORRENT_VERBOSE_UTP_LOG
std::string bitmask;
bitmask.reserve(size);
for (char const* b = ptr, *end = ptr + size; b != end; ++b)
{
unsigned char bitfield = unsigned(*b);
@ -1478,6 +1481,8 @@ void utp_socket_impl::write_payload(char* ptr, int size)
void utp_socket_impl::defer_ack()
{
if (m_deferred_ack) return;
UTP_LOGV("%8p: defer ack\n", this);
m_deferred_ack = true;
m_sm->defer_ack(this);
}
@ -1660,8 +1665,6 @@ bool utp_socket_impl::send_pkt(bool ack)
, h->extension);
#endif
TORRENT_ASSERT(!m_error);
error_code ec;
#ifdef TORRENT_DEBUG
// simulate 1% packet loss
@ -1928,6 +1931,7 @@ void utp_socket_impl::incoming(char const* buf, int size, packet* p, ptime now)
target->buf = ((char*)target->buf) + to_copy;
target->len -= to_copy;
buf += to_copy;
UTP_LOGV("%8p: copied %d bytes into user receive buffer\n", this, to_copy);
TORRENT_ASSERT(m_read_buffer_size >= to_copy);
m_read_buffer_size -= to_copy;
size -= to_copy;
@ -2470,16 +2474,16 @@ bool utp_socket_impl::incoming_packet(char const* buf, int size
m_remote_address = ep.address();
m_port = ep.port();
#if TORRENT_UTP_LOG
UTP_LOGV("%8p: state:%s\n"
, this, socket_state_names[m_state]);
#endif
m_ack_nr = ph->seq_nr;
m_seq_nr = random();
m_acked_seq_nr = (m_seq_nr - 1) & ACK_MASK;
m_loss_seq_nr = m_acked_seq_nr;
m_fast_resend_seq_nr = m_seq_nr;
#if TORRENT_UTP_LOG
UTP_LOGV("%8p: received ST_SYN state:%s seq_nr:%d ack_nr:%d\n"
, this, socket_state_names[m_state], m_seq_nr, m_ack_nr);
#endif
TORRENT_ASSERT(m_send_id == ph->connection_id);
TORRENT_ASSERT(m_recv_id == ((m_send_id + 1) & 0xffff));