summaryrefslogtreecommitdiff
path: root/src/core/xbixmdx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/xbixmdx.cpp')
-rwxr-xr-xsrc/core/xbixmdx.cpp64
1 files changed, 24 insertions, 40 deletions
diff --git a/src/core/xbixmdx.cpp b/src/core/xbixmdx.cpp
index 53d7053..95f342c 100755
--- a/src/core/xbixmdx.cpp
+++ b/src/core/xbixmdx.cpp
@@ -582,28 +582,29 @@ xbInt16 xbIxMdx::CheckTagIntegrity( void *vpTag, xbInt16 iOpt ){
char cKeyType;
char *pPrevKeyBuf = NULL;
xbMdxTag *npTag = (xbMdxTag *) vpTag;
- xbInt16 iAutoLock;
xbBool bDescending = npTag->cKeyFmt2 & 0x08;
+ #ifdef XB_LOCKING_SUPPORT
+ xbBool bLocked = xbFalse;
+ #endif
+
+
try{
// xbase->WriteLogMessage( "xbIxMdx::CheckTagIntegrity()", iOpt );
#ifdef XB_LOCKING_SUPPORT
- iAutoLock = dbf->GetAutoLock();
- if( iAutoLock && !dbf->GetTableLocked() ){
+ if( dbf->GetAutoLock() && !dbf->GetTableLocked() ){
if(( iRc = dbf->LockTable( XB_LOCK )) != XB_NO_ERROR ){
iErrorStop = 100;
throw iRc;
}
+ bLocked = xbTrue;
}
#endif
memset( npTag->cpKeyBuf2, 0x00, (size_t) npTag->iKeyLen );
cKeyType = GetKeyType( vpTag );
- // sMsg.Sprintf( "Checking index type [%c]", cKeyType );
- // xbase->WriteLogMessage( sMsg, iOpt );
-
pPrevKeyBuf = (char *) calloc( 1, (size_t) npTag->iKeyLen );
iRc = GetFirstKey( vpTag, 0 );
memcpy( pPrevKeyBuf, GetKeyData( npTag->npCurNode, npTag->npCurNode->iCurKeyNo, npTag->iKeyItemLen ), (size_t) npTag->iKeyLen );
@@ -704,14 +705,6 @@ xbInt16 xbIxMdx::CheckTagIntegrity( void *vpTag, xbInt16 iOpt ){
xbase->WriteLogMessage( sMsg, iOpt );
}
- #ifdef XB_LOCKING_SUPPORT
- if( iAutoLock && dbf->GetTableLocked() ){
- if(( iRc = dbf->LockTable( XB_UNLOCK )) != XB_NO_ERROR ){
- iErrorStop = 200;
- throw iRc;
- }
- }
- #endif
if( pPrevKeyBuf )
free( pPrevKeyBuf );
@@ -730,6 +723,13 @@ xbInt16 xbIxMdx::CheckTagIntegrity( void *vpTag, xbInt16 iOpt ){
xbase->WriteLogMessage( sMsg, iOpt );
}
}
+
+ #ifdef XB_LOCKING_SUPPORT
+ if( bLocked ){
+ dbf->LockTable( XB_UNLOCK );
+ }
+ #endif
+
return iRc;
}
@@ -1765,7 +1765,6 @@ xbInt16 xbIxMdx::DeleteTag( void *vpTag ){
/***********************************************************************/
#ifdef XB_DEBUG_SUPPORT
-
//! @brief Dump a given block for a tag
/*!
\param iOpt Output message destination<br>
@@ -1958,7 +1957,6 @@ xbInt16 xbIxMdx::DumpFreeBlocks( xbInt16 iOpt ){
}
/**************************************************************************************************************/
-
//! @brief Dump interior and leaf blocks for a given tag.
/*!
Dump blocks for given tag for index debugging purposes.
@@ -4325,12 +4323,12 @@ xbInt16 xbIxMdx::ReadHeadBlock( xbInt16 iOpt )
free( cNodeBuf );
if(( cNodeBuf = (char *) malloc( (size_t) GetBlockSize())) == NULL ){
- iErrorStop = 40;
+ iErrorStop = 150;
throw XB_NO_MEMORY;
}
if(( iRc = xbIxMdx::LoadTagTable()) != XB_NO_ERROR ){
- iErrorStop = 50;
+ iErrorStop = 160;
throw iRc;
}
@@ -4379,7 +4377,7 @@ xbInt16 xbIxMdx::Reindex( void **vpTag ){
xbInt16 iErrorStop = 0;
xbMdxTag * mpTag;
#ifdef XB_LOCKING_SUPPORT
- xbInt16 iAutoLock = 0;
+ xbBool bLocked = xbFalse;
#endif
if( vpTag )
@@ -4400,12 +4398,12 @@ xbInt16 xbIxMdx::Reindex( void **vpTag ){
try{
#ifdef XB_LOCKING_SUPPORT
- iAutoLock = dbf->GetAutoLock();
- if( iAutoLock && !dbf->GetTableLocked() ){
+ if( dbf->GetAutoLock() && !dbf->GetTableLocked() ){
if(( iRc = dbf->LockTable( XB_LOCK )) != XB_NO_ERROR ){
iErrorStop = 100;
throw iRc;
}
+ bLocked = xbTrue;
}
#endif
@@ -4524,34 +4522,20 @@ xbInt16 xbIxMdx::Reindex( void **vpTag ){
mpTag = (xbMdxTag *) GetTag( iCurTag++ );
}
}
-
- // unlock as necessary
- #ifdef XB_LOCKING_SUPPORT
- if( iAutoLock && dbf->GetTableLocked() ){
- if(( iRc = dbf->LockTable( XB_UNLOCK )) != XB_NO_ERROR ){
- iErrorStop = 190;
- throw iRc;
- }
- }
- #endif
-
-
}
catch (xbInt16 iRc ){
xbString sMsg;
sMsg.Sprintf( "xbIxMdx::ReIndex() Exception Caught. Error Stop = [%d] iRc = [%d]", iErrorStop, iRc );
xbase->WriteLogMessage( sMsg.Str() );
xbase->WriteLogMessage( GetErrorMessage( iRc ));
+ }
- // unlock as necessary
- #ifdef XB_LOCKING_SUPPORT
- if( iAutoLock && dbf->GetTableLocked() ){
- dbf->LockTable( XB_UNLOCK );
- }
- #endif
+ #ifdef XB_LOCKING_SUPPORT
+ if( bLocked ){
+ dbf->LockTable( XB_UNLOCK );
}
+ #endif
return iRc;
-
}
/***********************************************************************/