Purpose
The given Action function will be called whenever LQT_CloseDatabase or LQT_SyncDatabase is called.
The string Description is used in trace and debugging messages, and also in error messages; it should be a human-readable description of the action that the function is performing, or it could be an ASCII string containing the name of the function. The Description string is not copied; a pointer to it is retained. Therefore, it is an error to free it after calling LQT_AddActionOnClose.
The given Flags argument may be any combination of LQT_ON_SYNC and LQT_ON_CLOSE using bitwise or. If the LQT_ON_SYNC flag is given, the given Action is called by LQT_SyncDatabase; if LQT_ON_CLOSE is given, the given Action is called by LQT_CloseDatabase. It is unusual to have an action for the Sync case and not for the Close case, but it is not forbidden.
You can register any number of functions in this way. The most recently registered function is called first, and so on.
LQT_OpenDatabase uses this function to register the following functions, in order, so that LQT_FlushBlockCache is called last:
- LQT_FlushBlockCache (Write out cached low-level data blocks);
- LQT_WriteCurrentMaxWID (Write out largest allocated WID);
- LQTpFlushWIDCache (Write out cached WID index blocks);
- LQTp_FlushLastBlockCache (Write out cached lastblock data);
- LQT_SyncAndCloseAllKeyValueDatabases (Flush and close all open Dynamic Hashing (ndbm) key-value databases)
You can see these called by running a client with the Debug trace flag set (e.g. lqwordlist -t Debug).
Notes
The list of functions registered may change between revisions of lq-text, and is given here for illustrative purposes.