added storage assert, fixed policy assert

This commit is contained in:
Arvid Norberg 2007-09-19 19:55:11 +00:00
parent af95c01f24
commit 338eedf961
3 changed files with 12 additions and 9 deletions

View File

@ -344,7 +344,8 @@ namespace libtorrent
std::multimap<sha1_hash, int> m_hash_to_piece;
// this map contains partial hashes for downloading
// pieces.
// pieces. This is only accessed from within the
// disk-io thread.
std::map<int, partial_hash> m_piece_hasher;
disk_io_thread& m_io_thread;

View File

@ -1422,7 +1422,7 @@ namespace libtorrent
++total_connections;
if (!p.connection)
{
assert(m_torrent->connection_for(p.ip) == 0);
// assert(m_torrent->connection_for(p.ip) == 0);
continue;
}
if (!m_torrent->settings().allow_multiple_connections_per_ip)

View File

@ -400,16 +400,20 @@ namespace libtorrent
partial.update(&m_scratch_buffer[0], ph.offset);
whole.update(&m_scratch_buffer[0], slot_size1);
hasher partial_copy = ph.h;
std::cerr << partial_copy.final() << " " << partial.final() << std::endl;
assert(ph.offset == 0 || partial_copy.final() == partial.final());
#endif
int slot_size = piece_size - ph.offset;
if (slot_size == 0) return ph.h.final();
if (slot_size == 0)
{
assert(ph.h.final() == whole.final());
return ph.h.final();
}
m_scratch_buffer.resize(slot_size);
read_impl(&m_scratch_buffer[0], slot, ph.offset, slot_size, true);
ph.h.update(&m_scratch_buffer[0], slot_size);
sha1_hash ret = ph.h.final();
assert(whole.final() == ret);
return ret;
assert(whole.final() == ph.h.final());
return ph.h.final();
}
void storage::initialize(bool allocate_files)
@ -996,9 +1000,6 @@ namespace libtorrent
int err = statfs(query_path.native_directory_string().c_str(), &buf);
if (err == 0)
{
#ifndef NDEBUG
std::cerr << "buf.f_type " << std::hex << buf.f_type << std::endl;
#endif
switch (buf.f_type)
{
case 0x5346544e: // NTFS
@ -1297,6 +1298,7 @@ namespace libtorrent
if (i != m_piece_hasher.end())
{
assert(i->second.offset > 0);
assert(offset >= i->second.offset);
if (offset == i->second.offset)
{
i->second.offset += size;