Registers a callback that will be invoked when the active channel is being destroyed.


#include <bps/bps.h>
BPS_API int bps_register_channel_destroy_handler(void(*destroy_handler)(void *), void *data)


The callback that is invoked on channel destruction.
The user data that is passed to the destroy_handler.




The function is used for services that have channel specific resources allocated that require cleanup when the channel is destroyed. At a minimum, most services have at least one file descriptor that needs to be closed.

A channel can be destroyed for a variety of reason that include:

  • The thread that created the channel has terminated.

  • The application has called the bps_channel_destroy() function.

  • The final bps_shutdown() function has been called, and all channels are being destroyed.

The destroy_handler is invoked when the channel is destroyed and the user data is passed into the function as the first argument. In the destroy_handler, do not call BPS library functions that use the channel that is being destroyed, with the exception of the bps_get_domain_data() function.


BPS_SUCCESS when the handler has successfully been registered along with the data, BPS_FAILURE with the errno value set otherwise.