When an application and/or process has completed operations with the database, it must release resources by closing the open files and disconnecting from the database engine.
Below is the code for Done():
/*
* Done()
*
* This function handles the housekeeping of closing tables and
* freeing of associated memory
*/
#ifdef PROTOTYPE
VOID Done(VOID)
#else
VOID Done()
#endif
{
printf("DONE\n");
/* close table */
printf("\tClose table...\n");
if (ctdbCloseTable(hTable))
Handle_Error("Done(): ctdbCloseTable()");
/* logout */
printf("\tLogout...\n");
if (ctdbLogout(hSession))
Handle_Error("Done(): ctdbLogout()");
/* free handles */
ctdbFreeRecord(hRecord);
ctdbFreeTable(hTable);
ctdbFreeSession(hSession);
}