]> git.sur5r.net Git - openldap/commitdiff
Add more diagnostics including linear search version of idl_search()
authorKurt Zeilenga <kurt@openldap.org>
Tue, 26 Sep 2000 01:36:35 +0000 (01:36 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 26 Sep 2000 01:36:35 +0000 (01:36 +0000)
servers/slapd/back-bdb/dn2id.c
servers/slapd/back-bdb/idl.c

index 7c1ce7ce4040f9cc86dc4d91128f979871d2ee29..918f556f109588ca35e03d2276e3026009175158 100644 (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;
                                }
                        }
index 456d5cf2147f7cc9658fb74e9f5a227d6d262ab3..3206e2f216ab0f24bde693239116c89eaef67c0b 100644 (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 */