forked from premiere/premiere-libtorrent
fix link issue in build. caused corruption and crash in test_storage
This commit is contained in:
parent
aa975242e4
commit
6dbc7091d3
44
Jamfile
44
Jamfile
|
@ -25,6 +25,28 @@ if $(BOOST_ROOT)
|
||||||
|
|
||||||
VERSION = 1.0.0 ;
|
VERSION = 1.0.0 ;
|
||||||
|
|
||||||
|
rule coverage ( properties * )
|
||||||
|
{
|
||||||
|
local result ;
|
||||||
|
if <toolset>gcc in $(properties)
|
||||||
|
|| <toolset>darwin in $(properties)
|
||||||
|
|| <toolset>clang in $(properties)
|
||||||
|
{
|
||||||
|
result += <cxxflags>-fprofile-arcs <cxxflags>-ftest-coverage ;
|
||||||
|
|
||||||
|
if <toolset>gcc in $(properties)
|
||||||
|
|| <toolset>darwin in $(properties)
|
||||||
|
{
|
||||||
|
result += <linkflags>-lgcov ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += <linkflags>--coverage ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $(result) ;
|
||||||
|
}
|
||||||
|
|
||||||
# rule for linking the correct libraries depending
|
# rule for linking the correct libraries depending
|
||||||
# on features and target-os
|
# on features and target-os
|
||||||
rule linking ( properties * )
|
rule linking ( properties * )
|
||||||
|
@ -116,25 +138,6 @@ rule linking ( properties * )
|
||||||
result += <library>libsocket <library>libnsl ;
|
result += <library>libsocket <library>libnsl ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if <test-coverage>on in $(properties)
|
|
||||||
&& ( <toolset>gcc in $(properties)
|
|
||||||
|| <toolset>darwin in $(properties)
|
|
||||||
|| <toolset>clang in $(properties) )
|
|
||||||
{
|
|
||||||
result += <cxxflags>-fprofile-arcs <cxxflags>-ftest-coverage
|
|
||||||
<define>NDEBUG ;
|
|
||||||
|
|
||||||
if <toolset>gcc in $(properties)
|
|
||||||
|| <toolset>darwin in $(properties)
|
|
||||||
{
|
|
||||||
result += <linkflags>-lgcov ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result += <linkflags>--coverage ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# clock_gettime on linux requires librt
|
# clock_gettime on linux requires librt
|
||||||
if <need-librt>yes in $(properties)
|
if <need-librt>yes in $(properties)
|
||||||
{
|
{
|
||||||
|
@ -367,7 +370,7 @@ feature.compose <asio-debugging>on : <define>TORRENT_ASIO_DEBUGGING ;
|
||||||
feature pool-allocators : on off : composite propagated link-incompatible ;
|
feature pool-allocators : on off : composite propagated link-incompatible ;
|
||||||
feature.compose <pool-allocators>off : <define>TORRENT_DISABLE_POOL_ALLOCATOR ;
|
feature.compose <pool-allocators>off : <define>TORRENT_DISABLE_POOL_ALLOCATOR ;
|
||||||
|
|
||||||
feature allocator : pool system debug : composite ;
|
feature allocator : pool system debug : composite propagated ;
|
||||||
feature.compose <allocator>system : <define>TORRENT_DISABLE_POOL_ALLOCATOR ;
|
feature.compose <allocator>system : <define>TORRENT_DISABLE_POOL_ALLOCATOR ;
|
||||||
feature.compose <allocator>debug : <define>TORRENT_DISABLE_POOL_ALLOCATOR <define>TORRENT_DEBUG_BUFFERS ;
|
feature.compose <allocator>debug : <define>TORRENT_DISABLE_POOL_ALLOCATOR <define>TORRENT_DEBUG_BUFFERS ;
|
||||||
|
|
||||||
|
@ -431,6 +434,7 @@ feature debug-iterators : off on : composite propagated link-incompatible ;
|
||||||
feature.compose <debug-iterators>on : <define>_SCL_SECURE=1 <define>_GLIBCXX_DEBUG ;
|
feature.compose <debug-iterators>on : <define>_SCL_SECURE=1 <define>_GLIBCXX_DEBUG ;
|
||||||
|
|
||||||
feature test-coverage : off on : composite propagated ;
|
feature test-coverage : off on : composite propagated ;
|
||||||
|
feature.compose <test-coverage>on : <conditional>@coverage ;
|
||||||
|
|
||||||
feature fpic : off on : composite propagated link-incompatible ;
|
feature fpic : off on : composite propagated link-incompatible ;
|
||||||
feature.compose <fpic>on : <cflags>-fPIC ;
|
feature.compose <fpic>on : <cflags>-fPIC ;
|
||||||
|
|
|
@ -107,6 +107,9 @@ namespace libtorrent
|
||||||
|
|
||||||
file_set m_files;
|
file_set m_files;
|
||||||
mutex m_mutex;
|
mutex m_mutex;
|
||||||
|
#ifdef TORRENT_DEBUG
|
||||||
|
int m_in_use;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if TORRENT_CLOSE_MAY_BLOCK
|
#if TORRENT_CLOSE_MAY_BLOCK
|
||||||
void closer_thread_fun();
|
void closer_thread_fun();
|
||||||
|
|
|
@ -72,10 +72,6 @@ struct alloc_header
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_DEBUG_BUFFERS && (defined __linux__ || (defined __APPLE__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050))
|
|
||||||
void print_backtrace(char* out, int len, int max_depth = 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,17 @@ namespace libtorrent
|
||||||
, m_stop_thread(false)
|
, m_stop_thread(false)
|
||||||
, m_closer_thread(boost::bind(&file_pool::closer_thread_fun, this))
|
, m_closer_thread(boost::bind(&file_pool::closer_thread_fun, this))
|
||||||
#endif
|
#endif
|
||||||
{}
|
{
|
||||||
|
#ifdef TORRENT_DEBUG
|
||||||
|
m_in_use = 1337;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
file_pool::~file_pool()
|
file_pool::~file_pool()
|
||||||
{
|
{
|
||||||
|
#ifdef TORRENT_DEBUG
|
||||||
|
m_in_use = 0;
|
||||||
|
#endif
|
||||||
#if TORRENT_CLOSE_MAY_BLOCK
|
#if TORRENT_CLOSE_MAY_BLOCK
|
||||||
mutex::scoped_lock l(m_closer_mutex);
|
mutex::scoped_lock l(m_closer_mutex);
|
||||||
m_stop_thread = true;
|
m_stop_thread = true;
|
||||||
|
@ -176,6 +183,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT((m & file::rw_mask) == file::read_only
|
TORRENT_ASSERT((m & file::rw_mask) == file::read_only
|
||||||
|| (m & file::rw_mask) == file::read_write);
|
|| (m & file::rw_mask) == file::read_write);
|
||||||
mutex::scoped_lock l(m_mutex);
|
mutex::scoped_lock l(m_mutex);
|
||||||
|
TORRENT_ASSERT(m_in_use == 1337);
|
||||||
file_set::iterator i = m_files.find(std::make_pair(st, file_index));
|
file_set::iterator i = m_files.find(std::make_pair(st, file_index));
|
||||||
if (i != m_files.end())
|
if (i != m_files.end())
|
||||||
{
|
{
|
||||||
|
@ -260,15 +268,18 @@ namespace libtorrent
|
||||||
|
|
||||||
void file_pool::remove_oldest()
|
void file_pool::remove_oldest()
|
||||||
{
|
{
|
||||||
|
mutex::scoped_lock l(m_mutex);
|
||||||
|
TORRENT_ASSERT(m_in_use == 1337);
|
||||||
|
|
||||||
file_set::iterator i = std::min_element(m_files.begin(), m_files.end()
|
file_set::iterator i = std::min_element(m_files.begin(), m_files.end()
|
||||||
, boost::bind(&lru_file_entry::last_use, boost::bind(&file_set::value_type::second, _1))
|
, boost::bind(&lru_file_entry::last_use, boost::bind(&file_set::value_type::second, _1))
|
||||||
< boost::bind(&lru_file_entry::last_use, boost::bind(&file_set::value_type::second, _2)));
|
< boost::bind(&lru_file_entry::last_use, boost::bind(&file_set::value_type::second, _2)));
|
||||||
if (i == m_files.end()) return;
|
if (i == m_files.end()) return;
|
||||||
|
|
||||||
#if TORRENT_CLOSE_MAY_BLOCK
|
#if TORRENT_CLOSE_MAY_BLOCK
|
||||||
mutex::scoped_lock l(m_closer_mutex);
|
mutex::scoped_lock l_(m_closer_mutex);
|
||||||
m_queued_for_close.push_back(i->second.file_ptr);
|
m_queued_for_close.push_back(i->second.file_ptr);
|
||||||
l.unlock();
|
l_.unlock();
|
||||||
#endif
|
#endif
|
||||||
m_files.erase(i);
|
m_files.erase(i);
|
||||||
}
|
}
|
||||||
|
@ -276,6 +287,7 @@ namespace libtorrent
|
||||||
void file_pool::release(void* st, int file_index)
|
void file_pool::release(void* st, int file_index)
|
||||||
{
|
{
|
||||||
mutex::scoped_lock l(m_mutex);
|
mutex::scoped_lock l(m_mutex);
|
||||||
|
TORRENT_ASSERT(m_in_use == 1337);
|
||||||
file_set::iterator i = m_files.find(std::make_pair(st, file_index));
|
file_set::iterator i = m_files.find(std::make_pair(st, file_index));
|
||||||
if (i == m_files.end()) return;
|
if (i == m_files.end()) return;
|
||||||
|
|
||||||
|
@ -292,6 +304,7 @@ namespace libtorrent
|
||||||
void file_pool::release(void* st)
|
void file_pool::release(void* st)
|
||||||
{
|
{
|
||||||
mutex::scoped_lock l(m_mutex);
|
mutex::scoped_lock l(m_mutex);
|
||||||
|
TORRENT_ASSERT(m_in_use == 1337);
|
||||||
if (st == 0)
|
if (st == 0)
|
||||||
{
|
{
|
||||||
m_files.clear();
|
m_files.clear();
|
||||||
|
@ -311,8 +324,10 @@ namespace libtorrent
|
||||||
void file_pool::resize(int size)
|
void file_pool::resize(int size)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(size > 0);
|
TORRENT_ASSERT(size > 0);
|
||||||
if (size == m_size) return;
|
|
||||||
mutex::scoped_lock l(m_mutex);
|
mutex::scoped_lock l(m_mutex);
|
||||||
|
TORRENT_ASSERT(m_in_use == 1337);
|
||||||
|
if (size == m_size) return;
|
||||||
m_size = size;
|
m_size = size;
|
||||||
if (int(m_files.size()) <= m_size) return;
|
if (int(m_files.size()) <= m_size) return;
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ rule link_libtorrent ( properties * )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result +=
|
result +=
|
||||||
<library>/torrent//torrent/<link>static/<boost-link>static/<export-extra>on/<test-coverage>on ;
|
<library>/torrent//torrent/<link>static/<boost-link>static/<export-extra>on ;
|
||||||
}
|
}
|
||||||
return $(result) ;
|
return $(result) ;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue