Commit 406f33eb authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

This fixes dn2id delete bug... but breaks modrdn.

parent 05532e03
......@@ -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;
......
......@@ -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 );
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment