From f786600c593a78c8f1cd96a12ac6059f41837dd9 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Fri, 21 Jun 2013 10:47:09 -0400 Subject: [PATCH 37/39] Ticket 47329 - Improve slapi_back_transaction_begin() return code when transactions are not available Bug Description: The slapi_back_transaction_begin() function needs it's return codes to be changed to be more friendly for plug-in writers when transactions are not available. Fix Description: Added new error code SLAPI_BACK_TRANSACTION_NOT_SUPPORTED, and updated the slapi_plugin.h https://fedorahosted.org/389/ticket/47329 Reviewed by: Noriko, Ludwig, and Rich(Thanks!!!) (cherry picked from commit 8879ed2efa48e96f2b920a3ab83036b07e3b3ae4) (cherry picked from commit badcb1ac60bfb4c54fe264088a3c730b2ce2ac11) --- ldap/servers/slapd/backend.c | 26 +++++++++++++++++++++----- ldap/servers/slapd/slapi-plugin.h | 2 ++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ldap/servers/slapd/backend.c b/ldap/servers/slapd/backend.c index ad253f1..ead251e 100644 --- a/ldap/servers/slapd/backend.c +++ b/ldap/servers/slapd/backend.c @@ -648,8 +648,13 @@ int slapi_back_transaction_begin(Slapi_PBlock *pb) { IFP txn_begin; - slapi_pblock_get(pb, SLAPI_PLUGIN_DB_BEGIN_FN, (void*)&txn_begin); - return txn_begin(pb); + if(slapi_pblock_get(pb, SLAPI_PLUGIN_DB_BEGIN_FN, (void*)&txn_begin) || + !txn_begin) + { + return SLAPI_BACK_TRANSACTION_NOT_SUPPORTED; + } else { + return txn_begin(pb); + } } /* API to expose DB transaction commit */ @@ -657,7 +662,13 @@ int slapi_back_transaction_commit(Slapi_PBlock *pb) { IFP txn_commit; - slapi_pblock_get(pb, SLAPI_PLUGIN_DB_COMMIT_FN, (void*)&txn_commit); + if(slapi_pblock_get(pb, SLAPI_PLUGIN_DB_COMMIT_FN, (void*)&txn_commit) || + !txn_commit) + { + return SLAPI_BACK_TRANSACTION_NOT_SUPPORTED; + } else { + return txn_commit(pb); + } return txn_commit(pb); } @@ -666,6 +677,11 @@ int slapi_back_transaction_abort(Slapi_PBlock *pb) { IFP txn_abort; - slapi_pblock_get(pb, SLAPI_PLUGIN_DB_ABORT_FN, (void*)&txn_abort); - return txn_abort(pb); + if(slapi_pblock_get(pb, SLAPI_PLUGIN_DB_ABORT_FN, (void*)&txn_abort) || + !txn_abort) + { + return SLAPI_BACK_TRANSACTION_NOT_SUPPORTED; + } else { + return txn_abort(pb); + } } diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index 2f2152b..d456af8 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -6067,6 +6067,7 @@ const char * slapi_be_gettype(Slapi_Backend *be); * * \param pb Pblock which is supposed to set (Slapi_Backend *) to SLAPI_BACKEND * \return 0 if successful + * \return SLAPI_BACK_TRANSACTION_NOT_SUPPORTED if transaction support is not available for this backend * \return Non-zero if an error occurred * * \see slapi_back_transaction_commit @@ -6904,6 +6905,7 @@ typedef struct slapi_plugindesc { #define SLAPI_PARENT_TXN 190 #define SLAPI_TXN 191 #define SLAPI_TXN_RUV_MODS_FN 1901 +#define SLAPI_BACK_TRANSACTION_NOT_SUPPORTED 1902 /* * The following are used to pass information back and forth -- 1.7.1