lt sync - fixes lockup

This commit is contained in:
Marcos Pinto 2008-02-11 13:31:44 +00:00
parent c13fb94bcc
commit 1d7306910f
4 changed files with 23 additions and 15 deletions

View File

@ -334,6 +334,7 @@ namespace libtorrent
{
++num_requested;
blocks_requested = true;
TORRENT_ASSERT(i->info[k].num_peers > 0);
}
if (i->info[k].state == block_info::state_writing)
{

View File

@ -294,6 +294,7 @@ namespace libtorrent
|| std::find(rq.begin(), rq.end(), *i) != rq.end())
continue;
TORRENT_ASSERT(p.num_peers(*i) > 0);
busy_pieces.push_back(*i);
continue;
}
@ -333,6 +334,8 @@ namespace libtorrent
p.piece_info(i->piece_index, st);
TORRENT_ASSERT(st.requested + st.finished + st.writing == p.blocks_in_piece(i->piece_index));
#endif
TORRENT_ASSERT(p.is_requested(*i));
TORRENT_ASSERT(p.num_peers(*i) > 0);
c.add_request(*i);
c.send_block_requests();
}

View File

@ -797,12 +797,13 @@ namespace detail
INVARIANT_CHECK;
TORRENT_ASSERT(s.connection_speed > 0);
TORRENT_ASSERT(s.file_pool_size > 0);
// less than 5 seconds unchoke interval is insane
TORRENT_ASSERT(s.unchoke_interval >= 5);
m_settings = s;
if (m_settings.connection_speed <= 0) m_settings.connection_speed = 200;
m_files.resize(m_settings.file_pool_size);
// replace all occurances of '\n' with ' '.
std::string::iterator i = m_settings.user_agent.begin();
@ -2643,21 +2644,24 @@ namespace detail
TORRENT_ASSERT(*slot_iter == p.index);
int slot_index = static_cast<int>(slot_iter - tmp_pieces.begin());
const entry* ad = i->find_key("adler32");
if (ad && ad->type() == entry::int_t)
{
unsigned long adler
= torrent_ptr->filesystem().piece_crc(
slot_index
, torrent_ptr->block_size()
, p.info);
const entry& ad = (*i)["adler32"];
// crc's didn't match, don't use the resume data
if (ad.integer() != entry::integer_type(adler))
if (ad->integer() != entry::integer_type(adler))
{
error = "checksum mismatch on piece "
+ boost::lexical_cast<std::string>(p.index);
return;
}
}
tmp_unfinished.push_back(p);
}

View File

@ -569,7 +569,7 @@ namespace libtorrent
TORRENT_ASSERT(bits == 8 || j == num_bitmask_bytes - 1);
}
piece_struct["bitmask"] = bitmask;
/*
TORRENT_ASSERT(t->filesystem().slot_for(i->index) >= 0);
unsigned long adler
= t->filesystem().piece_crc(
@ -578,7 +578,7 @@ namespace libtorrent
, i->info);
piece_struct["adler32"] = adler;
*/
// push the struct onto the unfinished-piece list
up.push_back(piece_struct);
}