amoralej / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 years ago
Clone
Blob Blame History Raw
From a9135e8b535bc58a986d4b19b05e6ce2718c07aa Mon Sep 17 00:00:00 2001
From: Mark Reynolds <mreynolds@redhat.com>
Date: Thu, 11 Feb 2016 16:18:00 -0500
Subject: [PATCH 97/99] Ticket 47788 - Only check postop result if its a
 replication operation

Bug Description:  With IPA tests, without using replication, an error is
                  being triggered that is stoipping nomral updates from
                  going through.

Fix Description:  Move the error checking up into the code block above
                  which only executes for replicated operations.

https://fedorahosted.org/389/ticket/47788

Reviewed by: nhosoi & tbordaz(Thanks!!)

(cherry picked from commit d7b598da2eff95070936bf7c3e01bcd11c44ed60)
(cherry picked from commit bd254a2eea380ade90700b22567e1d9063890f02)
---
 ldap/servers/plugins/replication/repl5_plugins.c | 87 ++++++++++++------------
 1 file changed, 44 insertions(+), 43 deletions(-)

diff --git a/ldap/servers/plugins/replication/repl5_plugins.c b/ldap/servers/plugins/replication/repl5_plugins.c
index c2fa214..bb43b9b 100644
--- a/ldap/servers/plugins/replication/repl5_plugins.c
+++ b/ldap/servers/plugins/replication/repl5_plugins.c
@@ -1306,54 +1306,55 @@ process_postop (Slapi_PBlock *pb)
 			slapi_pblock_get( pb, SLAPI_OPERATION_PARAMETERS, &op_params );
 			slapi_ch_free((void **) &op_params->p.p_modrdn.modrdn_newsuperior_address.uniqueid);
 		}
-	}
-	if (!ignore_error_and_keep_going(retval)){
-		/*
-		 * We have an error we can't ignore.  Release the replica and close
-		 * the connection to stop the replication session.
-		 */
-		consumer_connection_extension *connext = NULL;
-		Slapi_Connection *conn = NULL;
-		char csn_str[CSN_STRSIZE] = {'\0'};
-		PRUint64 connid = 0;
-		int opid = 0;
 
-		slapi_pblock_get(pb, SLAPI_CONNECTION, &conn);
-		slapi_pblock_get(pb, SLAPI_OPERATION_ID, &opid);
-		slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
-		if (conn)
-		{
-			slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
-				"process_postop: Failed to apply update (%s) error (%d).  "
-				"Aborting replication session(conn=%" NSPRIu64 " op=%d)\n",
-				csn_as_string(opcsn, PR_FALSE, csn_str), retval,
-				connid, opid);
+		if (!ignore_error_and_keep_going(retval)){
 			/*
-			 * Release this replica so new sessions can begin
+			 * We have an error we can't ignore.  Release the replica and close
+			 * the connection to stop the replication session.
 			 */
-			connext = consumer_connection_extension_acquire_exclusive_access(conn, connid, opid);
-			if (connext && connext->replica_acquired)
+			consumer_connection_extension *connext = NULL;
+			Slapi_Connection *conn = NULL;
+			char csn_str[CSN_STRSIZE] = {'\0'};
+			PRUint64 connid = 0;
+			int opid = 0;
+
+			slapi_pblock_get(pb, SLAPI_CONNECTION, &conn);
+			slapi_pblock_get(pb, SLAPI_OPERATION_ID, &opid);
+			slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
+			if (conn)
 			{
-				int zero = 0;
-				Replica *r = (Replica*)object_get_data ((Object*)connext->replica_acquired);
-
-				replica_relinquish_exclusive_access(r, connid, opid);
-				object_release ((Object*)connext->replica_acquired);
-				connext->replica_acquired = NULL;
-				connext->isreplicationsession = 0;
-				slapi_pblock_set( pb, SLAPI_CONN_IS_REPLICATION_SESSION, &zero );
-			}
-			if (connext){
-				consumer_connection_extension_relinquish_exclusive_access(conn, connid, opid, PR_FALSE);
-			}
+				slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+					"process_postop: Failed to apply update (%s) error (%d).  "
+					"Aborting replication session(conn=%" NSPRIu64 " op=%d)\n",
+					csn_as_string(opcsn, PR_FALSE, csn_str), retval,
+					connid, opid);
+				/*
+				 * Release this replica so new sessions can begin
+				 */
+				connext = consumer_connection_extension_acquire_exclusive_access(conn, connid, opid);
+				if (connext && connext->replica_acquired)
+				{
+					int zero = 0;
+					Replica *r = (Replica*)object_get_data ((Object*)connext->replica_acquired);
+
+					replica_relinquish_exclusive_access(r, connid, opid);
+					object_release ((Object*)connext->replica_acquired);
+					connext->replica_acquired = NULL;
+					connext->isreplicationsession = 0;
+					slapi_pblock_set( pb, SLAPI_CONN_IS_REPLICATION_SESSION, &zero );
+				}
+				if (connext){
+					consumer_connection_extension_relinquish_exclusive_access(conn, connid, opid, PR_FALSE);
+				}
 
-			/*
-			 * Close the connection to end the current session with the
-			 * supplier.  This prevents new updates from coming in and
-			 * updating the consumer RUV - which would cause this failed
-			 * update to be never be replayed.
-			 */
-			slapi_disconnect_server(conn);
+				/*
+				 * Close the connection to end the current session with the
+				 * supplier.  This prevents new updates from coming in and
+				 * updating the consumer RUV - which would cause this failed
+				 * update to be never be replayed.
+				 */
+				slapi_disconnect_server(conn);
+			}
 		}
 	}
 	if (NULL == opcsn)
-- 
2.4.11