diff options
author | Noriko Hosoi <nhosoi@redhat.com> | 2010-02-10 17:19:43 -0800 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2010-02-10 17:19:43 -0800 |
commit | 508af98564fd93bf0eed9093c6b551e806ebee81 (patch) | |
tree | f9361422c8fd0eaa6903c80543f21c76a23988a3 /ldap/servers | |
parent | f81e7eac08e2af16fa6b8d245525c4a5ac5eb6f7 (diff) | |
download | ds-508af98564fd93bf0eed9093c6b551e806ebee81.tar.gz ds-508af98564fd93bf0eed9093c6b551e806ebee81.tar.xz ds-508af98564fd93bf0eed9093c6b551e806ebee81.zip |
563365 - Error handling problems in the backend functions
https://bugzilla.redhat.com/show_bug.cgi?id=563365
1) Error handling in ldbm_back_{add,delete,modify,modrdn} functions was
incomplete. When any error occurs after the transaction begins, the
changes made after that should be aborted. There were some cases the
abort was not called.
2) If modrdn failed in ldbm_back_modrdn, new DN in the DN cache was not
removed.
3) config_set_instancedir in libglobs.c was missing the function type.
Diffstat (limited to 'ldap/servers')
-rw-r--r-- | ldap/servers/slapd/back-ldbm/id2entry.c | 2 | ||||
-rw-r--r-- | ldap/servers/slapd/back-ldbm/ldbm_add.c | 67 | ||||
-rw-r--r-- | ldap/servers/slapd/back-ldbm/ldbm_delete.c | 53 | ||||
-rw-r--r-- | ldap/servers/slapd/back-ldbm/ldbm_modify.c | 19 | ||||
-rw-r--r-- | ldap/servers/slapd/back-ldbm/ldbm_modrdn.c | 69 | ||||
-rw-r--r-- | ldap/servers/slapd/libglobs.c | 1 |
6 files changed, 132 insertions, 79 deletions
diff --git a/ldap/servers/slapd/back-ldbm/id2entry.c b/ldap/servers/slapd/back-ldbm/id2entry.c index 31c91414..83bf94d8 100644 --- a/ldap/servers/slapd/back-ldbm/id2entry.c +++ b/ldap/servers/slapd/back-ldbm/id2entry.c @@ -193,7 +193,7 @@ id2entry_delete( backend *be, struct backentry *e, back_txn *txn ) Slapi_DN *sdn = slapi_sdn_dup(slapi_entry_get_sdn_const(e->ep_entry)); struct backdn *bdn = backdn_init(sdn, e->ep_id, 1); CACHE_REMOVE(&inst->inst_dncache, bdn); - backdn_free(&bdn); + CACHE_RETURN(&inst->inst_dncache, bdn); } rc = db->del( db,db_txn,&key,0 ); diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c index 75c64c3d..0db57f67 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_add.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c @@ -50,6 +50,12 @@ extern char *hassubordinates; static void delete_update_entrydn_operational_attributes(struct backentry *ep); +#define ADD_SET_ERROR(rc, error, count) \ +{ \ + (rc) = (error); \ + (count) = RETRY_TIMES; /* otherwise, the transaction may not be aborted */ \ +} + /* in order to find the parent, we must have either the parent dn or uniqueid This function will return true if either are set, or false otherwise */ static int @@ -659,14 +665,11 @@ ldbm_back_add( Slapi_PBlock *pb ) if (retval != 0) { LDAPDebug( LDAP_DEBUG_TRACE, "id2entry_add failed, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); + ADD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count); if (LDBM_OS_ERR_IS_DISKFULL(retval)) { disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; goto diskfull_return; } - ldap_result_code= LDAP_OPERATIONS_ERROR; - retry_count = RETRY_TIMES; /* otherwise, the transaction may not - be aborted */ goto error_return; } if(is_resurect_operation) @@ -680,14 +683,12 @@ ldbm_back_add( Slapi_PBlock *pb ) if (0 != retval) { LDAPDebug( LDAP_DEBUG_TRACE, "add 1 BAD, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); + ADD_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); if (LDBM_OS_ERR_IS_DISKFULL(retval)) { disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; goto diskfull_return; } - ldap_result_code= LDAP_OPERATIONS_ERROR; - retry_count = RETRY_TIMES; /* otherwise, the transaction may not - be aborted */ goto error_return; } retval = index_addordel_string(be,SLAPI_ATTR_UNIQUEID,slapi_entry_get_uniqueid(addingentry->ep_entry),addingentry->ep_id,BE_INDEX_DEL,&txn); @@ -699,14 +700,12 @@ ldbm_back_add( Slapi_PBlock *pb ) if (0 != retval) { LDAPDebug( LDAP_DEBUG_TRACE, "add 2 BAD, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); + ADD_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); if (LDBM_OS_ERR_IS_DISKFULL(retval)) { disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; goto diskfull_return; } - ldap_result_code= LDAP_OPERATIONS_ERROR; - retry_count = RETRY_TIMES; /* otherwise, the transaction may not - be aborted */ goto error_return; } retval = index_addordel_string(be,SLAPI_ATTR_NSCP_ENTRYDN,slapi_sdn_get_ndn(&sdn),addingentry->ep_id,BE_INDEX_DEL,&txn); @@ -718,14 +717,12 @@ ldbm_back_add( Slapi_PBlock *pb ) if (0 != retval) { LDAPDebug( LDAP_DEBUG_TRACE, "add 3 BAD, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); + ADD_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); if (LDBM_OS_ERR_IS_DISKFULL(retval)) { disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; goto diskfull_return; } - ldap_result_code= LDAP_OPERATIONS_ERROR; - retry_count = RETRY_TIMES; /* otherwise, the transaction may not - be aborted */ goto error_return; } } @@ -746,14 +743,11 @@ ldbm_back_add( Slapi_PBlock *pb ) if (retval != 0) { LDAPDebug( LDAP_DEBUG_ANY, "add: attempt to index %lu failed\n", (u_long)addingentry->ep_id, 0, 0 ); + ADD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count); if (LDBM_OS_ERR_IS_DISKFULL(retval)) { disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; goto diskfull_return; } - ldap_result_code= LDAP_OPERATIONS_ERROR; - retry_count = RETRY_TIMES; /* otherwise, the transaction may not - be aborted */ goto error_return; } if (parent_found) { @@ -768,14 +762,12 @@ ldbm_back_add( Slapi_PBlock *pb ) if (0 != retval) { LDAPDebug( LDAP_DEBUG_TRACE, "add 1 BAD, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); + ADD_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); if (LDBM_OS_ERR_IS_DISKFULL(retval)) { disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; goto diskfull_return; } - ldap_result_code= LDAP_OPERATIONS_ERROR; - retry_count = RETRY_TIMES; /* otherwise, the transaction may not - be aborted */ goto error_return; } } @@ -795,14 +787,12 @@ ldbm_back_add( Slapi_PBlock *pb ) LDAPDebug( LDAP_DEBUG_TRACE, "vlv_update_index failed, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); + ADD_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); if (LDBM_OS_ERR_IS_DISKFULL(retval)) { disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; goto diskfull_return; } - ldap_result_code= LDAP_OPERATIONS_ERROR; - retry_count = RETRY_TIMES; /* otherwise, the transaction may not - be aborted */ goto error_return; } } @@ -832,8 +822,8 @@ ldbm_back_add( Slapi_PBlock *pb ) if (cache_replace( &inst->inst_cache, tombstoneentry, addingentry ) != 0 ) { /* This happens if the dn of addingentry already exists */ - ldap_result_code= LDAP_ALREADY_EXISTS; cache_unlock_entry( &inst->inst_cache, tombstoneentry ); + ADD_SET_ERROR(ldap_result_code, LDAP_ALREADY_EXISTS, retry_count); goto error_return; } /* @@ -846,19 +836,18 @@ ldbm_back_add( Slapi_PBlock *pb ) } if (parent_found) { - /* switch the parent entry copy into play */ + /* switch the parent entry copy into play */ modify_switch_entries( &parent_modify_c,be); } retval = dblayer_txn_commit(li,&txn); if (0 != retval) { + ADD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count); if (LDBM_OS_ERR_IS_DISKFULL(retval)) { disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; goto diskfull_return; } - ldap_result_code= LDAP_OPERATIONS_ERROR; goto error_return; } @@ -891,16 +880,16 @@ error_return: disk_full = 1; } - /* It is safer not to abort when the transaction is not started. */ - if (retry_count > 0) { - dblayer_txn_abort(li,&txn); /* abort crashes in case disk full */ - } diskfull_return: - - if (disk_full) + if (disk_full) { rc= return_on_disk_full(li); - else + } else { + /* It is safer not to abort when the transaction is not started. */ + if (retry_count > 0) { + dblayer_txn_abort(li,&txn); /* abort crashes in case disk full */ + } rc= SLAPI_FAIL_GENERAL; + } common_return: if (addingentry_in_cache && addingentry) diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c index 97873003..82241146 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c @@ -45,6 +45,12 @@ #include "back-ldbm.h" +#define DEL_SET_ERROR(rc, error, count) \ +{ \ + (rc) = (error); \ + (count) = RETRY_TIMES; /* otherwise, the transaction may not be aborted */ \ +} + int ldbm_back_delete( Slapi_PBlock *pb ) { @@ -445,7 +451,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) LDAPDebug( LDAP_DEBUG_ANY, "id2entry_add failed, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } if (cache_add_tentative( &inst->inst_cache, tombstone, NULL) == 0) { @@ -467,7 +474,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) LDBM_OS_ERR_IS_DISKFULL(retval)) { disk_full = 1; } - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } } @@ -486,7 +494,7 @@ ldbm_back_delete( Slapi_PBlock *pb ) } if (retval != 0) { LDAPDebug( LDAP_DEBUG_TRACE, "index_del_entry failed\n", 0, 0, 0 ); - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } if(create_tombstone_entry) @@ -512,7 +520,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) SLAPI_ATTR_VALUE_TOMBSTONE, retval, (msg = dblayer_strerror( retval )) ? msg : "" ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } retval = index_addordel_string(be, SLAPI_ATTR_UNIQUEID, @@ -531,7 +540,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) SLAPI_ATTR_UNIQUEID, retval, (msg = dblayer_strerror( retval )) ? msg : "" ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } retval = index_addordel_string(be, SLAPI_ATTR_NSCP_ENTRYDN, @@ -550,7 +560,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) SLAPI_ATTR_NSCP_ENTRYDN, retval, (msg = dblayer_strerror( retval )) ? msg : "" ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } /* add a new usn to the entryusn index */ @@ -573,7 +584,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) SLAPI_ATTR_ENTRYUSN, retval, (msg = dblayer_strerror( retval )) ? msg : "" ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } } @@ -596,7 +608,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) SLAPI_ATTR_ENTRYUSN, retval, (msg = dblayer_strerror( retval )) ? msg : "" ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } } @@ -616,7 +629,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) retval, (msg = dblayer_strerror( retval )) ? msg : "" ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } } @@ -645,7 +659,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) SLAPI_ATTR_VALUE_TOMBSTONE, retval, (msg = dblayer_strerror( retval )) ? msg : "" ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } retval = index_addordel_string(be, SLAPI_ATTR_UNIQUEID, @@ -664,7 +679,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) SLAPI_ATTR_UNIQUEID, retval, (msg = dblayer_strerror( retval )) ? msg : "" ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } @@ -687,7 +703,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) SLAPI_ATTR_NSCP_ENTRYDN, retval, (msg = dblayer_strerror( retval )) ? msg : "" ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } } @@ -712,7 +729,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) SLAPI_ATTR_ENTRYUSN, retval, (msg = dblayer_strerror( retval )) ? msg : "" ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } } @@ -732,7 +750,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) retval, (msg = dblayer_strerror( retval )) ? msg : "" ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } } @@ -751,7 +770,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) LDAPDebug( LDAP_DEBUG_TRACE, "delete 3 BAD, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } } @@ -771,7 +791,8 @@ ldbm_back_delete( Slapi_PBlock *pb ) } if (retval != 0 ) { if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + DEL_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } } diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c index 9a0bea07..3cda1d80 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c @@ -50,6 +50,12 @@ extern char *hassubordinates; static void remove_illegal_mods(LDAPMod **mods); static int mods_have_effect (Slapi_Entry *entry, Slapi_Mods *smods); +#define MOD_SET_ERROR(rc, error, count) \ +{ \ + (rc) = (error); \ + (count) = RETRY_TIMES; /* otherwise, the transaction may not be aborted */ \ +} + /* Modify context structure constructor, sans allocation */ void modify_init(modify_context *mc,struct backentry *old_entry) { @@ -406,7 +412,7 @@ ldbm_back_modify( Slapi_PBlock *pb ) LDAPDebug( LDAP_DEBUG_ANY, "id2entry_add failed, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + MOD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } ec_in_cache = 1; @@ -420,7 +426,7 @@ ldbm_back_modify( Slapi_PBlock *pb ) LDAPDebug( LDAP_DEBUG_ANY, "index_add_mods failed, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + MOD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } /* @@ -440,7 +446,8 @@ ldbm_back_modify( Slapi_PBlock *pb ) "vlv_update_index failed, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + MOD_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } @@ -456,7 +463,7 @@ ldbm_back_modify( Slapi_PBlock *pb ) } if (cache_replace( &inst->inst_cache, e, ec ) != 0 ) { - ldap_result_code= LDAP_OPERATIONS_ERROR; + MOD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } @@ -516,9 +523,9 @@ error_return: disk_full = 1; } - if (disk_full) + if (disk_full) { rc= return_on_disk_full(li); - else if (ldap_result_code != LDAP_SUCCESS) { + } else if (ldap_result_code != LDAP_SUCCESS) { if (retry_count > 0) { /* It is safer not to abort when the transaction is not started. */ dblayer_txn_abort(li,&txn); /* abort crashes in case disk full */ diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c index 7af84323..117eb3b0 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c @@ -52,21 +52,27 @@ static int moddn_rename_children(back_txn *ptxn, Slapi_PBlock *pb, backend *be, static int modrdn_rename_entry_update_indexes(back_txn *ptxn, Slapi_PBlock *pb, struct ldbminfo *li, struct backentry *e, struct backentry *ec, Slapi_Mods *smods1, Slapi_Mods *smods2, Slapi_Mods *smods3); static void mods_remove_nsuniqueid(Slapi_Mods *smods); +#define MOD_SET_ERROR(rc, error, count) \ +{ \ + (rc) = (error); \ + (count) = RETRY_TIMES; /* otherwise, the transaction may not be aborted */ \ +} + int ldbm_back_modrdn( Slapi_PBlock *pb ) { backend *be; ldbm_instance *inst; - struct ldbminfo *li; + struct ldbminfo *li; struct backentry *e= NULL; struct backentry *ec= NULL; int ec_in_cache= 0; - back_txn txn; - back_txnid parent_txn; - int retval = -1; - char *msg; - Slapi_Entry *postentry = NULL; - char *errbuf = NULL; + back_txn txn; + back_txnid parent_txn; + int retval = -1; + char *msg; + Slapi_Entry *postentry = NULL; + char *errbuf = NULL; int disk_full = 0; int retry_count = 0; int ldap_result_code= LDAP_SUCCESS; @@ -697,7 +703,8 @@ ldbm_back_modrdn( Slapi_PBlock *pb ) LDAPDebug( LDAP_DEBUG_TRACE, "modrdn_rename_entry_update_indexes failed, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + MOD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count); + goto error_return; } /* @@ -719,6 +726,9 @@ ldbm_back_modrdn( Slapi_PBlock *pb ) char ebuf[ BUFSIZ ]; LDAPDebug( LDAP_DEBUG_ANY, "modrdn: rdn2typeval (%s) failed\n", escape_string( rdns[i], ebuf ), 0, 0 ); + if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; + MOD_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } svp[0] = &sv; @@ -726,21 +736,24 @@ ldbm_back_modrdn( Slapi_PBlock *pb ) retval = index_addordel_values_sv( be, type, svp, NULL, ec->ep_id, BE_INDEX_ADD, &txn ); if (DB_LOCK_DEADLOCK == retval) { - /* Retry txn */ - continue; + /* To retry txn, once break "for loop" */ + break; } - if (retval != 0 ) + else if (retval != 0 ) { LDAPDebug( LDAP_DEBUG_ANY, "modrdn: could not add new value to index, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; + MOD_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); + goto error_return; } } slapi_ldap_value_free( rdns ); if (DB_LOCK_DEADLOCK == retval) { /* Retry txn */ - goto error_return; + continue; } } } @@ -753,13 +766,18 @@ ldbm_back_modrdn( Slapi_PBlock *pb ) /* Retry txn */ continue; } - if (0 != retval) + else if (0 != retval) { - LDAPDebug( LDAP_DEBUG_TRACE, "moddn: could not update parent, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); + LDAPDebug( LDAP_DEBUG_ANY, "modrdn: " + "could not update parent, err=%d %s\n", retval, + (msg = dblayer_strerror( retval )) ? msg : "", 0 ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; + MOD_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); + goto error_return; } /* Push out the db modifications from the new parent entry */ - if(retval==0) + else /* retval == 0 */ { retval = modify_update_all(be, pb, &newparent_modify_context, &txn); if (DB_LOCK_DEADLOCK == retval) @@ -769,8 +787,14 @@ ldbm_back_modrdn( Slapi_PBlock *pb ) } if (0 != retval) { - LDAPDebug( LDAP_DEBUG_TRACE, "moddn: could not update parent, err=%d %s\n", retval, (msg = dblayer_strerror( retval )) ? msg : "", 0 ); + LDAPDebug( LDAP_DEBUG_ANY, "modrdn: " + "could not update parent, err=%d %s\n", retval, + (msg = dblayer_strerror( retval )) ? msg : "", + 0 ); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; + MOD_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); + goto error_return; } } } @@ -784,6 +808,8 @@ ldbm_back_modrdn( Slapi_PBlock *pb ) if (retval == DB_LOCK_DEADLOCK) continue; if (retval == DB_RUNRECOVERY || LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; + MOD_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } } @@ -800,6 +826,8 @@ ldbm_back_modrdn( Slapi_PBlock *pb ) e->ep_id, &txn); slapi_rdn_done(&newsrdn); if (rc) { + MOD_SET_ERROR(ldap_result_code, + LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } } @@ -821,6 +849,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb ) { if (retval == DB_RUNRECOVERY || LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; + MOD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } @@ -849,7 +878,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb ) if (0 != retval) { if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - ldap_result_code= LDAP_OPERATIONS_ERROR; + MOD_SET_ERROR(ldap_result_code, LDAP_OPERATIONS_ERROR, retry_count); goto error_return; } @@ -904,6 +933,12 @@ error_return: slapi_entry_free( postentry ); postentry= NULL; } + if (entryrdn_get_switch()) + { + struct backdn *bdn = dncache_find_id(&inst->inst_dncache, e->ep_id); + CACHE_REMOVE(&inst->inst_dncache, bdn); + CACHE_RETURN(&inst->inst_dncache, &bdn); + } if( ec!=NULL ) { if (ec_in_cache) { CACHE_REMOVE(&inst->inst_cache, ec); diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index efbda9ce..c4026ac6 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -4874,6 +4874,7 @@ config_get_instancedir() return retVal; } +int config_set_instancedir(const char *attrname, char *value, char *errorbuf, int apply) { int retVal = LDAP_SUCCESS; |