From dccdd30497e98558f69377d4bf5f10c702557e35 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 26 Sep 2000 19:26:08 +0000 Subject: [PATCH] Got base entry... --- servers/slapd/back-bdb/add.c | 2 +- servers/slapd/back-bdb/dn2id.c | 29 ++++++++++++++++++++++++----- servers/slapd/back-bdb/id2entry.c | 4 ++++ servers/slapd/back-bdb/search.c | 4 ++-- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 6fb0e2c656..0fbb162387 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -251,7 +251,7 @@ retry: rc = txn_abort( ltid ); ltid = NULL; op->o_private = NULL; - if( rc == 0 ) { + if( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, "bdb_add: txn_commit failed: %s (%d)\n", db_strerror(rc), rc, 0 ); diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index fa4fe3fc05..2876f438f1 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -25,7 +25,8 @@ bdb_dn2id_add( struct bdb_info *bdb = (struct bdb_info *) be->be_private; DB *db = bdb->bi_dn2id->bdi_db; - Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_add( \"%s\", %ld )\n", dn, id, 0 ); + Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_add( \"%s\", 0x%08lx )\n", + dn, id, 0 ); assert( id != NOID ); DBTzero( &key ); @@ -111,7 +112,8 @@ bdb_dn2id_delete( struct bdb_info *bdb = (struct bdb_info *) be->be_private; DB *db = bdb->bi_dn2id->bdi_db; - Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_delete( \"%s\", %ld )\n", dn, id, 0 ); + Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_delete( \"%s\", 0x%08lx )\n", + dn, id, 0 ); DBTzero( &key ); key.size = strlen( dn ) + 2; @@ -210,7 +212,7 @@ bdb_dn2id( /* fetch it */ rc = db->get( db, txn, &key, &data, 0 ); - Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: id=%ld: %s (%d)\n", + Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: id=0x%08lx: %s (%d)\n", id, db_strerror( rc ), rc ); ch_free( key.data ); @@ -250,6 +252,8 @@ bdb_dn2id_matched( while(1) { AC_MEMCPY( &((char *)key.data)[1], dn, key.size - 1 ); + *id = NOID; + /* fetch it */ rc = db->get( db, txn, &key, &data, 0 ); @@ -259,6 +263,9 @@ bdb_dn2id_matched( tmp = NULL; if( pdn == NULL || *pdn == '\0' ) { + Debug( LDAP_DEBUG_TRACE, + "<= bdb_dn2id_matched: no match\n", + 0, 0, 0 ); ch_free( pdn ); break; } @@ -268,15 +275,27 @@ bdb_dn2id_matched( key.size = strlen( dn ) + 2; } else if ( rc == 0 ) { + if( data.size != sizeof( ID ) ) { + Debug( LDAP_DEBUG_ANY, + "<= bdb_dn2id_matched: get size mismatch: " + "expected %ld, got %ld\n", + (long) sizeof(ID), (long) data.size, 0 ); + ch_free( tmp ); + } + if( in != dn ) { *matchedDN = (char *) dn; } + Debug( LDAP_DEBUG_TRACE, - "<= bdb_dn2id_matched: id=%ld: %s\n", - id, dn, 0 ); + "<= bdb_dn2id_matched: id=0x%08lx: %s\n", + *id, dn, 0 ); break; } else { + Debug( LDAP_DEBUG_ANY, + "<= bdb_dn2id_matched: get failed: %s (%d)\n", + db_strerror(rc), rc, 0 ); ch_free( tmp ); break; } diff --git a/servers/slapd/back-bdb/id2entry.c b/servers/slapd/back-bdb/id2entry.c index 5eb3f7f6aa..8fbff048d4 100644 --- a/servers/slapd/back-bdb/id2entry.c +++ b/servers/slapd/back-bdb/id2entry.c @@ -73,6 +73,10 @@ int bdb_id2entry( rc = entry_decode( &bv, e ); + if( rc == 0 ) { + (*e)->e_id = id; + } + ch_free( data.data ); return rc; } diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 901f4d4550..d67a89d984 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -361,7 +361,7 @@ static int base_candidate( Entry *e, ID *ids ) { - Debug(LDAP_DEBUG_TRACE, "base_candidates: base: \"%s\" (0x08lx)\n", + Debug(LDAP_DEBUG_ARGS, "base_candidates: base: \"%s\" (0x%08lx)\n", e->e_dn, (long) e->e_id, 0); ids[0] = 1; @@ -378,7 +378,7 @@ static int search_candidates( int manageDSAit, ID *ids ) { - Debug(LDAP_DEBUG_TRACE, "subtree_candidates: base: \"%s\" (0x08lx)\n", + Debug(LDAP_DEBUG_TRACE, "subtree_candidates: base: \"%s\" (0x%08lx)\n", e->e_dn, (long) e->e_id, 0); ids[0] = NOID; -- 2.39.5