Blob Blame Raw
From 8f54c897c404164c618c808435d3887e62d32915 Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Tue, 7 Oct 2014 14:02:20 -0700
Subject: [PATCH 79/84] Ticket #47912 - Proper handling of "No
 original_tombstone for changenumber" errors

Bug Description: As analyzed by Ludwig Krispen in
  https://fedorahosted.org/389/ticket/47912#comment:1,
an error message "No original_tombstone for ..." is always logged
if original_tombstone does not exist.  It should be just for the
case create_tombstone_entry.

Fix Description: This patch place the original_tombstone handling
in "if (create_tombstone_entry)" clause.

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

Reviewed by lkrispen@redhat.com (Thank you, Ludwig!!)

(cherry picked from commit 36381c120773872d3d4d2cb2417f155e6ac790a6)
---
 ldap/servers/slapd/back-ldbm/ldbm_delete.c | 48 +++++++++++++++---------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index 56ea3df..3de8efa 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -225,33 +225,33 @@ ldbm_back_delete( Slapi_PBlock *pb )
 			free_delete_existing_entry = 1; /* must free the dup */
 			if (create_tombstone_entry) {
 				slapi_sdn_set_ndn_byval(&nscpEntrySDN, slapi_sdn_get_ndn(slapi_entry_get_sdn(e->ep_entry)));
-			}
 
-			/* reset tombstone entry */
-			if (original_tombstone) {
-				/* must duplicate tombstone before returning it to cache,
-				 * which could free the entry. */
-				if ( (tmptombstone = backentry_dup( original_tombstone )) == NULL ) {
-					ldap_result_code= LDAP_OPERATIONS_ERROR;
-					goto error_return;
-				}
-				if (cache_is_in_cache(&inst->inst_cache, tombstone)) {
-					CACHE_REMOVE(&inst->inst_cache, tombstone);
-				}
-				CACHE_RETURN(&inst->inst_cache, &tombstone);
-				if (tombstone) {
+				/* reset tombstone entry */
+				if (original_tombstone) {
+					/* must duplicate tombstone before returning it to cache,
+					 * which could free the entry. */
+					if ( (tmptombstone = backentry_dup( original_tombstone )) == NULL ) {
+						ldap_result_code= LDAP_OPERATIONS_ERROR;
+						goto error_return;
+					}
+					if (cache_is_in_cache(&inst->inst_cache, tombstone)) {
+						CACHE_REMOVE(&inst->inst_cache, tombstone);
+					}
+					CACHE_RETURN(&inst->inst_cache, &tombstone);
+					if (tombstone) {
+						slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_delete", 
+						                "conn=%lu op=%d [retry: %d] tombstone %s is not freed!!! refcnt %d, state %d\n",
+						                conn_id, op_id, retry_count, slapi_entry_get_dn(tombstone->ep_entry),
+						                tombstone->ep_refcnt, tombstone->ep_state);
+					}
+					tombstone = original_tombstone;
+					original_tombstone = tmptombstone;
+					tmptombstone = NULL;
+				} else {
 					slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_delete", 
-					                "conn=%lu op=%d [retry: %d] tombstone %s is not freed!!! refcnt %d, state %d\n",
-					                conn_id, op_id, retry_count, slapi_entry_get_dn(tombstone->ep_entry),
-					                tombstone->ep_refcnt, tombstone->ep_state);
+					                "conn=%lu op=%d [retry: %d] No original_tombstone for %s!!\n",
+					                conn_id, op_id, retry_count, slapi_entry_get_dn(e->ep_entry));
 				}
-				tombstone = original_tombstone;
-				original_tombstone = tmptombstone;
-				tmptombstone = NULL;
-			} else {
-				slapi_log_error(SLAPI_LOG_FATAL, "ldbm_back_delete", 
-				                "conn=%lu op=%d [retry: %d] No original_tombstone for %s!!\n",
-				                conn_id, op_id, retry_count, slapi_entry_get_dn(e->ep_entry));
 			}
 			if (ruv_c_init) {
 				/* reset the ruv txn stuff */
-- 
1.9.3