]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/modrdn.c
Set lock detector to DEFAULT, not NORUN.
[openldap] / servers / slapd / back-bdb / modrdn.c
index 77c04fa12e948e95fe93987da1da0a11c480fa35..d1398ab308dadafc4f13aa0965527760eed62231 100644 (file)
@@ -1,7 +1,7 @@
 /* modrdn.c - bdb backend modrdn routine */
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
@@ -79,6 +79,7 @@ retry:        /* transaction retry */
                        text = "internal error";
                        goto return_results;
                }
+               ldap_pvt_thread_yield();
        }
 
        if( bdb->bi_txn ) {
@@ -119,7 +120,7 @@ retry:      /* transaction retry */
 
        if ( e == NULL ) {
                char* matched_dn = NULL;
-               struct berval** refs;
+               BerVarray refs;
 
                if( matched != NULL ) {
                        matched_dn = strdup( matched->e_dn );
@@ -137,7 +138,7 @@ retry:      /* transaction retry */
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        matched_dn, NULL, refs, NULL );
 
-               ber_bvecfree( refs );
+               ber_bvarray_free( refs );
                free( matched_dn );
 
                goto done;
@@ -146,7 +147,7 @@ retry:      /* transaction retry */
        if (!manageDSAit && is_entry_referral( e ) ) {
                /* parent is a referral, don't allow add */
                /* parent is an alias, don't allow add */
-               struct berval **refs = get_entry_referrals( be,
+               BerVarray refs = get_entry_referrals( be,
                        conn, op, e );
 
                Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n",
@@ -155,15 +156,21 @@ retry:    /* transaction retry */
                send_ldap_result( conn, op, rc = LDAP_REFERRAL,
                        e->e_dn, NULL, refs, NULL );
 
-               ber_bvecfree( refs );
+               ber_bvarray_free( refs );
                goto done;
        }
 
-       p_ndn.bv_val = dn_parent( be, e->e_ndn );
-       if (p_ndn.bv_val)
-               p_ndn.bv_len = e->e_nname.bv_len - (p_ndn.bv_val - e->e_ndn);
-       else
+       if ( be_issuffix( be, e->e_nname.bv_val ) ) {
                p_ndn.bv_len = 0;
+               p_ndn.bv_val = "";
+       } else {
+               rc = dnParent( e->e_nname.bv_val, (const char **)&p_ndn.bv_val );
+               if ( rc != LDAP_SUCCESS ) {
+                       text = "internal error";
+                       goto return_results;
+               }
+               p_ndn.bv_len = e->e_nname.bv_len - (p_ndn.bv_val - e->e_nname.bv_val);
+       }
        np_ndn = &p_ndn;
        if ( p_ndn.bv_len != 0 ) {
                /* Make sure parent entry exist and we can write its 
@@ -206,11 +213,17 @@ retry:    /* transaction retry */
                        "bdb_modrdn: wr to children of entry %s OK\n",
                        p_ndn.bv_val, 0, 0 );
                
-               p_dn.bv_val = dn_parent( be, e->e_dn );
-               if (p_dn.bv_val)
-                       p_dn.bv_len = e->e_name.bv_len - (p_dn.bv_val - e->e_dn);
-               else
+               if ( be_issuffix( be, e->e_name.bv_val ) ) {
                        p_dn.bv_len = 0;
+                       p_dn.bv_val = "";
+               } else {
+                       rc = dnParent( e->e_name.bv_val, &p_dn.bv_val );
+                       if ( rc != LDAP_SUCCESS ) {
+                               text = "internal error";
+                               goto return_results;
+                       }
+                       p_dn.bv_len = e->e_name.bv_len - (p_dn.bv_val - e->e_name.bv_val);
+               }
 
                Debug( LDAP_DEBUG_TRACE,
                        "bdb_modrdn: parent dn=%s\n",
@@ -418,7 +431,9 @@ retry:      /* transaction retry */
        /* Get attribute type and attribute value of our new rdn, we will
         * need to add that to our new entry
         */
-       if ( ldap_str2rdn( newrdn->bv_val, &new_rdn, &text, LDAP_DN_FORMAT_LDAP ) ) {
+       if ( ldap_str2rdn( newrdn->bv_val, &new_rdn, (char **)&text,
+               LDAP_DN_FORMAT_LDAP ) )
+       {
                Debug( LDAP_DEBUG_TRACE,
                        "bdb_modrdn: can't figure out type(s)/values(s) "
                        "of newrdn\n", 0, 0, 0 );
@@ -431,7 +446,9 @@ retry:      /* transaction retry */
                "bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n",
                new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val, 0 );
 
-       if ( ldap_str2rdn( dn->bv_val, &old_rdn, &text, LDAP_DN_FORMAT_LDAP ) ) {
+       if ( ldap_str2rdn( dn->bv_val, &old_rdn, (char **)&text,
+               LDAP_DN_FORMAT_LDAP ) )
+       {
                Debug( LDAP_DEBUG_TRACE,
                        "bdb_back_modrdn: can't figure out the old_rdn "
                        "type(s)/value(s)\n", 0, 0, 0 );
@@ -480,11 +497,11 @@ retry:    /* transaction retry */
 
                /* Apply modification */
                mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
-                       + 2 * sizeof( struct berval ) );
+                       + 2 * sizeof( struct berval ) );
                mod_tmp->sml_desc = desc;
-               mod_tmp->sml_bvalues = ( struct berval ** )( mod_tmp + 1 );
-               mod_tmp->sml_bvalues[ 0 ] = &new_rdn[0][ a_cnt ]->la_value;
-               mod_tmp->sml_bvalues[ 1 ] = NULL;
+               mod_tmp->sml_bvalues = ( BerVarray )( mod_tmp + 1 );
+               mod_tmp->sml_bvalues[ 0 ] = new_rdn[0][ a_cnt ]->la_value;
+               mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
                mod_tmp->sml_op = SLAP_MOD_SOFTADD;
                mod_tmp->sml_next = mod;
                mod = mod_tmp;
@@ -530,11 +547,11 @@ retry:    /* transaction retry */
 
                        /* Apply modification */
                        mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
-                               + 2 * sizeof ( struct berval ) );
+                               + 2 * sizeof ( struct berval ) );
                        mod_tmp->sml_desc = desc;
-                       mod_tmp->sml_bvalues = ( struct berval ** )(mod_tmp+1);
-                       mod_tmp->sml_bvalues[ 0 ] = &old_rdn[0][ d_cnt ]->la_value;
-                       mod_tmp->sml_bvalues[ 1 ] = NULL;
+                       mod_tmp->sml_bvalues = ( BerVarray )(mod_tmp+1);
+                       mod_tmp->sml_bvalues[ 0 ] = old_rdn[0][ d_cnt ]->la_value;
+                       mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
                        mod_tmp->sml_op = LDAP_MOD_DELETE;
                        mod_tmp->sml_next = mod;
                        mod = mod_tmp;