*** empty log message ***

This commit is contained in:
Arvid Norberg 2005-06-15 12:54:35 +00:00
parent cf8d7beb23
commit eca5300ebb
5 changed files with 53 additions and 9 deletions

View File

@ -524,6 +524,13 @@ namespace libtorrent
// may not even have been attempted when the
// time out is reached.
bool m_connecting;
// the number of bytes of metadata we have received
// so far from this per, only counting the current
// request. Any previously finished requests
// that have been forwarded to the torrent object
// do not count.
int m_metadata_progress;
};
}

View File

@ -130,6 +130,10 @@ namespace libtorrent
// debug purpose only
void print(std::ostream& os) const;
// this is called from the peer_connection for
// each piece of metadata it receives
void metadata_progress(int total_size, int received);
void check_files(
detail::piece_checker_data& data
, boost::mutex& mutex, bool lock_session = true);
@ -509,6 +513,9 @@ namespace libtorrent
// determines the storage state for this torrent.
const bool m_compact_mode;
int m_metadata_progress;
int m_metadata_size;
};
inline boost::posix_time::ptime torrent::next_announce() const

View File

@ -159,6 +159,7 @@ namespace
, map_entry("AR", "Arctic Torrent")
, map_entry("AZ", "Azureus")
, map_entry("BB", "BitBuddy")
, map_entry("BC", "BitComet")
, map_entry("BS", "BTSlave")
, map_entry("BX", "BittorrentX")
, map_entry("CT", "CTorrent")

View File

@ -124,6 +124,7 @@ namespace libtorrent
, boost::posix_time::seconds(0))
, m_waiting_metadata_request(false)
, m_connecting(false)
, m_metadata_progress(0)
{
INVARIANT_CHECK;
@ -203,6 +204,7 @@ namespace libtorrent
, boost::posix_time::seconds(0))
, m_waiting_metadata_request(false)
, m_connecting(true)
, m_metadata_progress(0)
{
INVARIANT_CHECK;
@ -1151,7 +1153,8 @@ namespace libtorrent
const char* ptr = &m_recv_buffer[1];
int extended_id = detail::read_int32(ptr);
if (!m_ses.m_extension_enabled[extended_id])
if (extended_id >= 0 && extended_id < num_supported_extensions
&& !m_ses.m_extension_enabled[extended_id])
throw protocol_error("'extended' message using disabled extension");
switch (extended_id)
@ -1165,7 +1168,8 @@ namespace libtorrent
case extended_listen_port_message:
on_listen_port(); break;
default:
throw protocol_error("unknown extended message id");
throw protocol_error("unknown extended message id: "
+ boost::lexical_cast<std::string>(extended_id));
};
}
@ -1218,15 +1222,17 @@ namespace libtorrent
if (m_packet_size > 500 * 1024)
throw protocol_error("metadata message larger than 500 kB");
if (m_recv_pos < m_packet_size) return;
if (m_recv_pos < 6) return;
std::vector<char>::iterator ptr = m_recv_buffer.begin()+5;
std::vector<char>::iterator ptr = m_recv_buffer.begin() + 5;
int type = detail::read_uint8(ptr);
switch (type)
{
case 0: // request
{
if (m_recv_pos < m_packet_size) return;
int start = detail::read_uint8(ptr);
int size = detail::read_uint8(ptr) + 1;
@ -1241,6 +1247,7 @@ namespace libtorrent
break;
case 1: // data
{
if (m_recv_pos < 14) return;
int total_size = detail::read_int32(ptr);
int offset = detail::read_int32(ptr);
int data_size = m_packet_size - 5 - 9;
@ -1252,6 +1259,11 @@ namespace libtorrent
if (offset + data_size > total_size)
throw protocol_error("invalid metadata message");
m_torrent->metadata_progress(total_size, m_recv_pos - 14
- m_metadata_progress);
m_metadata_progress = m_recv_pos - 14;
if (m_recv_pos < m_packet_size) return;
#ifdef TORRENT_VERBOSE_LOGGING
using namespace boost::posix_time;
(*m_logger) << to_simple_string(second_clock::universal_time())
@ -1259,17 +1271,22 @@ namespace libtorrent
<< offset << " size: " << data_size << " ]\n";
#endif
m_waiting_metadata_request = false;
m_torrent->received_metadata(&m_recv_buffer[5+9], data_size, offset, total_size);
m_metadata_progress = 0;
}
break;
case 2: // have no data
if (m_recv_pos < m_packet_size) return;
m_no_metadata = second_clock::universal_time();
if (m_waiting_metadata_request)
m_torrent->cancel_metadata_request(m_last_metadata_request);
m_waiting_metadata_request = false;
break;
default:
throw protocol_error("unknown metadata extension message: "
+ boost::lexical_cast<std::string>(type));
}
}

View File

@ -181,6 +181,8 @@ namespace libtorrent
, m_download_bandwidth_limit(std::numeric_limits<int>::max())
, m_save_path(complete(save_path))
, m_compact_mode(compact_mode)
, m_metadata_progress(0)
, m_metadata_size(0)
{
m_uploads_quota.min = 2;
m_connections_quota.min = 2;
@ -230,6 +232,8 @@ namespace libtorrent
, m_download_bandwidth_limit(std::numeric_limits<int>::max())
, m_save_path(complete(save_path))
, m_compact_mode(compact_mode)
, m_metadata_progress(0)
, m_metadata_size(0)
{
m_uploads_quota.min = 2;
m_connections_quota.min = 2;
@ -834,6 +838,8 @@ namespace libtorrent
if (lock_session) m = &m_ses.m_mutex;
boost::mutex::scoped_lock l(mutex);
if (data.abort) return;
boost::mutex::scoped_lock l2(*m);
m_num_pieces = std::count(
m_have_pieces.begin()
@ -1123,10 +1129,8 @@ namespace libtorrent
else
st.state = torrent_status::downloading_metadata;
st.progress = std::count(
m_have_metadata.begin()
, m_have_metadata.end()
, true) / 256.f;
if (m_metadata_size == 0) st.progress = 0.f;
else st.progress = std::min(1.f, m_metadata_progress / (float)m_metadata_size);
return st;
}
@ -1259,6 +1263,8 @@ namespace libtorrent
m_have_metadata.begin()
, m_have_metadata.begin() + req.first + req.second
, false);
m_metadata_progress = 0;
m_metadata_size = 0;
return false;
}
@ -1411,3 +1417,9 @@ namespace libtorrent
}
void torrent::metadata_progress(int total_size, int received)
{
m_metadata_progress += received;
m_metadata_size = total_size;
}