From 532a5f477da18b348f3b8807291c8c7498f11f50 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 3 Feb 2009 17:35:41 +0000 Subject: [PATCH] fixed checking files issue --- src/session_impl.cpp | 11 ++++++--- src/torrent.cpp | 59 +++++++++++++++++++++----------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 0760411ea..b5dd39d8e 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1933,18 +1933,21 @@ namespace aux { INVARIANT_CHECK; if (m_queued_for_checking.empty()) return; - check_queue_t::iterator next_check = m_queued_for_checking.begin(); + boost::shared_ptr next_check = *m_queued_for_checking.begin(); check_queue_t::iterator done = m_queued_for_checking.end(); for (check_queue_t::iterator i = m_queued_for_checking.begin() , end(m_queued_for_checking.end()); i != end; ++i) { TORRENT_ASSERT(*i == t || (*i)->should_check_files()); if (*i == t) done = i; - if (next_check == done || (*next_check)->queue_position() > (*i)->queue_position()) - next_check = i; + if (next_check == t || next_check->queue_position() > (*i)->queue_position()) + next_check = *i; } // only start a new one if we removed the one that is checking - if (next_check != done && t->state() == torrent_status::checking_files) (*next_check)->start_checking(); + if (done == m_queued_for_checking.end()) return; + + if (next_check != t && t->state() == torrent_status::checking_files) + next_check->start_checking(); m_queued_for_checking.erase(done); } diff --git a/src/torrent.cpp b/src/torrent.cpp index a6c1a6f35..f997bea7a 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -559,12 +559,12 @@ namespace libtorrent if (error && m_ses.m_alerts.should_post()) { m_ses.m_alerts.post_alert(fastresume_rejected_alert(get_handle(), error)); -#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING - (*m_ses.m_logger) << "fastresume data for " - << torrent_file().name() << " rejected: " - << error << "\n"; -#endif } +#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING + (*m_ses.m_logger) << "fastresume data for " + << torrent_file().name() << " rejected: " + << error << "\n"; +#endif if (error) { @@ -613,13 +613,13 @@ namespace libtorrent if (m_ses.m_alerts.should_post()) { m_ses.m_alerts.post_alert(file_error_alert(j.error_file, get_handle(), j.str)); -#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING - (*m_ses.m_logger) << time_now_string() << ": fatal disk error [" - " error: " << j.str << - " torrent: " << torrent_file().name() << - " ]\n"; -#endif } +#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING + (*m_ses.m_logger) << time_now_string() << ": fatal disk error [" + " error: " << j.str << + " torrent: " << torrent_file().name() << + " ]\n"; +#endif set_error(j.str); pause(); set_state(torrent_status::queued_for_checking); @@ -677,12 +677,12 @@ namespace libtorrent if (fastresume_rejected && m_ses.m_alerts.should_post()) { m_ses.m_alerts.post_alert(fastresume_rejected_alert(get_handle(), j.str)); -#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING - (*m_ses.m_logger) << "fastresume data for " - << torrent_file().name() << " rejected: " - << j.str << "\n"; -#endif } +#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING + (*m_ses.m_logger) << "fastresume data for " + << torrent_file().name() << " rejected: " + << j.str << "\n"; +#endif if (ret == 0) { @@ -810,13 +810,13 @@ namespace libtorrent if (m_ses.m_alerts.should_post()) { m_ses.m_alerts.post_alert(file_error_alert(j.error_file, get_handle(), j.str)); -#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING - (*m_ses.m_logger) << time_now_string() << ": fatal disk error [" - " error: " << j.str << - " torrent: " << torrent_file().name() << - " ]\n"; -#endif } +#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING + (*m_ses.m_logger) << time_now_string() << ": fatal disk error [" + " error: " << j.str << + " torrent: " << torrent_file().name() << + " ]\n"; +#endif set_error(j.str); pause(); return; @@ -841,7 +841,6 @@ namespace libtorrent void torrent::on_piece_checked(int ret, disk_io_job const& j) { session_impl::mutex_t::scoped_lock l(m_ses.m_mutex); - INVARIANT_CHECK; if (ret == piece_manager::disk_check_aborted) @@ -853,17 +852,15 @@ namespace libtorrent if (m_ses.m_alerts.should_post()) { m_ses.m_alerts.post_alert(file_error_alert(j.error_file, get_handle(), j.str)); -#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING - (*m_ses.m_logger) << time_now_string() << ": fatal disk error [" - " error: " << j.str << - " torrent: " << torrent_file().name() << - " ]\n"; -#endif } +#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING + (*m_ses.m_logger) << time_now_string() << ": fatal disk error [" + " error: " << j.str << + " torrent: " << torrent_file().name() << + " ]\n"; +#endif pause(); set_error(j.str); - if (!m_abort) m_ses.done_checking(shared_from_this()); - set_state(torrent_status::queued_for_checking); return; }