]> git.sur5r.net Git - openldap/commitdiff
This fixes dn2id delete bug... but breaks modrdn.
authorKurt Zeilenga <kurt@openldap.org>
Thu, 26 Aug 1999 00:48:24 +0000 (00:48 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 26 Aug 1999 00:48:24 +0000 (00:48 +0000)
libraries/libldbm/ldbm.c
servers/slapd/back-ldbm/add.c
servers/slapd/back-ldbm/delete.c
servers/slapd/back-ldbm/dn2id.c
servers/slapd/back-ldbm/modrdn.c

index e9091a9a106af873a9a8b3eb210336f27897b164..7d2cfc831b4255af85bd9d3b5ed3fc90fa4e1044 100644 (file)
@@ -441,12 +441,16 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize )
 
 #ifdef HAVE_ST_BLKSIZE
        if ( dbcachesize > 0 && stat( name, &st ) == 0 ) {
-               dbcachesize = (dbcachesize / st.st_blksize);
+               dbcachesize /= st.st_blksize;
+               if( dbcachesize == 0 ) dbcachesize = 1;
                gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) );
        }
 #else
-       dbcachesize = (dbcachesize / 4096);
-       gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) );
+       if ( dbcachesize > 0 ) {
+               dbcachesize /= 4096;
+               if( dbcachesize == 0 ) dbcachesize = 1;
+               gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) );
+       }
 #endif
 
        LDBM_UNLOCK;
index 8775e2951454d8f1f3791526e10ec4a356835c88..5f8f9052f539bf398f67b96847fbc051e263c87d 100644 (file)
@@ -252,7 +252,7 @@ ldbm_back_add(
        if ( id2entry_add( be, e ) != 0 ) {
                Debug( LDAP_DEBUG_TRACE, "id2entry_add failed\n", 0,
                    0, 0 );
-               (void) dn2id_delete( be, e->e_ndn );
+               (void) dn2id_delete( be, e->e_ndn, e->e_id );
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
                        NULL, NULL, NULL, NULL );
 
index 7db49948bb07c7f90472e70b7158d5ca4cf6b6ef..ae5c513c2694b23892d2b0810fab51fd913d397f 100644 (file)
@@ -141,7 +141,7 @@ ldbm_back_delete(
        }
 
        /* delete from dn2id mapping */
-       if ( dn2id_delete( be, e->e_ndn ) != 0 ) {
+       if ( dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
                Debug(LDAP_DEBUG_ARGS,
                        "<=- ldbm_back_delete: operations error %s\n",
                        dn, 0, 0);
index 26f75476aa55da994e8636ac7bbb7cc1923d4806..0501dd014dd299974e8b3bb4875ab64a85b61029 100644 (file)
@@ -87,7 +87,6 @@ dn2id_add(
 
                        charray_free( subtree );
                }
-
        }
 
        ldbm_cache_close( be, db );
@@ -187,14 +186,15 @@ dn2idl(
 int
 dn2id_delete(
     Backend    *be,
-    const char *dn
+    const char *dn,
+       ID id
 )
 {
        DBCache *db;
        Datum           key;
        int             rc;
 
-       Debug( LDAP_DEBUG_TRACE, "=> dn2id_delete( \"%s\" )\n", dn, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "=> dn2id_delete( \"%s\", %ld )\n", dn, id, 0 );
 
        if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT ))
            == NULL ) {
@@ -204,6 +204,44 @@ dn2id_delete(
                return( -1 );
        }
 
+
+       {
+               char *pdn = dn_parent( NULL, dn );
+
+               if( pdn != NULL ) {
+                       ldbm_datum_init( key );
+                       key.dsize = strlen( pdn ) + 2;
+                       key.dptr = ch_malloc( key.dsize );
+                       sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, pdn );
+                       (void) idl_delete_key( be, db, key, id );
+                       free( key.dptr );
+                       free( pdn );
+               }
+       }
+
+       {
+               char **subtree = dn_subtree( NULL, dn );
+
+               if( subtree != NULL ) {
+                       int i;
+                       for( i=0; subtree[i] != NULL; i++ ) {
+                               ldbm_datum_init( key );
+                               key.dsize = strlen( subtree[i] ) + 2;
+                               key.dptr = ch_malloc( key.dsize );
+                               sprintf( key.dptr, "%c%s",
+                                       DN_SUBTREE_PREFIX, subtree[i] );
+
+                               (void) idl_delete_key( be, db, key, id );
+
+                               free( key.dptr );
+
+                               if(rc == -1) break;
+                       }
+
+                       charray_free( subtree );
+               }
+       }
+
        ldbm_datum_init( key );
 
        key.dsize = strlen( dn ) + 2;
index fae002cec01f706798327c1841df88f53f1f8a7f..9ada4b1bc0163a264e6cd05886b17ebff23cb698 100644 (file)
@@ -280,7 +280,7 @@ ldbm_back_modrdn(
        ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
 
        /* delete old one */
-       if ( dn2id_delete( be, e->e_ndn ) != 0 ) {
+       if ( dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
                        NULL, NULL, NULL, NULL );
                goto return_results;