Skip to content
Snippets Groups Projects
Commit b0a60a5d authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

added function cache_find_entry_ndn2id that avoids an unnecessary call to...

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
parent 6196b246
No related branches found
No related tags found
No related merge requests found
......@@ -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 );
}
......
......@@ -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 ));
......
......@@ -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 ));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment