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

This commit is contained in:
Pierangelo Masarati 2001-07-11 08:41:42 +00:00
parent 6196b2463d
commit b0a60a5d3d
3 changed files with 26 additions and 8 deletions

View File

@ -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 );
}

View File

@ -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 ));

View File

@ -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 ));