From 0b711f12802e564c1c5a9cc18dbc9d6bd08e81f0 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 17 Nov 2014 03:10:00 +0000 Subject: [PATCH] remove unused variables. add some comments --- include/libtorrent/file.hpp | 1 + src/disk_buffer_pool.cpp | 8 +++++++- src/disk_io_thread.cpp | 4 +--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index 49e5e5572..5e395ca11 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -166,6 +166,7 @@ namespace libtorrent TORRENT_EXTRA_EXPORT std::string canonicalize_path(std::string const& f); #endif + // TODO: move this into a separate header file, TU pair class TORRENT_EXTRA_EXPORT directory : public boost::noncopyable { public: diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index 001206176..d448dc575 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -282,11 +282,17 @@ namespace libtorrent return allocate_buffer_impl(l, category); } + // we allow allocating more blocks even after we exceed the max size, + // but communicate back to the allocator (typically the peer_connection) + // that we have exceeded the limit via the out-parameter "exceeded". The + // caller is expected to honor this by not allocating any more buffers + // until the disk_observer object (passed in as "o") is invoked, indicating + // that there's more room in the pool now. This caps the amount of over- + // allocation to one block per peer connection. char* disk_buffer_pool::allocate_buffer(bool& exceeded , boost::shared_ptr o, char const* category) { mutex::scoped_lock l(m_pool_mutex); - bool was_exceeded = m_exceeded_max_size; char* ret = allocate_buffer_impl(l, category); if (m_exceeded_max_size) { diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 5c261f9c9..a6fd329df 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -1492,7 +1492,6 @@ namespace libtorrent { INVARIANT_CHECK; TORRENT_ASSERT(j->d.io.buffer_size <= m_disk_cache.block_size()); - int block_size = m_disk_cache.block_size(); // should we put this write job in the cache? // if we don't use the cache we shouldn't. @@ -1569,8 +1568,7 @@ namespace libtorrent TORRENT_ASSERT(r.length <= m_disk_cache.block_size()); TORRENT_ASSERT(r.length <= 16 * 1024); - int block_size = m_disk_cache.block_size(); - DLOG("do_read piece: %d block: %d\n", r.piece, r.start / block_size); + DLOG("do_read piece: %d block: %d\n", r.piece, r.start / m_disk_cache.block_size()); disk_io_job* j = allocate_job(disk_io_job::read); j->storage = storage->shared_from_this();