forked from premiere/premiere-libtorrent
check_cache_level after performing a job rather than before
If dirty blocks are added while the job is running there is a chance of deadlock if the dirty blocks cause the cache to exceed its size limit and no further jobs come in to trigger another check.
This commit is contained in:
parent
9c5bb25d65
commit
6e8db41dd2
|
@ -1087,18 +1087,18 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(j->next == 0);
|
||||
TORRENT_ASSERT((j->flags & disk_io_job::in_progress) || !j->storage);
|
||||
|
||||
mutex::scoped_lock l(m_cache_mutex);
|
||||
#if DEBUG_DISK_THREAD
|
||||
{
|
||||
mutex::scoped_lock l(m_cache_mutex);
|
||||
|
||||
check_cache_level(l, completed_jobs);
|
||||
|
||||
DLOG("perform_job job: %s ( %s%s) piece: %d offset: %d outstanding: %d\n"
|
||||
, job_action_name[j->action]
|
||||
, (j->flags & disk_io_job::fence) ? "fence ": ""
|
||||
, (j->flags & disk_io_job::force_copy) ? "force_copy ": ""
|
||||
, j->piece, j->d.io.offset
|
||||
, j->storage ? j->storage->num_outstanding_jobs() : -1);
|
||||
|
||||
l.unlock();
|
||||
DLOG("perform_job job: %s ( %s%s) piece: %d offset: %d outstanding: %d\n"
|
||||
, job_action_name[j->action]
|
||||
, (j->flags & disk_io_job::fence) ? "fence ": ""
|
||||
, (j->flags & disk_io_job::force_copy) ? "force_copy ": ""
|
||||
, j->piece, j->d.io.offset
|
||||
, j->storage ? j->storage->num_outstanding_jobs() : -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
boost::shared_ptr<piece_manager> storage = j->storage;
|
||||
|
||||
|
@ -1123,6 +1123,10 @@ namespace libtorrent
|
|||
|
||||
m_stats_counters.inc_stats_counter(counters::num_running_disk_jobs, -1);
|
||||
|
||||
mutex::scoped_lock l(m_cache_mutex);
|
||||
check_cache_level(l, completed_jobs);
|
||||
l.unlock();
|
||||
|
||||
if (ret == retry_job)
|
||||
{
|
||||
mutex::scoped_lock l2(m_job_mutex);
|
||||
|
|
Loading…
Reference in New Issue