Communication exit library error handing and return codes

When an error occurs in a communication exit library API, the API can return an ASCII text string in the errormsg field. That ASCII text string provides a more specific description of the problem than the return code. The database manager writes this entire string into the db2diag log files.

The memory for these error messages must be allocated by the communication exit library. Therefore, the library must also provide an API to free this memory: db2commexitFreeErrormsg.

In addition to the errormsg field, at initialization time a message log function pointer, logMessage_fn, is passed to the communication buffer exit library. The library can use the function to log any debugging information to the db2diag log files. For example:
// Log an message indicate init successful
  (*(logMessage_fn))(DB2COMMEXIT_LOG_CRITICAL,
                     "comm exit initialization successful",
                      strlen("comm. exit initialization successful"));
For more details about each parameter for the db2secLogMessage function, refer to the initialization API db2commexitInit in the related reference.

Return codes

Table 1. Return codes that a communication exit library can return to the database manager.
Return code Define value Details
0 DB2COMMEXIT_SUCCESS Successful execution
-1 DB2COMMEXIT_ERR_UNKNOWN The library encountered an unexpected error.
-2 DB2COMMEXIT_ERR_DROP_CONNECTION The library determined that the connection for which it was called must be terminated.