The mco_trans_callback function is called when a transaction is committed or rolled back. The function is registered with the mco_set_trans_callback() function.
MCO_RET mco_trans_callback(mco_trans_h trans, mco_trans_state state, void* arg);
The parameter trans is the transaction handle.
The parameter state is the transaction state. The possible values are:
MCO_TRANS_PRECOMMIT — the transaction is about to be committed.
Returning a non-MCO_S_OK value in this state will cause the transaction to be rolled
back.MCO_TRANS_POSTCOMMIT — the transaction has been committed.MCO_TRANS_ROLLBACK — the transaction has been rolled back.The parameter arg is a user-defined argument that was passed to the
mco_set_trans_callback()
function.
The callback should return MCO_S_OK. If the callback returns any value other than
MCO_S_OK while in the MCO_TRANS_PRECOMMIT state, the transaction will be rolled
back. Return values in other states (MCO_TRANS_POSTCOMMIT, MCO_TRANS_ROLLBACK)
are ignored.
static MCO_RET mco_trans_callback(mco_trans_h trans, mco_trans_state state, void* arg)
{
if (state == MCO_TRANS_POSTCOMMIT) {
((McoAsyncCommitSession*)arg)->commit();
}
return MCO_S_OK;
}