From cf6dc377c96b9b2f68c29dcdcd97af332dd50ad2 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 4 May 2009 06:42:24 +0000 Subject: [PATCH] define fixes for disk stats build configurations --- include/libtorrent/disk_io_thread.hpp | 8 ++++---- src/disk_io_thread.cpp | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 3faebdac0..67b0c5641 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISK_IO_THREAD #define TORRENT_DISK_IO_THREAD -#ifdef TORRENT_DISK_STATS +#if defined TORRENT_DISK_STATS || defined TORRENT_STATS #include #endif @@ -213,12 +213,12 @@ namespace libtorrent boost::pool m_pool; #endif -#ifdef TORRENT_STATS +#if defined TORRENT_DISK_STATS || defined TORRENT_STATS int m_allocations; - std::map m_categories; - std::map m_buf_to_category; #endif #ifdef TORRENT_DISK_STATS + std::map m_categories; + std::map m_buf_to_category; std::ofstream m_log; #endif #ifdef TORRENT_DEBUG diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index c0c7a979b..07e593f6c 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -55,7 +55,7 @@ namespace libtorrent , m_pool(block_size) #endif { -#ifdef TORRENT_STATS +#if defined TORRENT_DISK_STATS || defined TORRENT_STATS m_allocations = 0; #endif #ifdef TORRENT_DISK_STATS @@ -108,8 +108,10 @@ namespace libtorrent } #endif -#ifdef TORRENT_STATS +#if defined TORRENT_DISK_STATS || defined TORRENT_STATS ++m_allocations; +#endif +#ifdef TORRENT_DISK_STATS ++m_categories[category]; m_buf_to_category[ret] = category; m_log << log_time() << " " << category << ": " << m_categories[category] << "\n"; @@ -122,8 +124,10 @@ namespace libtorrent TORRENT_ASSERT(buf); mutex_t::scoped_lock l(m_pool_mutex); TORRENT_ASSERT(m_magic == 0x1337); -#ifdef TORRENT_STATS +#if defined TORRENT_DISK_STATS || defined TORRENT_STATS --m_allocations; +#endif +#ifdef TORRENT_DISK_STATS TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf]) != m_categories.end()); std::string const& category = m_buf_to_category[buf]; @@ -169,8 +173,10 @@ namespace libtorrent #endif } #endif -#ifdef TORRENT_STATS +#if defined TORRENT_DISK_STATS || defined TORRENT_STATS m_allocations += num_blocks; +#endif +#ifdef TORRENT_DISK_STATS m_categories[category] += num_blocks; m_buf_to_category[ret] = category; m_log << log_time() << " " << category << ": " << m_categories[category] << "\n"; @@ -184,8 +190,10 @@ namespace libtorrent TORRENT_ASSERT(num_blocks >= 1); mutex_t::scoped_lock l(m_pool_mutex); TORRENT_ASSERT(m_magic == 0x1337); -#ifdef TORRENT_STATS +#if defined TORRENT_DISK_STATS || defined TORRENT_STATS m_allocations -= num_blocks; +#endif +#ifdef TORRENT_DISK_STATS TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf]) != m_categories.end()); std::string const& category = m_buf_to_category[buf];