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; ++num_requested;
blocks_requested = true; blocks_requested = true;
TORRENT_ASSERT(i->info[k].num_peers > 0);
} }
if (i->info[k].state == block_info::state_writing) 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()) || std::find(rq.begin(), rq.end(), *i) != rq.end())
continue; continue;
TORRENT_ASSERT(p.num_peers(*i) > 0);
busy_pieces.push_back(*i); busy_pieces.push_back(*i);
continue; continue;
} }
@ -333,6 +334,8 @@ namespace libtorrent
p.piece_info(i->piece_index, st); p.piece_info(i->piece_index, st);
TORRENT_ASSERT(st.requested + st.finished + st.writing == p.blocks_in_piece(i->piece_index)); TORRENT_ASSERT(st.requested + st.finished + st.writing == p.blocks_in_piece(i->piece_index));
#endif #endif
TORRENT_ASSERT(p.is_requested(*i));
TORRENT_ASSERT(p.num_peers(*i) > 0);
c.add_request(*i); c.add_request(*i);
c.send_block_requests(); c.send_block_requests();
} }

View File

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

View File

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