From: Pierangelo Masarati Date: Wed, 11 Jul 2001 08:41:42 +0000 (+0000) Subject: added function cache_find_entry_ndn2id that avoids an unnecessary call to dn_normaliz... X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1241 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b0a60a5d3d7f088b450485606436259dc59016ee;p=openldap added function cache_find_entry_ndn2id that avoids an unnecessary call to dn_normalize; now dn2id calls this function, while the original function has been left as a wrapper --- diff --git a/servers/slapd/back-ldbm/cache.c b/servers/slapd/back-ldbm/cache.c index ecd8de2ac9..f87bb405f1 100644 --- a/servers/slapd/back-ldbm/cache.c +++ b/servers/slapd/back-ldbm/cache.c @@ -542,14 +542,33 @@ cache_find_entry_dn2id( Cache *cache, const char *dn ) +{ + char *ndn; + ID id; + + ndn = ch_strdup( dn ); + (void) dn_normalize( ndn ); + + id = cache_find_entry_ndn2id( be, cache, ndn ); + + free( ndn ); + + return ( id ); +} + +ID +cache_find_entry_ndn2id( + Backend *be, + Cache *cache, + const char *ndn +) { Entry e, *ep; ID id; int count = 0; - e.e_dn = (char *) dn; - e.e_ndn = ch_strdup( dn ); - (void) dn_normalize( e.e_ndn ); + /* this function is always called with normalized DN */ + e.e_ndn = (char *)ndn; try_again: /* set cache mutex */ @@ -589,7 +608,7 @@ try_again: #else Debug(LDAP_DEBUG_TRACE, "====> cache_find_entry_dn2id(\"%s\"): %ld (not ready) %d\n", - dn, id, state); + ndn, id, state); #endif @@ -611,7 +630,7 @@ try_again: #else Debug(LDAP_DEBUG_TRACE, "====> cache_find_entry_dn2id(\"%s\"): %ld (%d tries)\n", - dn, id, count); + ndn, id, count); #endif @@ -622,8 +641,6 @@ try_again: id = NOID; } - free(e.e_ndn); - return( id ); } diff --git a/servers/slapd/back-ldbm/dn2id.c b/servers/slapd/back-ldbm/dn2id.c index e680de1b56..57340fd9a6 100644 --- a/servers/slapd/back-ldbm/dn2id.c +++ b/servers/slapd/back-ldbm/dn2id.c @@ -134,7 +134,7 @@ dn2id( assert( idp ); /* first check the cache */ - if ( (*idp = cache_find_entry_dn2id( be, &li->li_cache, dn )) != NOID ) { + if ( (*idp = cache_find_entry_ndn2id( be, &li->li_cache, dn )) != NOID ) { #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, "dn2id: (%s)%ld in cache.\n", dn, *idp )); diff --git a/servers/slapd/back-ldbm/proto-back-ldbm.h b/servers/slapd/back-ldbm/proto-back-ldbm.h index 079c947756..c6aecfdb95 100644 --- a/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -53,6 +53,7 @@ void cache_return_entry_rw LDAP_P(( Cache *cache, Entry *e, int rw )); #define cache_return_entry_w(c, e) cache_return_entry_rw((c), (e), 1) ID cache_find_entry_dn2id LDAP_P(( Backend *be, Cache *cache, const char *dn )); +ID cache_find_entry_ndn2id LDAP_P(( Backend *be, Cache *cache, const char *ndn )); Entry * cache_find_entry_id LDAP_P(( Cache *cache, ID id, int rw )); int cache_delete_entry LDAP_P(( Cache *cache, Entry *e )); void cache_release_all LDAP_P(( Cache *cache ));