piece request fix + better logging of throttling

This commit is contained in:
Arvid Norberg 2008-02-27 20:37:41 +00:00
parent 69d2fc5a7b
commit 35c113c0cb
1 changed files with 30 additions and 6 deletions

View File

@ -1452,6 +1452,8 @@ namespace libtorrent
#if !defined NDEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
t->check_invariant();
#endif
request_a_block(*t, *this);
send_block_requests();
}
void peer_connection::on_disk_write_complete(int ret, disk_io_job const& j
@ -2564,7 +2566,7 @@ namespace libtorrent
if (m_bandwidth_limit[upload_channel].max_assignable() > 0)
{
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << "req bandwidth [ " << upload_channel << " ]\n";
(*m_logger) << time_now_string() << " *** REQUEST_BANDWIDTH [ upload ]\n";
#endif
// peers that we are not interested in are non-prioritized
@ -2576,7 +2578,18 @@ namespace libtorrent
return;
}
if (!can_write()) return;
if (!can_write())
{
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << time_now_string() << " *** CANNOT WRITE ["
" quota: " << m_bandwidth_limit[download_channel].quota_left() <<
" ignore: " << (m_ignore_bandwidth_limits?"yes":"no") <<
" buf: " << m_send_buffer.size() <<
" connecting: " << (m_connecting?"yes":"no") <<
" ]\n";
#endif
return;
}
// send the actual buffer
if (!m_send_buffer.empty())
@ -2589,7 +2602,7 @@ namespace libtorrent
TORRENT_ASSERT(amount_to_send > 0);
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << "async_write " << amount_to_send << " bytes\n";
(*m_logger) << time_now_string() << " *** ASYNC_WRITE [ bytes: " << amount_to_send << " ]\n";
#endif
std::list<asio::const_buffer> const& vec = m_send_buffer.build_iovec(amount_to_send);
m_socket->async_write_some(vec, bind(&peer_connection::on_send_data, self(), _1, _2));
@ -2616,7 +2629,7 @@ namespace libtorrent
if (m_bandwidth_limit[download_channel].max_assignable() > 0)
{
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << "req bandwidth [ " << download_channel << " ]\n";
(*m_logger) << time_now_string() << " *** REQUEST_BANDWIDTH [ download ]\n";
#endif
TORRENT_ASSERT(m_channel_state[download_channel] == peer_info::bw_idle);
m_channel_state[download_channel] = peer_info::bw_torrent;
@ -2626,7 +2639,18 @@ namespace libtorrent
return;
}
if (!can_read()) return;
if (!can_read())
{
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << time_now_string() << " *** CANNOT READ ["
" quota: " << m_bandwidth_limit[download_channel].quota_left() <<
" ignore: " << (m_ignore_bandwidth_limits?"yes":"no") <<
" outstanding: " << m_outstanding_writing_bytes <<
" outstanding-limit: " << m_ses.settings().max_outstanding_disk_bytes_per_connection <<
" ]\n";
#endif
return;
}
TORRENT_ASSERT(m_packet_size > 0);
int max_receive = m_packet_size - m_recv_pos;
@ -2640,7 +2664,7 @@ namespace libtorrent
TORRENT_ASSERT(m_packet_size > 0);
TORRENT_ASSERT(can_read());
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << "async_read " << max_receive << " bytes\n";
(*m_logger) << time_now_string() << " *** ASYNC_READ [ max: " << max_receive << " bytes ]\n";
#endif
m_socket->async_read_some(asio::buffer(&m_recv_buffer[m_recv_pos]
, max_receive), bind(&peer_connection::on_receive_data, self(), _1, _2));