From 1ee414f4b9c79baee080450a563f002bc4dc2050 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 14 Apr 2010 06:26:38 +0000 Subject: [PATCH] fixed iterator bug in disk I/O thread --- ChangeLog | 1 + src/disk_io_thread.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index fa034441d..d6f44ece8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,7 @@ incoming connection * added more detailed instrumentation of the disk I/O thread + * fixed iterator bug in disk I/O thread * fixed FIEMAP support on linux * fixed strict aliasing warning on gcc * fixed inconsistency when creating torrents with symlinks diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 2d8b4e8d0..9d340858f 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -1565,7 +1565,11 @@ namespace libtorrent m_log << log_time() << " sorting_job" << std::endl; #endif size_type phys_off = j.storage->physical_offset(j.piece, j.offset); + bool update_pos = sorted_read_jobs.empty(); sorted_read_jobs.insert(std::pair(phys_off, j)); + // if sorted_read_jobs used to be empty, + // we need to update the elevator position + if (update_pos) elevator_job_pos = sorted_read_jobs.begin(); continue; } } @@ -1600,6 +1604,7 @@ namespace libtorrent if (elevator_direction > 0) ++elevator_job_pos; else --elevator_job_pos; + TORRENT_ASSERT(to_erase != elevator_job_pos); sorted_read_jobs.erase(to_erase); }