fixed error reporting issue in disk I/O thread

This commit is contained in:
Arvid Norberg 2010-10-18 07:38:14 +00:00
parent 7aa9352dd0
commit 4b6a73417d
3 changed files with 21 additions and 0 deletions

View File

@ -53,6 +53,7 @@
* added more detailed instrumentation of the disk I/O thread * added more detailed instrumentation of the disk I/O thread
* fixed error reporting issue in disk I/O thread
* fixed file allocation issues on linux * fixed file allocation issues on linux
* fixed filename encoding and decoding issue on platforms using iconv * fixed filename encoding and decoding issue on platforms using iconv
* reports redundant downloads to tracker, fixed downloaded calculation to * reports redundant downloads to tracker, fixed downloaded calculation to

View File

@ -2036,10 +2036,15 @@ namespace libtorrent
mutex::scoped_lock l(m_piece_mutex); mutex::scoped_lock l(m_piece_mutex);
INVARIANT_CHECK; INVARIANT_CHECK;
TORRENT_ASSERT(!j.storage->error());
TORRENT_ASSERT(j.cache_min_time >= 0); TORRENT_ASSERT(j.cache_min_time >= 0);
if (in_use() >= m_settings.cache_size) if (in_use() >= m_settings.cache_size)
{
flush_cache_blocks(l, in_use() - m_settings.cache_size + 1); flush_cache_blocks(l, in_use() - m_settings.cache_size + 1);
if (test_error(j)) break;
}
TORRENT_ASSERT(!j.storage->error());
cache_piece_index_t& idx = m_pieces.get<0>(); cache_piece_index_t& idx = m_pieces.get<0>();
cache_piece_index_t::iterator p = find_cached_piece(m_pieces, j, l); cache_piece_index_t::iterator p = find_cached_piece(m_pieces, j, l);
@ -2068,9 +2073,12 @@ namespace libtorrent
flush_contiguous_blocks(const_cast<cached_piece_entry&>(*p) flush_contiguous_blocks(const_cast<cached_piece_entry&>(*p)
, l, m_settings.write_cache_line_size); , l, m_settings.write_cache_line_size);
if (p->num_blocks == 0) idx.erase(p); if (p->num_blocks == 0) idx.erase(p);
test_error(j);
TORRENT_ASSERT(!j.storage->error());
} }
else else
{ {
TORRENT_ASSERT(!j.storage->error());
if (cache_block(j, j.callback, j.cache_min_time, l) < 0) if (cache_block(j, j.callback, j.cache_min_time, l) < 0)
{ {
l.unlock(); l.unlock();
@ -2082,8 +2090,11 @@ namespace libtorrent
test_error(j); test_error(j);
break; break;
} }
// we successfully wrote the block. Ignore previous errors
j.storage->clear_error();
break; break;
} }
TORRENT_ASSERT(!j.storage->error());
} }
// we've now inserted the buffer // we've now inserted the buffer
// in the cache, we should not // in the cache, we should not
@ -2091,7 +2102,11 @@ namespace libtorrent
holder.release(); holder.release();
if (in_use() > m_settings.cache_size) if (in_use() > m_settings.cache_size)
{
flush_cache_blocks(l, in_use() - m_settings.cache_size); flush_cache_blocks(l, in_use() - m_settings.cache_size);
test_error(j);
}
TORRENT_ASSERT(!j.storage->error());
break; break;
} }
@ -2123,6 +2138,7 @@ namespace libtorrent
#ifdef TORRENT_DISK_STATS #ifdef TORRENT_DISK_STATS
m_log << log_time() << " hash" << std::endl; m_log << log_time() << " hash" << std::endl;
#endif #endif
TORRENT_ASSERT(!j.storage->error());
mutex::scoped_lock l(m_piece_mutex); mutex::scoped_lock l(m_piece_mutex);
INVARIANT_CHECK; INVARIANT_CHECK;
@ -2374,6 +2390,8 @@ namespace libtorrent
} }
#endif #endif
TORRENT_ASSERT(!j.storage || !j.storage->error());
// if (!j.callback) std::cerr << "DISK THREAD: no callback specified" << std::endl; // if (!j.callback) std::cerr << "DISK THREAD: no callback specified" << std::endl;
// else std::cerr << "DISK THREAD: invoking callback" << std::endl; // else std::cerr << "DISK THREAD: invoking callback" << std::endl;
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS

View File

@ -1647,6 +1647,8 @@ ret:
sha1_hash piece_manager::hash_for_piece_impl(int piece) sha1_hash piece_manager::hash_for_piece_impl(int piece)
{ {
TORRENT_ASSERT(!m_storage->error());
partial_hash ph; partial_hash ph;
std::map<int, partial_hash>::iterator i = m_piece_hasher.find(piece); std::map<int, partial_hash>::iterator i = m_piece_hasher.find(piece);