Added FTK console I/O routines to support FLAIM utilities. Misc. changes to the slab allocator.
git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@505 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
+68
-38
@@ -483,9 +483,10 @@
|
||||
#define NE_FLM_CLOSING_FILE 0xC226 ///< 0xC226 - Unexpected error occurred while closing a file.
|
||||
#define NE_FLM_GETTING_FILE_INFO 0xC227 ///< 0xC227 - Unexpected error occurred while getting information about a file.
|
||||
#define NE_FLM_EXPANDING_FILE 0xC228 ///< 0xC228 - Unexpected error occurred while expanding a file.
|
||||
#define NE_FLM_CHECKING_FILE_EXISTENCE 0xC229 ///< 0xC229 - Unexpected error occurred while checking to see if a file exists.
|
||||
#define NE_FLM_RENAMING_FILE 0xC22A ///< 0xC22A - Unexpected error occurred while renaming a file.
|
||||
#define NE_FLM_SETTING_FILE_INFO 0xC22B ///< 0xC22B - Unexpected error occurred while setting a file's information.
|
||||
#define NE_FLM_GETTING_FREE_BLOCKS 0xC229 ///< 0xC229 - Unexpected error getting free blocks from file system.
|
||||
#define NE_FLM_CHECKING_FILE_EXISTENCE 0xC22A ///< 0xC22A - Unexpected error occurred while checking to see if a file exists.
|
||||
#define NE_FLM_RENAMING_FILE 0xC22B ///< 0xC22B - Unexpected error occurred while renaming a file.
|
||||
#define NE_FLM_SETTING_FILE_INFO 0xC22C ///< 0xC22C - Unexpected error occurred while setting a file's information.
|
||||
|
||||
// Stream Errors - These are new
|
||||
|
||||
@@ -800,6 +801,9 @@
|
||||
#define F_THREAD_MIN_STACK_SIZE (16 * 1024)
|
||||
#define F_THREAD_DEFAULT_STACK_SIZE (16 * 1024)
|
||||
|
||||
#define F_DEFAULT_THREAD_GROUP 0
|
||||
#define F_INVALID_THREAD_GROUP 0xFFFFFFFF
|
||||
|
||||
typedef RCODE (* F_THREAD_FUNC)(IF_Thread *);
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1345,12 +1349,6 @@
|
||||
FLMUINT uiIoFlags,
|
||||
IF_FileHdl ** ppFile) = 0;
|
||||
|
||||
virtual RCODE FLMAPI createBlockFile(
|
||||
const char * pszFileName,
|
||||
FLMUINT uiIoFlags,
|
||||
FLMUINT uiBlockSize,
|
||||
IF_FileHdl ** ppFile) = 0;
|
||||
|
||||
virtual RCODE FLMAPI createUniqueFile(
|
||||
char * pszPath,
|
||||
const char * pszFileExtension,
|
||||
@@ -1366,12 +1364,6 @@
|
||||
FLMUINT uiIoFlags,
|
||||
IF_FileHdl ** ppFile) = 0;
|
||||
|
||||
virtual RCODE FLMAPI openBlockFile(
|
||||
const char * pszFileName,
|
||||
FLMUINT uiIoFlags,
|
||||
FLMUINT uiBlockSize,
|
||||
IF_FileHdl ** ppFile) = 0;
|
||||
|
||||
virtual RCODE FLMAPI openDir(
|
||||
const char * pszDirName,
|
||||
const char * pszPattern,
|
||||
@@ -1472,6 +1464,15 @@
|
||||
RCODE FLMAPI f_getcwd(
|
||||
char * pszDir);
|
||||
|
||||
RCODE FLMAPI f_pathReduce(
|
||||
const char * pszSourcePath,
|
||||
char * pszDestPath,
|
||||
char * pszString);
|
||||
|
||||
RCODE FLMAPI f_pathAppend(
|
||||
char * pszPath,
|
||||
const char * pszPathComponent);
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
@@ -1530,11 +1531,6 @@
|
||||
virtual void FLMAPI setMaxAutoExtendSize(
|
||||
FLMUINT uiMaxAutoExtendSize) = 0;
|
||||
|
||||
virtual void FLMAPI setBlockSize(
|
||||
FLMUINT uiBlockSize) = 0;
|
||||
|
||||
virtual FLMUINT FLMAPI getBlockSize( void) = 0;
|
||||
|
||||
virtual FLMUINT FLMAPI getSectorSize( void) = 0;
|
||||
|
||||
virtual FLMBOOL FLMAPI isReadOnly( void) = 0;
|
||||
@@ -2003,7 +1999,7 @@
|
||||
virtual RCODE FLMAPI startThread(
|
||||
F_THREAD_FUNC fnThread,
|
||||
const char * pszThreadName = NULL,
|
||||
FLMUINT uiThreadGroup = 0,
|
||||
FLMUINT uiThreadGroup = F_DEFAULT_THREAD_GROUP,
|
||||
FLMUINT uiAppId = 0,
|
||||
void * pvParm1 = NULL,
|
||||
void * pvParm2 = NULL,
|
||||
@@ -2054,7 +2050,7 @@
|
||||
IF_Thread ** ppThread,
|
||||
F_THREAD_FUNC fnThread,
|
||||
const char * pszThreadName = NULL,
|
||||
FLMUINT uiThreadGroup = 0,
|
||||
FLMUINT uiThreadGroup = F_DEFAULT_THREAD_GROUP,
|
||||
FLMUINT uiAppId = 0,
|
||||
void * pvParm1 = NULL,
|
||||
void * pvParm2 = NULL,
|
||||
@@ -3528,10 +3524,11 @@
|
||||
flminterface FLMEXP IF_FixedAlloc : public F_Object
|
||||
{
|
||||
virtual RCODE FLMAPI setup(
|
||||
IF_Relocator * pRelocator,
|
||||
IF_SlabManager * pSlabManager,
|
||||
IF_Relocator * pDefaultRelocator,
|
||||
FLMUINT uiCellSize,
|
||||
FLM_SLAB_USAGE * pUsageStats) = 0;
|
||||
FLM_SLAB_USAGE * pUsageStats,
|
||||
FLMUINT * puiTotalBytesAllocated) = 0;
|
||||
|
||||
virtual void * FLMAPI allocCell(
|
||||
IF_Relocator * pRelocator = NULL,
|
||||
@@ -3562,8 +3559,9 @@
|
||||
{
|
||||
virtual RCODE FLMAPI setup(
|
||||
IF_SlabManager * pSlabManager,
|
||||
IF_Relocator * pDefaultRelocator,
|
||||
FLM_SLAB_USAGE * pUsageStats,
|
||||
IF_Relocator * pDefaultRelocator = NULL) = 0;
|
||||
FLMUINT * puiTotalBytesAllocated) = 0;
|
||||
|
||||
virtual RCODE FLMAPI allocBuf(
|
||||
IF_Relocator * pRelocator,
|
||||
@@ -3605,8 +3603,10 @@
|
||||
{
|
||||
virtual RCODE FLMAPI setup(
|
||||
IF_SlabManager * pSlabManager,
|
||||
IF_Relocator * pDefaultRelocator,
|
||||
FLMUINT * puiCellSizes,
|
||||
FLM_SLAB_USAGE * pUsageStats) = 0;
|
||||
FLM_SLAB_USAGE * pUsageStats,
|
||||
FLMUINT * puiTotalBytesAllocated) = 0;
|
||||
|
||||
virtual RCODE FLMAPI allocBuf(
|
||||
IF_Relocator * pRelocator,
|
||||
@@ -4342,22 +4342,35 @@
|
||||
} eLockType;
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
/// Abstract base class to get lock information. The application must
|
||||
/// implement this class. A pointer to an object of this class is passed
|
||||
/// into IF_LockObject::getLockInfo().
|
||||
****************************************************************************/
|
||||
flminterface IF_LockInfoClient : public F_Object
|
||||
{
|
||||
virtual FLMBOOL FLMAPI setLockCount( // Return TRUE to continue, FALSE to stop
|
||||
FLMUINT uiTotalLocks) = 0;
|
||||
/// Return the lock count. This method is called by to tell the
|
||||
/// application how many lock holders plus lock waiters there are. This
|
||||
/// gives the application an opportunity to allocate memory to hold the
|
||||
/// information that will be returned via the
|
||||
/// IF_LockInfoClient::addLockInfo() method. The application should
|
||||
/// return TRUE from this method in order to continue, FALSE if it wants
|
||||
/// to stop and return from the IF_LockObject::getLockInfo() function.
|
||||
virtual FLMBOOL FLMAPI setLockCount(
|
||||
FLMUINT uiTotalLocks ///< Total number of lock holders plus lock waiters.
|
||||
) = 0;
|
||||
|
||||
virtual FLMBOOL FLMAPI addLockInfo( // Return TRUE to continue, FALSE to stop
|
||||
FLMUINT uiLockNum, // Position in queue (0 = lock holder,
|
||||
// 1 ... n = lock waiter)
|
||||
FLMUINT uiThreadID, // Thread ID of the lock holder/waiter
|
||||
FLMUINT uiTime) = 0; // For the lock holder, this is the
|
||||
// time when the lock was obtained.
|
||||
// For a lock waiter, this is the time
|
||||
// that the waiter was placed in the queue.
|
||||
// Both times are presented in milliseconds.
|
||||
/// Return lock information for a lock holder or waiter. This method
|
||||
/// is called for each thread that is either holding the lock or waiting
|
||||
/// to obtain the lock. The application should return TRUE from this
|
||||
/// method in order to continue, FALSE if it wants to stop and return
|
||||
/// from the IF_LockObject::getLockInfo() function.
|
||||
virtual FLMBOOL FLMAPI addLockInfo(
|
||||
FLMUINT uiLockNum, ///< Position in queue (0 = lock holder, 1..n = lock waiter).
|
||||
FLMUINT uiThreadID, ///< Thread ID of the lock holder/waiter.
|
||||
FLMUINT uiTime ///< For the lock holder, this is the amount of time the lock has been
|
||||
///< held.\ For a lock waiter, this is the amount of time the thread
|
||||
///< has been waiting to obtain the lock.\ Both times are milliseconds.
|
||||
) = 0;
|
||||
};
|
||||
|
||||
#define FLM_NO_TIMEOUT 0xFF
|
||||
@@ -4382,6 +4395,17 @@
|
||||
F_COUNT_TIME_STAT HeldLock; ///< Statistics on times when a thread was holding a lock on the database.
|
||||
} F_LOCK_STATS;
|
||||
|
||||
/****************************************************************************
|
||||
/// Structure that gives information on threads that are either waiting to
|
||||
/// obtain a lock or have obtained a lock.
|
||||
****************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
FLMUINT uiThreadId; ///< Thread id of thread that is waiting to obtain a lock or holds a lock.
|
||||
FLMUINT uiTime; ///< For lock holder, this is the time the lock was obtained.
|
||||
///< For the lock waiter, this is the time he started waiting for the lock.
|
||||
} F_LOCK_USER;
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
@@ -4405,6 +4429,7 @@
|
||||
FLMINT iPriority,
|
||||
eLockType * peCurrLockType,
|
||||
FLMUINT * puiThreadId,
|
||||
FLMUINT * puiLockHeldTime = NULL,
|
||||
FLMUINT * puiNumExclQueued = NULL,
|
||||
FLMUINT * puiNumSharedQueued = NULL,
|
||||
FLMUINT * puiPriorityCount = NULL) = 0;
|
||||
@@ -4412,6 +4437,9 @@
|
||||
virtual RCODE FLMAPI getLockInfo(
|
||||
IF_LockInfoClient * pLockInfo) = 0;
|
||||
|
||||
virtual RCODE FLMAPI getLockQueue(
|
||||
F_LOCK_USER ** ppLockUsers) = 0;
|
||||
|
||||
virtual FLMBOOL FLMAPI haveHigherPriorityWaiter(
|
||||
FLMINT iPriority) = 0;
|
||||
|
||||
@@ -4759,6 +4787,8 @@
|
||||
|
||||
void FLMAPI FTXSetRefreshState(
|
||||
FLMBOOL bDisable);
|
||||
|
||||
FLMBOOL FLMAPI FTXRefreshDisabled( void);
|
||||
|
||||
RCODE FLMAPI FTXAddKey(
|
||||
FLMUINT uiKey);
|
||||
|
||||
+42
-88
@@ -96,12 +96,6 @@ public:
|
||||
FLMUINT uiIoFlags,
|
||||
IF_FileHdl ** ppFile);
|
||||
|
||||
RCODE FLMAPI createBlockFile(
|
||||
const char * pszFileName,
|
||||
FLMUINT uiIoFlags,
|
||||
FLMUINT uiBlockSize,
|
||||
IF_FileHdl ** ppFile);
|
||||
|
||||
RCODE FLMAPI createUniqueFile(
|
||||
char * pszPath,
|
||||
const char * pszFileExtension,
|
||||
@@ -117,12 +111,6 @@ public:
|
||||
FLMUINT uiIoFlags,
|
||||
IF_FileHdl ** ppFile);
|
||||
|
||||
RCODE FLMAPI openBlockFile(
|
||||
const char * pszFileName,
|
||||
FLMUINT uiIoFlags,
|
||||
FLMUINT uiBlockSize,
|
||||
IF_FileHdl ** ppFile);
|
||||
|
||||
RCODE FLMAPI openDir(
|
||||
const char * pszDirName,
|
||||
const char * pszPattern,
|
||||
@@ -413,12 +401,30 @@ Desc:
|
||||
RCODE f_allocFileSystem(
|
||||
IF_FileSystem ** ppFileSystem)
|
||||
{
|
||||
if( (*ppFileSystem = f_new F_FileSystem) == NULL)
|
||||
RCODE rc = NE_FLM_OK;
|
||||
F_FileSystem * pFileSystem = NULL;
|
||||
|
||||
if( (pFileSystem = f_new F_FileSystem) == NULL)
|
||||
{
|
||||
return( RC_SET( NE_FLM_MEM));
|
||||
}
|
||||
|
||||
if( RC_BAD( rc = pFileSystem->setup()))
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
*ppFileSystem = pFileSystem;
|
||||
pFileSystem = NULL;
|
||||
|
||||
Exit:
|
||||
|
||||
if( pFileSystem)
|
||||
{
|
||||
pFileSystem->Release();
|
||||
}
|
||||
|
||||
return( NE_FLM_OK);
|
||||
return( rc);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -509,43 +515,6 @@ Exit:
|
||||
return( rc);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: Create a block-oriented file, return a file handle to created file.
|
||||
****************************************************************************/
|
||||
RCODE FLMAPI F_FileSystem::createBlockFile(
|
||||
const char * pszFileName,
|
||||
FLMUINT uiIoFlags,
|
||||
FLMUINT uiBlockSize,
|
||||
IF_FileHdl ** ppFileHdl)
|
||||
{
|
||||
RCODE rc = NE_FLM_OK;
|
||||
F_FileHdl * pFileHdl = NULL;
|
||||
|
||||
if( RC_BAD( rc = f_allocFileHdl( &pFileHdl)))
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
pFileHdl->setBlockSize( uiBlockSize);
|
||||
|
||||
if (RC_BAD( rc = pFileHdl->create( pszFileName, uiIoFlags)))
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
*ppFileHdl = pFileHdl;
|
||||
pFileHdl = NULL;
|
||||
|
||||
Exit:
|
||||
|
||||
if( pFileHdl)
|
||||
{
|
||||
pFileHdl->Release();
|
||||
}
|
||||
|
||||
return( rc);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: Create a unique file, return a file handle to created file.
|
||||
****************************************************************************/
|
||||
@@ -616,43 +585,6 @@ Exit:
|
||||
return( rc);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: Open a block-oriented file, return a file handle to opened file.
|
||||
****************************************************************************/
|
||||
RCODE FLMAPI F_FileSystem::openBlockFile(
|
||||
const char * pszFileName,
|
||||
FLMUINT uiIoFlags,
|
||||
FLMUINT uiBlockSize,
|
||||
IF_FileHdl ** ppFileHdl)
|
||||
{
|
||||
RCODE rc = NE_FLM_OK;
|
||||
F_FileHdl * pFileHdl = NULL;
|
||||
|
||||
if( RC_BAD( rc = f_allocFileHdl( &pFileHdl)))
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
pFileHdl->setBlockSize( uiBlockSize);
|
||||
|
||||
if (RC_BAD( rc = pFileHdl->open( pszFileName, uiIoFlags)))
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
*ppFileHdl = pFileHdl;
|
||||
pFileHdl = NULL;
|
||||
|
||||
Exit:
|
||||
|
||||
if( pFileHdl)
|
||||
{
|
||||
pFileHdl->Release();
|
||||
}
|
||||
|
||||
return( rc);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: Open a directory, return a file handle to opened directory.
|
||||
****************************************************************************/
|
||||
@@ -2482,3 +2414,25 @@ Exit:
|
||||
|
||||
return( rc);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
RCODE FLMAPI f_pathReduce(
|
||||
const char * pszSourcePath,
|
||||
char * pszDestPath,
|
||||
char * pszString)
|
||||
{
|
||||
return( f_getFileSysPtr()->pathReduce(
|
||||
pszSourcePath, pszDestPath, pszString));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
RCODE FLMAPI f_pathAppend(
|
||||
char * pszPath,
|
||||
const char * pszPathComponent)
|
||||
{
|
||||
return( f_getFileSysPtr()->pathAppend( pszPath, pszPathComponent));
|
||||
}
|
||||
|
||||
@@ -753,6 +753,20 @@ void FLMAPI FTXSetRefreshState(
|
||||
f_mutexUnlock( gv_pFtxInfo->hFtxMutex);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc:
|
||||
****************************************************************************/
|
||||
FLMBOOL FLMAPI FTXRefreshDisabled( void)
|
||||
{
|
||||
FLMBOOL bDisabled;
|
||||
|
||||
f_mutexLock( gv_pFtxInfo->hFtxMutex);
|
||||
bDisabled = gv_pFtxInfo->bRefreshDisabled;
|
||||
f_mutexUnlock( gv_pFtxInfo->hFtxMutex);
|
||||
|
||||
return( bDisabled);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: Allows a keyboard handler to add a key to the FTX key buffer
|
||||
****************************************************************************/
|
||||
|
||||
+148
-25
@@ -86,6 +86,7 @@ public:
|
||||
FLMINT iPriority,
|
||||
eLockType * peCurrLockType,
|
||||
FLMUINT * puiThreadId,
|
||||
FLMUINT * puiLockHeldTime,
|
||||
FLMUINT * puiNumExclQueued,
|
||||
FLMUINT * puiNumSharedQueued,
|
||||
FLMUINT * puiPriorityCount);
|
||||
@@ -93,6 +94,9 @@ public:
|
||||
RCODE FLMAPI getLockInfo(
|
||||
IF_LockInfoClient * pLockInfo);
|
||||
|
||||
RCODE FLMAPI getLockQueue(
|
||||
F_LOCK_USER ** ppLockUsers);
|
||||
|
||||
FLMBOOL FLMAPI haveHigherPriorityWaiter(
|
||||
FLMINT iPriority);
|
||||
|
||||
@@ -551,6 +555,8 @@ RCODE FLMAPI F_LockObject::lock(
|
||||
F_LOCK_WAITER LockWait;
|
||||
FLMBOOL bMutexLocked = FALSE;
|
||||
|
||||
f_assert( hWaitSem != F_SEM_NULL);
|
||||
|
||||
f_mutexLock( m_hMutex);
|
||||
bMutexLocked = TRUE;
|
||||
|
||||
@@ -808,58 +814,109 @@ RCODE FLMAPI F_LockObject::getLockInfo(
|
||||
FLMINT iPriority,
|
||||
eLockType * peCurrLockType,
|
||||
FLMUINT * puiThreadId,
|
||||
FLMUINT * puiLockHeldTime,
|
||||
FLMUINT * puiNumExclQueued,
|
||||
FLMUINT * puiNumSharedQueued,
|
||||
FLMUINT * puiPriorityCount)
|
||||
{
|
||||
F_LOCK_WAITER * pLockWaiter;
|
||||
|
||||
*puiNumExclQueued = 0;
|
||||
*puiNumSharedQueued = 0;
|
||||
*puiPriorityCount = 0;
|
||||
if( puiNumExclQueued)
|
||||
{
|
||||
*puiNumExclQueued = 0;
|
||||
}
|
||||
|
||||
if( puiNumSharedQueued)
|
||||
{
|
||||
*puiNumSharedQueued = 0;
|
||||
}
|
||||
|
||||
if( puiPriorityCount)
|
||||
{
|
||||
*puiPriorityCount = 0;
|
||||
}
|
||||
|
||||
if( puiThreadId)
|
||||
{
|
||||
*puiThreadId = 0;
|
||||
}
|
||||
|
||||
if( puiLockHeldTime)
|
||||
{
|
||||
*puiLockHeldTime = 0;
|
||||
}
|
||||
|
||||
f_mutexLock( m_hMutex);
|
||||
|
||||
// Get the type of lock, if any.
|
||||
|
||||
if (m_bExclLock)
|
||||
{
|
||||
*peCurrLockType = FLM_LOCK_EXCLUSIVE;
|
||||
*puiThreadId = m_uiLockThreadId;
|
||||
if( peCurrLockType)
|
||||
{
|
||||
*peCurrLockType = FLM_LOCK_EXCLUSIVE;
|
||||
}
|
||||
|
||||
if( puiThreadId)
|
||||
{
|
||||
*puiThreadId = m_uiLockThreadId;
|
||||
}
|
||||
|
||||
if( puiLockHeldTime)
|
||||
{
|
||||
*puiLockHeldTime = FLM_TIMER_UNITS_TO_MILLI(
|
||||
FLM_ELAPSED_TIME( FLM_GET_TIMER(), m_uiLockTime));
|
||||
}
|
||||
}
|
||||
else if (m_uiSharedLockCnt)
|
||||
{
|
||||
*peCurrLockType = FLM_LOCK_SHARED;
|
||||
*puiThreadId = 0;
|
||||
if( peCurrLockType)
|
||||
{
|
||||
*peCurrLockType = FLM_LOCK_SHARED;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*peCurrLockType = FLM_LOCK_NONE;
|
||||
*puiThreadId = 0;
|
||||
if( peCurrLockType)
|
||||
{
|
||||
*peCurrLockType = FLM_LOCK_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
// Get information on pending lock requests.
|
||||
|
||||
pLockWaiter = m_pFirstInList;
|
||||
for( ; pLockWaiter; pLockWaiter = pLockWaiter->pNextInList)
|
||||
if( puiNumExclQueued || puiNumSharedQueued || puiPriorityCount)
|
||||
{
|
||||
|
||||
// Count the number of exclusive and shared waiters.
|
||||
|
||||
if (pLockWaiter->bExclReq)
|
||||
pLockWaiter = m_pFirstInList;
|
||||
for( ; pLockWaiter; pLockWaiter = pLockWaiter->pNextInList)
|
||||
{
|
||||
(*puiNumExclQueued)++;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*puiNumSharedQueued)++;
|
||||
}
|
||||
|
||||
// Count the number of waiters at or above input priority.
|
||||
// Count the number of exclusive and shared waiters.
|
||||
|
||||
if (pLockWaiter->iPriority >= iPriority)
|
||||
{
|
||||
(*puiPriorityCount)++;
|
||||
if (pLockWaiter->bExclReq)
|
||||
{
|
||||
if( puiNumExclQueued)
|
||||
{
|
||||
(*puiNumExclQueued)++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( puiNumSharedQueued)
|
||||
{
|
||||
(*puiNumSharedQueued)++;
|
||||
}
|
||||
}
|
||||
|
||||
// Count the number of waiters at or above input priority.
|
||||
|
||||
if (pLockWaiter->iPriority >= iPriority)
|
||||
{
|
||||
if( puiPriorityCount)
|
||||
{
|
||||
(*puiPriorityCount)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -933,6 +990,72 @@ Exit:
|
||||
return( rc);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: Return a list that includes the current lock holder as well as
|
||||
the lock waiters.
|
||||
****************************************************************************/
|
||||
RCODE FLMAPI F_LockObject::getLockQueue(
|
||||
F_LOCK_USER ** ppLockUsers)
|
||||
{
|
||||
RCODE rc = NE_FLM_OK;
|
||||
F_LOCK_USER * pLockUser;
|
||||
F_LOCK_WAITER * pLockWaiter;
|
||||
FLMUINT uiCnt;
|
||||
FLMUINT uiElapTime;
|
||||
FLMUINT uiCurrTime;
|
||||
|
||||
f_mutexLock( m_hMutex);
|
||||
uiCurrTime = (FLMUINT)FLM_GET_TIMER();
|
||||
|
||||
if( !m_uiNumWaiters && !m_uiLockThreadId)
|
||||
{
|
||||
*ppLockUsers = NULL;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
uiCnt = m_uiNumWaiters + 1;
|
||||
|
||||
if( RC_BAD( rc = f_alloc(
|
||||
sizeof( F_LOCK_USER) * (uiCnt + 1), &pLockUser)))
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
*ppLockUsers = pLockUser;
|
||||
|
||||
// Output the lock holder first.
|
||||
|
||||
pLockUser->uiThreadId = m_uiLockThreadId;
|
||||
uiElapTime = FLM_ELAPSED_TIME( uiCurrTime, m_uiLockTime);
|
||||
pLockUser->uiTime = FLM_TIMER_UNITS_TO_MILLI( uiElapTime);
|
||||
pLockUser++;
|
||||
uiCnt--;
|
||||
|
||||
// Output the lock waiters.
|
||||
|
||||
pLockWaiter = m_pFirstInList;
|
||||
while( pLockWaiter && uiCnt)
|
||||
{
|
||||
pLockUser->uiThreadId = pLockWaiter->uiThreadId;
|
||||
uiElapTime = FLM_ELAPSED_TIME( uiCurrTime,
|
||||
pLockWaiter->uiWaitStartTime);
|
||||
pLockUser->uiTime = FLM_TIMER_UNITS_TO_MILLI( uiElapTime);
|
||||
pLockWaiter = pLockWaiter->pNextInList;
|
||||
pLockUser++;
|
||||
uiCnt--;
|
||||
}
|
||||
flmAssert( pLockWaiter == NULL && uiCnt == 0);
|
||||
|
||||
// Zero out the last one.
|
||||
|
||||
f_memset( pLockUser, 0, sizeof( F_LOCK_USER));
|
||||
|
||||
Exit:
|
||||
|
||||
f_mutexUnlock( m_hMutex);
|
||||
return( rc);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Desc: Returns TRUE if there are lock waiters with a priority > iPriority
|
||||
****************************************************************************/
|
||||
|
||||
+86
-60
@@ -318,10 +318,11 @@ public:
|
||||
virtual ~F_FixedAlloc();
|
||||
|
||||
RCODE FLMAPI setup(
|
||||
IF_Relocator * pRelocator,
|
||||
IF_SlabManager * pSlabManager,
|
||||
IF_Relocator * pDefaultRelocator,
|
||||
FLMUINT uiCellSize,
|
||||
FLM_SLAB_USAGE * pUsageStats);
|
||||
FLM_SLAB_USAGE * pUsageStats,
|
||||
FLMUINT * puiTotalBytesAllocated);
|
||||
|
||||
FINLINE void * FLMAPI allocCell(
|
||||
IF_Relocator * pRelocator,
|
||||
@@ -331,7 +332,7 @@ public:
|
||||
{
|
||||
void * pvCell;
|
||||
|
||||
f_assert( pRelocator);
|
||||
f_assert( pRelocator || m_pDefaultRelocator);
|
||||
|
||||
if( !bMutexLocked)
|
||||
{
|
||||
@@ -478,7 +479,7 @@ private:
|
||||
SLAB * m_pLastSlab;
|
||||
SLAB * m_pFirstSlabWithAvailCells;
|
||||
SLAB * m_pLastSlabWithAvailCells;
|
||||
IF_Relocator * m_pRelocator;
|
||||
IF_Relocator * m_pDefaultRelocator;
|
||||
FLMBOOL m_bAvailListSorted;
|
||||
FLMUINT m_uiSlabsWithAvailCells;
|
||||
FLMUINT m_uiSlabHeaderSize;
|
||||
@@ -489,6 +490,7 @@ private:
|
||||
FLMUINT m_uiCellsPerSlab;
|
||||
FLMUINT m_uiSlabSize;
|
||||
FLM_SLAB_USAGE * m_pUsageStats;
|
||||
FLMUINT * m_puiTotalBytesAllocated;
|
||||
|
||||
friend class F_BufferAlloc;
|
||||
friend class F_MultiAlloc;
|
||||
@@ -505,15 +507,15 @@ public:
|
||||
{
|
||||
f_memset( m_ppAllocators, 0, sizeof( m_ppAllocators));
|
||||
m_pSlabManager = NULL;
|
||||
m_pDefaultRelocator = NULL;
|
||||
}
|
||||
|
||||
virtual ~F_BufferAlloc();
|
||||
|
||||
RCODE FLMAPI setup(
|
||||
IF_SlabManager * pSlabManager,
|
||||
IF_Relocator * pDefaultRelocator,
|
||||
FLM_SLAB_USAGE * pUsageStats,
|
||||
IF_Relocator * pDefaultRelocator);
|
||||
FLMUINT * puiTotalBytesAllocated);
|
||||
|
||||
RCODE FLMAPI allocBuf(
|
||||
IF_Relocator * pRelocator,
|
||||
@@ -554,7 +556,6 @@ private:
|
||||
|
||||
IF_SlabManager * m_pSlabManager;
|
||||
IF_FixedAlloc * m_ppAllocators[ NUM_BUF_ALLOCATORS];
|
||||
IF_Relocator * m_pDefaultRelocator;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -578,20 +579,22 @@ public:
|
||||
|
||||
RCODE FLMAPI setup(
|
||||
IF_SlabManager * pSlabManager,
|
||||
IF_Relocator * pDefaultRelocator,
|
||||
FLMUINT * puiCellSizes,
|
||||
FLM_SLAB_USAGE * pUsageStats);
|
||||
FLM_SLAB_USAGE * pUsageStats,
|
||||
FLMUINT * puiTotalBytesAllocated);
|
||||
|
||||
RCODE FLMAPI allocBuf(
|
||||
IF_Relocator * pRelocator,
|
||||
FLMUINT uiSize,
|
||||
FLMBYTE ** ppucBuffer,
|
||||
FLMBOOL bMutexLocked = FALSE);
|
||||
FLMBOOL bMutexLocked);
|
||||
|
||||
RCODE FLMAPI reallocBuf(
|
||||
IF_Relocator * pRelocator,
|
||||
FLMUINT uiNewSize,
|
||||
FLMBYTE ** ppucBuffer,
|
||||
FLMBOOL bMutexLocked = FALSE);
|
||||
FLMBOOL bMutexLocked);
|
||||
|
||||
FINLINE void FLMAPI freeBuf(
|
||||
FLMBYTE ** ppucBuffer)
|
||||
@@ -2791,7 +2794,7 @@ F_FixedAlloc::F_FixedAlloc()
|
||||
m_pSlabManager = NULL;
|
||||
m_pFirstSlab = NULL;
|
||||
m_pLastSlab = NULL;
|
||||
m_pRelocator = NULL;
|
||||
m_pDefaultRelocator = NULL;
|
||||
m_pFirstSlabWithAvailCells = NULL;
|
||||
m_pLastSlabWithAvailCells = NULL;
|
||||
m_uiSlabsWithAvailCells = 0;
|
||||
@@ -2799,6 +2802,7 @@ F_FixedAlloc::F_FixedAlloc()
|
||||
m_uiTotalFreeCells = 0;
|
||||
m_uiSlabSize = 0;
|
||||
m_pUsageStats = NULL;
|
||||
m_puiTotalBytesAllocated = NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -2818,9 +2822,9 @@ F_FixedAlloc::~F_FixedAlloc()
|
||||
m_pSlabManager->Release();
|
||||
}
|
||||
|
||||
if( m_pRelocator)
|
||||
if( m_pDefaultRelocator)
|
||||
{
|
||||
m_pRelocator->Release();
|
||||
m_pDefaultRelocator->Release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2828,10 +2832,11 @@ F_FixedAlloc::~F_FixedAlloc()
|
||||
Desc: Setup method for any setup that can fail
|
||||
****************************************************************************/
|
||||
RCODE F_FixedAlloc::setup(
|
||||
IF_Relocator * pRelocator,
|
||||
IF_SlabManager * pSlabManager,
|
||||
IF_Relocator * pDefaultRelocator,
|
||||
FLMUINT uiCellSize,
|
||||
FLM_SLAB_USAGE * pUsageStats)
|
||||
FLM_SLAB_USAGE * pUsageStats,
|
||||
FLMUINT * puiTotalBytesAllocated)
|
||||
{
|
||||
RCODE rc = NE_FLM_OK;
|
||||
|
||||
@@ -2840,14 +2845,15 @@ RCODE F_FixedAlloc::setup(
|
||||
f_assert( pUsageStats != NULL);
|
||||
|
||||
m_pUsageStats = pUsageStats;
|
||||
m_puiTotalBytesAllocated = puiTotalBytesAllocated;
|
||||
|
||||
m_pSlabManager = pSlabManager;
|
||||
m_pSlabManager->AddRef();
|
||||
|
||||
if( pRelocator)
|
||||
if( pDefaultRelocator)
|
||||
{
|
||||
m_pRelocator = pRelocator;
|
||||
m_pRelocator->AddRef();
|
||||
m_pDefaultRelocator = pDefaultRelocator;
|
||||
m_pDefaultRelocator->AddRef();
|
||||
}
|
||||
|
||||
m_uiCellSize = uiCellSize;
|
||||
@@ -2856,7 +2862,7 @@ RCODE F_FixedAlloc::setup(
|
||||
// Get the alloc-aligned versions of all the sizes
|
||||
|
||||
m_uiSlabHeaderSize = getAllocAlignedSize( sizeof( SLAB));
|
||||
if (pRelocator)
|
||||
if (pDefaultRelocator)
|
||||
{
|
||||
m_uiCellHeaderSize = getAllocAlignedSize( sizeof( CELLHEADER));
|
||||
}
|
||||
@@ -3009,13 +3015,16 @@ void * F_FixedAlloc::getCell(
|
||||
pHeader->puiStack = NULL;
|
||||
}
|
||||
#endif
|
||||
if (!m_pRelocator)
|
||||
if (!m_pDefaultRelocator)
|
||||
{
|
||||
((CELLHEADER2 *)pHeader)->pRelocator = pRelocator;
|
||||
}
|
||||
|
||||
m_pUsageStats->ui64AllocatedCells++;
|
||||
|
||||
if( m_pUsageStats)
|
||||
{
|
||||
m_pUsageStats->ui64AllocatedCells++;
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
||||
return( pCell);
|
||||
@@ -3174,8 +3183,11 @@ void F_FixedAlloc::freeCell(
|
||||
m_pFirstSlabWithAvailCells = pSlab;
|
||||
}
|
||||
}
|
||||
|
||||
m_pUsageStats->ui64AllocatedCells--;
|
||||
|
||||
if( m_pUsageStats)
|
||||
{
|
||||
m_pUsageStats->ui64AllocatedCells--;
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
||||
@@ -3203,7 +3215,16 @@ F_FixedAlloc::SLAB * F_FixedAlloc::getAnotherSlab( void)
|
||||
|
||||
f_memset( pSlab, 0, sizeof( SLAB));
|
||||
pSlab->pvAllocator = (void *)this;
|
||||
m_pUsageStats->ui64Slabs++;
|
||||
|
||||
if( m_pUsageStats)
|
||||
{
|
||||
m_pUsageStats->ui64Slabs++;
|
||||
}
|
||||
|
||||
if( m_puiTotalBytesAllocated)
|
||||
{
|
||||
(*m_puiTotalBytesAllocated) += m_pSlabManager->getSlabSize();
|
||||
}
|
||||
|
||||
Exit:
|
||||
|
||||
@@ -3291,8 +3312,20 @@ void F_FixedAlloc::freeSlab(
|
||||
m_uiSlabsWithAvailCells--;
|
||||
f_assert( m_uiTotalFreeCells >= pSlab->ui16AvailCellCount);
|
||||
m_uiTotalFreeCells -= pSlab->ui16AvailCellCount;
|
||||
m_pUsageStats->ui64Slabs--;
|
||||
m_pSlabManager->freeSlab( (void **)&pSlab, TRUE);
|
||||
|
||||
if( m_pUsageStats)
|
||||
{
|
||||
f_assert( m_pUsageStats->ui64Slabs);
|
||||
m_pUsageStats->ui64Slabs--;
|
||||
}
|
||||
|
||||
if( m_puiTotalBytesAllocated)
|
||||
{
|
||||
f_assert( (*m_puiTotalBytesAllocated) >= m_pSlabManager->getSlabSize());
|
||||
(*m_puiTotalBytesAllocated) -= m_pSlabManager->getSlabSize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -3320,7 +3353,16 @@ void F_FixedAlloc::freeAll( void)
|
||||
m_uiSlabsWithAvailCells = 0;
|
||||
m_bAvailListSorted = TRUE;
|
||||
m_uiTotalFreeCells = 0;
|
||||
f_memset( m_pUsageStats, 0, sizeof( FLM_SLAB_USAGE));
|
||||
|
||||
if( m_pUsageStats)
|
||||
{
|
||||
f_memset( m_pUsageStats, 0, sizeof( FLM_SLAB_USAGE));
|
||||
}
|
||||
|
||||
if( m_puiTotalBytesAllocated)
|
||||
{
|
||||
m_puiTotalBytesAllocated = 0;
|
||||
}
|
||||
|
||||
m_pSlabManager->unlockMutex();
|
||||
}
|
||||
@@ -3464,7 +3506,7 @@ void F_FixedAlloc::defragmentMemory( void)
|
||||
pCellHeader = (CELLHEADER *)
|
||||
((FLMBYTE *)pCurSlab + m_uiSlabHeaderSize +
|
||||
(uiLoop * m_uiSizeOfCellAndHeader));
|
||||
if ((pRelocator = m_pRelocator) == NULL)
|
||||
if ((pRelocator = m_pDefaultRelocator) == NULL)
|
||||
{
|
||||
pRelocator = ((CELLHEADER2 *)pCellHeader)->pRelocator;
|
||||
}
|
||||
@@ -3592,11 +3634,6 @@ F_BufferAlloc::~F_BufferAlloc()
|
||||
}
|
||||
}
|
||||
|
||||
if( m_pDefaultRelocator)
|
||||
{
|
||||
m_pDefaultRelocator->Release();
|
||||
}
|
||||
|
||||
if( m_pSlabManager)
|
||||
{
|
||||
m_pSlabManager->Release();
|
||||
@@ -3608,24 +3645,19 @@ Desc:
|
||||
****************************************************************************/
|
||||
RCODE F_BufferAlloc::setup(
|
||||
IF_SlabManager * pSlabManager,
|
||||
IF_Relocator * pDefaultRelocator,
|
||||
FLM_SLAB_USAGE * pUsageStats,
|
||||
IF_Relocator * pDefaultRelocator)
|
||||
FLMUINT * puiTotalBytesAllocated)
|
||||
{
|
||||
RCODE rc = NE_FLM_OK;
|
||||
FLMUINT uiLoop;
|
||||
FLMUINT uiSize;
|
||||
|
||||
f_assert( pSlabManager);
|
||||
f_assert( !m_pDefaultRelocator);
|
||||
|
||||
m_pSlabManager = pSlabManager;
|
||||
m_pSlabManager->AddRef();
|
||||
|
||||
if( (m_pDefaultRelocator = pDefaultRelocator) != NULL)
|
||||
{
|
||||
m_pDefaultRelocator->AddRef();
|
||||
}
|
||||
|
||||
for( uiLoop = 0; uiLoop < NUM_BUF_ALLOCATORS; uiLoop++)
|
||||
{
|
||||
if( (m_ppAllocators[ uiLoop] = f_new F_FixedAlloc) == NULL)
|
||||
@@ -3708,8 +3740,8 @@ RCODE F_BufferAlloc::setup(
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if (RC_BAD( rc = m_ppAllocators[ uiLoop]->setup( NULL,
|
||||
pSlabManager, uiSize, pUsageStats)))
|
||||
if (RC_BAD( rc = m_ppAllocators[ uiLoop]->setup( pSlabManager,
|
||||
pDefaultRelocator, uiSize, pUsageStats, puiTotalBytesAllocated)))
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
@@ -3739,11 +3771,6 @@ RCODE F_BufferAlloc::allocBuf(
|
||||
*pbAllocatedOnHeap = FALSE;
|
||||
}
|
||||
|
||||
if( !pRelocator)
|
||||
{
|
||||
pRelocator = m_pDefaultRelocator;
|
||||
}
|
||||
|
||||
if( pAllocator)
|
||||
{
|
||||
f_assert( pAllocator->getCellSize() >= uiSize);
|
||||
@@ -3801,11 +3828,6 @@ RCODE F_BufferAlloc::reallocBuf(
|
||||
|
||||
f_assert( uiNewSize);
|
||||
|
||||
if( !pRelocator)
|
||||
{
|
||||
pRelocator = m_pDefaultRelocator;
|
||||
}
|
||||
|
||||
if( !uiOldSize)
|
||||
{
|
||||
rc = allocBuf( pRelocator, uiNewSize, pvInitialData, uiDataSize,
|
||||
@@ -3852,7 +3874,7 @@ RCODE F_BufferAlloc::reallocBuf(
|
||||
}
|
||||
|
||||
m_pSlabManager->incrementTotalBytesAllocated(
|
||||
f_msize( pucTmp), FALSE);
|
||||
f_msize( pucTmp), bLockedMutex);
|
||||
|
||||
if( pbAllocatedOnHeap)
|
||||
{
|
||||
@@ -3876,7 +3898,7 @@ RCODE F_BufferAlloc::reallocBuf(
|
||||
}
|
||||
|
||||
m_pSlabManager->decrementTotalBytesAllocated(
|
||||
f_msize( *ppucBuffer), TRUE);
|
||||
f_msize( *ppucBuffer), bLockedMutex);
|
||||
f_free( ppucBuffer);
|
||||
*ppucBuffer = pucTmp;
|
||||
}
|
||||
@@ -3893,9 +3915,10 @@ RCODE F_BufferAlloc::reallocBuf(
|
||||
}
|
||||
|
||||
m_pSlabManager->decrementTotalBytesAllocated(
|
||||
uiOldAllocSize, TRUE);
|
||||
uiOldAllocSize, bLockedMutex);
|
||||
|
||||
m_pSlabManager->incrementTotalBytesAllocated(
|
||||
f_msize( *ppucBuffer), TRUE);
|
||||
f_msize( *ppucBuffer), bLockedMutex);
|
||||
|
||||
if( pbAllocatedOnHeap)
|
||||
{
|
||||
@@ -4102,8 +4125,10 @@ Desc:
|
||||
****************************************************************************/
|
||||
RCODE F_MultiAlloc::setup(
|
||||
IF_SlabManager * pSlabManager,
|
||||
IF_Relocator * pDefaultRelocator,
|
||||
FLMUINT * puiCellSizes,
|
||||
FLM_SLAB_USAGE * pUsageStats)
|
||||
FLM_SLAB_USAGE * pUsageStats,
|
||||
FLMUINT * puiTotalBytesAllocated)
|
||||
{
|
||||
RCODE rc = NE_FLM_OK;
|
||||
FLMUINT uiLoop;
|
||||
@@ -4159,8 +4184,9 @@ RCODE F_MultiAlloc::setup(
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if( RC_BAD( rc = m_ppAllocators[ uiLoop]->setup( NULL,
|
||||
pSlabManager, m_puiCellSizes[ uiLoop], pUsageStats)))
|
||||
if( RC_BAD( rc = m_ppAllocators[ uiLoop]->setup( pSlabManager,
|
||||
pDefaultRelocator, m_puiCellSizes[ uiLoop],
|
||||
pUsageStats, puiTotalBytesAllocated)))
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
@@ -4270,7 +4296,7 @@ RCODE F_MultiAlloc::reallocBuf(
|
||||
|
||||
if( !(*ppucBuffer))
|
||||
{
|
||||
rc = allocBuf( pRelocator, uiNewSize, ppucBuffer);
|
||||
rc = allocBuf( pRelocator, uiNewSize, ppucBuffer, FALSE);
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
|
||||
+18
-9
@@ -562,22 +562,29 @@ Desc:
|
||||
****************************************************************************/
|
||||
#ifdef FLM_WIN
|
||||
void FLMAPI f_mutexLock(
|
||||
F_MUTEX hMutex)
|
||||
F_MUTEX hMutex)
|
||||
{
|
||||
F_INTERLOCK * pInterlock = (F_INTERLOCK *)hMutex;
|
||||
|
||||
#ifdef FLM_DEBUG
|
||||
if( pInterlock->locked)
|
||||
{
|
||||
f_assert( pInterlock->uiThreadId != _threadid);
|
||||
}
|
||||
#endif
|
||||
|
||||
while( f_atomicExchange( &pInterlock->locked, 1) != 0)
|
||||
{
|
||||
#ifdef FLM_DEBUG
|
||||
f_atomicInc( &(((F_INTERLOCK *)hMutex)->waitCount));
|
||||
f_atomicInc( &pInterlock->waitCount);
|
||||
#endif
|
||||
Sleep( 0);
|
||||
}
|
||||
|
||||
#ifdef FLM_DEBUG
|
||||
f_assert( ((F_INTERLOCK *)hMutex)->uiThreadId == 0);
|
||||
((F_INTERLOCK *)hMutex)->uiThreadId = _threadid;
|
||||
f_atomicInc( &(((F_INTERLOCK *)hMutex)->lockedCount));
|
||||
f_assert( pInterlock->uiThreadId == 0);
|
||||
pInterlock->uiThreadId = _threadid;
|
||||
f_atomicInc( &pInterlock->lockedCount);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -589,12 +596,14 @@ Desc:
|
||||
void FLMAPI f_mutexUnlock(
|
||||
F_MUTEX hMutex)
|
||||
{
|
||||
f_assert( ((F_INTERLOCK *)hMutex)->locked == 1);
|
||||
F_INTERLOCK * pInterlock = (F_INTERLOCK *)hMutex;
|
||||
|
||||
f_assert( pInterlock->locked == 1);
|
||||
#ifdef FLM_DEBUG
|
||||
f_assert( ((F_INTERLOCK *)hMutex)->uiThreadId == _threadid);
|
||||
((F_INTERLOCK *)hMutex)->uiThreadId = 0;
|
||||
f_assert( pInterlock->uiThreadId == _threadid);
|
||||
pInterlock->uiThreadId = 0;
|
||||
#endif
|
||||
f_atomicExchange( &(((F_INTERLOCK *)hMutex)->locked), 0);
|
||||
f_atomicExchange( &pInterlock->locked, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -589,17 +589,6 @@
|
||||
|
||||
RCODE FLMAPI unlock( void);
|
||||
|
||||
FINLINE void FLMAPI setBlockSize(
|
||||
FLMUINT uiBlockSize)
|
||||
{
|
||||
m_uiBlockSize = uiBlockSize;
|
||||
}
|
||||
|
||||
FINLINE FLMUINT FLMAPI getBlockSize( void)
|
||||
{
|
||||
return( m_uiBlockSize);
|
||||
}
|
||||
|
||||
FINLINE FLMUINT FLMAPI getSectorSize( void)
|
||||
{
|
||||
return( m_uiBytesPerSector);
|
||||
@@ -678,7 +667,6 @@
|
||||
FLMBOOL m_bOpenedExclusive;
|
||||
char * m_pszFileName;
|
||||
HANDLE m_FileHandle;
|
||||
FLMUINT m_uiBlockSize;
|
||||
FLMUINT m_uiBytesPerSector;
|
||||
FLMUINT64 m_ui64NotOnSectorBoundMask;
|
||||
FLMUINT64 m_ui64GetSectorBoundMask;
|
||||
@@ -793,17 +781,6 @@
|
||||
return( m_bOpenedReadOnly);
|
||||
}
|
||||
|
||||
FINLINE void FLMAPI setBlockSize(
|
||||
FLMUINT uiBlockSize)
|
||||
{
|
||||
m_uiBlockSize = uiBlockSize;
|
||||
}
|
||||
|
||||
FINLINE FLMUINT FLMAPI getBlockSize( void)
|
||||
{
|
||||
return( m_uiBlockSize);
|
||||
}
|
||||
|
||||
FINLINE FLMUINT FLMAPI getSectorSize( void)
|
||||
{
|
||||
return( m_uiBytesPerSector);
|
||||
@@ -867,7 +844,6 @@
|
||||
FLMBOOL m_bOpenedExclusive;
|
||||
char * m_pszFileName;
|
||||
int m_fd;
|
||||
FLMUINT m_uiBlockSize;
|
||||
FLMUINT m_uiBytesPerSector;
|
||||
FLMUINT64 m_ui64NotOnSectorBoundMask;
|
||||
FLMUINT64 m_ui64GetSectorBoundMask;
|
||||
@@ -965,11 +941,6 @@
|
||||
return( FLM_NLM_SECTOR_SIZE);
|
||||
}
|
||||
|
||||
FINLINE FLMUINT FLMAPI getBlockSize( void)
|
||||
{
|
||||
return( m_uiBlockSize);
|
||||
}
|
||||
|
||||
FINLINE FLMBOOL FLMAPI isReadOnly( void)
|
||||
{
|
||||
return( m_bOpenedReadOnly);
|
||||
@@ -979,12 +950,6 @@
|
||||
|
||||
RCODE FLMAPI unlock( void);
|
||||
|
||||
FINLINE void FLMAPI setBlockSize(
|
||||
FLMUINT uiBlockSize)
|
||||
{
|
||||
m_uiBlockSize = uiBlockSize;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
RCODE setup( void);
|
||||
@@ -1062,7 +1027,6 @@
|
||||
FLMBOOL m_bFileOpened;
|
||||
FLMBOOL m_bOpenedExclusive;
|
||||
FLMBOOL m_bOpenedReadOnly;
|
||||
FLMUINT m_uiBlockSize;
|
||||
|
||||
LONG m_lFileHandle;
|
||||
LONG m_lOpenAttr;
|
||||
|
||||
+11
-7
@@ -150,6 +150,7 @@ public:
|
||||
m_pszThreadName = NULL;
|
||||
m_pszThreadStatus = NULL;
|
||||
m_uiStatusBufLen = 0;
|
||||
m_uiThreadGroup = F_INVALID_THREAD_GROUP;
|
||||
m_pPrev = NULL;
|
||||
m_pNext = NULL;
|
||||
cleanupThread();
|
||||
@@ -167,12 +168,12 @@ public:
|
||||
|
||||
RCODE FLMAPI startThread(
|
||||
F_THREAD_FUNC fnThread,
|
||||
const char * pszThreadName = NULL,
|
||||
FLMUINT uiThreadGroup = 0,
|
||||
FLMUINT uiAppId = 0,
|
||||
void * pvParm1 = NULL,
|
||||
void * pvParm2 = NULL,
|
||||
FLMUINT uiStackSize = F_THREAD_DEFAULT_STACK_SIZE);
|
||||
const char * pszThreadName,
|
||||
FLMUINT uiThreadGroup,
|
||||
FLMUINT uiAppId,
|
||||
void * pvParm1,
|
||||
void * pvParm2,
|
||||
FLMUINT uiStackSize);
|
||||
|
||||
void FLMAPI stopThread( void);
|
||||
|
||||
@@ -436,6 +437,7 @@ RCODE FLMAPI F_Thread::startThread(
|
||||
#endif
|
||||
|
||||
f_assert( fnThread != NULL && m_fnThread == NULL);
|
||||
f_assert( uiThreadGroup != F_INVALID_THREAD_GROUP);
|
||||
|
||||
m_fnThread = fnThread;
|
||||
m_pvParm1 = pvParm1;
|
||||
@@ -758,7 +760,7 @@ void FLMAPI F_Thread::cleanupThread( void)
|
||||
m_pvParm1 = NULL;
|
||||
m_pvParm2 = NULL;
|
||||
m_uiThreadId = 0;
|
||||
m_uiThreadGroup = 0;
|
||||
m_uiThreadGroup = F_INVALID_THREAD_GROUP;
|
||||
m_uiAppId = 0;
|
||||
m_uiStartTime = 0;
|
||||
m_exitRc = NE_FLM_OK;
|
||||
@@ -980,6 +982,8 @@ void FLMAPI F_ThreadMgr::shutdownThreadGroup(
|
||||
{
|
||||
F_Thread * pThread;
|
||||
FLMUINT uiCount;
|
||||
|
||||
f_assert( uiThreadGroup != F_INVALID_THREAD_GROUP);
|
||||
|
||||
for( ;;)
|
||||
{
|
||||
|
||||
+29
-57
@@ -176,59 +176,46 @@ RCODE F_FileHdl::openOrCreate(
|
||||
|
||||
if( bDoDirectIO)
|
||||
{
|
||||
if( !m_uiBlockSize)
|
||||
if( RC_BAD( rc = pFileSystem->getSectorSize(
|
||||
pszFileName, &m_uiBytesPerSector)))
|
||||
{
|
||||
bDoDirectIO = FALSE;
|
||||
goto Exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( RC_BAD( rc = pFileSystem->getSectorSize(
|
||||
pszFileName, &m_uiBytesPerSector)))
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
m_ui64NotOnSectorBoundMask = m_uiBytesPerSector - 1;
|
||||
m_ui64GetSectorBoundMask = ~m_ui64NotOnSectorBoundMask;
|
||||
|
||||
m_ui64NotOnSectorBoundMask = m_uiBytesPerSector - 1;
|
||||
m_ui64GetSectorBoundMask = ~m_ui64NotOnSectorBoundMask;
|
||||
|
||||
// Can't do direct IO if the block size isn't a multiple of
|
||||
// the sector size.
|
||||
// Can't do direct IO if the block size isn't a multiple of
|
||||
// the sector size.
|
||||
|
||||
if( m_uiBlockSize < m_uiBytesPerSector ||
|
||||
m_uiBlockSize % m_uiBytesPerSector != 0)
|
||||
{
|
||||
bDoDirectIO = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( FLM_LINUX)
|
||||
FLMUINT uiMajor;
|
||||
FLMUINT uiMinor;
|
||||
FLMUINT uiRevision;
|
||||
{
|
||||
FLMUINT uiMajor;
|
||||
FLMUINT uiMinor;
|
||||
FLMUINT uiRevision;
|
||||
|
||||
f_getLinuxKernelVersion( &uiMajor, &uiMinor, &uiRevision);
|
||||
f_getLinuxKernelVersion( &uiMajor, &uiMinor, &uiRevision);
|
||||
|
||||
if( uiMajor > 2 || (uiMajor == 2 && uiMinor > 6) ||
|
||||
(uiMajor == 2 && uiMinor == 6 && uiRevision >= 5))
|
||||
{
|
||||
openFlags |= O_DIRECT;
|
||||
if( pFileSystem->canDoAsync())
|
||||
{
|
||||
m_bCanDoAsync = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bDoDirectIO = FALSE;
|
||||
}
|
||||
#elif defined( FLM_SOLARIS)
|
||||
if( uiMajor > 2 || (uiMajor == 2 && uiMinor > 6) ||
|
||||
(uiMajor == 2 && uiMinor == 6 && uiRevision >= 5))
|
||||
{
|
||||
openFlags |= O_DIRECT;
|
||||
if( pFileSystem->canDoAsync())
|
||||
{
|
||||
m_bCanDoAsync = TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
bDoDirectIO = FALSE;
|
||||
}
|
||||
}
|
||||
#elif defined( FLM_SOLARIS)
|
||||
if( pFileSystem->canDoAsync())
|
||||
{
|
||||
m_bCanDoAsync = TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Retry_Create:
|
||||
@@ -488,24 +475,9 @@ RCODE F_FileHdl::open(
|
||||
}
|
||||
}
|
||||
|
||||
// Loop on error open conditions.
|
||||
|
||||
for( ;;)
|
||||
if( RC_BAD( rc = openOrCreate( pszFileName, uiIoFlags, FALSE)))
|
||||
{
|
||||
if( RC_OK( rc = openOrCreate( pszFileName, uiIoFlags, FALSE)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if( rc != NE_FLM_IO_TOO_MANY_OPEN_FILES)
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
// If for some reason we cannot open the file, then
|
||||
// try to close some other file handle in the list.
|
||||
|
||||
// gv_XFlmSysData.pFileHdlMgr->releaseOneAvail( FALSE);
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
m_bFileOpened = TRUE;
|
||||
|
||||
+8
-35
@@ -37,7 +37,6 @@ F_FileHdl::F_FileHdl()
|
||||
m_bOpenedReadOnly = FALSE;
|
||||
m_pszFileName = NULL;
|
||||
m_FileHandle = INVALID_HANDLE_VALUE;
|
||||
m_uiBlockSize = 0;
|
||||
m_uiBytesPerSector = 0;
|
||||
m_ui64NotOnSectorBoundMask = 0;
|
||||
m_ui64GetSectorBoundMask = 0;
|
||||
@@ -109,30 +108,14 @@ RCODE F_FileHdl::openOrCreate(
|
||||
|
||||
if (m_bDoDirectIO)
|
||||
{
|
||||
if (!m_uiBlockSize)
|
||||
if (RC_BAD( rc = pFileSystem->getSectorSize(
|
||||
pszFileName, &m_uiBytesPerSector)))
|
||||
{
|
||||
m_bDoDirectIO = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RC_BAD( rc = pFileSystem->getSectorSize(
|
||||
pszFileName, &m_uiBytesPerSector)))
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
m_ui64NotOnSectorBoundMask = m_uiBytesPerSector - 1;
|
||||
m_ui64GetSectorBoundMask = ~m_ui64NotOnSectorBoundMask;
|
||||
|
||||
// Can't do direct IO if the block size isn't a multiple of
|
||||
// the sector size.
|
||||
|
||||
if (m_uiBlockSize < m_uiBytesPerSector ||
|
||||
m_uiBlockSize % m_uiBytesPerSector != 0)
|
||||
{
|
||||
m_bDoDirectIO = FALSE;
|
||||
}
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
m_ui64NotOnSectorBoundMask = m_uiBytesPerSector - 1;
|
||||
m_ui64GetSectorBoundMask = ~m_ui64NotOnSectorBoundMask;
|
||||
}
|
||||
|
||||
// Only enable asynchronous writes if direct I/O is enabled.
|
||||
@@ -440,19 +423,9 @@ RCODE F_FileHdl::open(
|
||||
m_bDeleteOnRelease = FALSE;
|
||||
}
|
||||
|
||||
// Loop on error open conditions.
|
||||
|
||||
for(;;)
|
||||
if( RC_BAD( rc = openOrCreate( pszFileName, uiIoFlags, FALSE)))
|
||||
{
|
||||
if( RC_OK( rc = openOrCreate( pszFileName, uiIoFlags, FALSE)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if( rc != NE_FLM_IO_TOO_MANY_OPEN_FILES )
|
||||
{
|
||||
goto Exit;
|
||||
}
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
m_bFileOpened = TRUE;
|
||||
|
||||
Reference in New Issue
Block a user