From dcd8bb6718b962d81bbc74112344c3771f312bd6 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 28 Oct 2009 19:56:18 +0000 Subject: [PATCH] move stats instrumentation to .cpp file to fix header dependency issue --- include/libtorrent/aux_/session_impl.hpp | 4 ++++ include/libtorrent/peer_connection.hpp | 13 ++++++------- src/peer_connection.cpp | 11 +++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 56d31532a..b905e493f 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -83,6 +83,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket_io.hpp" // for print_address #include "libtorrent/peer_connection.hpp" // for intrusive_ptr_release +#ifdef TORRENT_STATS +#include +#endif + namespace libtorrent { diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 9f1c7542d..b70ac87a7 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -483,18 +483,17 @@ namespace libtorrent virtual buffer::interval allocate_send_buffer(int size); virtual void setup_send(); +#if TORRENT_STATS + void log_buffer_usage(char* buffer, int size, char const* label); +#endif + template void append_send_buffer(char* buffer, int size, Destructor const& destructor) { -#if TORRENT_DISK_STATS - if (m_ses.m_disk_thread.is_disk_buffer(buffer)) - m_ses.m_disk_thread.rename_buffer(buffer, "queued send buffer"); +#if TORRENT_STATS + log_buffer_usage(buffer, size, "queued send buffer"); #endif m_send_buffer.append_buffer(buffer, size, size, destructor); -#ifdef TORRENT_STATS - m_ses.m_buffer_usage_logger << log_time() << " append_send_buffer: " << size << std::endl; - m_ses.log_buffer_usage(); -#endif } #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 13715d12a..1727138f8 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -325,6 +325,17 @@ namespace libtorrent std::fill(m_peer_id.begin(), m_peer_id.end(), 0); } +#if TORRENT_STATS + void peer_connection::log_buffer_usage(char* buffer, int size, char const* label) + { + if (m_ses.m_disk_thread.is_disk_buffer(buffer)) + m_ses.m_disk_thread.rename_buffer(buffer, label); + + m_ses.m_buffer_usage_logger << log_time() << " append_send_buffer: " << size << std::endl; + m_ses.log_buffer_usage(); + } +#endif + bool peer_connection::unchoke_compare(boost::intrusive_ptr const& p) const { TORRENT_ASSERT(p);