A CTDB_ON_TABLE_CLOSE callback is invoked before the FairCom DB data and index files are closed, but before the ctdbCloseTable() function returns. The handle passed as a parameter with this callback is a table handle and you can safely typecast the handle parameter to a pCTDBTABLE structure pointer. The close table callback may be used to undo and cleanup operations performed by the table open callback.
c-treeDB C API Example
CTDBRET ctdbDECL OnTableClose(CTHANDLE Handle)
{
pCTDBTABLE pTable = (pCTDBTABLE)Handle;
if (pTable && pTable->localTag)
{
pCTDBSESSION pSession = (pCTDBSESSION)pTable->pSession;
pLOCALTABLE pLocal = (pLOCALTABLE)pTable->localTag;
if (pLocal)
{
if (pLocal->dodaptr)
pSession->onFree(pLocal->dodaptr);
pSession->onFree(pTable->localTag);
}
pTable->localTag = NULL;
}
return CTDBRET_OK;
}