If the cmm_cmc_register() function is called while
a callback is registered, a CMM_EEXIST error is returned
because only one function can be registered at a time. To change the registration, cmm_cmc_unregister() must be called prior to registering the new
node with cmm_cmc_register().
Registration only needs to be done once to receive cluster membership
change notifications. When a process attempts to register more than once,
the first callback is kept and an error is returned.
The calling process must use the cmm_notify_getfd(3CMM)
and cmm_notify_dispatch(3CMM) functions to receive and
dispatch messages from nhcmmd(1M). An application defines the list of
notifications it receives by calling cmm_cmc_filter(3CMM).
Note that the order of callback notifications is the same as that of
the Cluster Membership Manager (CMM) notifications; one call to cmm_notify_dispatch(3CMM)
can lead to several calls to the callback (in fact as many as the number of
pending notifications). Within these callbacks, if functions are invoked concerning
the state of the cluster (for instance to get the number of nodes in the cluster),
the results of the functions do not refer to the state that the cluster is
in when the notification has been generated. Instead, the results of the functions
refer to the state of the cluster when the function is invoked. In the meantime,
some other modifications might have occurred in the cluster.
The callback function is invoked by the same thread as the one that
calls the cmm_notify_dispatch(3CMM) function. The function
is invoked by a library linked to the process. The library communicates with
the CMM API that supplies the membership change information passed as an argument
to the callback function.
The cmm_cmc_unregister() function removes the calling
process's registration so that no further delivery of cluster membership change
notifications is made. Only the process on which a callback is called can
remove the caller's registration. A child or a parent process cannot do this.
If the calling process callback function is active when the unregister
request is made, it is not canceled.
In case of fork(), the created child process does
not inherit the registration from its parent. It has to make its own registration.