Backout 30712/30705/30684 and bring back the volatileaprpool to test if that helps with memory.

Nicky 2012-11-03 22:35:33 +01:00
parent 468b85c026
commit 4226e07e90
11 changed files with 251 additions and 582 deletions

View File

@ -31,13 +31,7 @@
#include "apr_dso.h"
apr_pool_t *gAPRPoolp = NULL; // Global APR memory pool
// <FS:ND> Not thread safe
// LLVolatileAPRPool *LLAPRFile::sAPRFilePoolp = NULL ; //global volatile APR memory pool.
// </FS:ND>
LLVolatileAPRPool *LLAPRFile::sAPRFilePoolp = NULL ; //global volatile APR memory pool.
apr_thread_mutex_t *gLogMutexp = NULL;
apr_thread_mutex_t *gCallStacksLogMutexp = NULL;
@ -51,29 +45,17 @@ void ll_init_apr()
{
// Initialize APR and create the global pool
apr_initialize();
// <FS:ND> Make sure the pool gets its own allocator
// apr_pool_create(&gAPRPoolp, NULL);
apr_allocator_t *pAlloc(0);
apr_allocator_create( &pAlloc );
apr_pool_create_ex( &gAPRPoolp, 0, 0, pAlloc );
apr_allocator_owner_set( pAlloc, gAPRPoolp );
// <FS:ND>
apr_pool_create(&gAPRPoolp, NULL);
// Initialize the logging mutex
apr_thread_mutex_create(&gLogMutexp, APR_THREAD_MUTEX_UNNESTED, gAPRPoolp);
apr_thread_mutex_create(&gCallStacksLogMutexp, APR_THREAD_MUTEX_UNNESTED, gAPRPoolp);
}
//
// if(!LLAPRFile::sAPRFilePoolp)
// {
// LLAPRFile::sAPRFilePoolp = new LLVolatileAPRPool(FALSE) ;
// }
if(!LLAPRFile::sAPRFilePoolp)
{
LLAPRFile::sAPRFilePoolp = new LLVolatileAPRPool(FALSE) ;
}
}
@ -102,12 +84,11 @@ void ll_cleanup_apr()
apr_pool_destroy(gAPRPoolp);
gAPRPoolp = NULL;
}
// if (LLAPRFile::sAPRFilePoolp)
// {
// delete LLAPRFile::sAPRFilePoolp ;
// LLAPRFile::sAPRFilePoolp = NULL ;
// }
if (LLAPRFile::sAPRFilePoolp)
{
delete LLAPRFile::sAPRFilePoolp ;
LLAPRFile::sAPRFilePoolp = NULL ;
}
apr_terminate();
}
@ -136,20 +117,8 @@ void LLAPRPool::createAPRPool()
return ;
}
// <FS:ND> Use on allocator for each pool
// mStatus = apr_pool_create(&mPool, mParent);
// ll_apr_warn_status(mStatus) ;
apr_allocator_t *pAlloc(0);
mStatus = apr_allocator_create( &pAlloc );
mStatus = apr_pool_create(&mPool, mParent);
ll_apr_warn_status(mStatus) ;
mStatus = apr_pool_create_ex( &mPool, mParent, 0, pAlloc );
ll_apr_warn_status(mStatus) ;
apr_allocator_owner_set( pAlloc, mPool );
// <FS:ND>
if(mMaxSize > 0) //size is the number of blocks (which is usually 4K), NOT bytes.
{
@ -181,108 +150,103 @@ apr_pool_t* LLAPRPool::getAPRPool()
return mPool ;
}
// <FS:ND> Not thread safe
LLVolatileAPRPool::LLVolatileAPRPool(BOOL is_local, apr_pool_t *parent, apr_size_t size, BOOL releasePoolFlag)
: LLAPRPool(parent, size, releasePoolFlag),
mNumActiveRef(0),
mNumTotalRef(0),
mMutexPool(NULL),
mMutexp(NULL)
{
//create mutex
// LLVolatileAPRPool::LLVolatileAPRPool(BOOL is_local, apr_pool_t *parent, apr_size_t size, BOOL releasePoolFlag)
// : LLAPRPool(parent, size, releasePoolFlag),
// mNumActiveRef(0),
// mNumTotalRef(0),
// mMutexPool(NULL),
// mMutexp(NULL)
// {
// //create mutex
//
// // <FS:ND> Crashfix/FIRE-4090/FIRE-4820: is_local is default to TRUE. And of today (2012-07-15) all instances of LLVolatileAPRPool seem
// // to be created just using this default argument.
// // Using apr_os_thread_current and apr_os_thread_equal it appears that there are pools that get access from different threads nonetheless.
// // This would explain why mNumActiveRef sometimes gets garbled.
// // Resolution: Always use a mutex and give it a broader test is this helps.
//
// // if(!is_local) //not a local apr_pool, that is: shared by multiple threads.
//
// // </FS:ND>
//
// {
// apr_pool_create(&mMutexPool, NULL); // Create a pool for mutex
// apr_thread_mutex_create(&mMutexp, APR_THREAD_MUTEX_UNNESTED, mMutexPool);
// }
// }
//
// LLVolatileAPRPool::~LLVolatileAPRPool()
// {
// //delete mutex
// if(mMutexp)
// {
// apr_thread_mutex_destroy(mMutexp);
// apr_pool_destroy(mMutexPool);
// }
// }
//
// //
// //define this virtual function to avoid any mistakenly calling LLAPRPool::getAPRPool().
// //
// //virtual
// apr_pool_t* LLVolatileAPRPool::getAPRPool()
// {
// return LLVolatileAPRPool::getVolatileAPRPool() ;
// }
//
// apr_pool_t* LLVolatileAPRPool::getVolatileAPRPool()
// {
// LLScopedLock lock(mMutexp) ;
//
// mNumTotalRef++ ;
// mNumActiveRef++ ;
//
// if(!mPool)
// {
// createAPRPool() ;
// }
//
// return mPool ;
// }
//
// void LLVolatileAPRPool::clearVolatileAPRPool()
// {
// LLScopedLock lock(mMutexp) ;
//
// if(mNumActiveRef > 0)
// {
// mNumActiveRef--;
// if(mNumActiveRef < 1)
// {
// if(isFull())
// {
// mNumTotalRef = 0 ;
//
// //destroy the apr_pool.
// releaseAPRPool() ;
// }
// else
// {
// //This does not actually free the memory,
// //it just allows the pool to re-use this memory for the next allocation.
// apr_pool_clear(mPool) ;
// }
// }
// }
// else
// {
// llassert_always(mNumActiveRef > 0) ;
// }
//
// //paranoia check if the pool is jammed.
// //will remove the check before going to release.
// llassert_always(mNumTotalRef < (FULL_VOLATILE_APR_POOL << 2)) ;
// }
//
// BOOL LLVolatileAPRPool::isFull()
// {
// return mNumTotalRef > FULL_VOLATILE_APR_POOL ;
// }
// <FS:ND> Crashfix/FIRE-4090/FIRE-4820: is_local is default to TRUE. And of today (2012-07-15) all instances of LLVolatileAPRPool seem
// to be created just using this default argument.
// Using apr_os_thread_current and apr_os_thread_equal it appears that there are pools that get access from different threads nonetheless.
// This would explain why mNumActiveRef sometimes gets garbled.
// Resolution: Always use a mutex and give it a broader test is this helps.
// </FS:ND>
// if(!is_local) //not a local apr_pool, that is: shared by multiple threads.
// </FS:ND>
{
apr_pool_create(&mMutexPool, NULL); // Create a pool for mutex
apr_thread_mutex_create(&mMutexp, APR_THREAD_MUTEX_UNNESTED, mMutexPool);
}
}
LLVolatileAPRPool::~LLVolatileAPRPool()
{
//delete mutex
if(mMutexp)
{
apr_thread_mutex_destroy(mMutexp);
apr_pool_destroy(mMutexPool);
}
}
//
//define this virtual function to avoid any mistakenly calling LLAPRPool::getAPRPool().
//
//virtual
apr_pool_t* LLVolatileAPRPool::getAPRPool()
{
return LLVolatileAPRPool::getVolatileAPRPool() ;
}
apr_pool_t* LLVolatileAPRPool::getVolatileAPRPool()
{
LLScopedLock lock(mMutexp) ;
mNumTotalRef++ ;
mNumActiveRef++ ;
if(!mPool)
{
createAPRPool() ;
}
return mPool ;
}
void LLVolatileAPRPool::clearVolatileAPRPool()
{
LLScopedLock lock(mMutexp) ;
if(mNumActiveRef > 0)
{
mNumActiveRef--;
if(mNumActiveRef < 1)
{
if(isFull())
{
mNumTotalRef = 0 ;
//destroy the apr_pool.
releaseAPRPool() ;
}
else
{
//This does not actually free the memory,
//it just allows the pool to re-use this memory for the next allocation.
apr_pool_clear(mPool) ;
}
}
}
else
{
llassert_always(mNumActiveRef > 0) ;
}
//paranoia check if the pool is jammed.
//will remove the check before going to release.
llassert_always(mNumTotalRef < (FULL_VOLATILE_APR_POOL << 2)) ;
}
BOOL LLVolatileAPRPool::isFull()
{
return mNumTotalRef > FULL_VOLATILE_APR_POOL ;
}
//---------------------------------------------------------------------
//
// LLScopedLock
@ -360,14 +324,14 @@ void ll_apr_assert_status(apr_status_t status, apr_dso_handle_t *handle)
// LLAPRFile functions
//
LLAPRFile::LLAPRFile()
: mFile(NULL)
// mCurrentFilePoolp(NULL)
: mFile(NULL),
mCurrentFilePoolp(NULL)
{
}
LLAPRFile::LLAPRFile(const std::string& filename, apr_int32_t flags, LLVolatileAPRPool* pool)
: mFile(NULL)
// mCurrentFilePoolp(NULL)
: mFile(NULL),
mCurrentFilePoolp(NULL)
{
open(filename, flags, pool);
}
@ -386,11 +350,11 @@ apr_status_t LLAPRFile::close()
mFile = NULL ;
}
// if(mCurrentFilePoolp)
// {
// mCurrentFilePoolp->clearVolatileAPRPool() ;
// mCurrentFilePoolp = NULL ;
// }
if(mCurrentFilePoolp)
{
mCurrentFilePoolp->clearVolatileAPRPool() ;
mCurrentFilePoolp = NULL ;
}
return ret ;
}
@ -401,10 +365,9 @@ apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, LLV
//check if already open some file
llassert_always(!mFile) ;
// llassert_always(!mCurrentFilePoolp) ;
llassert_always(!mCurrentFilePoolp) ;
// apr_pool_t* apr_pool = pool ? pool->getVolatileAPRPool() : NULL ;
apr_pool_t* apr_pool(0);
apr_pool_t* apr_pool = pool ? pool->getVolatileAPRPool() : NULL ;
// <FS:ND> Convert filenames with UTF-8 charaters into a shortfilename (8.3) if running under windows
@ -436,9 +399,9 @@ apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, LLV
*sizep = file_size;
}
// if(!mCurrentFilePoolp)
if(!mCurrentFilePoolp)
{
// mCurrentFilePoolp = pool ;
mCurrentFilePoolp = pool ;
if(!mFile)
{
@ -456,11 +419,10 @@ apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, BOO
//check if already open some file
llassert_always(!mFile) ;
// llassert_always(!mCurrentFilePoolp) ;
// llassert_always(use_global_pool) ; //be aware of using gAPRPoolp.
llassert_always(!mCurrentFilePoolp) ;
llassert_always(use_global_pool) ; //be aware of using gAPRPoolp.
// s = apr_file_open(&mFile, ndConvertFilename(filename).c_str(), flags, APR_OS_DEFAULT, gAPRPoolp);
s = apr_file_open(&mFile, ndConvertFilename(filename).c_str(), flags, APR_OS_DEFAULT, m_Pool.getAPRPool());
s = apr_file_open(&mFile, ndConvertFilename(filename).c_str(), flags, APR_OS_DEFAULT, gAPRPoolp);
if (s != APR_SUCCESS || !mFile)
{
mFile = NULL ;
@ -473,15 +435,13 @@ apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, BOO
apr_pool_t* LLAPRFile::getAPRFilePool(apr_pool_t* pool)
{
// if(!pool)
// {
// mCurrentFilePoolp = sAPRFilePoolp ;
// return mCurrentFilePoolp->getVolatileAPRPool() ;
// }
//
// return pool ;
if(!pool)
{
mCurrentFilePoolp = sAPRFilePoolp ;
return mCurrentFilePoolp->getVolatileAPRPool() ;
}
return m_Pool.getAPRPool();
return pool ;
}
// File I/O
@ -540,8 +500,7 @@ S32 LLAPRFile::seek(apr_seek_where_t where, S32 offset)
//
//static
// apr_status_t LLAPRFile::close(apr_file_t* file_handle, LLVolatileAPRPool* pool)
apr_status_t LLAPRFile::close(apr_file_t* file_handle, LLAPRPool* pool)
apr_status_t LLAPRFile::close(apr_file_t* file_handle, LLVolatileAPRPool* pool)
{
apr_status_t ret = APR_SUCCESS ;
if(file_handle)
@ -550,26 +509,23 @@ apr_status_t LLAPRFile::close(apr_file_t* file_handle, LLAPRPool* pool)
file_handle = NULL ;
}
// if(pool)
// {
// pool->clearVolatileAPRPool() ;
// }
if(pool)
{
pool->clearVolatileAPRPool() ;
}
return ret ;
}
//static
// apr_file_t* LLAPRFile::open(const std::string& filename, LLVolatileAPRPool* pool, apr_int32_t flags)
apr_file_t* LLAPRFile::open(const std::string& filename, LLAPRPool* pool, apr_int32_t flags)
apr_file_t* LLAPRFile::open(const std::string& filename, LLVolatileAPRPool* pool, apr_int32_t flags)
{
apr_status_t s;
apr_file_t* file_handle ;
// pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
// s = apr_file_open(&file_handle, ndConvertFilename(filename).c_str(), flags, APR_OS_DEFAULT, pool->getVolatileAPRPool());
s = apr_file_open(&file_handle, ndConvertFilename(filename).c_str(), flags, APR_OS_DEFAULT, pool->getAPRPool() );
pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
s = apr_file_open(&file_handle, ndConvertFilename(filename).c_str(), flags, APR_OS_DEFAULT, pool->getVolatileAPRPool());
if (s != APR_SUCCESS || !file_handle)
{
ll_apr_warn_status(s);
@ -618,10 +574,7 @@ S32 LLAPRFile::seek(apr_file_t* file_handle, apr_seek_where_t where, S32 offset)
S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool)
{
//*****************************************
// apr_file_t* file_handle = open(filename, pool, APR_READ|APR_BINARY);
LLAPRPool oPool;
apr_file_t* file_handle = open(filename, &oPool, APR_READ|APR_BINARY);
apr_file_t* file_handle = open(filename, pool, APR_READ|APR_BINARY);
//*****************************************
if (!file_handle)
{
@ -655,8 +608,7 @@ S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nb
}
//*****************************************
// close(file_handle, pool) ;
close(file_handle, &oPool) ;
close(file_handle, pool) ;
//*****************************************
return (S32)bytes_read;
}
@ -672,10 +624,7 @@ S32 LLAPRFile::writeEx(const std::string& filename, void *buf, S32 offset, S32 n
}
//*****************************************
// apr_file_t* file_handle = open(filename, pool, flags);
LLAPRPool oPool;
apr_file_t* file_handle = open(filename, &oPool, flags);
apr_file_t* file_handle = open(filename, pool, flags);
//*****************************************
if (!file_handle)
{
@ -709,8 +658,7 @@ S32 LLAPRFile::writeEx(const std::string& filename, void *buf, S32 offset, S32 n
}
//*****************************************
// LLAPRFile::close(file_handle, pool);
LLAPRFile::close(file_handle, &oPool);
LLAPRFile::close(file_handle, pool);
//*****************************************
return (S32)bytes_written;
@ -721,12 +669,9 @@ bool LLAPRFile::remove(const std::string& filename, LLVolatileAPRPool* pool)
{
apr_status_t s;
// pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
// s = apr_file_remove(filename.c_str(), pool->getVolatileAPRPool());
// pool->clearVolatileAPRPool() ;
LLAPRPool oPool;
s = apr_file_remove(filename.c_str(), oPool.getAPRPool());
pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
s = apr_file_remove(filename.c_str(), pool->getVolatileAPRPool());
pool->clearVolatileAPRPool() ;
if (s != APR_SUCCESS)
{
@ -747,12 +692,9 @@ bool LLAPRFile::rename(const std::string& filename, const std::string& newname,
{
apr_status_t s;
// pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
// s = apr_file_rename(filename.c_str(), newname.c_str(), pool->getVolatileAPRPool());
// pool->clearVolatileAPRPool() ;
LLAPRPool oPool;
s = apr_file_rename(filename.c_str(), newname.c_str(), oPool.getAPRPool() );
pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
s = apr_file_rename(filename.c_str(), newname.c_str(), pool->getVolatileAPRPool());
pool->clearVolatileAPRPool() ;
if (s != APR_SUCCESS)
{
@ -769,21 +711,18 @@ bool LLAPRFile::isExist(const std::string& filename, LLVolatileAPRPool* pool, ap
apr_file_t* apr_file;
apr_status_t s;
// pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
// s = apr_file_open(&apr_file, ndConvertFilename(filename).c_str(), flags, APR_OS_DEFAULT, pool->getVolatileAPRPool());
LLAPRPool oPool;
s = apr_file_open(&apr_file, ndConvertFilename(filename).c_str(), flags, APR_OS_DEFAULT, oPool.getAPRPool() );
pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
s = apr_file_open(&apr_file, ndConvertFilename(filename).c_str(), flags, APR_OS_DEFAULT, pool->getVolatileAPRPool());
if (s != APR_SUCCESS || !apr_file)
{
// pool->clearVolatileAPRPool() ;
pool->clearVolatileAPRPool() ;
return false;
}
else
{
apr_file_close(apr_file) ;
// pool->clearVolatileAPRPool() ;
pool->clearVolatileAPRPool() ;
return true;
}
}
@ -795,15 +734,12 @@ S32 LLAPRFile::size(const std::string& filename, LLVolatileAPRPool* pool)
apr_finfo_t info;
apr_status_t s;
// pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
// s = apr_file_open(&apr_file, ndConvertFilename(filename).c_str(), APR_READ, APR_OS_DEFAULT, pool->getVolatileAPRPool());
LLAPRPool oPool;
s = apr_file_open(&apr_file, ndConvertFilename(filename).c_str(), APR_READ, APR_OS_DEFAULT, oPool.getAPRPool() );
pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
s = apr_file_open(&apr_file, ndConvertFilename(filename).c_str(), APR_READ, APR_OS_DEFAULT, pool->getVolatileAPRPool());
if (s != APR_SUCCESS || !apr_file)
{
// pool->clearVolatileAPRPool() ;
pool->clearVolatileAPRPool() ;
return 0;
}
@ -812,7 +748,7 @@ S32 LLAPRFile::size(const std::string& filename, LLVolatileAPRPool* pool)
apr_status_t s = apr_file_info_get(&info, APR_FINFO_SIZE, apr_file);
apr_file_close(apr_file) ;
// pool->clearVolatileAPRPool() ;
pool->clearVolatileAPRPool() ;
if (s == APR_SUCCESS)
{
@ -830,13 +766,10 @@ bool LLAPRFile::makeDir(const std::string& dirname, LLVolatileAPRPool* pool)
{
apr_status_t s;
// pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
// s = apr_dir_make(dirname.c_str(), APR_FPROT_OS_DEFAULT, pool->getVolatileAPRPool());
// pool->clearVolatileAPRPool() ;
LLAPRPool oPool;
s = apr_dir_make(dirname.c_str(), APR_FPROT_OS_DEFAULT, oPool.getAPRPool() );
pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
s = apr_dir_make(dirname.c_str(), APR_FPROT_OS_DEFAULT, pool->getVolatileAPRPool());
pool->clearVolatileAPRPool() ;
if (s != APR_SUCCESS)
{
ll_apr_warn_status(s);
@ -851,12 +784,9 @@ bool LLAPRFile::removeDir(const std::string& dirname, LLVolatileAPRPool* pool)
{
apr_status_t s;
// pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
// s = apr_file_remove(dirname.c_str(), pool->getVolatileAPRPool());
// pool->clearVolatileAPRPool() ;
LLAPRPool oPool;
s = apr_file_remove(dirname.c_str(), oPool.getAPRPool() );
pool = pool ? pool : LLAPRFile::sAPRFilePoolp ;
s = apr_file_remove(dirname.c_str(), pool->getVolatileAPRPool());
pool->clearVolatileAPRPool() ;
if (s != APR_SUCCESS)
{

View File

@ -96,32 +96,25 @@ protected:
//which clears memory automatically.
//so it can not hold static data or data after memory is cleared
//
class LL_COMMON_API LLVolatileAPRPool : public LLAPRPool
{
public:
LLVolatileAPRPool(BOOL is_local = TRUE, apr_pool_t *parent = NULL, apr_size_t size = 0, BOOL releasePoolFlag = TRUE);
virtual ~LLVolatileAPRPool();
// <FS:ND> Not thread safe
/*virtual*/ apr_pool_t* getAPRPool() ; //define this virtual function to avoid any mistakenly calling LLAPRPool::getAPRPool().
apr_pool_t* getVolatileAPRPool() ;
void clearVolatileAPRPool() ;
// class LL_COMMON_API LLVolatileAPRPool : public LLAPRPool
// {
// public:
// LLVolatileAPRPool(BOOL is_local = TRUE, apr_pool_t *parent = NULL, apr_size_t size = 0, BOOL releasePoolFlag = TRUE);
// virtual ~LLVolatileAPRPool();
//
// /*virtual*/ apr_pool_t* getAPRPool() ; //define this virtual function to avoid any mistakenly calling LLAPRPool::getAPRPool().
// apr_pool_t* getVolatileAPRPool() ;
// void clearVolatileAPRPool() ;
//
// BOOL isFull() ;
//
// private:
// S32 mNumActiveRef ; //number of active pointers pointing to the apr_pool.
// S32 mNumTotalRef ; //number of total pointers pointing to the apr_pool since last creating.
//
// apr_thread_mutex_t *mMutexp;
// apr_pool_t *mMutexPool;
// } ;
BOOL isFull() ;
private:
S32 mNumActiveRef ; //number of active pointers pointing to the apr_pool.
S32 mNumTotalRef ; //number of total pointers pointing to the apr_pool since last creating.
typedef void LLVolatileAPRPool;
// </FS:ND>
apr_thread_mutex_t *mMutexp;
apr_pool_t *mMutexPool;
} ;
/**
* @class LLScopedLock
@ -212,8 +205,7 @@ class LL_COMMON_API LLAPRFile : boost::noncopyable
// make this non copyable since a copy closes the file
private:
apr_file_t* mFile ;
LLAPRPool m_Pool;
// LLVolatileAPRPool *mCurrentFilePoolp ; //currently in use apr_pool, could be one of them: sAPRFilePoolp, or a temp pool.
LLVolatileAPRPool *mCurrentFilePoolp ; //currently in use apr_pool, could be one of them: sAPRFilePoolp, or a temp pool.
public:
LLAPRFile() ;
@ -242,13 +234,11 @@ private:
//static components
//
public:
// static LLVolatileAPRPool *sAPRFilePoolp ; //a global apr_pool for APRFile, which is used only when local pool does not exist.
static LLVolatileAPRPool *sAPRFilePoolp ; //a global apr_pool for APRFile, which is used only when local pool does not exist.
private:
// static apr_file_t* open(const std::string& filename, LLVolatileAPRPool* pool, apr_int32_t flags);
// static apr_status_t close(apr_file_t* file, LLVolatileAPRPool* pool) ;
static apr_file_t* open(const std::string& filename, LLAPRPool* pool, apr_int32_t flags);
static apr_status_t close(apr_file_t* file, LLAPRPool* pool) ;
static apr_file_t* open(const std::string& filename, LLVolatileAPRPool* pool, apr_int32_t flags);
static apr_status_t close(apr_file_t* file, LLVolatileAPRPool* pool) ;
static S32 seek(apr_file_t* file, apr_seek_where_t where, S32 offset);
public:
// returns false if failure:
@ -277,9 +267,6 @@ bool LL_COMMON_API ll_apr_warn_status(apr_status_t status, apr_dso_handle_t* han
void LL_COMMON_API ll_apr_assert_status(apr_status_t status);
void LL_COMMON_API ll_apr_assert_status(apr_status_t status, apr_dso_handle_t* handle);
// <FS:ND> Not thread safe at all, but must do for now
extern "C" LL_COMMON_API apr_pool_t* gAPRPoolp; // Global APR memory pool
// </FS:ND>
#endif // LL_LLAPR_H

View File

@ -111,26 +111,11 @@ LLThread::LLThread(const std::string& name, apr_pool_t *poolp) :
else
{
mIsLocalPool = TRUE;
// <FS:ND> Make sure the pool gets its own allocator
// apr_pool_create(&mAPRPoolp, NULL); // Create a subpool for this thread
apr_allocator_t *pAlloc(0);
apr_allocator_create( &pAlloc );
apr_pool_create_ex( &mAPRPoolp, 0, 0, pAlloc );
apr_allocator_owner_set( pAlloc, mAPRPoolp );
// <FS:ND>
apr_pool_create(&mAPRPoolp, NULL); // Create a subpool for this thread
}
mRunCondition = new LLCondition(mAPRPoolp);
// <FS:ND> Removed LLVolatileAPRPool
// mLocalAPRFilePoolp = NULL ;
// </FS:ND>
mLocalAPRFilePoolp = NULL ;
}
@ -138,15 +123,11 @@ LLThread::~LLThread()
{
shutdown();
// <FS:ND> Removed LLVolatileAPRPool
// if(mLocalAPRFilePoolp)
// {
// delete mLocalAPRFilePoolp ;
// mLocalAPRFilePoolp = NULL ;
// }
// </FS:ND>
if(mLocalAPRFilePoolp)
{
delete mLocalAPRFilePoolp ;
mLocalAPRFilePoolp = NULL ;
}
}
void LLThread::shutdown()
@ -194,10 +175,7 @@ void LLThread::shutdown()
delete mRunCondition;
mRunCondition = 0;
// <FS:ND> Removed LLVolatileAPRPool
// if (mIsLocalPool && mAPRPoolp)
if ( mAPRPoolp)
// </FS:ND>
if (mIsLocalPool && mAPRPoolp)
{
apr_pool_destroy(mAPRPoolp);
mAPRPoolp = 0;

View File

@ -84,11 +84,8 @@ public:
void start(void);
apr_pool_t *getAPRPool() { return mAPRPoolp; }
LLVolatileAPRPool* getLocalAPRFilePool() { return mLocalAPRFilePoolp ; }
// <FS:ND> Removed LLVolatileAPRPool
// LLVolatileAPRPool* getLocalAPRFilePool() { return mLocalAPRFilePoolp ; }
// </FS:ND>
U32 getID() const { return mID; }
private:
@ -110,10 +107,7 @@ protected:
//a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used.
//Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes.
// otherwise it will cause severe memory leaking!!! --bao
// <FS:ND> Removed LLVolatileAPRPool
// LLVolatileAPRPool *mLocalAPRFilePoolp ;
// </FS:ND>
LLVolatileAPRPool *mLocalAPRFilePoolp ;
void setQuitting();

View File

@ -39,34 +39,13 @@ LLThreadSafeQueueImplementation::LLThreadSafeQueueImplementation(apr_pool_t * po
mPool(pool),
mQueue(0)
{
// <FS:ND> Make sure the pool gets its own allocator
// if(mOwnsPool) {
// apr_status_t status = apr_pool_create(&mPool, 0);
// if(status != APR_SUCCESS) throw LLThreadSafeQueueError("failed to allocate pool");
// } else {
// ; // No op.
// }
if(mOwnsPool)
{
apr_allocator_t *pAlloc(0);
apr_status_t status = apr_allocator_create( &pAlloc );
status = apr_pool_create_ex( &mPool, 0, 0, pAlloc );
apr_allocator_owner_set( pAlloc, mPool );
if(status != APR_SUCCESS)
throw LLThreadSafeQueueError("failed to allocate pool");
}
else
{
if(mOwnsPool) {
apr_status_t status = apr_pool_create(&mPool, 0);
if(status != APR_SUCCESS) throw LLThreadSafeQueueError("failed to allocate pool");
} else {
; // No op.
}
// <FS:ND>
apr_status_t status = apr_queue_create(&mQueue, capacity, mPool);
if(status != APR_SUCCESS) throw LLThreadSafeQueueError("failed to allocate queue");
}

View File

@ -39,14 +39,10 @@ LLWorkerThread::LLWorkerThread(const std::string& name, bool threaded, bool shou
{
mDeleteMutex = new LLMutex(NULL);
// <FS:ND> Removed LLVolatileAPRPool
// if(!mLocalAPRFilePoolp)
// {
// mLocalAPRFilePoolp = new LLVolatileAPRPool() ;
// }
// </FS:ND>
if(!mLocalAPRFilePoolp)
{
mLocalAPRFilePoolp = new LLVolatileAPRPool() ;
}
}
LLWorkerThread::~LLWorkerThread()

View File

@ -67,14 +67,10 @@ LLLFSThread::LLLFSThread(bool threaded) :
LLQueuedThread("LFS", threaded),
mPriorityCounter(PRIORITY_LOWBITS)
{
// <FS:ND> Removed LLVolatileAPRPool
// if(!mLocalAPRFilePoolp)
// {
// mLocalAPRFilePoolp = new LLVolatileAPRPool() ;
// }
// </FS:ND>
if(!mLocalAPRFilePoolp)
{
mLocalAPRFilePoolp = new LLVolatileAPRPool() ;
}
}
LLLFSThread::~LLLFSThread()
@ -187,12 +183,7 @@ bool LLLFSThread::Request::processRequest()
{
llassert(mOffset >= 0);
LLAPRFile infile ; // auto-closes
// <FS:ND> Removed LLVolatileAPRPool
// infile.open(mFileName, LL_APR_RB, mThread->getLocalAPRFilePool());
infile.open(mFileName, LL_APR_RB, 0, 0);
// </FS:ND>
infile.open(mFileName, LL_APR_RB, mThread->getLocalAPRFilePool());
if (!infile.getFileHandle())
{
llwarns << "LLLFS: Unable to read file: " << mFileName << llendl;
@ -215,12 +206,7 @@ bool LLLFSThread::Request::processRequest()
if (mOffset < 0)
flags |= APR_APPEND;
LLAPRFile outfile ; // auto-closes
// <FS:ND> Removed LLVolatileAPRPool
// outfile.open(mFileName, flags, mThread->getLocalAPRFilePool());
outfile.open(mFileName, flags, 0, 0);
// </FS:ND>
outfile.open(mFileName, flags, mThread->getLocalAPRFilePool());
if (!outfile.getFileHandle())
{
llwarns << "LLLFS: Unable to write file: " << mFileName << llendl;

View File

@ -46,13 +46,7 @@ void LLMainLoopRepeater::start(void)
{
if(mQueue != 0) return;
// <FS:ND> Make sure the queue gets it's own pool
// mQueue = new LLThreadSafeQueue<LLSD>(gAPRPoolp, 1024);
mQueue = new LLThreadSafeQueue<LLSD>(0, 1024);
// </FS:ND>
mQueue = new LLThreadSafeQueue<LLSD>(gAPRPoolp, 1024);
mMainLoopConnection = LLEventPumps::instance().
obtain("mainloop").listen(LLEventPump::inventName(), boost::bind(&LLMainLoopRepeater::onMainLoop, this, _1));
mRepeaterConnection = LLEventPumps::instance().

View File

@ -177,12 +177,7 @@ private:
bool LLTextureCacheLocalFileWorker::doRead()
{
// <FS:ND> Removed LLVolatileAPRPool
// S32 local_size = LLAPRFile::size(mFileName, mCache->getLocalAPRFilePool());
S32 local_size = LLAPRFile::size(mFileName, 0);
// </FS:ND>
S32 local_size = LLAPRFile::size(mFileName, mCache->getLocalAPRFilePool());
if (local_size > 0 && mFileName.size() > 4)
{
@ -256,12 +251,7 @@ bool LLTextureCacheLocalFileWorker::doRead()
}
mReadData = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), mDataSize);
// <FS:ND> Removed LLVolatileAPRPool
// S32 bytes_read = LLAPRFile::readEx(mFileName, mReadData, mOffset, mDataSize, mCache->getLocalAPRFilePool());
S32 bytes_read = LLAPRFile::readEx(mFileName, mReadData, mOffset, mDataSize, 0);
// </FS:ND>
S32 bytes_read = LLAPRFile::readEx(mFileName, mReadData, mOffset, mDataSize, mCache->getLocalAPRFilePool());
if (bytes_read != mDataSize)
{
@ -342,14 +332,7 @@ bool LLTextureCacheRemoteWorker::doRead()
// Is it a JPEG2000 file?
{
local_filename = filename + ".j2c";
// <FS: ND> Removed LLVolatileAPRPool
// local_size = LLAPRFile::size(local_filename, mCache->getLocalAPRFilePool());
local_size = LLAPRFile::size(local_filename, 0 );
// </FS:ND>
local_size = LLAPRFile::size(local_filename, mCache->getLocalAPRFilePool());
if (local_size > 0)
{
mImageFormat = IMG_CODEC_J2C;
@ -359,14 +342,7 @@ bool LLTextureCacheRemoteWorker::doRead()
if (local_size == 0)
{
local_filename = filename + ".jpg";
// <FS:ND> Removed LLVolatileAPRPool
// local_size = LLAPRFile::size(local_filename, mCache->getLocalAPRFilePool());
local_size = LLAPRFile::size(local_filename, 0);
// </FS:ND>
local_size = LLAPRFile::size(local_filename, mCache->getLocalAPRFilePool());
if (local_size > 0)
{
mImageFormat = IMG_CODEC_JPEG;
@ -377,14 +353,7 @@ bool LLTextureCacheRemoteWorker::doRead()
if (local_size == 0)
{
local_filename = filename + ".tga";
// <FS:ND> Removed LLVolatileAPRPool
// local_size = LLAPRFile::size(local_filename, mCache->getLocalAPRFilePool());
local_size = LLAPRFile::size(local_filename, 0);
// </FS:ND>
local_size = LLAPRFile::size(local_filename, mCache->getLocalAPRFilePool());
if (local_size > 0)
{
mImageFormat = IMG_CODEC_TGA;
@ -410,15 +379,8 @@ bool LLTextureCacheRemoteWorker::doRead()
}
// Allocate read buffer
mReadData = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), mDataSize);
// <FS:ND> Removed LLVolatileAPRPool
// S32 bytes_read = LLAPRFile::readEx(local_filename,
// mReadData, mOffset, mDataSize, mCache->getLocalAPRFilePool());
S32 bytes_read = LLAPRFile::readEx(local_filename, mReadData, mOffset, mDataSize, 0);
// </FS:ND>
S32 bytes_read = LLAPRFile::readEx(local_filename,
mReadData, mOffset, mDataSize, mCache->getLocalAPRFilePool());
if (bytes_read != mDataSize)
{
llwarns << "Error reading file from local cache: " << local_filename
@ -469,15 +431,8 @@ bool LLTextureCacheRemoteWorker::doRead()
size = llmin(size, mDataSize);
// Allocate the read buffer
mReadData = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), size);
// <FS:ND> Removed LLVolatileAPRPool
// S32 bytes_read = LLAPRFile::readEx(mCache->mHeaderDataFileName,
// mReadData, offset, size, mCache->getLocalAPRFilePool());
S32 bytes_read = LLAPRFile::readEx(mCache->mHeaderDataFileName, mReadData, offset, size, 0);
// </FS:NS>
S32 bytes_read = LLAPRFile::readEx(mCache->mHeaderDataFileName,
mReadData, offset, size, mCache->getLocalAPRFilePool());
if (bytes_read != size)
{
llwarns << "LLTextureCacheWorker: " << mID
@ -503,13 +458,7 @@ bool LLTextureCacheRemoteWorker::doRead()
if (!done && (mState == BODY))
{
std::string filename = mCache->getTextureFileName(mID);
// <FS:ND> Removed LLVolatileAPRPool
// S32 filesize = LLAPRFile::size(filename, mCache->getLocalAPRFilePool());
S32 filesize = LLAPRFile::size(filename, 0);
// </FS:ND>>
S32 filesize = LLAPRFile::size(filename, mCache->getLocalAPRFilePool());
if (filesize && (filesize + TEXTURE_CACHE_ENTRY_SIZE) > mOffset)
{
@ -549,18 +498,10 @@ bool LLTextureCacheRemoteWorker::doRead()
mReadData = data;
// Read the data at last
// <FS:ND> Removed LLVolatileAPRPool
// S32 bytes_read = LLAPRFile::readEx(filename,
// mReadData + data_offset,
// file_offset, file_size,
// mCache->getLocalAPRFilePool());
S32 bytes_read = LLAPRFile::readEx(filename,mReadData + data_offset, file_offset, file_size, 0 );
// </FS:ND>
S32 bytes_read = LLAPRFile::readEx(filename,
mReadData + data_offset,
file_offset, file_size,
mCache->getLocalAPRFilePool());
if (bytes_read != file_size)
{
llwarns << "LLTextureCacheWorker: " << mID
@ -661,26 +602,13 @@ bool LLTextureCacheRemoteWorker::doWrite()
U8* padBuffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), TEXTURE_CACHE_ENTRY_SIZE);
memset(padBuffer, 0, TEXTURE_CACHE_ENTRY_SIZE); // Init with zeros
memcpy(padBuffer, mWriteData, mDataSize); // Copy the write buffer
// <FS:ND> Removed LLVolatileAPRPool
// bytes_written = LLAPRFile::writeEx(mCache->mHeaderDataFileName, padBuffer, offset, size, mCache->getLocalAPRFilePool());
bytes_written = LLAPRFile::writeEx(mCache->mHeaderDataFileName, padBuffer, offset, size, 0);
// </FS:ND>
bytes_written = LLAPRFile::writeEx(mCache->mHeaderDataFileName, padBuffer, offset, size, mCache->getLocalAPRFilePool());
FREE_MEM(LLImageBase::getPrivatePool(), padBuffer);
}
else
{
// Write the header record (== first TEXTURE_CACHE_ENTRY_SIZE bytes of the raw file) in the header file
// <FS:ND> Removed LLVolatileAPRPool
// bytes_written = LLAPRFile::writeEx(mCache->mHeaderDataFileName, mWriteData, offset, size, mCache->getLocalAPRFilePool());
bytes_written = LLAPRFile::writeEx(mCache->mHeaderDataFileName, mWriteData, offset, size, 0);
// </FS:ND>
bytes_written = LLAPRFile::writeEx(mCache->mHeaderDataFileName, mWriteData, offset, size, mCache->getLocalAPRFilePool());
}
if (bytes_written <= 0)
@ -713,17 +641,10 @@ bool LLTextureCacheRemoteWorker::doWrite()
// build the cache file name from the UUID
std::string filename = mCache->getTextureFileName(mID);
// llinfos << "Writing Body: " << filename << " Bytes: " << file_offset+file_size << llendl;
// <FS:ND> Removed LLVolatileAPRPool
// S32 bytes_written = LLAPRFile::writeEx( filename,
// mWriteData + TEXTURE_CACHE_ENTRY_SIZE,
// 0, file_size,
// mCache->getLocalAPRFilePool());
S32 bytes_written = LLAPRFile::writeEx( filename, mWriteData + TEXTURE_CACHE_ENTRY_SIZE, 0, file_size, 0);
// </FS:ND>
S32 bytes_written = LLAPRFile::writeEx( filename,
mWriteData + TEXTURE_CACHE_ENTRY_SIZE,
0, file_size,
mCache->getLocalAPRFilePool());
if (bytes_written <= 0)
{
llwarns << "LLTextureCacheWorker: " << mID
@ -926,14 +847,7 @@ BOOL LLTextureCache::isInLocal(const LLUUID& id)
// Is it a JPEG2000 file?
{
local_filename = filename + ".j2c";
// <FS:ND> Removed LLVolatileAPRPool
// local_size = LLAPRFile::size(local_filename, getLocalAPRFilePool());
local_size = LLAPRFile::size(local_filename, 0);
// </FS:ND>
local_size = LLAPRFile::size(local_filename, getLocalAPRFilePool());
if (local_size > 0)
{
return TRUE ;
@ -943,14 +857,7 @@ BOOL LLTextureCache::isInLocal(const LLUUID& id)
// If not, is it a jpeg file?
{
local_filename = filename + ".jpg";
// <FS:ND> Removed LLVolatileAPRPool
// local_size = LLAPRFile::size(local_filename, getLocalAPRFilePool());
local_size = LLAPRFile::size(local_filename, 0);
// </FS:ND>
local_size = LLAPRFile::size(local_filename, getLocalAPRFilePool());
if (local_size > 0)
{
return TRUE ;
@ -960,14 +867,7 @@ BOOL LLTextureCache::isInLocal(const LLUUID& id)
// Hmm... What about a targa file? (used for UI texture mostly)
{
local_filename = filename + ".tga";
// <FS:ND> Removed LLVolatileAPRPool
// local_size = LLAPRFile::size(local_filename, getLocalAPRFilePool());
local_size = LLAPRFile::size(local_filename, 0);
// </FS:ND>
local_size = LLAPRFile::size(local_filename, getLocalAPRFilePool());
if (local_size > 0)
{
return TRUE ;
@ -1013,22 +913,10 @@ void LLTextureCache::purgeCache(ELLPath location)
if(LLFile::isdir(mTexturesDirName))
{
std::string file_name = gDirUtilp->getExpandedFilename(location, entries_filename);
// <FS:ND> Removed LLVolatileAPRPool
// LLAPRFile::remove(file_name, getLocalAPRFilePool());
LLAPRFile::remove(file_name, 0);
// </FS:ND>
LLAPRFile::remove(file_name, getLocalAPRFilePool());
file_name = gDirUtilp->getExpandedFilename(location, cache_filename);
// <FS:ND> Removed LLVolatileAPRPool
// LLAPRFile::remove(file_name, getLocalAPRFilePool());
LLAPRFile::remove(file_name, 0);
// </FS:ND>
LLAPRFile::remove(file_name, getLocalAPRFilePool());
purgeAllTextures(true);
}
@ -1104,14 +992,7 @@ LLAPRFile* LLTextureCache::openHeaderEntriesFile(bool readonly, S32 offset)
{
llassert_always(mHeaderAPRFile == NULL);
apr_int32_t flags = readonly ? APR_READ|APR_BINARY : APR_READ|APR_WRITE|APR_BINARY;
// <FS:ND> Removed LLVolatileAPRPool
// mHeaderAPRFile = new LLAPRFile(mHeaderEntriesFileName, flags, getLocalAPRFilePool());
mHeaderAPRFile = new LLAPRFile(mHeaderEntriesFileName, flags, 0);
// </FS:ND>
mHeaderAPRFile = new LLAPRFile(mHeaderEntriesFileName, flags, getLocalAPRFilePool());
if(offset > 0)
{
mHeaderAPRFile->seek(APR_SET, offset);
@ -1134,19 +1015,11 @@ void LLTextureCache::readEntriesHeader()
{
// mHeaderEntriesInfo initializes to default values so safe not to read it
llassert_always(mHeaderAPRFile == NULL);
// <FS:ND> Removed LLVolatileAPRPool
// if (LLAPRFile::isExist(mHeaderEntriesFileName, getLocalAPRFilePool()))
// {
// LLAPRFile::readEx(mHeaderEntriesFileName, (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo),
// getLocalAPRFilePool());
// }
if (LLAPRFile::isExist(mHeaderEntriesFileName, 0) )
if (LLAPRFile::isExist(mHeaderEntriesFileName, getLocalAPRFilePool()))
{
LLAPRFile::readEx(mHeaderEntriesFileName, (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo), 0);
LLAPRFile::readEx(mHeaderEntriesFileName, (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo),
getLocalAPRFilePool());
}
// </FS:ND>
else //create an empty entries header.
{
mHeaderEntriesInfo.mVersion = sHeaderCacheVersion ;
@ -1160,13 +1033,8 @@ void LLTextureCache::writeEntriesHeader()
llassert_always(mHeaderAPRFile == NULL);
if (!mReadOnly)
{
// <FS:ND> Removed LLVolatileAPRPool
// LLAPRFile::writeEx(mHeaderEntriesFileName, (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo),
// getLocalAPRFilePool());
LLAPRFile::writeEx(mHeaderEntriesFileName, (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo), 0);
// </FS:ND>
LLAPRFile::writeEx(mHeaderEntriesFileName, (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo),
getLocalAPRFilePool());
}
}
@ -1755,14 +1623,7 @@ void LLTextureCache::purgeTextures(bool validate)
if (uuididx == validate_idx)
{
LL_DEBUGS("TextureCache") << "Validating: " << filename << "Size: " << entries[idx].mBodySize << LL_ENDL;
// <FS:ND> Removed LLVolatileAPRPool
// S32 bodysize = LLAPRFile::size(filename, getLocalAPRFilePool());
S32 bodysize = LLAPRFile::size(filename, 0);
// </FS:ND>
S32 bodysize = LLAPRFile::size(filename, getLocalAPRFilePool());
if (bodysize != entries[idx].mBodySize)
{
LL_WARNS("TextureCache") << "TEXTURE CACHE BODY HAS BAD SIZE: " << bodysize << " != " << entries[idx].mBodySize
@ -1997,13 +1858,7 @@ void LLTextureCache::removeCachedTexture(const LLUUID& id)
mTexturesSizeMap.erase(id);
}
mHeaderIDMap.erase(id);
// <FS:ND> Removed LLVolatileAPRPool
// LLAPRFile::remove(getTextureFileName(id), getLocalAPRFilePool());
LLAPRFile::remove(getTextureFileName(id), 0);
// </FS:ND>
LLAPRFile::remove(getTextureFileName(id), getLocalAPRFilePool());
}
//called after mHeaderMutex is locked.
@ -2015,12 +1870,7 @@ void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename)
{
if (entry.mBodySize == 0) // Always attempt to remove when mBodySize > 0.
{
// <FS:ND> Removed LLVolatileAPRPool
// if (LLAPRFile::isExist(filename, getLocalAPRFilePool())) // Sanity check. Shouldn't exist when body size is 0.
if (LLAPRFile::isExist(filename, 0)) // Sanity check. Shouldn't exist when body size is 0.
// </FS:ND>
if (LLAPRFile::isExist(filename, getLocalAPRFilePool())) // Sanity check. Shouldn't exist when body size is 0.
{
LL_WARNS("TextureCache") << "Entry has body size of zero but file " << filename << " exists. Deleting this file, too." << LL_ENDL;
}
@ -2040,12 +1890,7 @@ void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename)
if (file_maybe_exists)
{
// <FS:ND> Removed LLVolatileAPRPool
// LLAPRFile::remove(filename, getLocalAPRFilePool());
LLAPRFile::remove(filename, 0);
// </FS:ND>
LLAPRFile::remove(filename, getLocalAPRFilePool());
}
}

View File

@ -268,10 +268,7 @@ LLVOCache::LLVOCache():
mCacheSize(1)
{
mEnabled = gSavedSettings.getBOOL("ObjectCacheEnabled");
// <FS:ND> Removed LLVolatileAPRPool
// mLocalAPRFilePoolp = new LLVolatileAPRPool() ;
// </FS:ND>
mLocalAPRFilePoolp = new LLVolatileAPRPool() ;
}
LLVOCache::~LLVOCache()
@ -281,10 +278,7 @@ LLVOCache::~LLVOCache()
writeCacheHeader();
clearCacheInMemory();
}
// <FS:ND> Removed LLVolatileAPRPool
// delete mLocalAPRFilePoolp;
// </FS:ND>
delete mLocalAPRFilePoolp;
}
void LLVOCache::setDirNames(ELLPath location)
@ -441,10 +435,7 @@ void LLVOCache::removeFromCache(HeaderEntryInfo* entry)
std::string filename;
getObjectCacheFilename(entry->mHandle, filename);
// LLAPRFile::remove(filename, mLocalAPRFilePoolp);
LLAPRFile::remove(filename, 0);
LLAPRFile::remove(filename, mLocalAPRFilePoolp);
entry->mTime = INVALID_TIME ;
updateEntry(entry) ; //update the head file.
}
@ -461,11 +452,9 @@ void LLVOCache::readCacheHeader()
clearCacheInMemory();
bool success = true ;
// if (LLAPRFile::isExist(mHeaderFileName, mLocalAPRFilePoolp))
if (LLAPRFile::isExist(mHeaderFileName, 0))
if (LLAPRFile::isExist(mHeaderFileName, mLocalAPRFilePoolp))
{
// LLAPRFile apr_file(mHeaderFileName, APR_READ|APR_BINARY, mLocalAPRFilePoolp);
LLAPRFile apr_file(mHeaderFileName, APR_READ|APR_BINARY, 0 );
LLAPRFile apr_file(mHeaderFileName, APR_READ|APR_BINARY, mLocalAPRFilePoolp);
//read the meta element
success = check_read(&apr_file, &mMetaInfo, sizeof(HeaderMetaInfo)) ;
@ -550,8 +539,7 @@ void LLVOCache::writeCacheHeader()
bool success = true ;
{
// LLAPRFile apr_file(mHeaderFileName, APR_CREATE|APR_WRITE|APR_BINARY, mLocalAPRFilePoolp);
LLAPRFile apr_file(mHeaderFileName, APR_CREATE|APR_WRITE|APR_BINARY, 0);
LLAPRFile apr_file(mHeaderFileName, APR_CREATE|APR_WRITE|APR_BINARY, mLocalAPRFilePoolp);
//write the meta element
success = check_write(&apr_file, &mMetaInfo, sizeof(HeaderMetaInfo)) ;
@ -589,9 +577,7 @@ void LLVOCache::writeCacheHeader()
BOOL LLVOCache::updateEntry(const HeaderEntryInfo* entry)
{
// LLAPRFile apr_file(mHeaderFileName, APR_WRITE|APR_BINARY, mLocalAPRFilePoolp);
LLAPRFile apr_file(mHeaderFileName, APR_WRITE|APR_BINARY, 0);
LLAPRFile apr_file(mHeaderFileName, APR_WRITE|APR_BINARY, mLocalAPRFilePoolp);
apr_file.seek(APR_SET, entry->mIndex * sizeof(HeaderEntryInfo) + sizeof(HeaderMetaInfo)) ;
return check_write(&apr_file, (void*)entry, sizeof(HeaderEntryInfo)) ;
@ -617,8 +603,7 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
{
std::string filename;
getObjectCacheFilename(handle, filename);
// LLAPRFile apr_file(filename, APR_READ|APR_BINARY, mLocalAPRFilePoolp);
LLAPRFile apr_file(filename, APR_READ|APR_BINARY, 0);
LLAPRFile apr_file(filename, APR_READ|APR_BINARY, mLocalAPRFilePoolp);
LLUUID cache_id ;
success = check_read(&apr_file, cache_id.mData, UUID_BYTES) ;
@ -741,8 +726,7 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry:
{
std::string filename;
getObjectCacheFilename(handle, filename);
// LLAPRFile apr_file(filename, APR_CREATE|APR_WRITE|APR_BINARY, mLocalAPRFilePoolp);
LLAPRFile apr_file(filename, APR_CREATE|APR_WRITE|APR_BINARY, 0);
LLAPRFile apr_file(filename, APR_CREATE|APR_WRITE|APR_BINARY, mLocalAPRFilePoolp);
success = check_write(&apr_file, (void*)id.mData, UUID_BYTES) ;

View File

@ -142,11 +142,7 @@ private:
U32 mNumEntries;
std::string mHeaderFileName ;
std::string mObjectCacheDirName;
// <FS:ND> Removed LLVolatileAPRPool
// LLVolatileAPRPool* mLocalAPRFilePoolp ;
// </FS:ND>
LLVolatileAPRPool* mLocalAPRFilePoolp ;
header_entry_queue_t mHeaderEntryQueue;
handle_entry_map_t mHandleEntryMap;