*** empty log message ***

This commit is contained in:
Arvid Norberg 2005-05-29 17:25:13 +00:00
parent 4c2f32544c
commit e525456498
3 changed files with 25 additions and 12 deletions

View File

@ -131,7 +131,7 @@ namespace libtorrent
void check_files(
detail::piece_checker_data& data
, boost::mutex& mutex);
, boost::mutex& mutex, bool lock_session = true);
stat statistics() const { return m_stat; }
size_type bytes_left() const;

View File

@ -86,9 +86,7 @@ namespace libtorrent
{
// build a vector of all the pieces we don't have
std::vector<int> piece_list;
piece_list.reserve(
pieces.size()
- std::accumulate(pieces.begin(), pieces.end(), 0));
piece_list.reserve(std::count(pieces.begin(), pieces.end(), false));
for (std::vector<bool>::const_iterator i = pieces.begin();
i != pieces.end(); ++i)
@ -115,8 +113,8 @@ namespace libtorrent
assert(m_piece_info.size() == 2);
piece_pos& p = m_piece_map[index];
std::vector<std::vector<int> >& dst_vec = pick_piece_info_vector(p.downloading
, p.filtered);
std::vector<std::vector<int> >& dst_vec = pick_piece_info_vector(
p.downloading, p.filtered);
assert((int)dst_vec.size() > peer_count);
p.index = (int)dst_vec[peer_count].size();
dst_vec[peer_count].push_back(index);
@ -138,7 +136,7 @@ namespace libtorrent
}
}
#ifndef NDEBUG
// integrity_check();
integrity_check();
#endif
}
@ -456,7 +454,7 @@ namespace libtorrent
piece_pos& p = m_piece_map[index];
remove(p.downloading, p.filtered, peer_count, info_index);
#ifndef NDEBUG
// integrity_check();
integrity_check();
#endif
}
@ -466,6 +464,10 @@ namespace libtorrent
assert(index >= 0);
assert(index < (int)m_piece_map.size());
#ifndef NDEBUG
integrity_check();
#endif
piece_pos& p = m_piece_map[index];
if (p.filtered == 1) return;
p.filtered = 1;

View File

@ -789,14 +789,25 @@ namespace libtorrent
}
void torrent::check_files(detail::piece_checker_data& data,
boost::mutex& mutex)
boost::mutex& mutex, bool lock_session)
{
assert(m_storage.get());
m_storage->check_pieces(mutex, data, m_have_pieces, m_compact_mode);
m_num_pieces = std::accumulate(
// TODO: temporary solution. This function should only
// be called from the checker thread, and then this
// hack can be removed (because the session should always
// be locked then)
boost::mutex temp;
boost::mutex* m = &temp;
if (lock_session) m = &m_ses.m_mutex;
boost::mutex::scoped_lock l(mutex);
boost::mutex::scoped_lock l2(*m);
m_num_pieces = std::count(
m_have_pieces.begin()
, m_have_pieces.end()
, 0);
, true);
m_picker->files_checked(m_have_pieces, data.unfinished_pieces);
}
@ -1209,7 +1220,7 @@ namespace libtorrent
// TODO: this check should be moved to the checker thread
// not really a high priority, since no files would usually
// be available if the metadata wasn't available.
check_files(d, m);
check_files(d, m, false);
if (m_ses.m_alerts.should_post(alert::info))
{