From: Howard Chu Date: Wed, 3 Dec 2003 12:30:28 +0000 (+0000) Subject: Reorganize, attempt some fault tolerance... X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~288 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=841e8659103fafed818a4ef5fb43b8cc010aab99;p=openldap Reorganize, attempt some fault tolerance... --- diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index ea5e71ee82..1707dadb3e 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -582,23 +582,13 @@ ldbm_back_modrdn( goto return_results; } - /* check for abandon */ if ( op->o_abandon ) { goto return_results; } - /* delete old one */ - if ( dn2id_delete( op->o_bd, &e->e_nname, e->e_id ) != 0 ) { - send_ldap_error( op, rs, LDAP_OTHER, - "DN index delete fail" ); - goto return_results; - } - (void) cache_delete_entry( &li->li_cache, e ); - /* XXX: there is no going back! */ - free( e->e_dn ); old_ndn = e->e_nname; e->e_name = new_dn; @@ -610,13 +600,6 @@ ldbm_back_modrdn( * They are used by cache. */ - /* add new one */ - if ( dn2id_add( op->o_bd, &e->e_nname, e->e_id ) != 0 ) { - send_ldap_error( op, rs, LDAP_OTHER, - "DN index add failed" ); - goto return_results; - } - /* modify memory copy of entry */ rs->sr_err = ldbm_modify_internal( op, &mod[0], e, &rs->sr_text, textbuf, textlen ); @@ -624,30 +607,40 @@ ldbm_back_modrdn( case LDAP_SUCCESS: break; - case SLAPD_ABANDON: - /* too late ... */ - goto return_results; - default: - /* here we may try to delete the newly added dn */ - if ( dn2id_delete( op->o_bd, &e->e_nname, e->e_id ) != 0 || - dn2id_add( op->o_bd, &old_ndn, e->e_id ) != 0 ) { - /* we already are in trouble ... */ - ; - } send_ldap_result( op, rs ); + /* FALLTHRU */ + case SLAPD_ABANDON: goto return_results; } - (void) cache_update_entry( &li->li_cache, e ); + /* add new one */ + if ( dn2id_add( op->o_bd, &e->e_nname, e->e_id ) != 0 ) { + send_ldap_error( op, rs, LDAP_OTHER, + "DN index add failed" ); + goto return_results; + } + /* delete old one */ + if ( dn2id_delete( op->o_bd, &old_ndn, e->e_id ) != 0 ) { + /* undo add of new one */ + dn2id_delete( op->o_bd, &e->e_nname, e->e_id ); + send_ldap_error( op, rs, LDAP_OTHER, + "DN index delete fail" ); + goto return_results; + } /* id2entry index */ if ( id2entry_add( op->o_bd, e ) != 0 ) { + /* Try to undo */ + dn2id_delete( op->o_bd, &e->e_nname, e->e_id ); + dn2id_add( op->o_bd, &old_ndn, e->e_id ); send_ldap_error( op, rs, LDAP_OTHER, "entry update failed" ); goto return_results; } + (void) cache_update_entry( &li->li_cache, e ); + rs->sr_err = LDAP_SUCCESS; rs->sr_text = NULL; send_ldap_result( op, rs );