From 856228da3d53916df6a4b545dfd4a1c905cb989f Mon Sep 17 00:00:00 2001 From: rakshasa Date: Sat, 10 Apr 2010 07:05:39 +0000 Subject: [PATCH] * Don't throw an exception on 'download->resume_flags() != ~uint32_t()' as there seems to be a race condition where a torrent doing the final hashing might get some flags set. Instead just clear it and hope nothing bad happens. See #1292. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1161 e378c898-3ddf-0310-93e7-cc216c733640 --- src/core/download_list.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/download_list.cc b/src/core/download_list.cc index c5c5396a..0d1fe4ed 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -600,8 +600,18 @@ DownloadList::confirm_finished(Download* download) { rpc::commands.call_catch("event.download.finished", rpc::make_target(download), torrent::Object(), "Download event action failed: "); - if (download->resume_flags() != ~uint32_t()) - throw torrent::internal_error("DownloadList::confirm_finished(...) download->resume_flags() != ~uint32_t()."); +// if (download->resume_flags() != ~uint32_t()) +// throw torrent::internal_error("DownloadList::confirm_finished(...) download->resume_flags() != ~uint32_t()."); + + // See #1292. + // + // Just reset the value for the moment. If a torrent finishes while + // others are hashing, or some other situtation that causes resume + // flag to change could cause the state to be invalid. + // + // TODO: Add a check when setting the flags to see if the torrent is + // being hashed. + download->set_resume_flags(~uint32_t()); if (!download->is_active() && rpc::call_command_value("d.state", rpc::make_target(download)) == 1) resume(download, torrent::Download::start_no_create | torrent::Download::start_skip_tracker | torrent::Download::start_keep_baseline);