BioAPI_RETURN BioAPI MDSU_Term( MDSU_CONTEXT *pContext ) { BioAPI_RETURN rv = CSSM_OK; /* Parameter check */ if ( pContext == NULL ) { rv = CSSMERR_CSSM_INVALID_POINTER; } else { /* Commit the records in the cache */ MDSU_Commit( pContext ); /* Free the commit cache */ MDSU_free( pContext, pContext->pCommitCache ); /* Close the database handle */ if ( ( rv = s_MDSUFuncs.DbClose( pContext->hDb ) ) == CSSM_OK ) { /* Close the MDS connection */ if ( ( rv = MDS_Terminate( pContext->hMds ) ) == CSSM_OK ) { /* Wipe the context */ memset( pContext, 0, sizeof(MDSU_CONTEXT) ); } } /* DbClose */ } /* Validation */ return rv; }
// // Cleanup (only called if the ModuleNexus is explicitly reset) // Directory::~Directory() { if (mCDSA.DBHandle) CssmError::check(DbClose(mCDSA)); CssmError::check(MDS_Terminate(mds())); }
BioAPI_RETURN BioAPI MDSU_Init( MDSU_CONTEXT *pContext, const BioAPI_MEMORY_FUNCS *pMemFuncs, const BioAPI_UUID *pUuid, const char *szDirectoryName, CSSM_DB_ACCESS_TYPE AccessType, uint32 CommitSize ) { BioAPI_RETURN rv = CSSM_OK; /* Parameter check */ if ( ( pContext == NULL ) || ( pMemFuncs == NULL ) || ( szDirectoryName == NULL ) ) { rv = CSSMERR_CSSM_INVALID_POINTER; } else { /* Set the default access value if one is not specified */ if ( AccessType == 0 ) { AccessType = CSSM_DB_ACCESS_READ; } /* Wipe the context clean */ memset( pContext, 0, sizeof(MDSU_CONTEXT) ); /* Set the memory functions */ pContext->MemFuncs = *pMemFuncs; /* Attempt to initialize the MDS and get an MDS handle */ if ( ( rv = MDS_Initialize( pUuid, NULL, &pContext->MemFuncs, &s_MDSUFuncs, &pContext->hMds ) ) == CSSM_OK ) { /* Open the requested MDS directory */ if ( ( rv = s_MDSUFuncs.DbOpen( pContext->hMds, szDirectoryName, NULL, AccessType, NULL, NULL, &pContext->hDb.DBHandle ) ) == CSSM_OK ) { pContext->hDb.DLHandle = pContext->hMds; /* Copy the proper values into the MDSU context */ if ( pUuid != NULL ) { BioAPI_CopyUuid (&pContext->ModuleUuid, pUuid); } else { BioAPI_ClearUuid (&pContext->ModuleUuid); } /* Allocate the commit cache */ pContext->pCommitCache = MDSU_calloc( pContext, sizeof(CSSM_DB_UNIQUE_RECORD_PTR), CommitSize ); pContext->CommitSize = CommitSize; pContext->CacheCount = 0; /* Close the database if there is an error condition */ if ( rv != CSSM_OK ) { s_MDSUFuncs.DbClose( pContext->hDb ); } } /* Terminate the MDS in an error condition */ if ( rv != CSSM_OK ) { MDS_Terminate( pContext->hMds ); memset( pContext, 0, sizeof(MDSU_CONTEXT) ); } } /* MDS_Initialize */ } /* Validation */ return rv; }
QMDS::~QMDS() { MDS_Terminate( ); memset( &m_dlFunctions, 0, sizeof(MDS_FUNCS) ); }