*** empty log message ***
This commit is contained in:
parent
4011f16044
commit
6ff7e76ab2
|
@ -208,7 +208,7 @@ namespace libtorrent
|
|||
void set_failed() { m_failed = true; }
|
||||
bool failed() const { return m_failed; }
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
boost::shared_ptr<logger> m_logger;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -216,11 +216,11 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
// selects which vector to look in
|
||||
unsigned peer_count : 7;
|
||||
unsigned peer_count : 11;
|
||||
// is 1 if the piece is marked as being downloaded
|
||||
unsigned downloading : 1;
|
||||
// index in to the piece_info vector
|
||||
unsigned index : 24;
|
||||
unsigned index : 20;
|
||||
|
||||
bool operator!=(piece_pos p)
|
||||
{ return index != p.index || peer_count != p.peer_count; }
|
||||
|
@ -254,7 +254,7 @@ namespace libtorrent
|
|||
|
||||
// this maps indices to number of peers that has this piece and
|
||||
// index into the m_piece_info vectors.
|
||||
// 0xffffff means that we have the piece, so it doesn't
|
||||
// 0xfffff means that we have the piece, so it doesn't
|
||||
// exist in the piece_info buckets
|
||||
std::vector<piece_pos> m_piece_map;
|
||||
|
||||
|
|
|
@ -264,6 +264,8 @@ namespace libtorrent
|
|||
|
||||
#ifndef NDEBUG
|
||||
void check_invariant(const char *place = 0);
|
||||
#endif
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
boost::shared_ptr<logger> create_log(std::string const& name);
|
||||
boost::shared_ptr<logger> m_logger;
|
||||
#endif
|
||||
|
|
|
@ -63,7 +63,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
namespace libtorrent
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
struct logger;
|
||||
#endif
|
||||
|
||||
|
@ -313,11 +313,15 @@ namespace libtorrent
|
|||
|
||||
torrent_handle get_handle() const;
|
||||
|
||||
// DEBUG
|
||||
#ifndef NDEBUG
|
||||
// LOGGING
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
logger* spawn_logger(const char* title);
|
||||
|
||||
virtual void debug_log(const std::string& line);
|
||||
#endif
|
||||
|
||||
// DEBUG
|
||||
#ifndef NDEBUG
|
||||
void check_invariant() const;
|
||||
#endif
|
||||
|
||||
|
@ -508,3 +512,4 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#endif // TORRENT_TORRENT_HPP_INCLUDED
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace libtorrent
|
|||
|
||||
address m_tracker_address;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
virtual void debug_log(const std::string& line) = 0;
|
||||
#endif
|
||||
private:
|
||||
|
@ -178,3 +178,4 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#endif // TORRENT_TRACKER_MANAGER_HPP_INCLUDED
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ namespace libtorrent
|
|||
m_send_buffer += base64encode(auth);
|
||||
}
|
||||
m_send_buffer += "\r\n\r\n";
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester())
|
||||
{
|
||||
requester().debug_log("==> TRACKER_REQUEST [ str: " + m_send_buffer + " ]");
|
||||
|
@ -223,7 +223,7 @@ namespace libtorrent
|
|||
info_hash_str << req.info_hash;
|
||||
requester().debug_log("info_hash: " + info_hash_str.str() + "\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
m_socket = s;
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ namespace libtorrent
|
|||
// the connections list.
|
||||
bool http_tracker_connection::tick()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
try
|
||||
{
|
||||
#endif
|
||||
|
@ -246,9 +246,9 @@ namespace libtorrent
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester()) requester().debug_log("tracker connection tick");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// if we have a send buffer and the socket is ready for writing
|
||||
// send the buffer
|
||||
|
@ -287,9 +287,9 @@ namespace libtorrent
|
|||
if (!m_socket->is_readable()) return false;
|
||||
m_request_time = second_clock::universal_time();
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester()) requester().debug_log("tracker connection socket readable");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// if the receive buffer is full, expand it with http_buffer_size
|
||||
if ((int)m_buffer.size() == m_recv_pos)
|
||||
|
@ -317,9 +317,9 @@ namespace libtorrent
|
|||
|
||||
if (received > 0) m_recv_pos += received;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester()) requester().debug_log("received: " + boost::lexical_cast<std::string>(m_recv_pos));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (m_state == read_status)
|
||||
{
|
||||
|
@ -339,9 +339,9 @@ namespace libtorrent
|
|||
// if we don't have a full line yet, wait.
|
||||
if (newline == end) return false;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester()) requester().debug_log(std::string(m_buffer.begin(), newline));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
std::istringstream line(std::string(m_buffer.begin(), newline));
|
||||
++newline;
|
||||
|
@ -380,9 +380,9 @@ namespace libtorrent
|
|||
{
|
||||
line.assign(m_buffer.begin(), newline);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester()) requester().debug_log(line);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (line.substr(0, 16) == "Content-Length: ")
|
||||
{
|
||||
|
@ -450,9 +450,9 @@ namespace libtorrent
|
|||
else if (line.size() < 3)
|
||||
{
|
||||
m_state = read_body;
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester()) requester().debug_log("end of http header");
|
||||
#endif
|
||||
#endif
|
||||
if (m_code >= 300 && m_code < 400)
|
||||
{
|
||||
if (m_location.empty())
|
||||
|
@ -465,7 +465,7 @@ namespace libtorrent
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester()) requester().debug_log("Redirecting to \"" + m_location + "\"");
|
||||
#endif
|
||||
std::string::size_type i = m_location.find('?');
|
||||
|
@ -523,7 +523,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
return false;
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
|
@ -653,3 +653,4 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -175,6 +175,7 @@ namespace
|
|||
, map_entry("U", "UPnP")
|
||||
, map_entry("XT", "XanTorrent")
|
||||
, map_entry("ZT", "ZipTorrent")
|
||||
, map_entry("pX", "pHoeniX")
|
||||
};
|
||||
|
||||
bool compare_first_string(map_entry const& e, char const* str)
|
||||
|
|
|
@ -136,9 +136,9 @@ namespace libtorrent
|
|||
assert(!m_socket->is_blocking());
|
||||
assert(m_torrent != 0);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
m_logger = m_ses.create_log(s->sender().as_string().c_str());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
std::fill(m_peer_id.begin(), m_peer_id.end(), 0);
|
||||
|
||||
|
@ -220,9 +220,9 @@ namespace libtorrent
|
|||
|
||||
std::fill(m_peer_id.begin(), m_peer_id.end(), 0);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
m_logger = m_ses.create_log(s->sender().as_string().c_str());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// initialize the extension list to zero, since
|
||||
// we don't know which extensions the other
|
||||
|
@ -277,13 +277,13 @@ namespace libtorrent
|
|||
|
||||
if (piece_list.size() == m_have_piece.size())
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " *** THIS IS A SEED ***\n";
|
||||
#endif
|
||||
// if we're a seed too, disconnect
|
||||
if (m_torrent->is_seed())
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " we're also a seed, disconnecting\n";
|
||||
#endif
|
||||
throw protocol_error("seed to seed connection redundant, disconnecting");
|
||||
|
@ -297,7 +297,7 @@ namespace libtorrent
|
|||
|
||||
peer_connection::~peer_connection()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
if (m_logger)
|
||||
{
|
||||
|
@ -440,11 +440,11 @@ namespace libtorrent
|
|||
, m_ses.get_peer_id().end()
|
||||
, m_send_buffer.begin() + pos);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> HANDSHAKE\n";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
send_buffer_updated();
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (m_recv_pos < m_packet_size) return;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== CHOKE\n";
|
||||
|
@ -548,7 +548,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (m_recv_pos < m_packet_size) return;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== UNCHOKE\n";
|
||||
|
@ -571,7 +571,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (m_recv_pos < m_packet_size) return;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== INTERESTED\n";
|
||||
|
@ -600,7 +600,7 @@ namespace libtorrent
|
|||
m_requests.clear();
|
||||
send_buffer_updated();
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== NOT_INTERESTED\n";
|
||||
|
@ -629,7 +629,7 @@ namespace libtorrent
|
|||
if (index >= (int)m_have_piece.size() || index < 0)
|
||||
throw protocol_error("have message with higher index than the number of pieces");
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== HAVE [ piece: " << index << "]\n";
|
||||
|
@ -637,8 +637,8 @@ namespace libtorrent
|
|||
|
||||
if (m_have_piece[index])
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
(*m_logger) << " oops.. we already knew that: " << index << "\n";
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " got redundant HAVE message for index: " << index << "\n";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
@ -682,7 +682,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (m_recv_pos < m_packet_size) return;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== BITFIELD\n";
|
||||
|
@ -738,13 +738,13 @@ namespace libtorrent
|
|||
|
||||
if (piece_list.size() == m_have_piece.size())
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " *** THIS IS A SEED ***\n";
|
||||
#endif
|
||||
// if we're a seed too, disconnect
|
||||
if (m_torrent->is_seed())
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " we're also a seed, disconnecting\n";
|
||||
#endif
|
||||
throw protocol_error("seed to seed connection redundant, disconnecting");
|
||||
|
@ -778,7 +778,7 @@ namespace libtorrent
|
|||
{
|
||||
// if we don't have valid metadata yet,
|
||||
// we shouldn't get a request
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== UNEXPECTED_REQUEST [ "
|
||||
|
@ -798,7 +798,7 @@ namespace libtorrent
|
|||
// memory consumption.
|
||||
// ignore requests if the client
|
||||
// is making too many of them.
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== TOO MANY REQUESTS [ "
|
||||
|
@ -831,7 +831,7 @@ namespace libtorrent
|
|||
|
||||
m_requests.push_back(r);
|
||||
send_buffer_updated();
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== REQUEST [ piece: " << r.piece << " | s: " << r.start << " | l: " << r.length << " ]\n";
|
||||
|
@ -839,7 +839,7 @@ namespace libtorrent
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== INVALID_REQUEST [ "
|
||||
|
@ -907,7 +907,7 @@ namespace libtorrent
|
|||
|
||||
if (!verify_piece(p))
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== INVALID_PIECE [ piece: " << p.piece << " | "
|
||||
|
@ -917,7 +917,7 @@ namespace libtorrent
|
|||
throw protocol_error("invalid piece packet");
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
for (std::deque<piece_block>::iterator i = m_download_queue.begin();
|
||||
i != m_download_queue.end();
|
||||
|
@ -979,7 +979,7 @@ namespace libtorrent
|
|||
, m_peer_id
|
||||
, "got a block that was not requested"));
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " *** The block we just got was not requested ***\n";
|
||||
#endif
|
||||
}
|
||||
|
@ -1049,7 +1049,7 @@ namespace libtorrent
|
|||
m_selector.remove_writable(m_socket);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== CANCEL [ piece: " << r.piece << " | s: " << r.start << " | l: " << r.length << " ]\n";
|
||||
|
@ -1077,7 +1077,7 @@ namespace libtorrent
|
|||
try
|
||||
{
|
||||
entry e = bdecode(m_recv_buffer.begin()+1, m_recv_buffer.end());
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
entry::dictionary_type& extensions = e.dict();
|
||||
std::stringstream ext;
|
||||
e.print(ext);
|
||||
|
@ -1092,7 +1092,7 @@ namespace libtorrent
|
|||
m_extension_messages[i] = (int)f->integer();
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << "supported extensions:\n";
|
||||
for (entry::dictionary_type::const_iterator i = extensions.begin();
|
||||
i != extensions.end();
|
||||
|
@ -1235,7 +1235,7 @@ namespace libtorrent
|
|||
if (offset + data_size > total_size)
|
||||
throw protocol_error("invalid metadata message");
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " <== METADATA [ tot: " << total_size << " offset: "
|
||||
|
@ -1280,7 +1280,7 @@ namespace libtorrent
|
|||
|
||||
if (is_local())
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< "<== LISTEN_PORT [ UNEXPECTED ]\n";
|
||||
#endif
|
||||
|
@ -1290,7 +1290,7 @@ namespace libtorrent
|
|||
const char* ptr = &m_recv_buffer[5];
|
||||
unsigned short port = detail::read_uint16(ptr);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< "<== LISTEN_PORT [ port: " << port << " ]\n";
|
||||
#endif
|
||||
|
@ -1393,11 +1393,12 @@ namespace libtorrent
|
|||
// length
|
||||
detail::write_int32(block_size, ptr);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> CANCEL [ piece: " << block.piece_index << " | s: " << block_offset << " | l: " << block_size << " | " << block.block_index << " ]\n";
|
||||
#endif
|
||||
<< " ==> CANCEL [ piece: " << block.piece_index << " | s: "
|
||||
<< block_offset << " | l: " << block_size << " | " << block.block_index << " ]\n";
|
||||
#endif
|
||||
|
||||
send_buffer_updated();
|
||||
}
|
||||
|
@ -1441,7 +1442,7 @@ namespace libtorrent
|
|||
// length
|
||||
detail::write_int32(block_size, ptr);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> REQUEST [ "
|
||||
|
@ -1455,7 +1456,7 @@ namespace libtorrent
|
|||
r.start = block_offset;
|
||||
r.length = block_size;
|
||||
assert(verify_piece(r));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
send_buffer_updated();
|
||||
}
|
||||
|
@ -1519,12 +1520,12 @@ namespace libtorrent
|
|||
// abort if the peer doesn't support the metadata extension
|
||||
if (!supports_extension(extended_metadata_message)) return;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> METADATA_REQUEST [ start: " << req.first
|
||||
<< " size: " << req.second << " ]\n";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
std::back_insert_iterator<std::vector<char> > ptr(m_send_buffer);
|
||||
|
||||
|
@ -1565,11 +1566,11 @@ namespace libtorrent
|
|||
|
||||
if (m_torrent->num_pieces() == 0) return;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> BITFIELD\n";
|
||||
#endif
|
||||
#endif
|
||||
const int packet_size = ((int)m_have_piece.size() + 7) / 8 + 5;
|
||||
const int old_size = (int)m_send_buffer.size();
|
||||
m_send_buffer.resize(old_size + packet_size);
|
||||
|
@ -1591,11 +1592,11 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> EXTENSIONS\n";
|
||||
#endif
|
||||
#endif
|
||||
assert(m_supports_extensions);
|
||||
|
||||
entry extension_list(entry::dictionary_t);
|
||||
|
@ -1631,11 +1632,12 @@ namespace libtorrent
|
|||
char msg[] = {0,0,0,1,msg_choke};
|
||||
m_send_buffer.insert(m_send_buffer.end(), msg, msg+sizeof(msg));
|
||||
m_choked = true;
|
||||
#ifndef NDEBUG
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> CHOKE\n";
|
||||
#endif
|
||||
#endif
|
||||
m_num_invalid_requests = 0;
|
||||
m_requests.clear();
|
||||
send_buffer_updated();
|
||||
|
@ -1649,11 +1651,12 @@ namespace libtorrent
|
|||
char msg[] = {0,0,0,1,msg_unchoke};
|
||||
m_send_buffer.insert(m_send_buffer.end(), msg, msg+sizeof(msg));
|
||||
m_choked = false;
|
||||
#ifndef NDEBUG
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> UNCHOKE\n";
|
||||
#endif
|
||||
#endif
|
||||
send_buffer_updated();
|
||||
}
|
||||
|
||||
|
@ -1665,11 +1668,12 @@ namespace libtorrent
|
|||
char msg[] = {0,0,0,1,msg_interested};
|
||||
m_send_buffer.insert(m_send_buffer.end(), msg, msg+sizeof(msg));
|
||||
m_interesting = true;
|
||||
#ifndef NDEBUG
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> INTERESTED\n";
|
||||
#endif
|
||||
#endif
|
||||
send_buffer_updated();
|
||||
}
|
||||
|
||||
|
@ -1684,11 +1688,11 @@ namespace libtorrent
|
|||
|
||||
m_became_uninteresting = second_clock::universal_time();
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> NOT_INTERESTED\n";
|
||||
#endif
|
||||
#endif
|
||||
send_buffer_updated();
|
||||
}
|
||||
|
||||
|
@ -1708,11 +1712,12 @@ namespace libtorrent
|
|||
char* ptr = msg+5;
|
||||
detail::write_int32(index, ptr);
|
||||
m_send_buffer.insert(m_send_buffer.end(), msg, msg + packet_size);
|
||||
#ifndef NDEBUG
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> HAVE [ piece: " << index << " ]\n";
|
||||
#endif
|
||||
#endif
|
||||
send_buffer_updated();
|
||||
}
|
||||
|
||||
|
@ -1910,9 +1915,10 @@ namespace libtorrent
|
|||
assert(m_recv_pos == m_packet_size);
|
||||
|
||||
m_packet_size = reinterpret_cast<unsigned char&>(m_recv_buffer[0]);
|
||||
#ifndef NDEBUG
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " protocol length: " << m_packet_size << "\n";
|
||||
#endif
|
||||
#endif
|
||||
if (m_packet_size > 100 || m_packet_size <= 0)
|
||||
{
|
||||
std::stringstream s;
|
||||
|
@ -1934,22 +1940,24 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, received);
|
||||
if (m_recv_pos < m_packet_size) break;
|
||||
assert(m_recv_pos == m_packet_size);
|
||||
#ifndef NDEBUG
|
||||
(*m_logger) << " protocol: '" << std::string(m_recv_buffer.begin(), m_recv_buffer.end()) << "'\n";
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " protocol: '" << std::string(m_recv_buffer.begin()
|
||||
, m_recv_buffer.end()) << "'\n";
|
||||
#endif
|
||||
const char protocol_string[] = "BitTorrent protocol";
|
||||
if (!std::equal(m_recv_buffer.begin(), m_recv_buffer.end(), protocol_string))
|
||||
if (!std::equal(m_recv_buffer.begin(), m_recv_buffer.end()
|
||||
, protocol_string))
|
||||
{
|
||||
const char cmd[] = "version";
|
||||
if (m_recv_buffer.size() == 7 && std::equal(m_recv_buffer.begin(), m_recv_buffer.end(), cmd))
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << "sending libtorrent version\n";
|
||||
#endif
|
||||
m_socket->send("libtorrent version " LIBTORRENT_VERSION "\n", 27);
|
||||
throw protocol_error("closing");
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << "incorrect protocol name\n";
|
||||
#endif
|
||||
std::stringstream s;
|
||||
|
@ -1990,9 +1998,9 @@ namespace libtorrent
|
|||
if (m_torrent == 0)
|
||||
{
|
||||
// we couldn't find the torrent!
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " couldn't find a torrent with the given info_hash\n";
|
||||
#endif
|
||||
#endif
|
||||
throw protocol_error("got info-hash that is not in our session");
|
||||
}
|
||||
|
||||
|
@ -2000,9 +2008,9 @@ namespace libtorrent
|
|||
{
|
||||
// paused torrents will not accept
|
||||
// incoming connections
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " rejected connection to paused torrent\n";
|
||||
#endif
|
||||
#endif
|
||||
throw protocol_error("connection rejected by paused torrent");
|
||||
}
|
||||
|
||||
|
@ -2023,9 +2031,9 @@ namespace libtorrent
|
|||
// verify info hash
|
||||
if (!std::equal(m_recv_buffer.begin()+8, m_recv_buffer.begin() + 28, (const char*)m_torrent->torrent_file().info_hash().begin()))
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " received invalid info_hash\n";
|
||||
#endif
|
||||
#endif
|
||||
throw protocol_error("invalid info-hash in handshake");
|
||||
}
|
||||
}
|
||||
|
@ -2036,9 +2044,9 @@ namespace libtorrent
|
|||
m_packet_size = 20;
|
||||
m_recv_pos = 0;
|
||||
m_recv_buffer.resize(20);
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " info_hash received\n";
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2049,7 +2057,7 @@ namespace libtorrent
|
|||
if (m_recv_pos < m_packet_size) break;
|
||||
assert(m_recv_pos == m_packet_size);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
{
|
||||
peer_id tmp;
|
||||
std::copy(m_recv_buffer.begin(), m_recv_buffer.begin() + 20, (char*)tmp.begin());
|
||||
|
@ -2064,7 +2072,7 @@ namespace libtorrent
|
|||
s << "\n";
|
||||
(*m_logger) << s.str();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
std::copy(m_recv_buffer.begin(), m_recv_buffer.begin() + 20, (char*)m_peer_id.begin());
|
||||
|
||||
if (!m_active)
|
||||
|
@ -2097,9 +2105,9 @@ namespace libtorrent
|
|||
// don't accept packets larger than 1 MB
|
||||
if (m_packet_size > 1024*1024 || m_packet_size < 0)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " packet too large (packet_size > 1 Megabyte), abort\n";
|
||||
#endif
|
||||
#endif
|
||||
// packet too large
|
||||
throw protocol_error("packet > 1 MB");
|
||||
}
|
||||
|
@ -2202,7 +2210,7 @@ namespace libtorrent
|
|||
, r.piece
|
||||
, r.start
|
||||
, r.length);
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> PIECE [ piece: " << r.piece << " | s: " << r.start << " | l: " << r.length << " ]\n";
|
||||
|
@ -2371,11 +2379,11 @@ namespace libtorrent
|
|||
char noop[] = {0,0,0,0};
|
||||
m_send_buffer.insert(m_send_buffer.end(), noop, noop+4);
|
||||
m_last_sent = second_clock::universal_time();
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
using namespace boost::posix_time;
|
||||
(*m_logger) << to_simple_string(second_clock::universal_time())
|
||||
<< " ==> NOP\n";
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2421,3 +2429,4 @@ namespace libtorrent
|
|||
assert(m_selector.is_writability_monitored(m_socket));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,10 @@ namespace libtorrent
|
|||
assert(blocks_per_piece > 0);
|
||||
assert(total_num_blocks > 0);
|
||||
|
||||
// the piece index is stored in 20 bits, which limits the allowed
|
||||
// number of pieces somewhat
|
||||
if (m_piece_map.size() >= 0xfffff) throw std::runtime_error("too many pieces in torrent");
|
||||
|
||||
m_blocks_per_piece = blocks_per_piece;
|
||||
m_blocks_in_last_piece = total_num_blocks % blocks_per_piece;
|
||||
if (m_blocks_in_last_piece == 0) m_blocks_in_last_piece = blocks_per_piece;
|
||||
|
@ -72,7 +76,7 @@ namespace libtorrent
|
|||
|
||||
// allocate the piece_map to cover all pieces
|
||||
// and make them invalid (as if though we already had every piece)
|
||||
std::fill(m_piece_map.begin(), m_piece_map.end(), piece_pos(0, 0xffffff));
|
||||
std::fill(m_piece_map.begin(), m_piece_map.end(), piece_pos(0, 0xfffff));
|
||||
}
|
||||
|
||||
void piece_picker::files_checked(
|
||||
|
@ -105,7 +109,7 @@ namespace libtorrent
|
|||
int index = *i;
|
||||
assert(index >= 0);
|
||||
assert(index < (int)m_piece_map.size());
|
||||
assert(m_piece_map[index].index == 0xffffff);
|
||||
assert(m_piece_map[index].index == 0xfffff);
|
||||
|
||||
int peer_count = m_piece_map[index].peer_count;
|
||||
assert(peer_count == 0);
|
||||
|
@ -186,14 +190,14 @@ namespace libtorrent
|
|||
*/
|
||||
}
|
||||
|
||||
if (i->index == 0xffffff)
|
||||
if (i->index == 0xfffff)
|
||||
{
|
||||
assert(t == 0 || t->have_piece(index));
|
||||
assert(i->downloading == 0);
|
||||
|
||||
// make sure there's no entry
|
||||
// with this index. (there shouldn't
|
||||
// be since the piece_map is 0xffffff)
|
||||
// be since the piece_map is 0xfffff)
|
||||
for (std::vector<std::vector<int> >::const_iterator i = m_piece_info.begin();
|
||||
i != m_piece_info.end();
|
||||
++i)
|
||||
|
@ -327,7 +331,7 @@ namespace libtorrent
|
|||
assert((int)src_vec[peer_count].size() > elem_index);
|
||||
|
||||
int index = src_vec[peer_count][elem_index];
|
||||
m_piece_map[index].index = 0xffffff;
|
||||
m_piece_map[index].index = 0xfffff;
|
||||
|
||||
if (downloading)
|
||||
{
|
||||
|
@ -380,11 +384,12 @@ namespace libtorrent
|
|||
int peer_count = m_piece_map[i].peer_count;
|
||||
int index = m_piece_map[i].index;
|
||||
|
||||
assert(peer_count < 2048);
|
||||
m_piece_map[i].peer_count++;
|
||||
|
||||
// if we have the piece, we don't have to move
|
||||
// any entries in the piece_info vector
|
||||
if (index == 0xffffff) return;
|
||||
if (index == 0xfffff) return;
|
||||
|
||||
move(m_piece_map[i].downloading, peer_count, index);
|
||||
|
||||
|
@ -405,12 +410,12 @@ namespace libtorrent
|
|||
|
||||
int peer_count = m_piece_map[i].peer_count;
|
||||
int index = m_piece_map[i].index;
|
||||
assert(m_piece_map[i].peer_count > 0);
|
||||
assert(peer_count > 0);
|
||||
|
||||
if (m_piece_map[i].peer_count > 0)
|
||||
m_piece_map[i].peer_count--;
|
||||
|
||||
if (index == 0xffffff) return;
|
||||
if (index == 0xfffff) return;
|
||||
move(m_piece_map[i].downloading, peer_count, index);
|
||||
}
|
||||
|
||||
|
@ -424,7 +429,7 @@ namespace libtorrent
|
|||
|
||||
assert(m_piece_map[index].downloading == 1);
|
||||
|
||||
assert(info_index != 0xffffff);
|
||||
assert(info_index != 0xfffff);
|
||||
remove(m_piece_map[index].downloading, peer_count, info_index);
|
||||
#ifndef NDEBUG
|
||||
// integrity_check();
|
||||
|
@ -575,7 +580,7 @@ namespace libtorrent
|
|||
assert(block.piece_index < (int)m_piece_map.size());
|
||||
assert(block.block_index < (int)max_blocks_per_piece);
|
||||
|
||||
if (m_piece_map[block.piece_index].index == 0xffffff) return true;
|
||||
if (m_piece_map[block.piece_index].index == 0xfffff) return true;
|
||||
if (m_piece_map[block.piece_index].downloading == 0) return false;
|
||||
std::vector<downloading_piece>::const_iterator i
|
||||
= std::find_if(m_downloads.begin(), m_downloads.end(), has_index(block.piece_index));
|
||||
|
|
|
@ -224,8 +224,8 @@ namespace libtorrent { namespace detail
|
|||
, m_max_connections(-1)
|
||||
, m_incoming_connection(false)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
m_logger = create_log("main session");
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
m_logger = create_log("main_session");
|
||||
#endif
|
||||
std::fill(m_extension_enabled, m_extension_enabled
|
||||
+ peer_connection::num_supported_extensions, true);
|
||||
|
@ -799,15 +799,11 @@ namespace libtorrent { namespace detail
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
boost::shared_ptr<logger> session_impl::create_log(std::string const& name)
|
||||
{
|
||||
// current options are file_logger, cout_logger and null_logger
|
||||
#if defined(TORRENT_VERBOSE_LOGGING)
|
||||
return boost::shared_ptr<logger>(new file_logger(name + ".log"));
|
||||
#else
|
||||
return boost::shared_ptr<logger>(new null_logger());
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -300,8 +300,8 @@ namespace libtorrent
|
|||
// returns true on success
|
||||
bool storage::move_storage(path save_path)
|
||||
{
|
||||
std::string old_path;
|
||||
std::string new_path;
|
||||
path old_path;
|
||||
path new_path;
|
||||
|
||||
save_path = complete(save_path);
|
||||
|
||||
|
@ -318,27 +318,23 @@ namespace libtorrent
|
|||
if (single_file.has_branch_path())
|
||||
create_directory(save_path / single_file.branch_path());
|
||||
|
||||
old_path = (m_pimpl->save_path / single_file)
|
||||
.native_file_string();
|
||||
new_path = (save_path / m_pimpl->info.begin_files()->path)
|
||||
.native_file_string();
|
||||
old_path = m_pimpl->save_path / single_file;
|
||||
new_path = save_path / m_pimpl->info.begin_files()->path;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(m_pimpl->info.num_files() > 1);
|
||||
old_path = (m_pimpl->save_path / m_pimpl->info.name())
|
||||
.native_directory_string();
|
||||
new_path = (save_path / m_pimpl->info.name())
|
||||
.native_directory_string();
|
||||
old_path = m_pimpl->save_path / m_pimpl->info.name();
|
||||
new_path = save_path / m_pimpl->info.name();
|
||||
}
|
||||
|
||||
int ret = std::rename(old_path.c_str(), new_path.c_str());
|
||||
// This seems to return -1 even when it successfully moves the file
|
||||
// if (ret == 0)
|
||||
try
|
||||
{
|
||||
rename(old_path, new_path);
|
||||
m_pimpl->save_path = save_path;
|
||||
return true;
|
||||
}
|
||||
catch (std::exception&) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -375,9 +371,9 @@ namespace libtorrent
|
|||
|
||||
size_type storage::read(
|
||||
char* buf
|
||||
, int slot
|
||||
, int offset
|
||||
, int size)
|
||||
, int slot
|
||||
, int offset
|
||||
, int size)
|
||||
{
|
||||
assert(buf != 0);
|
||||
assert(slot >= 0 && slot < m_pimpl->info.num_pieces());
|
||||
|
|
|
@ -313,7 +313,7 @@ namespace libtorrent
|
|||
std::random_shuffle(peer_list.begin(), peer_list.end());
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
std::stringstream s;
|
||||
s << "TRACKER RESPONSE:\n"
|
||||
"interval: " << m_duration << "\n"
|
||||
|
@ -1265,7 +1265,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::tracker_request_timed_out()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
debug_log("*** tracker timed out");
|
||||
#endif
|
||||
if (m_ses.m_alerts.should_post(alert::warning))
|
||||
|
@ -1285,7 +1285,7 @@ namespace libtorrent
|
|||
// it anymore
|
||||
void torrent::tracker_request_error(int response_code, const std::string& str)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
debug_log(std::string("*** tracker error: ") + str);
|
||||
#endif
|
||||
if (m_ses.m_alerts.should_post(alert::warning))
|
||||
|
@ -1303,7 +1303,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
void torrent::debug_log(const std::string& line)
|
||||
{
|
||||
(*m_ses.m_logger) << line << "\n";
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace libtorrent
|
|||
|
||||
if (len < 8)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester())
|
||||
requester().debug_log("udp_tracker_connection: "
|
||||
"got a message with size < 8, ignoring");
|
||||
|
@ -246,7 +246,7 @@ namespace libtorrent
|
|||
|
||||
if (len < 24)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester())
|
||||
requester().debug_log("udp_tracker_connection: "
|
||||
"got a message with size < 24, ignoring");
|
||||
|
@ -292,7 +292,7 @@ namespace libtorrent
|
|||
|
||||
if (len < 8)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester())
|
||||
requester().debug_log("udp_tracker_connection: "
|
||||
"got a message with size < 8, ignoring");
|
||||
|
@ -312,7 +312,7 @@ namespace libtorrent
|
|||
if (action != connect) return false;
|
||||
if (m_transaction_id != transaction)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester())
|
||||
requester().debug_log("udp_tracker_connection: "
|
||||
"got a message with incorrect transaction id, ignoring");
|
||||
|
@ -322,7 +322,7 @@ namespace libtorrent
|
|||
|
||||
if (len < 16)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (has_requester())
|
||||
requester().debug_log("udp_tracker_connection: "
|
||||
"got a connection message size < 16, ignoring");
|
||||
|
@ -340,3 +340,4 @@ namespace libtorrent
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue