src/core/fm.c

Go to the documentation of this file.
00001 
00015 #include <misc/result.h>
00016 #include <misc/malloc.h>
00017 #include <misc/debug.h>
00018 #include <misc/mutex.h>
00019 #include <misc/generic_types.h>
00020 #include <core/config.h>
00021 #include <core/fm.h>
00022 #include <core/tx.h>
00023 #include <core/txdesc.h>
00024 
00025 void
00026 txc_fm_init(txc_tx_t *txd)
00027 {
00028         txd->fm_abort = TXC_BOOL_FALSE;
00029         txd->fm_error_result = 0;
00030         txd->fm_flags = 0;
00031 }
00032 
00033 void
00034 txc_fm_register(txc_tx_t *txd, int flags, int *error_result)
00035 {
00036         txd->fm_flags = flags;
00037         txd->fm_error_result = error_result;
00038 }
00039 
00040 
00041 void 
00042 txc_fm_transaction_postbegin(txc_tx_t *txd)
00043 {
00044         if (txd->fm_abort == TXC_BOOL_TRUE) {
00045                 txc_tx_abort_transaction(txd, TXC_ABORTREASON_USERABORT);
00046         }
00047 }
00048 
00049 
00050 void
00051 txc_fm_handle_commit_failure(txc_tx_t *txd, int error_result)
00052 {
00053         if (txd->fm_error_result) {
00054                 *txd->fm_error_result = error_result;
00055         }       
00056 }
00057 
00058 
00059 void
00060 txc_fm_handle_undo_failure(txc_tx_t *txd, int error_result)
00061 {
00062         if (error_result) {
00063                 if (txd->fm_error_result) {
00064                         *txd->fm_error_result = error_result;
00065                 }       
00066                 if (txd->fm_flags && TXC_FM_NO_RETRY) {
00067                         /* 
00068                          * The transaction is already at the rollback state and will
00069                          * restart after finished with the undo actions. Set the
00070                          * fm_abort flag so that we abort the transaction right
00071                          * after restart.
00072                          */
00073                         txd->fm_abort = TXC_BOOL_TRUE;
00074                 }       
00075         }
00076         /* 
00077          * Reset the failure flags for the next dynamic instance of the 
00078          * current transaction.
00079          */
00080         txd->fm_flags = 0;
00081 }

Generated on Wed Dec 9 20:32:39 2009 for xCalls by  doxygen 1.4.7