added validation check to disk_buffer_pool (and disk_io_thread in 0.14). This should catch any reference to the disk_io_thread after it has been destructed
This commit is contained in:
parent
b75648445e
commit
807c1fc397
|
@ -166,6 +166,9 @@ namespace libtorrent
|
|||
struct disk_buffer_pool : boost::noncopyable
|
||||
{
|
||||
disk_buffer_pool(int block_size);
|
||||
#ifdef TORRENT_DEBUG
|
||||
~disk_buffer_pool();
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
bool is_disk_buffer(char* buffer) const;
|
||||
|
@ -217,6 +220,9 @@ namespace libtorrent
|
|||
#endif
|
||||
#ifdef TORRENT_DISK_STATS
|
||||
std::ofstream m_log;
|
||||
#endif
|
||||
#ifdef TORRENT_DEBUG
|
||||
int m_magic;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -61,12 +61,24 @@ namespace libtorrent
|
|||
#endif
|
||||
#ifdef TORRENT_DISK_STATS
|
||||
m_log.open("disk_buffers.log", std::ios::trunc);
|
||||
#endif
|
||||
#ifdef TORRENT_DEBUG
|
||||
m_magic = 0x1337;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
disk_buffer_pool::~disk_buffer_pool()
|
||||
{
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
m_magic = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
bool disk_buffer_pool::is_disk_buffer(char* buffer) const
|
||||
{
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
#ifdef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||
return true;
|
||||
#else
|
||||
|
@ -79,6 +91,7 @@ namespace libtorrent
|
|||
char* disk_buffer_pool::allocate_buffer(char const* category)
|
||||
{
|
||||
mutex_t::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
|
||||
|
@ -109,6 +122,7 @@ namespace libtorrent
|
|||
{
|
||||
TORRENT_ASSERT(buf);
|
||||
mutex_t::scoped_lock l(m_pool_mutex);
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
#ifdef TORRENT_STATS
|
||||
--m_allocations;
|
||||
TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf])
|
||||
|
@ -139,6 +153,7 @@ namespace libtorrent
|
|||
char* disk_buffer_pool::allocate_buffers(int num_blocks, char const* category)
|
||||
{
|
||||
mutex_t::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 * num_blocks);
|
||||
#else
|
||||
|
@ -169,6 +184,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(buf);
|
||||
TORRENT_ASSERT(num_blocks >= 1);
|
||||
mutex_t::scoped_lock l(m_pool_mutex);
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
#ifdef TORRENT_STATS
|
||||
m_allocations -= num_blocks;
|
||||
TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf])
|
||||
|
@ -198,6 +214,7 @@ namespace libtorrent
|
|||
|
||||
void disk_buffer_pool::release_memory()
|
||||
{
|
||||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||
mutex_t::scoped_lock l(m_pool_mutex);
|
||||
m_pool.release_memory();
|
||||
|
|
Loading…
Reference in New Issue