From: Kurt Zeilenga Date: Tue, 26 Sep 2000 00:12:31 +0000 (+0000) Subject: Fix initialization, add additional diagnostics X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1893 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=11797cdbeb4bd3539e6a369304f099e623bab532;p=openldap Fix initialization, add additional diagnostics --- diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index aa66fc0b85..6f63d36e20 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -124,7 +124,7 @@ bdb_db_open( BackendDB *be ) rc = bdb->bi_dbenv->set_lg_dir( bdb->bi_dbenv, dir ); if( rc != 0 ) { Debug( LDAP_DEBUG_ANY, - "bi_back_db_open: set_lg_dir(%s) failed: %s (%d)\n", + "bdb_db_open: set_lg_dir(%s) failed: %s (%d)\n", dir, db_strerror(rc), rc ); return rc; } @@ -142,7 +142,7 @@ bdb_db_open( BackendDB *be ) #endif Debug( LDAP_DEBUG_TRACE, - "bi_back_db_open: dbenv_open(%s)\n", + "bdb_db_open: dbenv_open(%s)\n", bdb->bi_dbenv_home, 0, 0); rc = bdb->bi_dbenv->open( bdb->bi_dbenv, @@ -158,6 +158,9 @@ bdb_db_open( BackendDB *be ) flags = DB_THREAD | DB_CREATE; + bdb->bi_databases = (struct bdb_db_info **) ch_malloc( + BDB_INDICES * sizeof(struct bdb_db_info *) ); + /* open (and create) main database */ for( i = 0; i < BDB_INDICES; i++ ) { struct bdb_db_info *db; @@ -185,6 +188,8 @@ bdb_db_open( BackendDB *be ) bdb->bi_dbenv_home, db_strerror(rc), rc ); return rc; } + + bdb->bi_databases[i] = db; } /* open (and create) index databases */ diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index 11b96f3b9b..096dcec539 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -20,6 +20,9 @@ int bdb_tool_entry_open( { int rc; struct bdb_info *bdb = (struct bdb_info *) be->be_private; + + assert( be != NULL ); + assert( bdb != NULL ); rc = bdb->bi_id2entry->bdi_db->cursor( bdb->bi_id2entry->bdi_db, NULL, &cursor, 0 ); @@ -41,6 +44,8 @@ int bdb_tool_entry_close( { struct bdb_info *bdb = (struct bdb_info *) be->be_private; + assert( be != NULL ); + if( key.data ) { ch_free( key.data ); key.data = NULL; @@ -64,6 +69,7 @@ ID bdb_tool_entry_next( int rc; ID id; + assert( be != NULL ); assert( slapMode & SLAP_TOOL_MODE ); assert( cursor != NULL ); @@ -86,6 +92,8 @@ Entry* bdb_tool_entry_get( BackendDB *be, ID id ) int rc; Entry *e; struct berval bv; + + assert( be != NULL ); assert( slapMode & SLAP_TOOL_MODE ); assert( data.data != NULL ); @@ -108,6 +116,7 @@ ID bdb_tool_entry_put( struct bdb_info *bdb = (struct bdb_info *) be->be_private; DB_TXN *tid; + assert( be != NULL ); assert( slapMode & SLAP_TOOL_MODE ); Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n", @@ -115,23 +124,35 @@ ID bdb_tool_entry_put( rc = txn_begin( bdb->bi_dbenv, NULL, &tid, 0 ); if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_tool_entry_put: txn_begin failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); return NOID; } rc = bdb_next_id( be, tid, &e->e_id ); if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_tool_entry_put: next_id failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); goto done; } /* add dn2id indices */ rc = bdb_dn2id_add( be, tid, e->e_ndn, e->e_id ); if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_tool_entry_put: dn2id_add failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); goto done; } /* id2entry index */ rc = bdb_id2entry_add( be, tid, e ); if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_tool_entry_put: id2entry_add failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); goto done; } @@ -146,10 +167,16 @@ done: if( rc == 0 ) { rc = txn_commit( tid, 0 ); if( rc != 0 ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_tool_entry_put: txn_commit failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); e->e_id = NOID; } } else { + Debug( LDAP_DEBUG_ANY, + "=> bdb_tool_entry_put: txn_aborted!\n", + 0, 0, 0 ); txn_abort( tid ); e->e_id = NOID; }