1
0
Эх сурвалжийг харах

Ticket #47897 - Need to move slapi_pblock_set(pb, SLAPI_MODRDN_EXISTING_ENTRY, original_entry->ep_entry) prior to original_entry overwritten

Bug Description: In the DEADLOCK retry code in ldbm_back_modrdn,
SLAPI_MODRDN_EXISTING_ENTRY in pblock is reset with the new entry
to be renamed.  The location of the setting entry was inappropriate,
thus instead of the entry, but its backup is set in pblock.

Fix Description: Moving the slapi_pblock_set(SLAPI_MODRDN_EXISTING_
ENTRY) to the correct position.

Plus, in the DEADLOCK retry code, original_entry is duplicated and
used for the next loop.  The source of the duplication has to be
the clean entry before updated in the backend code, but in ldbm_add,
ldbm_modify, and ldbm_modrdn, the current entry was duplicated and
set to the original entry, which could have been updated in the
previous loop.  This patch fixes it, as well.

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

Reviewed by [email protected] (Thank you, Theirry!!)
Noriko Hosoi 11 жил өмнө
parent
commit
2aabb017bd

+ 1 - 1
ldap/servers/slapd/back-ldbm/ldbm_add.c

@@ -225,7 +225,7 @@ ldbm_back_add( Slapi_PBlock *pb )
 			slapi_pblock_set(pb, SLAPI_TXN, parent_txn);
 			/* must duplicate addingentry before returning it to cache,
 			 * which could free the entry. */
-			if ( (tmpentry = backentry_dup( addingentry )) == NULL ) {
+			if ((tmpentry = backentry_dup(originalentry?originalentry:addingentry)) == NULL) {
 				ldap_result_code= LDAP_OPERATIONS_ERROR;
 				goto error_return;
 			}

+ 1 - 1
ldap/servers/slapd/back-ldbm/ldbm_modify.c

@@ -521,7 +521,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
 			if (ec) {
 				/* must duplicate ec before returning it to cache,
 				 * which could free the entry. */
-				if ( (tmpentry = backentry_dup( ec )) == NULL ) {
+				if ((tmpentry = backentry_dup(original_entry?original_entry:ec)) == NULL) {
 					ldap_result_code= LDAP_OPERATIONS_ERROR;
 					goto error_return;
 				}

+ 2 - 2
ldap/servers/slapd/back-ldbm/ldbm_modrdn.c

@@ -275,7 +275,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
             orig_dn_newsuperiordn = slapi_sdn_dup(orig_dn_newsuperiordn);
             /* must duplicate ec before returning it to cache,
              * which could free the entry. */
-            if ( (tmpentry = backentry_dup( ec )) == NULL ) {
+            if ((tmpentry = backentry_dup(original_entry?original_entry:ec)) == NULL) {
                 ldap_result_code= LDAP_OPERATIONS_ERROR;
                 goto error_return;
             }
@@ -295,10 +295,10 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
                 slapi_entry_free(ent);
                 slapi_pblock_set( pb, SLAPI_MODRDN_EXISTING_ENTRY, NULL );
             }
+            slapi_pblock_set( pb, SLAPI_MODRDN_EXISTING_ENTRY, original_entry->ep_entry );
             ec = original_entry;
             original_entry = tmpentry;
             tmpentry = NULL;
-            slapi_pblock_set( pb, SLAPI_MODRDN_EXISTING_ENTRY, original_entry->ep_entry );
             free_modrdn_existing_entry = 0; /* owned by original_entry now */
             if (!cache_is_in_cache(&inst->inst_cache, ec)) {
                 /* Put the resetted entry 'ec' into the cache again. */