From d01f571e7c892056a775b8b3c9c7195ac197260d Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sun, 8 Aug 1999 00:54:27 +0000 Subject: [PATCH] Fix typo in previous commit as well as integrate bubble move replacement. --- servers/slapd/back-bdb2/back-bdb2.h | 2 -- servers/slapd/back-bdb2/idl.c | 36 +++++++++++++---------- servers/slapd/back-bdb2/proto-back-bdb2.h | 4 +-- servers/slapd/back-bdb2/search.c | 6 ++-- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/servers/slapd/back-bdb2/back-bdb2.h b/servers/slapd/back-bdb2/back-bdb2.h index 4a8879d4ec..cfcc492425 100644 --- a/servers/slapd/back-bdb2/back-bdb2.h +++ b/servers/slapd/back-bdb2/back-bdb2.h @@ -119,8 +119,6 @@ struct attrinfo { */ }; -#define MAXDBCACHE 10 - /* this could be made an option */ #ifndef SLAPD_NEXTID_CHUNK #define SLAPD_NEXTID_CHUNK 32 diff --git a/servers/slapd/back-bdb2/idl.c b/servers/slapd/back-bdb2/idl.c index e5a2867c5b..5b000f308e 100644 --- a/servers/slapd/back-bdb2/idl.c +++ b/servers/slapd/back-bdb2/idl.c @@ -646,7 +646,7 @@ bdb2i_idl_insert( ID_BLOCK **idl, ID id, unsigned int maxids ) /* make a slot for the new id */ SAFEMEMCPY( &ID_BLOCK_ID(*idl, i), &ID_BLOCK_ID(*idl, i+1), - ID_BLOCKS_NIDS(*idl) - i ); + ID_BLOCK_NIDS(*idl) - i ); ID_BLOCK_ID(*idl, i) = id; ID_BLOCK_NIDS(*idl)++; @@ -993,10 +993,14 @@ bdb2i_idl_notin( * NIDS > 1 return 1 * otherwise return NOID * otherwise return first ID + * + * cursor is set to 1 */ ID -bdb2i_idl_firstid( ID_BLOCK *idl ) +bdb2i_idl_firstid( ID_BLOCK *idl, ID *cursor ) { + *cursor = 1; + if ( idl == NULL || ID_BLOCK_NIDS(idl) == 0 ) { return( NOID ); } @@ -1010,27 +1014,27 @@ bdb2i_idl_firstid( ID_BLOCK *idl ) /* return next ID after id - * if ALLIDS block, increment id. + * if ALLIDS block, cursor is id + * increment id * if id < NIDS return id * otherwise NOID. - * otherwise SEARCH for next id (ugh!) + * otherwise cursor is index into block + * if index < nids + * return id at index then increment */ ID -bdb2i_idl_nextid( ID_BLOCK *idl, ID id ) +bdb2i_idl_nextid( ID_BLOCK *idl, ID *cursor ) { - unsigned int i; - if ( ID_BLOCK_ALLIDS( idl ) ) { - return( ++id < ID_BLOCK_NIDS(idl) ? id : NOID ); - } - - for ( i = 0; i < ID_BLOCK_NIDS(idl) && ID_BLOCK_ID(idl, i) <= id; i++ ) { - ; /* NULL */ + if( ++(*cursor) < ID_BLOCK_NIDS(idl) ) { + return *cursor; + } else { + return NOID; + } } - if ( i >= ID_BLOCK_NIDS(idl) ) { - return( NOID ); - } else { - return( ID_BLOCK_ID(idl, i) ); + if ( *cursor < ID_BLOCK_NIDS(idl) ) { + return ID_BLOCK_ID(idl, (*cursor)++); } + return NOID; } diff --git a/servers/slapd/back-bdb2/proto-back-bdb2.h b/servers/slapd/back-bdb2/proto-back-bdb2.h index e6ac08c6e6..f0583e1f14 100644 --- a/servers/slapd/back-bdb2/proto-back-bdb2.h +++ b/servers/slapd/back-bdb2/proto-back-bdb2.h @@ -130,8 +130,8 @@ int bdb2i_idl_delete_key LDAP_P(( BackendDB *be, struct dbcache *db, Datum key, ID_BLOCK * bdb2i_idl_intersection LDAP_P(( BackendDB *be, ID_BLOCK *a, ID_BLOCK *b )); ID_BLOCK * bdb2i_idl_union LDAP_P(( BackendDB *be, ID_BLOCK *a, ID_BLOCK *b )); ID_BLOCK * bdb2i_idl_notin LDAP_P(( BackendDB *be, ID_BLOCK *a, ID_BLOCK *b )); -ID bdb2i_idl_firstid LDAP_P(( ID_BLOCK *idl )); -ID bdb2i_idl_nextid LDAP_P(( ID_BLOCK *idl, ID id )); +ID bdb2i_idl_firstid LDAP_P(( ID_BLOCK *idl, ID *cursor )); +ID bdb2i_idl_nextid LDAP_P(( ID_BLOCK *idl, ID *cursor )); /* * index.c diff --git a/servers/slapd/back-bdb2/search.c b/servers/slapd/back-bdb2/search.c index 6fa45c895a..9117aeafb9 100644 --- a/servers/slapd/back-bdb2/search.c +++ b/servers/slapd/back-bdb2/search.c @@ -40,7 +40,7 @@ bdb2i_back_search_internal( char *text; time_t stoptime; ID_BLOCK *candidates; - ID id; + ID id, cursor; Entry *e; struct berval **v2refs = NULL; Entry *matched = NULL; @@ -147,8 +147,8 @@ bdb2i_back_search_internal( goto done; } - for ( id = bdb2i_idl_firstid( candidates ); id != NOID; - id = bdb2i_idl_nextid( candidates, id ) ) + for ( id = bdb2i_idl_firstid( candidates, &cursor ); id != NOID; + id = bdb2i_idl_nextid( candidates, &cursor ) ) { int scopeok = 0; -- 2.39.5