diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index ee7717f12..d16b87cd7 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -88,7 +88,7 @@ bool ll_apr_warn_status(apr_status_t status) void ll_apr_assert_status(apr_status_t status) { - llassert(ll_apr_warn_status(status) == false); + llassert(!ll_apr_warn_status(status)); } //--------------------------------------------------------------------- @@ -146,7 +146,7 @@ apr_status_t LLAPRFile::open(std::string const& filename, apr_int32_t flags, acc apr_status_t status; { - apr_pool_t* apr_file_open_pool; + apr_pool_t* apr_file_open_pool; // The use of apr_pool_t is OK here. // This is a temporary variable for a pool that is passed directly to apr_file_open below. if (access_type == short_lived) { @@ -199,7 +199,6 @@ apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, BOO // File I/O S32 LLAPRFile::read(void *buf, S32 nbytes) { - //llassert_always(mFile); (ASC-TUDCC) -HgB if(!mFile) { llwarns << "apr mFile is removed by somebody else. Can not read." << llendl ; @@ -222,7 +221,6 @@ S32 LLAPRFile::read(void *buf, S32 nbytes) S32 LLAPRFile::write(const void *buf, S32 nbytes) { - // llassert_always(mFile); (ASC-TUDCC) -HgB if(!mFile) { llwarns << "apr mFile is removed by somebody else. Can not write." << llendl ; diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index e7c3c53f1..3574e1790 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -113,7 +113,7 @@ typedef LLAtomic32 LLAtomicU32; typedef LLAtomic32 LLAtomicS32; // File IO convenience functions. -// Returns NULL if the file fails to openm sets *sizep to file size of not NULL +// Returns NULL if the file fails to open, sets *sizep to file size if not NULL // abbreviated flags #define LL_APR_R (APR_READ) // "r" #define LL_APR_W (APR_CREATE|APR_TRUNCATE|APR_WRITE) // "w" @@ -131,7 +131,7 @@ typedef LLAtomic32 LLAtomicS32; // especially do not put some time-costly operations between open() and close(). // otherwise it might lock the APRFilePool. //there are two different apr_pools the APRFile can use: -// 1, a temperary pool passed to an APRFile function, which is used within this function and only once. +// 1, a temporary pool passed to an APRFile function, which is used within this function and only once. // 2, a global pool. // @@ -189,7 +189,7 @@ public: }; /** - * @brief Function which approprately logs error or remains quiet on + * @brief Function which appropriately logs error or remains quiet on * APR_SUCCESS. * @return Returns true if status is an error condition. */ diff --git a/indra/llcommon/llaprpool.h b/indra/llcommon/llaprpool.h index 133f60316..dc123e942 100644 --- a/indra/llcommon/llaprpool.h +++ b/indra/llcommon/llaprpool.h @@ -60,9 +60,9 @@ extern void ll_init_apr(); class LL_COMMON_API LLAPRPool { protected: - apr_pool_t* mPool; //!< Pointer to the underlaying pool. NULL if not initialized. + apr_pool_t* mPool; //!< Pointer to the underlaying pool. NULL if not initialized. LLAPRPool* mParent; //!< Pointer to the parent pool, if any. Only valid when mPool is non-zero. - apr_os_thread_t mOwner; //!< The thread that owns this memory pool. Only valid when mPool is non-zero. + apr_os_thread_t mOwner; //!< The thread that owns this memory pool. Only valid when mPool is non-zero. public: //! Construct an uninitialized (destructed) pool. diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 8ae458c1c..ef52dde46 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -399,6 +399,15 @@ LLMutexBase::LLMutexBase() : { } +bool LLMutexBase::isSelfLocked() const +{ +#if LL_DARWIN + return mLockingThread == LLThread::currentID(); +#else + return mLockingThread == local_thread_ID; +#endif +} + void LLMutexBase::lock() { #if LL_DARWIN @@ -431,7 +440,7 @@ void LLMutexBase::unlock() apr_thread_mutex_unlock(mAPRMutexp); } - + //---------------------------------------------------------------------------- //static diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index f0e4f39f5..c5a06f19c 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -73,7 +73,7 @@ class LL_COMMON_API LLThread { private: static U32 sIDIter; - + public: typedef enum e_thread_status { @@ -179,13 +179,17 @@ public: LLMutexBase() ; - void lock(); //blocks + void lock(); // blocks void unlock(); // Returns true if lock was obtained successfully. bool tryLock() { return !APR_STATUS_IS_EBUSY(apr_thread_mutex_trylock(mAPRMutexp)); } // non-blocking, but does do a lock/unlock so not free bool isLocked() { bool is_not_locked = tryLock(); if (is_not_locked) unlock(); return !is_not_locked; } + + // Returns true if locked by this thread. + bool isSelfLocked() const; + // get ID of locking thread U32 lockingThread() const { return mLockingThread; }