Modified to use lock manager in toolkit.

git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@490 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
dsandersoremutah
2006-05-31 15:23:25 +00:00
parent f23dd3c2a9
commit 78bd30e364
21 changed files with 115 additions and 1912 deletions

View File

@@ -497,37 +497,6 @@ void F_Database::logMustCloseReason(
}
}
/****************************************************************************
Desc: Acquires a write lock on the database
****************************************************************************/
RCODE F_Database::dbWriteLock(
F_SEM hWaitSem,
SFLM_DB_STATS * pDbStats,
FLMUINT uiTimeout)
{
RCODE rc = NE_SFLM_OK;
if (RC_BAD( rc = m_pWriteLockObj->Lock( NULL, hWaitSem, FALSE,
(FLMBOOL)(uiTimeout ? TRUE : FALSE),
TRUE, uiTimeout, 0, pDbStats)))
{
goto Exit;
}
Exit:
return( rc);
}
/****************************************************************************
Desc: This routine unlocks the write lock on a database.
****************************************************************************/
void F_Database::dbWriteUnlock(
SFLM_DB_STATS * pDbStats)
{
(void)m_pWriteLockObj->Unlock( FALSE, NULL, FALSE, pDbStats);
}
/****************************************************************************
Desc: This shuts down the background threads
Note: This routine assumes that the global mutex is locked. The mutex will
@@ -656,35 +625,6 @@ FSTATIC void flmFreeEvent(
f_free( &pEvent);
}
/****************************************************************************
Desc: This routine determines the hash bucket for a string.
****************************************************************************/
FLMUINT flmStrHashBucket(
char * pszStr, // Pointer to string to be hashed
FBUCKET * pHashTbl, // Hash table to use
FLMUINT uiNumBuckets) // Number of hash buckets
{
FLMUINT uiHashIndex;
if ((uiHashIndex = (FLMUINT)*pszStr) >= uiNumBuckets)
{
uiHashIndex -= uiNumBuckets;
}
while (*pszStr)
{
if ((uiHashIndex =
(FLMUINT)((pHashTbl [uiHashIndex].uiHashValue) ^ (FLMUINT)(f_toupper( *pszStr)))) >=
uiNumBuckets)
{
uiHashIndex -= uiNumBuckets;
}
pszStr++;
}
return( uiHashIndex);
}
/****************************************************************************
Desc: This routine links a notify request into a notification list and
then waits to be notified that the event has occurred.
@@ -732,7 +672,7 @@ RCODE F_Database::linkToBucket( void)
FLMUINT uiBucket;
pBucket = gv_SFlmSysData.pDatabaseHashTbl;
uiBucket = flmStrHashBucket( m_pszDbPath, pBucket, FILE_HASH_ENTRIES);
uiBucket = f_strHashBucket( m_pszDbPath, pBucket, FILE_HASH_ENTRIES);
pBucket = &pBucket [uiBucket];
if (pBucket->pFirstInBucket)
{
@@ -955,12 +895,6 @@ RCODE F_DbSystem::monitorThrd(
uiCurrTime = uiLastUnusedCleanupTime = FLM_GET_TIMER();
}
// Call the lock manager to check timeouts. It is critial
// that this routine be called on a regular interval to
// timeout lock waiters that have expired.
gv_SFlmSysData.pServerLockMgr->CheckLockTimeouts( FALSE, FALSE);
// Check the adjusting cache limit
(void)gv_SFlmSysData.pGlobalCacheMgr->adjustCache( &uiCurrTime,
@@ -1503,26 +1437,6 @@ RCODE F_DbSystem::init( void)
flmDbgLogInit();
#endif
// Allocate and Initialize FLAIM Server Lock Manager.
if ((gv_SFlmSysData.pServerLockMgr = f_new ServerLockManager) == NULL)
{
rc = RC_SET( NE_SFLM_MEM);
goto Exit;
}
if (RC_BAD( rc = gv_SFlmSysData.pServerLockMgr->setupLockMgr()))
{
goto Exit;
}
// Set up hash table for lock manager.
if (RC_BAD( rc = gv_SFlmSysData.pServerLockMgr->SetupHashTbl()))
{
goto Exit;
}
// Set up mutexes for the event table.
for (iEventCategory = 0;
@@ -1745,33 +1659,6 @@ void F_DbSystem::cleanup( void)
f_mutexDestroy( &gv_SFlmSysData.hStatsMutex);
}
// Free (release) FLAIM's Server Lock Manager.
if (gv_SFlmSysData.pServerLockMgr)
{
FLMUINT uiRefCnt;
// Release all locks.
gv_SFlmSysData.pServerLockMgr->CheckLockTimeouts( FALSE, TRUE);
// Release the lock manager.
uiRefCnt = gv_SFlmSysData.pServerLockMgr->Release();
// No one else should have a reference to the server lock manager
// at this point, so lets trip a flmAssert if the object was really
// not deleted.
#ifdef FLM_DEBUG
flmAssert( 0 == uiRefCnt);
#else
// Quiet the compiler about the unused variable
(void)uiRefCnt;
#endif
gv_SFlmSysData.pServerLockMgr = NULL;
}
// Make sure the purge list is empty
if( gv_SFlmSysData.pRowCacheMgr->m_pPurgeList)