From 56e4c488734c4e94f1767698ae52676829d4b922 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 17 Mar 2013 17:13:34 +0000 Subject: [PATCH] merged disk buffer pool change from RC_0_16 --- ChangeLog | 4 ++++ include/libtorrent/disk_buffer_pool.hpp | 10 ---------- src/disk_buffer_pool.cpp | 20 -------------------- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 34c733517..c5596a17e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,10 @@ * fix uTP edge case where udp socket buffer fills up * fix nagle implementation in uTP + * don't use pool allocator for disk blocks (cache may now return pages to the kernel) + +0.16.9 release + * fix long filename truncation on windows * distinguish file open mode when checking files and downloading/seeding with bittorrent. updates storage interface * improve file_storage::map_file when dealing with invalid input diff --git a/include/libtorrent/disk_buffer_pool.hpp b/include/libtorrent/disk_buffer_pool.hpp index 70b639e8b..b61a37e88 100644 --- a/include/libtorrent/disk_buffer_pool.hpp +++ b/include/libtorrent/disk_buffer_pool.hpp @@ -38,10 +38,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/session_settings.hpp" #include "libtorrent/allocator.hpp" -#ifndef TORRENT_DISABLE_POOL_ALLOCATOR -#include -#endif - #ifdef TORRENT_DISK_STATS #include #endif @@ -101,12 +97,6 @@ namespace libtorrent mutable mutex m_pool_mutex; -#ifndef TORRENT_DISABLE_POOL_ALLOCATOR - // memory pool for read and write operations - // and disk cache - boost::pool m_pool; -#endif - #if defined TORRENT_DISK_STATS || defined TORRENT_STATS int m_allocations; #endif diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index 17b72d503..196c4a2a7 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -47,9 +47,6 @@ namespace libtorrent disk_buffer_pool::disk_buffer_pool(int block_size) : m_block_size(block_size) , m_in_use(0) -#ifndef TORRENT_DISABLE_POOL_ALLOCATOR - , m_pool(block_size, m_settings.cache_buffer_chunk_size) -#endif { #if defined TORRENT_DISK_STATS || defined TORRENT_STATS m_allocations = 0; @@ -83,11 +80,7 @@ namespace libtorrent if (m_buf_to_category.find(buffer) == m_buf_to_category.end()) return false; #endif -#ifdef TORRENT_DISABLE_POOL_ALLOCATOR return true; -#else - return m_pool.is_from(buffer); -#endif } bool disk_buffer_pool::is_disk_buffer(char* buffer) const @@ -101,12 +94,7 @@ namespace libtorrent { mutex::scoped_lock l(m_pool_mutex); TORRENT_ASSERT(m_magic == 0x1337); -#ifdef TORRENT_DISABLE_POOL_ALLOCATOR char* ret = page_aligned_allocator::malloc(m_block_size); -#else - char* ret = (char*)m_pool.malloc(); - m_pool.set_next_size(m_settings.cache_buffer_chunk_size); -#endif ++m_in_use; #if TORRENT_USE_MLOCK if (m_settings.lock_disk_cache) @@ -197,21 +185,13 @@ namespace libtorrent #endif } #endif -#ifdef TORRENT_DISABLE_POOL_ALLOCATOR page_aligned_allocator::free(buf); -#else - m_pool.free(buf); -#endif --m_in_use; } void disk_buffer_pool::release_memory() { TORRENT_ASSERT(m_magic == 0x1337); -#ifndef TORRENT_DISABLE_POOL_ALLOCATOR - mutex::scoped_lock l(m_pool_mutex); - m_pool.release_memory(); -#endif } }