#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;
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 );
}
/* 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);
charray_free( subtree );
}
-
}
ldbm_cache_close( be, db );
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 ) {
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;
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;