remove unused aligned_holder class. fix logging issue of out-of-bound piece requests

This commit is contained in:
arvidn 2016-03-19 23:32:50 -04:00
parent e9b334ce63
commit 85cf5ac195
2 changed files with 7 additions and 28 deletions

View File

@ -53,29 +53,6 @@ namespace libtorrent
#endif
};
struct TORRENT_EXTRA_EXPORT aligned_holder
{
aligned_holder(): m_buf(0) {}
aligned_holder(int size): m_buf(page_aligned_allocator::malloc(size)) {}
~aligned_holder() { if (m_buf) page_aligned_allocator::free(m_buf); }
char* get() const { return m_buf; }
void reset(char* buf = 0)
{
if (m_buf) page_aligned_allocator::free(m_buf);
m_buf = buf;
}
void swap(aligned_holder& h)
{
char* tmp = m_buf;
m_buf = h.m_buf;
h.m_buf = tmp;
}
private:
aligned_holder(aligned_holder const&);
aligned_holder& operator=(aligned_holder const&);
char* m_buf;
};
}
#endif

View File

@ -2212,6 +2212,9 @@ namespace libtorrent
m_counters.inc_stats_counter(counters::piece_requests);
#ifndef TORRENT_DISABLE_LOGGING
const bool valid_piece_index
= r.piece >= 0 && r.piece < int(t->torrent_file().num_pieces());
peer_log(peer_log_alert::incoming_message, "REQUEST"
, "piece: %d s: %x l: %x", r.piece, r.start, r.length);
#endif
@ -2222,9 +2225,6 @@ namespace libtorrent
m_counters.inc_stats_counter(counters::invalid_piece_requests);
++m_num_invalid_requests;
#ifndef TORRENT_DISABLE_LOGGING
const bool valid_piece_index
= r.piece >= 0 && r.piece < int(t->torrent_file().num_pieces());
peer_log(peer_log_alert::info, "INVALID_REQUEST", "piece not superseeded "
"i: %d t: %d n: %d h: %d ss1: %d ss2: %d"
, m_peer_interested
@ -2306,7 +2306,8 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_LOGGING
peer_log(peer_log_alert::info, "INVALID_REQUEST", "peer is not interested "
" t: %d n: %d block_limit: %d"
, int(t->torrent_file().piece_size(r.piece))
, valid_piece_index
? int(t->torrent_file().piece_size(r.piece)) : -1
, t->torrent_file().num_pieces()
, t->block_size());
peer_log(peer_log_alert::info, "INTERESTED", "artificial incoming INTERESTED message");
@ -2346,7 +2347,8 @@ namespace libtorrent
peer_log(peer_log_alert::info, "INVALID_REQUEST"
, "i: %d t: %d n: %d h: %d block_limit: %d"
, m_peer_interested
, int(t->torrent_file().piece_size(r.piece))
, valid_piece_index
? int(t->torrent_file().piece_size(r.piece)) : -1
, t->torrent_file().num_pieces()
, t->has_piece_passed(r.piece)
, t->block_size());