forked from premiere/premiere-libtorrent
improve peer logging
This commit is contained in:
parent
7878f68370
commit
77be259938
|
@ -3979,6 +3979,9 @@ namespace libtorrent {
|
||||||
if (m_request_large_blocks)
|
if (m_request_large_blocks)
|
||||||
{
|
{
|
||||||
int const blocks_per_piece = t->torrent_file().piece_length() / t->block_size();
|
int const blocks_per_piece = t->torrent_file().piece_length() / t->block_size();
|
||||||
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
|
std::stringstream log_msg;
|
||||||
|
#endif
|
||||||
|
|
||||||
while (!m_request_queue.empty())
|
while (!m_request_queue.empty())
|
||||||
{
|
{
|
||||||
|
@ -4000,10 +4003,11 @@ namespace libtorrent {
|
||||||
if (m_queued_time_critical) --m_queued_time_critical;
|
if (m_queued_time_critical) --m_queued_time_critical;
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
peer_log(peer_log_alert::info, "MERGING_REQUEST"
|
if (should_log(peer_log_alert::info))
|
||||||
, "piece: %d block: %d"
|
{
|
||||||
, static_cast<int>(block.block.piece_index)
|
log_msg << " (" << block.block.piece_index << ", "
|
||||||
, block.block.block_index);
|
<< block.block.block_index << ")";
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
block_offset = block.block.block_index * t->block_size();
|
block_offset = block.block.block_index * t->block_size();
|
||||||
|
@ -4018,6 +4022,12 @@ namespace libtorrent {
|
||||||
check_invariant();
|
check_invariant();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
|
peer_log(peer_log_alert::info, "MERGING_REQUEST"
|
||||||
|
, "%s", log_msg.str().c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// the verification will fail for coalesced blocks
|
// the verification will fail for coalesced blocks
|
||||||
|
|
|
@ -300,6 +300,11 @@ void web_peer_connection::write_request(peer_request const& r)
|
||||||
const int block_size = t->block_size();
|
const int block_size = t->block_size();
|
||||||
const int piece_size = t->torrent_file().piece_length();
|
const int piece_size = t->torrent_file().piece_length();
|
||||||
peer_request pr;
|
peer_request pr;
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
|
std::stringstream log_msg;
|
||||||
|
#endif
|
||||||
|
|
||||||
while (size > 0)
|
while (size > 0)
|
||||||
{
|
{
|
||||||
int request_offset = r.start + r.length - size;
|
int request_offset = r.start + r.length - size;
|
||||||
|
@ -309,8 +314,8 @@ void web_peer_connection::write_request(peer_request const& r)
|
||||||
m_requests.push_back(pr);
|
m_requests.push_back(pr);
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
peer_log(peer_log_alert::outgoing_message, "REQUESTING", "piece: %d start: %d len: %d"
|
if (should_log(peer_log_alert::info))
|
||||||
, static_cast<int>(pr.piece), pr.start, pr.length);
|
log_msg << " (" << pr.piece << ", " << pr.start << ", " << pr.length << ")";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_web->restart_request == m_requests.front())
|
if (m_web->restart_request == m_requests.front())
|
||||||
|
@ -322,9 +327,9 @@ void web_peer_connection::write_request(peer_request const& r)
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
if (should_log(peer_log_alert::info))
|
if (should_log(peer_log_alert::info))
|
||||||
{
|
{
|
||||||
peer_log(peer_log_alert::info, "RESTART_DATA", "data: %d req: (%d, %d) size: %d"
|
log_msg << " (restart data: " << m_piece.size()
|
||||||
, int(m_piece.size()), static_cast<int>(front.piece), front.start
|
<< " req: (" << front.piece << ", " << front.start << ") size: "
|
||||||
, front.start + front.length - 1);
|
<< (front.start + front.length - 1);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
TORRENT_UNUSED(front);
|
TORRENT_UNUSED(front);
|
||||||
|
@ -345,6 +350,10 @@ void web_peer_connection::write_request(peer_request const& r)
|
||||||
size -= pr.length;
|
size -= pr.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
|
peer_log(peer_log_alert::outgoing_message, "REQUESTING", "%s", log_msg.str().c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
bool const single_file_request = t->torrent_file().num_files() == 1;
|
bool const single_file_request = t->torrent_file().num_files() == 1;
|
||||||
int const proxy_type = m_settings.get_int(settings_pack::proxy_type);
|
int const proxy_type = m_settings.get_int(settings_pack::proxy_type);
|
||||||
bool const using_proxy = (proxy_type == settings_pack::http
|
bool const using_proxy = (proxy_type == settings_pack::http
|
||||||
|
|
Loading…
Reference in New Issue