andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
Blob Blame History Raw
From af4c7884bb714ede42b08eed3cc321cbb3c5e33c Mon Sep 17 00:00:00 2001
From: Mark Reynolds <mreynolds@redhat.com>
Date: Thu, 18 Dec 2014 09:08:52 -0500
Subject: [PATCH 285/305] Ticket 47750 - During delete operation do not refresh
 cache entry if it is a tombstone

Bug Description:  After calling the betxn postop plugins do not attempt to refresh the
                  entry if it was converted to a tombstone.  A tombstone entry does
                  not have its entry mutex allocated, and it will be dereferenced.

Fix Description:  If the entry is converted to a tombstone, there is no need to
                  refresh it in the first place.  Skip the cache refresh if its a
                  tombstone.  If its not a tombstone, we also need to return the
                  cache entry if it was not changed in betxn postop, because we
                  incremented its refcnt while checking if it was updated.

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

Reviewed by: nhosoi(Thanks!)

(cherry picked from commit 4ae67943e807b869aeda213dcd39b59feb5f8259)
(cherry picked from commit 83ecd4509b28f6d6b0cd210cd767d6b29026c182)
---
 ldap/servers/slapd/back-ldbm/ldbm_delete.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index e86d45f..48058d6 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -1116,12 +1116,15 @@ ldbm_back_delete( Slapi_PBlock *pb )
 
 	/* delete from cache and clean up */
 	if (e) {
-		struct backentry *old_e = e;
-
-		e = cache_find_id(&inst->inst_cache,e->ep_id);
-		if(e != old_e){
-			/* return the old entry, and proceed with the new one */
-			CACHE_RETURN(&inst->inst_cache, &old_e);
+		if(!create_tombstone_entry){
+			struct backentry *old_e = e;
+			e = cache_find_id(&inst->inst_cache,e->ep_id);
+			if(e != old_e){
+				cache_unlock_entry(&inst->inst_cache, old_e);
+				CACHE_RETURN(&inst->inst_cache, &old_e);
+			} else {
+				CACHE_RETURN(&inst->inst_cache, &e);
+			}
 		}
 		if (cache_is_in_cache(&inst->inst_cache, e)) {
 			ep_id = e->ep_id;
-- 
1.9.3