Add more diagnostics including linear search version of idl_search()

This commit is contained in:
Kurt Zeilenga 2000-09-26 01:36:35 +00:00
parent 7b97ddabeb
commit 5a30d0a9dd
2 changed files with 45 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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 */