A CTDB_ON_DATABASE_DISCONNECT callback is invoked just before a database disconnect is performed. The handle passed as a parameter with this callback is a database handle and you can safely typecast the handle parameter to a pCTDBDATABASE structure pointer.
The database disconnect callback may be used to undo and cleanup any operations performed by a database connect callback.
Below is an example demonstrating how to clear the callbacks established by the database connect callback.
FairCom DB API C API Example
CTDBRET ctdbDECL OnDatabaseDisconnect(CTHANDLE Handle)
{
CTDBRET Retval = CTDBRET_OK;
pCTDBDATABASE pDatabase = (pCTDBDATABASE)Handle;
if (!pDatabase)
Retval = CTDBRET_NOTDATABASE;
else
{
Retval = ctdbClearCallback(Handle, CTDB_ON_TABLE_OPEN);
if (Retval == CTDBRET_OK)
Retval = ctdbClearCallback(Handle, CTDB_ON_TABLE_CLOSE);
}
return Retval;
}