diff --git a/libtorrent/src/piece_picker.cpp b/libtorrent/src/piece_picker.cpp index dbdba17f0..9bd02f3c4 100755 --- a/libtorrent/src/piece_picker.cpp +++ b/libtorrent/src/piece_picker.cpp @@ -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) { diff --git a/libtorrent/src/policy.cpp b/libtorrent/src/policy.cpp index 2fdc5358a..0599096d5 100755 --- a/libtorrent/src/policy.cpp +++ b/libtorrent/src/policy.cpp @@ -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(); } diff --git a/libtorrent/src/session_impl.cpp b/libtorrent/src/session_impl.cpp index a93ad7cb0..486f7d31e 100755 --- a/libtorrent/src/session_impl.cpp +++ b/libtorrent/src/session_impl.cpp @@ -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,20 +2644,23 @@ namespace detail TORRENT_ASSERT(*slot_iter == p.index); int slot_index = static_cast(slot_iter - tmp_pieces.begin()); - unsigned long adler - = torrent_ptr->filesystem().piece_crc( - slot_index - , torrent_ptr->block_size() - , p.info); - - const entry& ad = (*i)["adler32"]; + const entry* ad = i->find_key("adler32"); - // crc's didn't match, don't use the resume data - if (ad.integer() != entry::integer_type(adler)) + if (ad && ad->type() == entry::int_t) { - error = "checksum mismatch on piece " - + boost::lexical_cast(p.index); - return; + unsigned long adler + = torrent_ptr->filesystem().piece_crc( + slot_index + , torrent_ptr->block_size() + , p.info); + + // crc's didn't match, don't use the resume data + if (ad->integer() != entry::integer_type(adler)) + { + error = "checksum mismatch on piece " + + boost::lexical_cast(p.index); + return; + } } tmp_unfinished.push_back(p); diff --git a/libtorrent/src/torrent_handle.cpp b/libtorrent/src/torrent_handle.cpp index 635390537..71d0e1628 100755 --- a/libtorrent/src/torrent_handle.cpp +++ b/libtorrent/src/torrent_handle.cpp @@ -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); }