From 33939161501585fbe840e0b9bcfe3949e202c67e Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Thu, 18 Jul 2013 11:38:30 -0700
Subject: [PATCH 2/2] Ticket #47367 - (phase 2) ldapdelete returns non-leaf
 entry error while trying to remove a leaf entry

Fix description:
1) Make sure add/modify/modrdn/delete plug-in callbacks return
SLAPI_PLUGIN_SUCCESS (==0) on SUCCESS and SLAPI_PLUGIN_FAILURE
(==-1) on FAILURE.  And set error code to SLAPI_RESULT_CODE in
pblock, if any.
2) replication: eliminated multimaster_betxnpreop_* which were
used for calling urp.  Urp needs to be processed at bepreop
timing.
---
 ldap/servers/plugins/automember/automember.c     |  23 +--
 ldap/servers/plugins/cos/cos.c                   |   2 +-
 ldap/servers/plugins/dna/dna.c                   |  18 ++-
 ldap/servers/plugins/linkedattrs/linked_attrs.c  |  34 +++--
 ldap/servers/plugins/memberof/memberof.c         |  16 +-
 ldap/servers/plugins/mep/mep.c                   |  41 ++---
 ldap/servers/plugins/pam_passthru/pam_ptpreop.c  |  12 +-
 ldap/servers/plugins/referint/referint.c         |  52 +++----
 ldap/servers/plugins/replication/repl5.h         |   4 -
 ldap/servers/plugins/replication/repl5_plugins.c | 184 ++++++-----------------
 ldap/servers/plugins/retrocl/retrocl_po.c        |  12 +-
 ldap/servers/plugins/roles/roles_plugin.c        |   2 +-
 ldap/servers/plugins/statechange/statechange.c   |  22 +--
 ldap/servers/plugins/usn/usn.c                   |  65 +++++---
 ldap/servers/plugins/views/views.c               |  35 ++---
 ldap/servers/slapd/add.c                         |   2 +-
 ldap/servers/slapd/delete.c                      |   2 +-
 ldap/servers/slapd/modify.c                      |   2 +-
 ldap/servers/slapd/modrdn.c                      |   2 +-
 ldap/servers/slapd/plugin.c                      |  22 +--
 20 files changed, 247 insertions(+), 305 deletions(-)

diff --git a/ldap/servers/plugins/automember/automember.c b/ldap/servers/plugins/automember/automember.c
index 49f47f7..2ba3314 100644
--- a/ldap/servers/plugins/automember/automember.c
+++ b/ldap/servers/plugins/automember/automember.c
@@ -1686,7 +1686,7 @@ automember_pre_op(Slapi_PBlock * pb, int modop)
     LDAPMod **mods;
     int free_entry = 0;
     char *errstr = NULL;
-    int ret = 0;
+    int ret = SLAPI_PLUGIN_SUCCESS;
 
     slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
                     "--> automember_pre_op\n");
@@ -1771,7 +1771,8 @@ automember_pre_op(Slapi_PBlock * pb, int modop)
                         "automember_pre_op: operation failure [%d]\n", ret);
         slapi_send_ldap_result(pb, ret, NULL, errstr, 0, NULL);
         slapi_ch_free((void **)&errstr);
-        ret = -1;
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ret);
+        ret = SLAPI_PLUGIN_FAILURE;
     }
 
     slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
@@ -1822,7 +1823,7 @@ automember_mod_post_op(Slapi_PBlock *pb)
     slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
                     "<-- automember_mod_post_op\n");
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 static int
@@ -1838,7 +1839,7 @@ automember_add_post_op(Slapi_PBlock *pb)
 
     /* Just bail if we aren't ready to service requests yet. */
     if (!g_plugin_started || !automember_oktodo(pb))
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
 
     /* Reload config if a config entry was added. */
     if ((sdn = automember_get_sdn(pb))) {
@@ -1854,7 +1855,7 @@ automember_add_post_op(Slapi_PBlock *pb)
 
     /* If replication, just bail. */
     if (automember_isrepl(pb)) {
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     /* Get the newly added entry. */
@@ -1868,7 +1869,7 @@ automember_add_post_op(Slapi_PBlock *pb)
                                                    tombstone);
         slapi_value_free(&tombstone);
         if (rc) {
-            return 0;
+            return SLAPI_PLUGIN_SUCCESS;
         }
 
         /* Check if a config entry applies
@@ -1878,7 +1879,7 @@ automember_add_post_op(Slapi_PBlock *pb)
         /* Bail out if the plug-in close function was just called. */
         if (!g_plugin_started) {
             automember_config_unlock();
-            return 0;
+            return SLAPI_PLUGIN_SUCCESS;
         }
 
         if (!PR_CLIST_IS_EMPTY(g_automember_config)) {
@@ -1907,7 +1908,7 @@ bail:
     slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
                     "<-- automember_add_post_op\n");
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 /*
@@ -1925,7 +1926,7 @@ automember_del_post_op(Slapi_PBlock *pb)
 
     /* Just bail if we aren't ready to service requests yet. */
     if (!g_plugin_started || !automember_oktodo(pb)) {
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     /* Reload config if a config entry was deleted. */
@@ -1941,7 +1942,7 @@ automember_del_post_op(Slapi_PBlock *pb)
     slapi_log_error(SLAPI_LOG_TRACE, AUTOMEMBER_PLUGIN_SUBSYSTEM,
                     "<-- automember_del_post_op\n");
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 typedef struct _task_data
@@ -2193,7 +2194,7 @@ void automember_rebuild_task_thread(void *arg){
                 /* Does the entry meet scope and filter requirements? */
                 if (slapi_dn_issuffix(slapi_sdn_get_dn(td->base_dn), config->scope) &&
                     (slapi_filter_test_simple(entries[i], config->filter) == 0))
-                {		
+                {
                     automember_update_membership(config, entries[i], NULL);
                 }
                 list = PR_NEXT_LINK(list);
diff --git a/ldap/servers/plugins/cos/cos.c b/ldap/servers/plugins/cos/cos.c
index 0d76d99..55ff850 100644
--- a/ldap/servers/plugins/cos/cos.c
+++ b/ldap/servers/plugins/cos/cos.c
@@ -306,6 +306,6 @@ int cos_post_op( Slapi_PBlock *pb )
 	cos_cache_change_notify(pb);
 
 	LDAPDebug( LDAP_DEBUG_TRACE, "<-- cos_post_op\n",0,0,0);
-	return 0; /* always succeed */
+	return SLAPI_PLUGIN_SUCCESS; /* always succeed */
 }
 
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index f5ebec6..f044c76 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -70,8 +70,8 @@
 
 #define DNA_DN "cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config" /* temporary */
 
-#define DNA_SUCCESS 0
-#define DNA_FAILURE -1
+#define DNA_SUCCESS SLAPI_PLUGIN_SUCCESS
+#define DNA_FAILURE SLAPI_PLUGIN_FAILURE
 
 /* Default range request timeout */
 /* use the default replication timeout */
@@ -3016,7 +3016,7 @@ dna_create_valcheck_filter(struct configEntry *config_entry, PRUint64 value, cha
 static int
 _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr)
 {
-    int ret = 0;
+    int ret = DNA_SUCCESS;
     PRCList *list = NULL;
     struct configEntry *config_entry = NULL;
     char *dn = NULL;
@@ -3195,7 +3195,7 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr)
                 slapi_ch_free((void **)&types_to_generate);
             }
 next:
-            ret = 0;
+            ret = DNA_SUCCESS;
             list = PR_NEXT_LINK(list);
         }
     }
@@ -3212,7 +3212,7 @@ bail:
 static int
 _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods, char **errstr)
 {
-    int ret = 0;
+    int ret = DNA_SUCCESS;
     PRCList *list = NULL;
     struct configEntry *config_entry = NULL;
     char *dn = NULL;
@@ -3594,6 +3594,7 @@ bail:
                         "dna_pre_op: operation failure [%d]\n", ret);
         slapi_send_ldap_result(pb, ret, NULL, errstr, 0, NULL);
         slapi_ch_free((void **)&errstr);
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ret);
         ret = DNA_FAILURE;
     }
 
@@ -3659,7 +3660,7 @@ static int dna_be_txn_pre_op(Slapi_PBlock *pb, int modtype)
     char *dn = NULL;
     char *type = NULL;
     int numvals, e_numvals = 0;
-    int i, len, ret = 0;
+    int i, len, ret = DNA_SUCCESS;
 
     slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
                     "--> dna_be_txn_pre_op\n");
@@ -3905,13 +3906,14 @@ bail:
                           "dna_be_txn_pre_op: operation failure [%d]\n", ret);
         slapi_send_ldap_result(pb, ret, NULL, errstr, 0, NULL);
         slapi_ch_free((void **)&errstr);
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ret);
         ret = DNA_FAILURE;
     }
 
     slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
                     "<-- dna_be_txn_pre_op\n");
 
-        return ret;
+    return ret;
 }
 
 static int dna_config_check_post_op(Slapi_PBlock * pb)
@@ -3932,7 +3934,7 @@ static int dna_config_check_post_op(Slapi_PBlock * pb)
     slapi_log_error(SLAPI_LOG_TRACE, DNA_PLUGIN_SUBSYSTEM,
                     "<-- dna_config_check_post_op\n");
 
-    return 0;
+    return DNA_SUCCESS;
 }
 
 
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index 7d8370d..30a8653 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -1536,7 +1536,7 @@ linked_attrs_pre_op(Slapi_PBlock * pb, int modop)
     LDAPMod **mods = NULL;
     int free_entry = 0;
     char *errstr = NULL;
-    int ret = 0;
+    int ret = SLAPI_PLUGIN_SUCCESS;
 
     slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
                     "--> linked_attrs_pre_op\n");
@@ -1603,7 +1603,8 @@ linked_attrs_pre_op(Slapi_PBlock * pb, int modop)
                         "linked_attrs_pre_op: operation failure [%d]\n", ret);
         slapi_send_ldap_result(pb, ret, NULL, errstr, 0, NULL);
         slapi_ch_free((void **)&errstr);
-        ret = -1;
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ret);
+        ret = SLAPI_PLUGIN_FAILURE;
     }
 
     slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
@@ -1640,7 +1641,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
 
     /* Just bail if we aren't ready to service requests yet. */
     if (!g_plugin_started)
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
 
     /* We don't want to process internal modify
      * operations that originate from this plugin.
@@ -1649,7 +1650,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
 
     if (caller_id == linked_attrs_get_plugin_id()) {
         /* Just return without processing */
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     if (linked_attrs_oktodo(pb) &&
@@ -1675,7 +1676,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
             /* Bail out if the plug-in close function was just called. */
             if (!g_plugin_started) {
                 linked_attrs_unlock();
-                return 0;
+                return SLAPI_PLUGIN_SUCCESS;
             }
 
             linked_attrs_find_config(dn, type, &config);
@@ -1729,7 +1730,7 @@ linked_attrs_mod_post_op(Slapi_PBlock *pb)
     slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
                     "<-- linked_attrs_mod_post_op\n");
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 static int
@@ -1743,7 +1744,7 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
 
     /* Just bail if we aren't ready to service requests yet. */
     if (!g_plugin_started || !linked_attrs_oktodo(pb))
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
 
     /* Reload config if a config entry was added. */
     if ((dn = linked_attrs_get_dn(pb))) {
@@ -1773,7 +1774,7 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
             /* Bail out if the plug-in close function was just called. */
             if (!g_plugin_started) {
                 linked_attrs_unlock();
-                return 0;
+                return SLAPI_PLUGIN_SUCCESS;
             }
 
             linked_attrs_find_config(dn, type, &config);
@@ -1808,7 +1809,7 @@ linked_attrs_add_post_op(Slapi_PBlock *pb)
     slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
                     "<-- linked_attrs_add_post_op\n");
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 static int
@@ -1822,7 +1823,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
 
     /* Just bail if we aren't ready to service requests yet. */
     if (!g_plugin_started || !linked_attrs_oktodo(pb))
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
 
     /* Reload config if a config entry was deleted. */
     if ((dn = linked_attrs_get_dn(pb))) {
@@ -1852,7 +1853,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
             /* Bail out if the plug-in close function was just called. */
             if (!g_plugin_started) {
                 linked_attrs_unlock();
-                return 0;
+                return SLAPI_PLUGIN_SUCCESS;
             }
 
             linked_attrs_find_config(dn, type, &config);
@@ -1920,7 +1921,7 @@ linked_attrs_del_post_op(Slapi_PBlock *pb)
     slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
                     "<-- linked_attrs_del_post_op\n");
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 static int
@@ -1932,7 +1933,7 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
     Slapi_Attr *attr = NULL;
     char *type = NULL;
     struct configEntry *config = NULL;
-    int rc = 0;
+    int rc = SLAPI_PLUGIN_SUCCESS;
 
     slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
                     "--> linked_attrs_modrdn_post_op\n");
@@ -1978,7 +1979,7 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
         /* Bail out if the plug-in close function was just called. */
         if (!g_plugin_started) {
             linked_attrs_unlock();
-            return 0;
+            return SLAPI_PLUGIN_SUCCESS;
         }
 
         linked_attrs_find_config(old_dn, type, &config);
@@ -2069,7 +2070,10 @@ linked_attrs_modrdn_post_op(Slapi_PBlock *pb)
 done:
     slapi_log_error(SLAPI_LOG_TRACE, LINK_PLUGIN_SUBSYSTEM,
                     "<-- linked_attrs_modrdn_post_op\n");
-
+    if (rc) {
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+        rc = SLAPI_PLUGIN_FAILURE;
+    }
     return rc;
 }
 
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index e362cab..5aa22fd 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -380,7 +380,7 @@ int memberof_postop_close(Slapi_PBlock *pb)
  */
 int memberof_postop_del(Slapi_PBlock *pb)
 {
-	int ret = 0;
+	int ret = SLAPI_PLUGIN_SUCCESS;
 	MemberOfConfig configCopy = {0, 0, 0, 0};
 	Slapi_DN *sdn;
 	void *caller_id = NULL;
@@ -393,7 +393,7 @@ int memberof_postop_del(Slapi_PBlock *pb)
 	slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &caller_id);
 	if (caller_id == memberof_get_plugin_id()) {
 		/* Just return without processing */
-		return 0;
+		return SLAPI_PLUGIN_SUCCESS;
 	}
 
 	if(memberof_oktodo(pb) && (sdn = memberof_getsdn(pb)))
@@ -626,7 +626,7 @@ int memberof_call_foreach_dn(Slapi_PBlock *pb, Slapi_DN *sdn,
  */
 int memberof_postop_modrdn(Slapi_PBlock *pb)
 {
-	int ret = 0;
+	int ret = SLAPI_PLUGIN_SUCCESS;
 	void *caller_id = NULL;
 
 	slapi_log_error( SLAPI_LOG_TRACE, MEMBEROF_PLUGIN_SUBSYSTEM,
@@ -637,7 +637,7 @@ int memberof_postop_modrdn(Slapi_PBlock *pb)
 	slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &caller_id);
 	if (caller_id == memberof_get_plugin_id()) {
 		/* Just return without processing */
-		return 0;
+		return SLAPI_PLUGIN_SUCCESS;
 	}
 
 	if(memberof_oktodo(pb))
@@ -801,7 +801,7 @@ int memberof_replace_dn_type_callback(Slapi_Entry *e, void *callback_data)
  */
 int memberof_postop_modify(Slapi_PBlock *pb)
 {
-	int ret = 0;
+	int ret = SLAPI_PLUGIN_SUCCESS;
 	Slapi_DN *sdn = NULL;
 	Slapi_Mods *smods = 0;
 	Slapi_Mod *smod = 0;
@@ -817,7 +817,7 @@ int memberof_postop_modify(Slapi_PBlock *pb)
 	slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &caller_id);
 	if (caller_id == memberof_get_plugin_id()) {
 		/* Just return without processing */
-		return 0;
+		return SLAPI_PLUGIN_SUCCESS;
 	}
 
 	if(memberof_oktodo(pb) && (sdn = memberof_getsdn(pb)))
@@ -945,7 +945,7 @@ int memberof_postop_modify(Slapi_PBlock *pb)
  */
 int memberof_postop_add(Slapi_PBlock *pb)
 {
-	int ret = 0;
+	int ret = SLAPI_PLUGIN_SUCCESS;
 	int interested = 0;
 	Slapi_DN *sdn = 0;
 	void *caller_id = NULL;
@@ -958,7 +958,7 @@ int memberof_postop_add(Slapi_PBlock *pb)
 	slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &caller_id);
 	if (caller_id == memberof_get_plugin_id()) {
 		/* Just return without processing */
-		return 0;
+		return SLAPI_PLUGIN_SUCCESS;
 	}
 
 	if(memberof_oktodo(pb) && (sdn = memberof_getsdn(pb)))
diff --git a/ldap/servers/plugins/mep/mep.c b/ldap/servers/plugins/mep/mep.c
index d4835ce..3e63773 100644
--- a/ldap/servers/plugins/mep/mep.c
+++ b/ldap/servers/plugins/mep/mep.c
@@ -1984,7 +1984,7 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
     char *errstr = NULL;
     struct configEntry *config = NULL;
     void *caller_id = NULL;
-    int ret = 0;
+    int ret = SLAPI_PLUGIN_SUCCESS;
 
     slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
                     "--> mep_pre_op\n");
@@ -2268,7 +2268,8 @@ mep_pre_op(Slapi_PBlock * pb, int modop)
                         "mep_pre_op: operation failure [%d]\n", ret);
         slapi_send_ldap_result(pb, ret, NULL, errstr, 0, NULL);
         slapi_ch_free((void **)&errstr);
-        ret = -1;
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &ret);
+        ret = SLAPI_PLUGIN_FAILURE;
     }
 
     slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
@@ -2322,7 +2323,7 @@ mep_mod_post_op(Slapi_PBlock *pb)
 
     /* Just bail if we aren't ready to service requests yet. */
     if (!g_plugin_started)
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
 
     if (mep_oktodo(pb) && (sdn = mep_get_sdn(pb))) {
         /* First check if the config or a template is being modified. */
@@ -2439,7 +2440,7 @@ mep_mod_post_op(Slapi_PBlock *pb)
     slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
                     "<-- mep_mod_post_op\n");
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 static int
@@ -2454,7 +2455,7 @@ mep_add_post_op(Slapi_PBlock *pb)
 
     /* Just bail if we aren't ready to service requests yet. */
     if (!g_plugin_started || !mep_oktodo(pb))
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
 
     /* Reload config if a config entry was added. */
     if ((sdn = mep_get_sdn(pb))) {
@@ -2469,7 +2470,7 @@ mep_add_post_op(Slapi_PBlock *pb)
 
     /* If replication, just bail. */
     if (mep_isrepl(pb)) {
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     /* Get the newly added entry. */
@@ -2478,7 +2479,7 @@ mep_add_post_op(Slapi_PBlock *pb)
     if (e) {
         /* If the entry is a tombstone, just bail. */
         if (mep_has_tombstone_value(e)) {
-            return 0;
+            return SLAPI_PLUGIN_SUCCESS;
         }
 
         /* Check if a config entry applies
@@ -2488,7 +2489,7 @@ mep_add_post_op(Slapi_PBlock *pb)
         /* Bail out if the plug-in close function was just called. */
         if (!g_plugin_started) {
             mep_config_unlock();
-            return 0;
+            return SLAPI_PLUGIN_SUCCESS;
         }
 
         mep_find_config(e, &config);
@@ -2506,7 +2507,7 @@ mep_add_post_op(Slapi_PBlock *pb)
     slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
                     "<-- mep_add_post_op\n");
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 static int
@@ -2520,7 +2521,7 @@ mep_del_post_op(Slapi_PBlock *pb)
 
     /* Just bail if we aren't ready to service requests yet. */
     if (!g_plugin_started || !mep_oktodo(pb)) {
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     /* Reload config if a config entry was deleted. */
@@ -2535,7 +2536,7 @@ mep_del_post_op(Slapi_PBlock *pb)
 
     /* If replication, just bail. */
     if (mep_isrepl(pb)) {
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     /* Get deleted entry, then go through types to find config. */
@@ -2546,7 +2547,7 @@ mep_del_post_op(Slapi_PBlock *pb)
 
         /* If the entry is a tombstone, just bail. */
         if (mep_has_tombstone_value(e)) {
-            return 0;
+            return SLAPI_PLUGIN_SUCCESS;
         }
 
         /* See if we're an origin entry . */
@@ -2575,7 +2576,7 @@ mep_del_post_op(Slapi_PBlock *pb)
     slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
                     "<-- mep_del_post_op\n");
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 static int
@@ -2593,7 +2594,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
 
     /* Just bail if we aren't ready to service requests yet. */
     if (!g_plugin_started || !mep_oktodo(pb))
-        return 0;;
+        return SLAPI_PLUGIN_SUCCESS;;
 
     /* Reload config if an existing config entry was renamed,
      * or if the new dn brings an entry into the scope of the
@@ -2606,7 +2607,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
         slapi_log_error(SLAPI_LOG_PLUGIN, MEP_PLUGIN_SUBSYSTEM,
                         "mep_modrdn_post_op: Error "
                         "retrieving post-op entry\n");
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     if ((old_sdn = mep_get_sdn(pb))) {
@@ -2620,12 +2621,12 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
 
     /* If replication, just bail. */
     if (mep_isrepl(pb)) {
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     /* If the entry is a tombstone, just bail. */
     if (mep_has_tombstone_value(post_e)) {
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     /* See if we're an origin entry . */
@@ -2647,7 +2648,7 @@ mep_modrdn_post_op(Slapi_PBlock *pb)
         if (!g_plugin_started) {
             mep_config_unlock();
             slapi_pblock_destroy(mep_pb);
-            return 0;
+            return SLAPI_PLUGIN_SUCCESS;
         }
 
         mep_find_config(post_e, &config);
@@ -2818,7 +2819,7 @@ bailmod:
         /* Bail out if the plug-in close function was just called. */
         if (!g_plugin_started) {
             mep_config_unlock();
-            return 0;
+            return SLAPI_PLUGIN_SUCCESS;
         }
 
         mep_find_config(post_e, &config);
@@ -2832,7 +2833,7 @@ bailmod:
     slapi_log_error(SLAPI_LOG_TRACE, MEP_PLUGIN_SUBSYSTEM,
                     "<-- mep_modrdn_post_op\n");
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 static int
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptpreop.c b/ldap/servers/plugins/pam_passthru/pam_ptpreop.c
index 7d9ff8b..abf93e3 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptpreop.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptpreop.c
@@ -229,7 +229,7 @@ pam_passthruauth_init( Slapi_PBlock *pb )
     slapi_log_error( SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
                      "<= pam_passthruauth_init\n" );
 
-  bail:
+bail:
     return status;
 }
 
@@ -574,7 +574,7 @@ pam_passthru_preop(Slapi_PBlock *pb, int modtype)
     Slapi_Entry *e = NULL;
     LDAPMod **mods;
     char returntext[SLAPI_DSE_RETURNTEXT_SIZE];
-    int ret = 0;
+    int ret = SLAPI_PLUGIN_SUCCESS;
 
     slapi_log_error(SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
                     "=> pam_passthru_preop\n");
@@ -640,11 +640,11 @@ pam_passthru_preop(Slapi_PBlock *pb, int modtype)
 
     }
 
-  bail:
+bail:
     /* If we are refusing the operation, return the result to the client. */
     if (ret) {
         slapi_send_ldap_result(pb, ret, NULL, returntext, 0, NULL);
-        ret = -1;
+        ret = SLAPI_PLUGIN_FAILURE;
     }
 
     slapi_log_error(SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
@@ -683,7 +683,7 @@ pam_passthru_modrdn_preop(Slapi_PBlock *pb)
 static int
 pam_passthru_postop(Slapi_PBlock *pb)
 {
-    int ret = 0;
+    int ret = SLAPI_PLUGIN_SUCCESS;
     Slapi_DN *sdn = NULL;
     Slapi_DN *new_sdn = NULL;
     Slapi_Entry *e = NULL;
@@ -737,7 +737,7 @@ pam_passthru_postop(Slapi_PBlock *pb)
     slapi_log_error(SLAPI_LOG_TRACE, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
                     "<= pam_passthru_postop\n");
 
-  bail:
+bail:
     return ret;
 }
 
diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c
index 234c322..d31f53c 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -194,7 +194,7 @@ referint_postop_del( Slapi_PBlock *pb )
 
     if (0 == refint_started) {
         /* not initialized yet */
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     if ( slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &isrepop ) != 0  ||
@@ -203,33 +203,33 @@ referint_postop_del( Slapi_PBlock *pb )
     {
         slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
             "referint_postop_del: could not get parameters\n" );
-        return( -1 );
+        return SLAPI_PLUGIN_FAILURE;
     }
     /*
      *  This plugin should only execute if the delete was successful
      *  and this is not a replicated op(unless its allowed)
      */
     if(oprc != 0 || (isrepop && !allow_repl)){
-        return( 0 );
+        return SLAPI_PLUGIN_SUCCESS;
     }
     /* get the args */
     if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0) {
         slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
             "referint_postop failed to get argc\n" );
-        return( -1 );
+        return SLAPI_PLUGIN_FAILURE;
     }
     if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0) {
         slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
             "referint_postop failed to get argv\n" );
-        return( -1 );
+        return SLAPI_PLUGIN_FAILURE;
     }
-	
+
     if(argv == NULL){
         slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
             "referint_postop_del, args are NULL\n" );
-        return( -1 );
+        return SLAPI_PLUGIN_FAILURE;
     }
-	
+
     if (argc >= 3) {
         /* argv[0] will be the delay */
         delay = atoi(argv[0]);
@@ -239,19 +239,19 @@ referint_postop_del( Slapi_PBlock *pb )
 
         if(delay == -1){
             /* integrity updating is off */
-            rc = 0;
+            rc = SLAPI_PLUGIN_SUCCESS;
         } else if(delay == 0){ /* no delay */
             /* call function to update references to entry */
             rc = update_integrity(argv, sdn, NULL, NULL, logChanges);
         } else {
             /* write the entry to integrity log */
             writeintegritylog(pb, argv[1], sdn, NULL, NULL, NULL /* slapi_get_requestor_sdn(pb) */);
-            rc = 0;
+            rc = SLAPI_PLUGIN_SUCCESS;
         }
     } else {
         slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
             "referint_postop insufficient arguments supplied\n" );
-        return( -1 );
+        return SLAPI_PLUGIN_FAILURE;
     }
 
     return( rc );
@@ -279,30 +279,30 @@ referint_postop_modrdn( Slapi_PBlock *pb )
     {
         slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
             "referint_postop_modrdn: could not get parameters\n" );
-        return( -1 );
+        return SLAPI_PLUGIN_FAILURE;
     }
     /*
      *  This plugin should only execute if the delete was successful
      *  and this is not a replicated op (unless its allowed)
      */
     if(oprc != 0 || (isrepop && !allow_repl)){
-        return( 0 );
+        return SLAPI_PLUGIN_SUCCESS;
     }
     /* get the args */
     if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0) {
         slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
             "referint_postop failed to get argv\n" );
-        return( -1 );
+        return SLAPI_PLUGIN_FAILURE;
     }
     if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0) {
         slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
             "referint_postop failed to get argv\n" );
-        return( -1 );
+        return SLAPI_PLUGIN_FAILURE;
     }
     if(argv == NULL){
         slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
             "referint_postop_modrdn, args are NULL\n" );
-        return( -1 );
+        return SLAPI_PLUGIN_FAILURE;
     }
 
     if (argc >= 3) {
@@ -314,19 +314,19 @@ referint_postop_modrdn( Slapi_PBlock *pb )
     } else {
         slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
             "referint_postop_modrdn insufficient arguments supplied\n" );
-        return( -1 );
+        return SLAPI_PLUGIN_FAILURE;
     }
 
     if(delay == -1){
         /* integrity updating is off */
-        rc = 0;
+        rc = SLAPI_PLUGIN_SUCCESS;
     } else if(delay == 0){ /* no delay */
         /* call function to update references to entry */
         rc = update_integrity(argv, sdn, newrdn, newsuperior, logChanges);
     } else {
         /* write the entry to integrity log */
         writeintegritylog(pb, argv[1], sdn, newrdn, newsuperior, NULL /* slapi_get_requestor_sdn(pb) */);
-        rc = 0;
+        rc = SLAPI_PLUGIN_SUCCESS;
     }
 
     return( rc );
@@ -720,12 +720,12 @@ update_integrity(char **argv, Slapi_DN *origSDN,
     int search_result;
     int nval = 0;
     int i, j;
-    int rc;
+    int rc = SLAPI_PLUGIN_SUCCESS;
 
     if ( argv == NULL ){
         slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
             "referint_postop required config file arguments missing\n" );
-        rc = -1;
+        rc = SLAPI_PLUGIN_FAILURE;
         goto free_and_return;
     } 
     /*
@@ -818,7 +818,7 @@ update_integrity(char **argv, Slapi_DN *origSDN,
                         slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
                             "update_integrity search (base=%s filter=%s) returned "
                             "error %d\n", search_base, filter, search_result);
-                        rc = -1;
+                        rc = SLAPI_PLUGIN_FAILURE;
                         goto free_and_return;
                     }
                 }
@@ -828,7 +828,7 @@ update_integrity(char **argv, Slapi_DN *origSDN,
         }
     }
     /* if got here, then everything good rc = 0 */
-    rc = 0;
+    rc = SLAPI_PLUGIN_SUCCESS;
 
 free_and_return:
     /* free filter and search_results_pb */
@@ -878,7 +878,7 @@ int referint_postop_start( Slapi_PBlock *pb)
             keeprunning_mutex = PR_NewLock();
             keeprunning_cv = PR_NewCondVar(keeprunning_mutex);
             keeprunning =1;
-			
+
             referint_tid = PR_CreateThread (PR_USER_THREAD,
                                referint_thread_func,
                                (void *)argv,
@@ -1075,7 +1075,7 @@ int my_fgetc(PRFileDesc *stream)
     }
 
     return retval;
-}	
+}
 
 int
 GetNextLine(char *dest, int size_dest, PRFileDesc *stream) {
@@ -1083,7 +1083,7 @@ GetNextLine(char *dest, int size_dest, PRFileDesc *stream) {
     char nextchar ='\0';
     int  done     = 0;
     int  i        = 0;
-	
+
     while(!done){
         if( ( nextchar = my_fgetc(stream) ) != 0){
             if( i < (size_dest - 1) ){
diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h
index 0fa7ee4..b2c69a3 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -217,10 +217,6 @@ int multimaster_bepreop_add (Slapi_PBlock *pb);
 int multimaster_bepreop_delete (Slapi_PBlock *pb);
 int multimaster_bepreop_modify (Slapi_PBlock *pb);
 int multimaster_bepreop_modrdn (Slapi_PBlock *pb);
-int multimaster_betxnpreop_add (Slapi_PBlock *pb);
-int multimaster_betxnpreop_delete (Slapi_PBlock *pb);
-int multimaster_betxnpreop_modify (Slapi_PBlock *pb);
-int multimaster_betxnpreop_modrdn (Slapi_PBlock *pb);
 int replica_ruv_smods_for_op (Slapi_PBlock *pb, char **uniqueid,
 	Slapi_Mods **smods);
 int multimaster_bepostop_modrdn (Slapi_PBlock *pb);
diff --git a/ldap/servers/plugins/replication/repl5_plugins.c b/ldap/servers/plugins/replication/repl5_plugins.c
index c2e95dc..4c048dc 100644
--- a/ldap/servers/plugins/replication/repl5_plugins.c
+++ b/ldap/servers/plugins/replication/repl5_plugins.c
@@ -190,13 +190,13 @@ multimaster_preop_add (Slapi_PBlock *pb)
         copy_operation_parameters(pb);
         slapi_operation_set_csngen_handler(op,
                                            (void*)replica_generate_next_csn);
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     if (!is_mmr_replica (pb))
     {
         copy_operation_parameters(pb);
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
@@ -241,7 +241,7 @@ multimaster_preop_add (Slapi_PBlock *pb)
                         slapi_ch_free ((void**)&target_uuid);
                         slapi_ch_free ((void**)&superior_uuid);
 
-                        return -1;
+                        return SLAPI_PLUGIN_FAILURE;
                     }
 
                     operation_set_csn(op, csn);                    
@@ -296,7 +296,7 @@ multimaster_preop_add (Slapi_PBlock *pb)
 
     copy_operation_parameters(pb);
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 int 
@@ -320,13 +320,13 @@ multimaster_preop_delete (Slapi_PBlock *pb)
     	slapi_operation_set_replica_attr_handler ( op, (void*)replica_get_attr );
         slapi_operation_set_csngen_handler(op,
                                            (void*)replica_generate_next_csn);
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     if (!is_mmr_replica (pb))
     {
         copy_operation_parameters(pb);
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
@@ -366,7 +366,7 @@ multimaster_preop_delete (Slapi_PBlock *pb)
                         csn_free (&csn);
                         slapi_ch_free ((void**)&target_uuid);
 
-                        return -1;
+                        return SLAPI_PLUGIN_FAILURE;
                     }
 
                     /*
@@ -396,7 +396,7 @@ multimaster_preop_delete (Slapi_PBlock *pb)
     copy_operation_parameters(pb);
     slapi_operation_set_replica_attr_handler ( op, (void*)replica_get_attr );
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 int 
@@ -419,13 +419,13 @@ multimaster_preop_modify (Slapi_PBlock *pb)
         copy_operation_parameters(pb);
         slapi_operation_set_csngen_handler(op,
                                            (void*)replica_generate_next_csn);
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     if (!is_mmr_replica (pb))
     {
         copy_operation_parameters(pb);
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
@@ -465,7 +465,7 @@ multimaster_preop_modify (Slapi_PBlock *pb)
                         csn_free (&csn);
                         slapi_ch_free ((void**)&target_uuid);
 
-                        return -1;
+                        return SLAPI_PLUGIN_FAILURE;
                     }
 
                     /*
@@ -498,7 +498,7 @@ multimaster_preop_modify (Slapi_PBlock *pb)
     }
 
     copy_operation_parameters(pb);
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 int 
@@ -521,13 +521,13 @@ multimaster_preop_modrdn (Slapi_PBlock *pb)
         copy_operation_parameters(pb);
         slapi_operation_set_csngen_handler(op,
                                            (void*)replica_generate_next_csn);
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     if (!is_mmr_replica (pb))
     {
         copy_operation_parameters(pb);
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
@@ -577,7 +577,7 @@ multimaster_preop_modrdn (Slapi_PBlock *pb)
                         slapi_ch_free ((void**)&newsuperior_uuid);
                         ldap_mods_free (modrdn_mods, 1);
 
-                        return -1;
+                        return SLAPI_PLUGIN_FAILURE;
                     }
 
                     operation_set_csn(op, csn);
@@ -625,19 +625,19 @@ multimaster_preop_modrdn (Slapi_PBlock *pb)
 
     copy_operation_parameters(pb);
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 int 
 multimaster_preop_search (Slapi_PBlock *pb)
 {
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 int 
 multimaster_preop_compare (Slapi_PBlock *pb)
 {
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 int
@@ -651,7 +651,7 @@ multimaster_ruv_search(Slapi_PBlock *pb)
         slapi_pblock_get( pb, SLAPI_OPERATION, &operation);
 
         if ((e == NULL) || (operation == NULL))
-                return 0;
+                return SLAPI_PLUGIN_SUCCESS;
 
         if (!operation_is_flag_set(operation, OP_FLAG_INTERNAL) && is_ruv_tombstone_entry(e)) {
                 /* We are about to send back the database RUV, we need to return
@@ -670,7 +670,7 @@ multimaster_ruv_search(Slapi_PBlock *pb)
                 slapi_sdn_free(&suffix_sdn);
         }
         
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
 }
 
 static void
@@ -737,7 +737,7 @@ purge_entry_state_information (Slapi_PBlock *pb)
 int 
 multimaster_bepreop_add (Slapi_PBlock *pb)
 {
-	int rc= 0;
+	int rc= SLAPI_PLUGIN_SUCCESS;
 	Slapi_Operation *op;
 	int is_replicated_operation;
 	int is_fixup_operation;
@@ -762,7 +762,7 @@ multimaster_bepreop_add (Slapi_PBlock *pb)
 int 
 multimaster_bepreop_delete (Slapi_PBlock *pb)
 {
-	int rc= 0;
+	int rc= SLAPI_PLUGIN_SUCCESS;
 	Slapi_Operation *op;
 	int is_replicated_operation;
 	int is_fixup_operation;
@@ -787,7 +787,7 @@ multimaster_bepreop_delete (Slapi_PBlock *pb)
 int 
 multimaster_bepreop_modify (Slapi_PBlock *pb)
 {
-	int rc= 0;
+	int rc= SLAPI_PLUGIN_SUCCESS;
 	Slapi_Operation *op;
 	int is_replicated_operation;
 	int is_fixup_operation;
@@ -815,7 +815,7 @@ multimaster_bepreop_modify (Slapi_PBlock *pb)
 int 
 multimaster_bepreop_modrdn (Slapi_PBlock *pb)
 {
-	int rc= 0;
+	int rc= SLAPI_PLUGIN_SUCCESS;
 	Slapi_Operation *op;
 	int is_replicated_operation;
 	int is_fixup_operation;
@@ -840,99 +840,6 @@ multimaster_bepreop_modrdn (Slapi_PBlock *pb)
 	return rc;
 }
 
-/* betxn preop's */
-int 
-multimaster_betxnpreop_add (Slapi_PBlock *pb)
-{
-	int rc= 0;
-	Slapi_Operation *op;
-	int is_replicated_operation;
-	int is_fixup_operation;
-
-	slapi_pblock_get(pb, SLAPI_OPERATION, &op);
-	is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
-	is_fixup_operation= operation_is_flag_set(op,OP_FLAG_REPL_FIXUP);
-
-	/* For replicated operations, apply URP algorithm */
-	if (!is_fixup_operation)
-	{
-		if (is_replicated_operation) { 
-			rc = urp_add_operation(pb);
-		}
-	}
-
-	return rc;
-}
-
-int 
-multimaster_betxnpreop_delete (Slapi_PBlock *pb)
-{
-	int rc= 0;
-	Slapi_Operation *op;
-	int is_replicated_operation;
-	int is_fixup_operation;
-
-	slapi_pblock_get(pb, SLAPI_OPERATION, &op);
-	is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
-	is_fixup_operation= operation_is_flag_set(op,OP_FLAG_REPL_FIXUP);
-
-	/* For replicated operations, apply URP algorithm */
-	if(!is_fixup_operation)
-	{
-		if (is_replicated_operation) {
-			rc = urp_delete_operation(pb);
-		}
-	}
-
-	return rc;
-}
-
-int 
-multimaster_betxnpreop_modify (Slapi_PBlock *pb)
-{
-	int rc= 0;
-	Slapi_Operation *op;
-	int is_replicated_operation;
-	int is_fixup_operation;
-
-	slapi_pblock_get(pb, SLAPI_OPERATION, &op);
-	is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
-	is_fixup_operation= operation_is_flag_set(op,OP_FLAG_REPL_FIXUP);
-
-	/* For replicated operations, apply URP algorithm */
-	if(!is_fixup_operation)
-	{
-		if (is_replicated_operation) {
-			rc = urp_modify_operation(pb);
-		}
-	}
-
-	return rc;
-}
-
-int 
-multimaster_betxnpreop_modrdn (Slapi_PBlock *pb)
-{
-	int rc= 0;
-	Slapi_Operation *op;
-	int is_replicated_operation;
-	int is_fixup_operation;
-
-	slapi_pblock_get(pb, SLAPI_OPERATION, &op);
-	is_replicated_operation= operation_is_flag_set(op,OP_FLAG_REPLICATED);
-	is_fixup_operation= operation_is_flag_set(op,OP_FLAG_REPL_FIXUP);
-
-	/* For replicated operations, apply URP algorithm */
-	if(!is_fixup_operation)
-	{
-		if (is_replicated_operation) {
-			rc = urp_modrdn_operation(pb);
-		}
-	}
-
-	return rc;
-}
-
 int 
 multimaster_bepostop_modrdn (Slapi_PBlock *pb)
 {
@@ -943,7 +850,7 @@ multimaster_bepostop_modrdn (Slapi_PBlock *pb)
 	{
 		urp_post_modrdn_operation (pb);
 	}
-	return 0;
+	return SLAPI_PLUGIN_SUCCESS;
 }
 
 int 
@@ -956,14 +863,14 @@ multimaster_bepostop_delete (Slapi_PBlock *pb)
 	{
 		urp_post_delete_operation (pb);
 	}
-	return 0;
+	return SLAPI_PLUGIN_SUCCESS;
 }
 
 /* postop - write to changelog */
 int 
 multimaster_postop_bind (Slapi_PBlock *pb)
 {
-	return 0;
+	return SLAPI_PLUGIN_SUCCESS;
 }
 
 int 
@@ -1018,7 +925,7 @@ multimaster_betxnpostop_modify (Slapi_PBlock *pb)
 int
 multimaster_be_betxnpostop_delete (Slapi_PBlock *pb)
 {
-    int rc = 0;
+    int rc = SLAPI_PLUGIN_SUCCESS;
     /* original betxnpost */
     rc = write_changelog_and_ruv(pb);
     /* original bepost */
@@ -1152,7 +1059,7 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
 	int rc;
 	slapi_operation_parameters *op_params = NULL;
 	Object *repl_obj;
-	int return_value = 0;
+	int return_value = SLAPI_PLUGIN_SUCCESS;
 	Replica *r;
 	Slapi_Backend *be;
 	int is_replicated_operation = 0;
@@ -1162,7 +1069,7 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
 	if ((operation_is_flag_set(op, OP_FLAG_REPL_FIXUP)) ||
 		(operation_is_flag_set(op, OP_FLAG_TOMBSTONE_ENTRY)))
 	{
-		return 0;
+		return return_value;
 	}
 
 	/* ignore operations intended for chaining backends - they will be
@@ -1174,18 +1081,18 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
 	if (!is_replicated_operation &&
 		slapi_be_is_flag_set(be,SLAPI_BE_FLAG_REMOTE_DATA))
 	{
-		return 0;
+		return return_value;
 	}
 
 	slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
 	if (rc) { /* op failed - just return */
-		return 0;
+		return return_value;
 	}
 
 	/* we only log changes for operations applied to a replica */
 	repl_obj = replica_get_replica_for_op (pb);
 	if (repl_obj == NULL)
-		return 0;
+		return return_value;
  
 	r = (Replica*)object_get_data (repl_obj);
 	PR_ASSERT (r);
@@ -1247,7 +1154,7 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
 		if( op_params->csn && is_cleaned_rid(csn_get_replicaid(op_params->csn))){
 			/* this RID has been cleaned */
 			object_release (repl_obj);
-			return 0;
+			return return_value;
 		}
 
 		/* we might have stripped all the mods - in that case we do not
@@ -1260,7 +1167,7 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
 			{
 				slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
 								"write_changelog_and_ruv: Skipped due to DISKFULL\n");
-				return 0;
+				return return_value;
 			}
 			slapi_pblock_get(pb, SLAPI_TXN, &txn);
 			rc = cl5WriteOperationTxn(repl_name, repl_gen, op_params, 
@@ -1276,7 +1183,7 @@ write_changelog_and_ruv (Slapi_PBlock *pb)
 					op_params->target_address.uniqueid,
 					op_params->operation_type,
 					csn_as_string(op_params->csn, PR_FALSE, csn_str));
-				return_value = 1;
+				return_value = SLAPI_PLUGIN_FAILURE;
 			}
 		}
 
@@ -1346,7 +1253,7 @@ process_postop (Slapi_PBlock *pb)
     if ((operation_is_flag_set(op, OP_FLAG_REPL_FIXUP)) ||
 		(operation_is_flag_set(op, OP_FLAG_TOMBSTONE_ENTRY)))
 	{
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
 	}
 
 	/* ignore operations intended for chaining backends - they will be
@@ -1358,24 +1265,27 @@ process_postop (Slapi_PBlock *pb)
 	if (!is_replicated_operation &&
 		slapi_be_is_flag_set(be,SLAPI_BE_FLAG_REMOTE_DATA))
 	{
-		return 0;
+		return SLAPI_PLUGIN_SUCCESS;
 	}
 
 	get_repl_session_id (pb, sessionid, &opcsn);
 
-    slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
+	slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
 	if (rc == LDAP_SUCCESS)
 	{
-        agmtlist_notify_all(pb);
+		agmtlist_notify_all(pb);
+		rc = SLAPI_PLUGIN_SUCCESS;
 	}
-    else if (opcsn)
+	else if (opcsn)
 	{
-        rc = cancel_opcsn (pb); 
+		rc = cancel_opcsn (pb); 
 
 		/* Don't try to get session id since conn is always null */
 		slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
 			"%s process postop: canceling operation csn\n", sessionid);
-    }
+	} else {
+		rc = SLAPI_PLUGIN_FAILURE;
+	}
 
 	/* the target unique id is set in the modify_preop above, so 
 	   we need to free it */
@@ -1469,7 +1379,7 @@ cancel_opcsn (Slapi_PBlock *pb)
         object_release (repl_obj);
     }
     
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 
diff --git a/ldap/servers/plugins/retrocl/retrocl_po.c b/ldap/servers/plugins/retrocl/retrocl_po.c
index c3d1c41..382c98a 100644
--- a/ldap/servers/plugins/retrocl/retrocl_po.c
+++ b/ldap/servers/plugins/retrocl/retrocl_po.c
@@ -581,24 +581,24 @@ int retrocl_postob (Slapi_PBlock *pb,int optype)
     
     if (slapi_be_logchanges(be) == 0) {
         LDAPDebug0Args(LDAP_DEBUG_TRACE,"not applying change if not logging\n");
-	return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
     
     if (retrocl_be_changelog == NULL || be == retrocl_be_changelog) {
         LDAPDebug0Args(LDAP_DEBUG_TRACE,"not applying change if no/cl be\n");
-	return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
 
     if (rc != LDAP_SUCCESS) {
         LDAPDebug1Arg(LDAP_DEBUG_TRACE,"not applying change if op failed %d\n",rc);
-	return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     if (slapi_op_abandoned(pb)) {
         LDAPDebug0Args(LDAP_DEBUG_PLUGIN,"not applying change if op abandoned\n");
-	return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
     curtime = current_time();
@@ -613,12 +613,12 @@ int retrocl_postob (Slapi_PBlock *pb,int optype)
 
     if (op == NULL) {
         LDAPDebug0Args(LDAP_DEBUG_TRACE,"not applying change if no op\n");
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
     }
 
 	if (operation_is_flag_set(op, OP_FLAG_TOMBSTONE_ENTRY)){
         LDAPDebug0Args(LDAP_DEBUG_TRACE,"not applying change for nsTombstone entries\n");
-        return 0;
+        return SLAPI_PLUGIN_SUCCESS;
 	}
 	
     switch ( optype ) {
diff --git a/ldap/servers/plugins/roles/roles_plugin.c b/ldap/servers/plugins/roles/roles_plugin.c
index 9db76ca..b00e9a7 100644
--- a/ldap/servers/plugins/roles/roles_plugin.c
+++ b/ldap/servers/plugins/roles/roles_plugin.c
@@ -355,7 +355,7 @@ static int roles_post_op( Slapi_PBlock *pb )
     roles_cache_change_notify(pb);
 
     slapi_log_error( SLAPI_LOG_PLUGIN, ROLES_PLUGIN_SUBSYSTEM, "<-- roles_post_op\n");
-    return 0; /* always succeed */
+    return SLAPI_PLUGIN_SUCCESS; /* always succeed */
 }
 
 static void roles_set_plugin_identity(void * identity)
diff --git a/ldap/servers/plugins/statechange/statechange.c b/ldap/servers/plugins/statechange/statechange.c
index 0b2b737..307ea75 100644
--- a/ldap/servers/plugins/statechange/statechange.c
+++ b/ldap/servers/plugins/statechange/statechange.c
@@ -110,7 +110,7 @@ void plugin_init_debug_level(int *level_ptr)
 */
 int statechange_init( Slapi_PBlock *pb )
 {
-	int ret = 0;
+	int ret = SLAPI_PLUGIN_SUCCESS;
 	Slapi_Entry *plugin_entry = NULL;
 	char *plugin_type = NULL;
 	int postadd = SLAPI_PLUGIN_POST_ADD_FN;
@@ -148,7 +148,7 @@ int statechange_init( Slapi_PBlock *pb )
     {
         slapi_log_error( SLAPI_LOG_FATAL, SCN_PLUGIN_SUBSYSTEM,
                          "statechange_init: failed to register plugin\n" );
-		ret = -1;
+		ret = SLAPI_PLUGIN_FAILURE;
     }
 
 	slapi_log_error( SLAPI_LOG_TRACE, SCN_PLUGIN_SUBSYSTEM, "<-- statechange_init\n");
@@ -163,7 +163,7 @@ int statechange_init( Slapi_PBlock *pb )
 */
 static int statechange_start( Slapi_PBlock *pb )
 {
-	int ret = 0;
+	int ret = SLAPI_PLUGIN_SUCCESS;
 
 	slapi_log_error( SLAPI_LOG_TRACE, SCN_PLUGIN_SUBSYSTEM, "--> statechange_start\n");
 
@@ -177,14 +177,14 @@ static int statechange_start( Slapi_PBlock *pb )
 	{
 		/* badness */
 		slapi_log_error( SLAPI_LOG_FATAL, SCN_PLUGIN_SUBSYSTEM, "statechange: failed to create lock\n");
-		ret = -1;
+		ret = SLAPI_PLUGIN_FAILURE;
 	}
 	else
 	{
 		if( slapi_apib_register(StateChange_v1_0_GUID, api) )
 		{
 			slapi_log_error( SLAPI_LOG_FATAL, SCN_PLUGIN_SUBSYSTEM, "statechange: failed to publish state change interface\n");
-			ret = -1;
+			ret = SLAPI_PLUGIN_FAILURE;
 		}
 	}
 
@@ -207,7 +207,7 @@ static int statechange_close( Slapi_PBlock *pb )
 
 	slapi_log_error( SLAPI_LOG_TRACE, SCN_PLUGIN_SUBSYSTEM, "<-- statechange_close\n");
 
-	return 0;
+	return SLAPI_PLUGIN_SUCCESS;
 }
 
 
@@ -251,7 +251,7 @@ static int statechange_post_op( Slapi_PBlock *pb, int modtype )
 	struct slapi_entry *e_after = NULL;
 
 	if(head == 0)
-		return 0;
+		return SLAPI_PLUGIN_SUCCESS;
 
 	slapi_log_error( SLAPI_LOG_TRACE, SCN_PLUGIN_SUBSYSTEM, "--> statechange_post_op\n");
 
@@ -317,13 +317,13 @@ bail:
 	slapi_unlock_mutex(buffer_lock);
 
 	slapi_log_error( SLAPI_LOG_TRACE, SCN_PLUGIN_SUBSYSTEM, "<-- statechange_post_op\n");
-	return 0; /* always succeed */
+	return SLAPI_PLUGIN_SUCCESS; /* always succeed */
 }
 
 
 static int _statechange_register(char *caller_id, char *dn, char *filter, void *caller_data, notify_callback func)
 {
-	int ret = -1;
+	int ret = SLAPI_PLUGIN_FAILURE;
 	SCNotify *item;
 
 	/* simple - we don't check for duplicates */
@@ -352,7 +352,7 @@ static int _statechange_register(char *caller_id, char *dn, char *filter, void *
 			slapi_ch_free_string(&item->filter);
 			slapi_ch_free_string(&writable_filter);
 			slapi_ch_free((void **)&item);
-			return -1;
+			return ret;
 		} else if (!writable_filter) {
 			item->realfilter = NULL;
 		}
@@ -375,7 +375,7 @@ static int _statechange_register(char *caller_id, char *dn, char *filter, void *
 		slapi_unlock_mutex(buffer_lock);
 		slapi_ch_free_string(&writable_filter);
 
-		ret = 0;
+		ret = SLAPI_PLUGIN_SUCCESS;
 	}
 
 	return ret;
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index 4473618..338517f 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -148,13 +148,13 @@ bail:
 static int
 usn_preop_init(Slapi_PBlock *pb)
 {
-    int rc = 0;
+    int rc = SLAPI_PLUGIN_SUCCESS;
     int predel = SLAPI_PLUGIN_PRE_DELETE_FN;
 
     if (slapi_pblock_set(pb, predel, (void *)usn_preop_delete) != 0) {
         slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
                         "usn_preop_init: failed to register preop plugin\n");
-        rc = -1;
+        rc = SLAPI_PLUGIN_FAILURE;
     }
 
     return rc;
@@ -163,7 +163,7 @@ usn_preop_init(Slapi_PBlock *pb)
 static int
 usn_bepreop_init(Slapi_PBlock *pb)
 {
-    int rc = 0;
+    int rc = SLAPI_PLUGIN_SUCCESS;
     int premod = SLAPI_PLUGIN_BE_PRE_MODIFY_FN;
     int premdn = SLAPI_PLUGIN_BE_PRE_MODRDN_FN;
 
@@ -175,7 +175,7 @@ usn_bepreop_init(Slapi_PBlock *pb)
         (slapi_pblock_set(pb, premdn, (void *)usn_bepreop_modify) != 0)) {
         slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
                        "usn_bepreop_init: failed to register bepreop plugin\n");
-        rc = -1;
+        rc = SLAPI_PLUGIN_FAILURE;
     }
 
     return rc;
@@ -184,7 +184,7 @@ usn_bepreop_init(Slapi_PBlock *pb)
 static int
 usn_betxnpreop_init(Slapi_PBlock *pb)
 {
-    int rc = 0;
+    int rc = SLAPI_PLUGIN_SUCCESS;
     int preadd = SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN;
     int predel = SLAPI_PLUGIN_BE_TXN_PRE_DELETE_TOMBSTONE_FN;
 
@@ -192,7 +192,7 @@ usn_betxnpreop_init(Slapi_PBlock *pb)
         (slapi_pblock_set(pb, predel, (void *)usn_betxnpreop_delete) != 0)) { 
         slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
                  "usn_betxnpreop_init: failed to register betxnpreop plugin\n");
-        rc = -1;
+        rc = SLAPI_PLUGIN_FAILURE;
     }
 
     return rc;
@@ -201,7 +201,7 @@ usn_betxnpreop_init(Slapi_PBlock *pb)
 static int
 usn_bepostop_init(Slapi_PBlock *pb)
 {
-    int rc = 0;
+    int rc = SLAPI_PLUGIN_SUCCESS;
     Slapi_Entry *plugin_entry = NULL;
     char *plugin_type = NULL;
     int postadd = SLAPI_PLUGIN_BE_POST_ADD_FN;
@@ -227,7 +227,7 @@ usn_bepostop_init(Slapi_PBlock *pb)
         (slapi_pblock_set(pb, postmdn, (void *)usn_bepostop) != 0)) {
         slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
                      "usn_bepostop_init: failed to register bepostop plugin\n");
-        rc = -1;
+        rc = SLAPI_PLUGIN_FAILURE;
     }
 
     return rc;
@@ -236,12 +236,12 @@ usn_bepostop_init(Slapi_PBlock *pb)
 static int
 usn_rootdse_init()
 {
-    int rc = -1;
+    int rc = SLAPI_PLUGIN_FAILURE;
 
     if (slapi_config_register_callback(SLAPI_OPERATION_SEARCH, DSE_FLAG_PREOP,
                                         "", LDAP_SCOPE_BASE, "(objectclass=*)", 
                                         usn_rootdse_search, NULL)) {
-        rc = 0;
+        rc = SLAPI_PLUGIN_SUCCESS;
     }
 
     return rc;
@@ -254,7 +254,7 @@ usn_rootdse_init()
 static int
 usn_start(Slapi_PBlock *pb)
 {
-    int rc = 0;
+    int rc = SLAPI_PLUGIN_SUCCESS;
     Slapi_Value *value;
 
     slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM, "--> usn_start\n");
@@ -262,6 +262,7 @@ usn_start(Slapi_PBlock *pb)
     rc = usn_rootdse_init();
     rc |= usn_cleanup_start(pb);
     if (rc) {
+        rc = SLAPI_PLUGIN_FAILURE;
         goto bail;
     }
     if (0) { /* Not executed; test code for slapi_get_plugin_default_config */
@@ -284,7 +285,9 @@ usn_start(Slapi_PBlock *pb)
     /* add nsds5ReplicatedAttributeList: (objectclass=*) $ EXCLUDE entryusn 
      * to cn=plugin default config,cn=config */
     value = slapi_value_new_string("(objectclass=*) $ EXCLUDE entryusn");
-    rc = slapi_set_plugin_default_config("nsds5ReplicatedAttributeList", value);
+    if (slapi_set_plugin_default_config("nsds5ReplicatedAttributeList", value)) {
+        rc = SLAPI_PLUGIN_FAILURE;
+    }
     slapi_value_free(&value);
     g_plugin_started = 1;
 bail:
@@ -302,7 +305,7 @@ usn_close(Slapi_PBlock *pb)
 
     slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM, "<-- usn_close\n");
 
-    return 0;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 /* 
@@ -311,7 +314,6 @@ usn_close(Slapi_PBlock *pb)
 static int
 usn_preop_delete(Slapi_PBlock *pb)
 {
-    int rc = 0;
     Slapi_Operation *op = NULL;
 
     slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
@@ -323,7 +325,7 @@ usn_preop_delete(Slapi_PBlock *pb)
     slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
                     "<-- usn_preop_delete\n");
 
-    return rc;
+    return SLAPI_PLUGIN_SUCCESS;
 }
 
 static void
@@ -407,7 +409,7 @@ usn_betxnpreop_add(Slapi_PBlock *pb)
 {
     Slapi_Entry *e = NULL;
     Slapi_Backend *be = NULL;
-    int rc = LDAP_SUCCESS;
+    int rc = SLAPI_PLUGIN_SUCCESS;
 
     slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
                     "--> usn_betxnpreop_add\n");
@@ -416,11 +418,15 @@ usn_betxnpreop_add(Slapi_PBlock *pb)
     slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e);
     if (NULL == e) {
         rc = LDAP_NO_SUCH_OBJECT;    
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+        rc = SLAPI_PLUGIN_FAILURE;
         goto bail;
     }
     slapi_pblock_get(pb, SLAPI_BACKEND, &be);
     if (NULL == be) {
         rc = LDAP_PARAM_ERROR;    
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+        rc = SLAPI_PLUGIN_FAILURE;
         goto bail;
     }
     _usn_add_next_usn(e, be);
@@ -439,7 +445,7 @@ usn_betxnpreop_delete(Slapi_PBlock *pb)
 {
     Slapi_Entry *e = NULL;
     Slapi_Backend *be = NULL;
-    int rc = LDAP_SUCCESS;
+    int rc = SLAPI_PLUGIN_SUCCESS;
 
     slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
                     "--> usn_betxnpreop_delete\n");
@@ -448,11 +454,15 @@ usn_betxnpreop_delete(Slapi_PBlock *pb)
     slapi_pblock_get(pb, SLAPI_DELETE_BEPREOP_ENTRY, &e);
     if (NULL == e) {
         rc = LDAP_NO_SUCH_OBJECT;    
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+        rc = SLAPI_PLUGIN_FAILURE;
         goto bail;
     }
     slapi_pblock_get(pb, SLAPI_BACKEND, &be);
     if (NULL == be) {
         rc = LDAP_PARAM_ERROR;    
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+        rc = SLAPI_PLUGIN_FAILURE;
         goto bail;
     }
     _usn_add_next_usn(e, be);
@@ -472,7 +482,7 @@ usn_bepreop_modify (Slapi_PBlock *pb)
 {
     LDAPMod **mods = NULL;
     Slapi_Backend *be = NULL;
-    int rc = LDAP_SUCCESS;
+    int rc = SLAPI_PLUGIN_SUCCESS;
 
     slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
                     "--> usn_bepreop_modify\n");
@@ -483,6 +493,9 @@ usn_bepreop_modify (Slapi_PBlock *pb)
     if (NULL == be) {
         slapi_log_error(SLAPI_LOG_FATAL, USN_PLUGIN_SUBSYSTEM,
                     "usn_bepreop_modify: no backend.\n");
+        rc = LDAP_PARAM_ERROR;    
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+        rc = SLAPI_PLUGIN_FAILURE;
         goto bail;
     }
     if (LDAP_SUCCESS == _usn_mod_next_usn(&mods, be)) {
@@ -498,7 +511,7 @@ bail:
 static int
 usn_bepostop (Slapi_PBlock *pb)
 {
-    int rc = -1;
+    int rc = SLAPI_PLUGIN_FAILURE;
     Slapi_Backend *be = NULL;
 
     slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
@@ -507,12 +520,16 @@ usn_bepostop (Slapi_PBlock *pb)
     /* if op is not successful, don't increment the counter */
     slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
     if (LDAP_SUCCESS != rc) {
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+        rc = SLAPI_PLUGIN_FAILURE;
         goto bail;
     }
 
     slapi_pblock_get(pb, SLAPI_BACKEND, &be);
     if (NULL == be) {
         rc = LDAP_PARAM_ERROR;    
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+        rc = SLAPI_PLUGIN_FAILURE;
         goto bail;
     }
 
@@ -529,7 +546,7 @@ bail:
 static int
 usn_bepostop_modify (Slapi_PBlock *pb)
 {
-    int rc = -1;
+    int rc = SLAPI_PLUGIN_FAILURE;
     Slapi_Backend *be = NULL;
     LDAPMod **mods = NULL;
     int i;
@@ -540,6 +557,7 @@ usn_bepostop_modify (Slapi_PBlock *pb)
     /* if op is not successful, don't increment the counter */
     slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
     if (LDAP_SUCCESS != rc) {
+        rc = SLAPI_PLUGIN_FAILURE;
         goto bail;
     }
 
@@ -560,6 +578,8 @@ usn_bepostop_modify (Slapi_PBlock *pb)
     slapi_pblock_get(pb, SLAPI_BACKEND, &be);
     if (NULL == be) {
         rc = LDAP_PARAM_ERROR;    
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+        rc = SLAPI_PLUGIN_FAILURE;
         goto bail;
     }
 
@@ -577,7 +597,7 @@ bail:
 static int
 usn_bepostop_delete (Slapi_PBlock *pb)
 {
-    int rc = -1;
+    int rc = SLAPI_PLUGIN_FAILURE;
     Slapi_Backend *be = NULL;
 
     slapi_log_error(SLAPI_LOG_TRACE, USN_PLUGIN_SUBSYSTEM,
@@ -586,12 +606,15 @@ usn_bepostop_delete (Slapi_PBlock *pb)
     /* if op is not successful, don't increment the counter */
     slapi_pblock_get(pb, SLAPI_RESULT_CODE, &rc);
     if (LDAP_SUCCESS != rc) {
+        rc = SLAPI_PLUGIN_FAILURE;
         goto bail;
     }
 
     slapi_pblock_get(pb, SLAPI_BACKEND, &be);
     if (NULL == be) {
         rc = LDAP_PARAM_ERROR;    
+        slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
+        rc = SLAPI_PLUGIN_FAILURE;
         goto bail;
     }
 
diff --git a/ldap/servers/plugins/views/views.c b/ldap/servers/plugins/views/views.c
index 0892b0d..c6fd628 100644
--- a/ldap/servers/plugins/views/views.c
+++ b/ldap/servers/plugins/views/views.c
@@ -185,7 +185,7 @@ void * view_get_plugin_identity()
 */
 int views_init( Slapi_PBlock *pb )
 {
-	int ret = 0;
+	int ret = SLAPI_PLUGIN_SUCCESS;
 	void * plugin_identity=NULL;
 
 	slapi_log_error( SLAPI_LOG_TRACE, VIEWS_PLUGIN_SUBSYSTEM, "--> views_init\n");
@@ -209,7 +209,7 @@ int views_init( Slapi_PBlock *pb )
     {
         slapi_log_error( SLAPI_LOG_FATAL, VIEWS_PLUGIN_SUBSYSTEM,
                          "views_init: failed to register plugin\n" );
-		ret = -1;
+		ret = SLAPI_PLUGIN_FAILURE;
     }
 
 	slapi_log_error( SLAPI_LOG_TRACE, VIEWS_PLUGIN_SUBSYSTEM, "<-- views_init\n");
@@ -238,7 +238,7 @@ void views_unlock()
 */
 static int views_start( Slapi_PBlock *pb )
 {
-	int ret = 0;
+	int ret = SLAPI_PLUGIN_SUCCESS;
 	void **statechange_api;
 
 	slapi_log_error( SLAPI_LOG_TRACE, VIEWS_PLUGIN_SUBSYSTEM, "--> views_start\n");
@@ -270,7 +270,7 @@ static int views_start( Slapi_PBlock *pb )
 	if( slapi_apib_register(Views_v1_0_GUID, api) )
 	{
 		slapi_log_error( SLAPI_LOG_FATAL, VIEWS_PLUGIN_SUBSYSTEM, "views: failed to publish views interface\n");
-		ret = -1;
+		ret = SLAPI_PLUGIN_FAILURE;
 	}
 
 	slapi_log_error( SLAPI_LOG_TRACE, VIEWS_PLUGIN_SUBSYSTEM, "<-- views_start\n");
@@ -296,7 +296,7 @@ static int _internal_api_views_entry_dn_exists(char *view_dn, char *e_dn)
 
 static int _internal_api_views_entry_exists_general(char *view_dn, Slapi_Entry *e, char *e_dn)
 {
-	int ret = 0;
+	int ret = SLAPI_PLUGIN_SUCCESS;
 	viewEntry *view;
 	char *dn;
 
@@ -326,7 +326,7 @@ static int _internal_api_views_entry_exists_general(char *view_dn, Slapi_Entry *
 	if(slapi_dn_issuffix(dn, view_dn))
 	{
 		/* this entry is physically contained in the view hiearchy */
-		ret = -1;
+		ret = SLAPI_PLUGIN_FAILURE;
 		goto bail;
 	}
 
@@ -346,7 +346,7 @@ static int _internal_api_views_entry_exists_general(char *view_dn, Slapi_Entry *
 		if(0==slapi_filter_test_simple(e,view->includeAncestorFiltersFilter))
 		{
 			/* this entry would appear in the view */
-			ret = -1;
+			ret = SLAPI_PLUGIN_FAILURE;
 		}
 	}
 
@@ -408,7 +408,7 @@ static int views_close( Slapi_PBlock *pb )
 
 	slapi_log_error( SLAPI_LOG_TRACE, VIEWS_PLUGIN_SUBSYSTEM, "<-- views_close\n");
 
-	return 0;
+	return SLAPI_PLUGIN_SUCCESS;
 }
 
 
@@ -419,7 +419,7 @@ static int views_close( Slapi_PBlock *pb )
 */
 static int views_cache_create()
 {
-	int ret = -1;
+	int ret = SLAPI_PLUGIN_FAILURE;
 
 	slapi_log_error( SLAPI_LOG_TRACE, VIEWS_PLUGIN_SUBSYSTEM, "--> views_cache_create\n");
 
@@ -474,7 +474,7 @@ static int views_cache_create()
 	{
 		/* its ok to not have views to cache */
 		theCache.cache_built = 0;
-		ret = 0;
+		ret = SLAPI_PLUGIN_SUCCESS;
 	}
 
 	theCache.currentUpdaterThread = 0;
@@ -530,7 +530,7 @@ int views_cache_dn_compare(const void *e1, const void *e2)
  */
 static int views_cache_index()
 {
-	int ret = -1;
+	int ret = SLAPI_PLUGIN_FAILURE;
 	int i;
 	viewEntry *theView = theCache.pCacheViews;
 	viewEntry *current = 0;
@@ -558,7 +558,7 @@ static int views_cache_index()
 		/* sort the views */
 		qsort(theCache.ppViewIndex, theCache.view_count, sizeof(viewEntry*), views_cache_view_compare);
 
-		ret = 0;
+		ret = SLAPI_PLUGIN_SUCCESS;
 	}
 
 	return ret;
@@ -569,7 +569,7 @@ static int views_cache_index()
 	views_cache_view_index_bsearch - RECURSIVE
 	----------------------------------------
 	performs a binary search on the cache view index
-	return -1 if key is not found
+	return SLAPI_PLUGIN_FAILURE if key is not found
 */
 viewEntry *views_cache_view_index_bsearch( const char *key, int lower, int upper )
 {
@@ -617,7 +617,7 @@ viewEntry *views_cache_view_index_bsearch( const char *key, int lower, int upper
 */
 static viewEntry *views_cache_find_view(char *view)
 {
-	viewEntry *ret = 0;  /* assume failure */
+	viewEntry *ret = SLAPI_PLUGIN_SUCCESS;  /* assume failure */
 
 	if(theCache.view_count != 1)
 		ret = views_cache_view_index_bsearch(view, 0, theCache.view_count-1);
@@ -1119,7 +1119,7 @@ static void views_cache_create_inclusion_filter(viewEntry *pView)
 */
 static int views_cache_build_view_list(viewEntry **pViews)
 {
-	int ret = 0;
+	int ret = SLAPI_PLUGIN_SUCCESS;
 	Slapi_PBlock *pSuffixSearch = 0;
 	Slapi_Entry **pSuffixList = 0;
 	Slapi_Attr *suffixAttr;
@@ -1192,7 +1192,7 @@ static int views_cache_build_view_list(viewEntry **pViews)
 	else
 	{
 		slapi_log_error(SLAPI_LOG_PLUGIN, VIEWS_PLUGIN_SUBSYSTEM, "views_cache_build_view_list: failed to find suffixes\n");
-		ret = -1;
+		ret = SLAPI_PLUGIN_FAILURE;
 	}
 
 	/* clean up */
@@ -1215,7 +1215,8 @@ struct dn_views_info {
 
 /* does same funcationality as views_add_dn_views except it is invoked via a callback */
 
-static int	views_dn_views_cb (Slapi_Entry* e, void *callback_data) {
+static int	views_dn_views_cb (Slapi_Entry* e, void *callback_data)
+{
 	struct dn_views_info *info;
 	char *pDn = 0;
 	struct berval **dnVals;
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index b2319fa..0695727 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -714,7 +714,7 @@ static void op_shared_add (Slapi_PBlock *pb)
 	sdn = slapi_sdn_dup(slapi_entry_get_sdn_const(e));
 	slapi_pblock_set(pb, SLAPI_ADD_TARGET_SDN, (void *)sdn);
 	if (plugin_call_plugins(pb, internal_op ? SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN :
-	                        SLAPI_PLUGIN_PRE_ADD_FN) == 0)
+	                        SLAPI_PLUGIN_PRE_ADD_FN) == SLAPI_PLUGIN_SUCCESS)
 	{
 		int	rc;
 		Slapi_Entry	*ec;
diff --git a/ldap/servers/slapd/delete.c b/ldap/servers/slapd/delete.c
index ced6351..68409c7 100644
--- a/ldap/servers/slapd/delete.c
+++ b/ldap/servers/slapd/delete.c
@@ -353,7 +353,7 @@ static void op_shared_delete (Slapi_PBlock *pb)
 	 * post-delete plugins.
 	 */
 	if (plugin_call_plugins(pb, internal_op ? SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN : 
-							SLAPI_PLUGIN_PRE_DELETE_FN) == 0)
+							SLAPI_PLUGIN_PRE_DELETE_FN) == SLAPI_PLUGIN_SUCCESS)
 	{
 		int	rc;
 
diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c
index cc1621b..0a8854b 100644
--- a/ldap/servers/slapd/modify.c
+++ b/ldap/servers/slapd/modify.c
@@ -1050,7 +1050,7 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw)
 	 */
 	slapi_pblock_set (pb, SLAPI_MODIFY_MODS, (void*)slapi_mods_get_ldapmods_passout (&smods));
 	if (plugin_call_plugins(pb, internal_op ? SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN : 
-							SLAPI_PLUGIN_PRE_MODIFY_FN) == 0)
+							SLAPI_PLUGIN_PRE_MODIFY_FN) == SLAPI_PLUGIN_SUCCESS)
 	{
 		int	rc;
 
diff --git a/ldap/servers/slapd/modrdn.c b/ldap/servers/slapd/modrdn.c
index e1d2440..457c2b0 100644
--- a/ldap/servers/slapd/modrdn.c
+++ b/ldap/servers/slapd/modrdn.c
@@ -642,7 +642,7 @@ op_shared_rename(Slapi_PBlock *pb, int passin_args)
 	 * post-modrdn plugins.
 	 */
 	if (plugin_call_plugins(pb, internal_op ? SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN :
-							SLAPI_PLUGIN_PRE_MODRDN_FN) == 0)
+							SLAPI_PLUGIN_PRE_MODRDN_FN) == SLAPI_PLUGIN_SUCCESS)
 	{
 		int	rc= LDAP_OPERATIONS_ERROR;
 		slapi_pblock_set(pb, SLAPI_PLUGIN, be->be_database);
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index 52b9c3c..aa33b02 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -1453,9 +1453,8 @@ plugin_call_func (struct slapdplugin *list, int operation, Slapi_PBlock *pb, int
 			if (( rc = func (pb)) != 0 )
 			{
 				if (SLAPI_PLUGIN_PREOPERATION == list->plg_type ||
-					SLAPI_PLUGIN_INTERNAL_PREOPERATION == list->plg_type ||
-					SLAPI_PLUGIN_BETXNPREOPERATION == list->plg_type ||
-                    SLAPI_PLUGIN_START_FN == operation )
+				    SLAPI_PLUGIN_INTERNAL_PREOPERATION == list->plg_type ||
+				    SLAPI_PLUGIN_START_FN == operation )
 				{
 					/*
 					 * We bail out of plugin processing for preop plugins
@@ -1465,13 +1464,18 @@ plugin_call_func (struct slapdplugin *list, int operation, Slapi_PBlock *pb, int
 					 */
 					return_value = rc;
 					break;
-				} else if (SLAPI_PLUGIN_BEPREOPERATION == list->plg_type ||
-					SLAPI_PLUGIN_BEPOSTOPERATION == list->plg_type)
+				}
+				else if (SLAPI_PLUGIN_BEPREOPERATION == list->plg_type ||
+				         SLAPI_PLUGIN_BETXNPREOPERATION == list->plg_type ||
+				         SLAPI_PLUGIN_BEPOSTOPERATION == list->plg_type)
 				{
-					/* respect fatal error (-1); should not OR it */
-					if (-1 == rc) {
+					/* 
+					 * respect fatal error SLAPI_PLUGIN_FAILURE (-1);
+					 * should not OR it.
+					 */
+					if (SLAPI_PLUGIN_FAILURE == rc) {
 						return_value = rc;
-					} else if (-1 != return_value) {
+					} else if (SLAPI_PLUGIN_FAILURE != return_value) {
 						/* OR the result into the return value 
 						 * for be pre/postops */
 						return_value |= rc;
@@ -3233,4 +3237,4 @@ slapi_disordely_shutdown(PRBool set)
         is_disordely_shutdown = PR_TRUE;
     }
     return (is_disordely_shutdown);
-}
\ No newline at end of file
+}
-- 
1.8.1.4

