All callbacks excepting the TMCB_REQUEST_IN are associates to a transaction. It means they will be run only when the event will hint the transaction the callbacks were register for. TMCB_REQUEST_IN is a global callback - it means it will be run for all transactions.
--------------------------------
TMCB_REQUEST_IN -- a brand-new request was received and is about to establish transaction; it is not yet cloned and lives in pkg mem -- your last chance to mangle it before it gets shmem-ized (then, it's read-only); it's called from HASH_LOCK, so be careful. It is guaranteed not to be a retransmission. The transactional context is mostly incomplete -- this callback is called in very early stage before the message is shmem-ized (so that you can work with it).
TMCB_RESPONSE_IN -- a brand-new reply was received which matches an existing transaction. It may or may not be a retransmission.
TMCB_RESPONSE_PRE_OUT -- a final reply is about to be sent out (either local or proxied); you cannnot change the reply, but it is usefull to update your state before putting the reply on the network and to avoid any races (receiving an ACK before updating with the status of the reply)
TMCB_RESPONSE_OUT -- a final reply was sent out (either local or proxied) -- there is nothing more you can change from the callback, it is good for accounting-like uses.
TMCB_ON_FAILURE -- called on receipt of a reply or timer; it means all branches completed with a failure; that's a chance for example to add new transaction branches
TMCB_RESPONSE_FWDED -- called when a reply is about to be forwarded; it is called after a message is received but before a message is sent out: it is called when the decision is made to forward a reply; it is parametrized by pkg message which caused the transaction to complete (which is not necessarily the same which will be forwarded). As forwarding has not been executed and may fail, there is no guarantee a reply will be successfully sent out at this point of time.
: the reply callbacks will not be evoked if "silent C-timer hits". That's a feature to clean transactional state from a proxy quickly -- transactions will then complete statelessly. If you wish to disable this feature, either set the global option "noisy_ctimer" to 1, or set t->noisy_ctimer for selected transaction.
TMCB_REQUEST_FWDED -- request is being forwarded out. It is called before a message is forwarded and it is your last chance to change its shape.
TMCB_LOCAL_COMPLETED -- final reply for localy initiated transaction arrived. Message may be FAKED_REPLY.
IMPORTANT NOTES:
1) that callbacks MUST be installed before forking (callback lists do not live in shmem and have no access protection), i.e., at best from mod_init functions.
2) the callback's param MUST be in shared memory and will NOT be freed by TM; you must do it yourself from the callback function if necessary.
1.5.6