From 5a30d0a9dd55cad29d7dda85419087702aadfe68 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 26 Sep 2000 01:36:35 +0000 Subject: [PATCH] Add more diagnostics including linear search version of idl_search() --- servers/slapd/back-bdb/dn2id.c | 24 ++++++++++++++++++++++-- servers/slapd/back-bdb/idl.c | 25 +++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 7c1ce7ce40..918f556f10 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -41,6 +41,8 @@ bdb_dn2id_add( /* store it -- don't override */ rc = db->put( db, txn, &key, &data, DB_NOOVERWRITE ); if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_add: put failed: %s %d\n", + db_strerror(rc), rc, 0 ); goto done; } @@ -54,11 +56,15 @@ bdb_dn2id_add( pdn, key.size - 1 ); rc = bdb_idl_insert_key( be, db, txn, &key, id ); - free( pdn ); if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_dn2id_add: parent (%s) insert failed: %d\n", + pdn, rc, 0 ); + free( pdn ); goto done; } + free( pdn ); } } @@ -76,6 +82,10 @@ bdb_dn2id_add( rc = bdb_idl_insert_key( be, db, txn, &key, id ); if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n", + subtree[i], rc, 0 ); + charray_free( subtree ); goto done; } } @@ -113,6 +123,8 @@ bdb_dn2id_delete( /* store it -- don't override */ rc = db->del( db, txn, &key, 0 ); if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_delete: delete failed: %s %d\n", + db_strerror(rc), rc, 0 ); goto done; } @@ -126,11 +138,15 @@ bdb_dn2id_delete( pdn, key.size - 1 ); rc = bdb_idl_delete_key( be, db, txn, &key, id ); - free( pdn ); if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_dn2id_delete: parent (%s) delete failed: %d\n", + pdn, rc, 0 ); + free( pdn ); goto done; } + free( pdn ); } } @@ -148,6 +164,10 @@ bdb_dn2id_delete( rc = bdb_idl_delete_key( be, db, txn, &key, id ); if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n", + subtree[i], rc, 0 ); + charray_free( subtree ); goto done; } } diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index 456d5cf214..3206e2f216 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -16,6 +16,7 @@ int bdb_idl_search( ID *ids, ID id ) { +#if BDB_IDL_BINARY_SEARCH /* * binary search of id in ids * if found, returns position of id @@ -48,6 +49,16 @@ int bdb_idl_search( ID *ids, ID id ) } else { return cursor + 1; } +#else + /* linear search */ + int i; + for( i=1; i<=ids[0]; i++ ) { + if( id <= ids[i] ) { + return i; + } + } + return i; +#endif } static int idl_insert( ID *ids, ID id ) @@ -147,7 +158,12 @@ bdb_idl_insert_key( } else { rc = idl_insert( ids, id ); - if( rc != 0 ) return rc; + if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_idl_insert_key: idl_insert failed (%d)\n", + rc, 0, 0 ); + return rc; + } data.size = (ids[0]+1) * sizeof( ID ); } @@ -210,7 +226,12 @@ bdb_idl_delete_key( } else { rc = idl_delete( ids, id ); - if( rc != 0 ) return rc; + if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_idl_insert_key: idl_insert failed (%d)\n", + rc, 0, 0 ); + return rc; + } if( BDB_IS_ALLIDS(ids) ) { /* delete the key */ -- 2.39.5