add commit failed cb (#550)
* add revert failed cb * add revert failed cb * add commit failed cb * add commit failed cb
This commit is contained in:
parent
c02630c83b
commit
7ea344c51f
2 changed files with 18 additions and 0 deletions
|
|
@ -806,6 +806,20 @@ plugin_transaction_revert_all(clixon_handle h,
|
|||
return retval; /* ignore errors */
|
||||
}
|
||||
|
||||
/*! Revert a commit for failed plugin
|
||||
* The commit failed is called for only failed plugin before revert all cb.
|
||||
*/
|
||||
static int
|
||||
plugin_transaction_commit_failed(clixon_plugin_t *cp,
|
||||
clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
trans_cb_t *fn;
|
||||
|
||||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_commit_failed) != NULL)
|
||||
return plugin_transaction_call_one(h, cp, fn, __FUNCTION__, td);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! Call single plugin transaction_commit() in a commit transaction
|
||||
*
|
||||
|
|
@ -848,6 +862,8 @@ plugin_transaction_commit_all(clixon_handle h,
|
|||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
i++;
|
||||
if (plugin_transaction_commit_one(cp, h, td) < 0){
|
||||
/* First make an effort ro revert transaction for the failed plugin */
|
||||
plugin_transaction_commit_failed(cp, h, td);
|
||||
/* Make an effort to revert transaction */
|
||||
plugin_transaction_revert_all(h, td, i-1);
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -402,6 +402,7 @@ struct clixon_plugin_api{
|
|||
trans_cb_t *cb_trans_complete; /* Transaction validation complete */
|
||||
trans_cb_t *cb_trans_commit; /* Transaction commit */
|
||||
trans_cb_t *cb_trans_commit_done; /* Transaction when commit done */
|
||||
trans_cb_t *cb_trans_commit_failed; /* Transaction commit failed*/
|
||||
trans_cb_t *cb_trans_revert; /* Transaction revert */
|
||||
trans_cb_t *cb_trans_end; /* Transaction completed */
|
||||
trans_cb_t *cb_trans_abort; /* Transaction aborted */
|
||||
|
|
@ -424,6 +425,7 @@ struct clixon_plugin_api{
|
|||
#define ca_trans_complete u.cau_backend.cb_trans_complete
|
||||
#define ca_trans_commit u.cau_backend.cb_trans_commit
|
||||
#define ca_trans_commit_done u.cau_backend.cb_trans_commit_done
|
||||
#define ca_trans_commit_failed u.cau_backend.cb_trans_commit_failed
|
||||
#define ca_trans_revert u.cau_backend.cb_trans_revert
|
||||
#define ca_trans_end u.cau_backend.cb_trans_end
|
||||
#define ca_trans_abort u.cau_backend.cb_trans_abort
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue