Blame SOURCES/0037-Ticket-47329-Improve-slapi_back_transaction_begin-re.patch

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