From: Pierangelo Masarati Date: Sat, 7 Jul 2001 14:49:42 +0000 (+0000) Subject: dn2idl API changed for consistency with other dn2id* funcs X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1248 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=04c29fb3ea7c79d82f909d2833ef03503e130a30;p=openldap dn2idl API changed for consistency with other dn2id* funcs --- diff --git a/servers/slapd/back-ldbm/dn2id.c b/servers/slapd/back-ldbm/dn2id.c index 088bc45bb0..e680de1b56 100644 --- a/servers/slapd/back-ldbm/dn2id.c +++ b/servers/slapd/back-ldbm/dn2id.c @@ -203,16 +203,16 @@ dn2id( return( 0 ); } -ID_BLOCK * +int dn2idl( Backend *be, const char *dn, - int prefix + int prefix, + ID_BLOCK **idlp ) { DBCache *db; Datum key; - ID_BLOCK *idl; #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY, @@ -221,6 +221,8 @@ dn2idl( Debug( LDAP_DEBUG_TRACE, "=> dn2idl( \"%c%s\" )\n", prefix, dn, 0 ); #endif + assert( idlp != NULL ); + *idlp = NULL; if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT )) == NULL ) { @@ -232,7 +234,7 @@ dn2idl( LDBM_SUFFIX, 0, 0 ); #endif - return NULL; + return -1; } ldbm_datum_init( key ); @@ -241,13 +243,13 @@ dn2idl( key.dptr = ch_malloc( key.dsize ); sprintf( key.dptr, "%c%s", prefix, dn ); - idl = idl_fetch( be, db, key ); + *idlp = idl_fetch( be, db, key ); ldbm_cache_close( be, db ); free( key.dptr ); - return( idl ); + return( 0 ); } diff --git a/servers/slapd/back-ldbm/filterindex.c b/servers/slapd/back-ldbm/filterindex.c index 7ba65aae25..f71c4f13ff 100644 --- a/servers/slapd/back-ldbm/filterindex.c +++ b/servers/slapd/back-ldbm/filterindex.c @@ -55,7 +55,12 @@ filter_candidates( Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 ); #endif - result = dn2idl( be, f->f_dn, DN_ONE_PREFIX ); + /* an error is treated as an empty list */ + if ( dn2idl( be, f->f_dn, DN_ONE_PREFIX, &result ) != 0 + && result != NULL ) { + idl_free( result ); + result = NULL; + } break; case SLAPD_FILTER_DN_SUBTREE: @@ -66,7 +71,12 @@ filter_candidates( Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 ); #endif - result = dn2idl( be, f->f_dn, DN_SUBTREE_PREFIX ); + /* an error is treated as an empty list */ + if ( dn2idl( be, f->f_dn, DN_SUBTREE_PREFIX, &result ) != 0 + && result != NULL ) { + idl_free( result ); + result = NULL; + } break; case LDAP_FILTER_PRESENT: diff --git a/servers/slapd/back-ldbm/proto-back-ldbm.h b/servers/slapd/back-ldbm/proto-back-ldbm.h index 350120a3b0..079c947756 100644 --- a/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -78,7 +78,7 @@ void *ldbm_cache_sync_daemon LDAP_P(( void *)); int dn2id_add LDAP_P(( Backend *be, const char *dn, ID id )); int dn2id LDAP_P(( Backend *be, const char *dn, ID *idp )); -ID_BLOCK *dn2idl LDAP_P(( Backend *be, const char *dn, int prefix )); +int dn2idl LDAP_P(( Backend *be, const char *dn, int prefix, ID_BLOCK **idlp )); int dn2id_delete LDAP_P(( Backend *be, const char *dn, ID id )); Entry * dn2entry_rw LDAP_P(( Backend *be, const char *dn, Entry **matched, int rw ));