static void lru_print(struct cache *cache);
#endif
-/*
- * the cache has three entry points (ways to find things):
- *
- * by entry e.g., if you already have an entry from the cache
- * and want to delete it. (really by entry ptr)
- * by dn e.g., when looking for the base object of a search
- * by id e.g., for search candidates
- *
- * these correspond to three different avl trees that are maintained.
- */
-#define cache_entry_cmp entry_cmp
-#define cache_entrydn_cmp entry_dn_cmp
-#define cache_entryid_cmp entry_id_cmp
-
static int
cache_entry_rdwr_lock(Entry *e, int rw)
{
- Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%slock: ID: %lu\n",
+ Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%slock: ID: %ld\n",
rw ? "w" : "r", e->e_id, 0);
if (rw)
static int
cache_entry_rdwr_trylock(Entry *e, int rw)
{
- Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%strylock: ID: %lu\n",
+ Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%strylock: ID: %ld\n",
rw ? "w" : "r", e->e_id, 0);
if (rw)
static int
cache_entry_rdwr_unlock(Entry *e, int rw)
{
- Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%sunlock: ID: %lu\n",
+ Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%sunlock: ID: %ld\n",
rw ? "w" : "r", e->e_id, 0);
if (rw)
if ( LEI(e)->lei_state == CACHE_ENTRY_CREATING ) {
Debug( LDAP_DEBUG_TRACE,
- "====> cache_return_entry_%s( %lu ): created (%d)\n",
+ "====> cache_return_entry_%s( %ld ): created (%d)\n",
rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt );
LEI(e)->lei_state = CACHE_ENTRY_READY;
} else if ( LEI(e)->lei_state == CACHE_ENTRY_DELETED ) {
if( LEI(e)->lei_refcnt > 0 ) {
Debug( LDAP_DEBUG_TRACE,
- "====> cache_return_entry_%s( %lu ): delete pending (%d)\n",
+ "====> cache_return_entry_%s( %ld ): delete pending (%d)\n",
rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt );
} else {
Debug( LDAP_DEBUG_TRACE,
- "====> cache_return_entry_%s( %lu ): deleted (%d)\n",
+ "====> cache_return_entry_%s( %ld ): deleted (%d)\n",
rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt );
cache_entry_private_destroy( e );
} else {
Debug( LDAP_DEBUG_TRACE,
- "====> cache_return_entry_%s( %lu ): returned (%d)\n",
+ "====> cache_return_entry_%s( %ld ): returned (%d)\n",
rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt);
}
if( cache_entry_private_init(e) != 0 ) {
Debug( LDAP_DEBUG_ANY,
- "====> cache_add_entry( %lu ): \"%s\": private init failed!\n",
+ "====> cache_add_entry( %ld ): \"%s\": private init failed!\n",
e->e_id, e->e_dn, 0 );
return( -1 );
}
if ( avl_insert( &cache->c_dntree, (caddr_t) e,
- cache_entrydn_cmp, avl_dup_error ) != 0 )
+ entry_dn_cmp, avl_dup_error ) != 0 )
{
Debug( LDAP_DEBUG_TRACE,
- "====> cache_add_entry( %lu ): \"%s\": already in dn cache\n",
+ "====> cache_add_entry( %ld ): \"%s\": already in dn cache\n",
e->e_id, e->e_dn, 0 );
cache_entry_private_destroy(e);
/* id tree */
if ( avl_insert( &cache->c_idtree, (caddr_t) e,
- cache_entryid_cmp, avl_dup_error ) != 0 )
+ entry_id_cmp, avl_dup_error ) != 0 )
{
Debug( LDAP_DEBUG_ANY,
- "====> cache_add_entry( %lu ): \"%s\": already in id cache\n",
+ "====> cache_add_entry( %ld ): \"%s\": already in id cache\n",
e->e_id, e->e_dn, 0 );
/* delete from dn tree inserted above */
if ( avl_delete( &cache->c_dntree, (caddr_t) e,
- cache_entrydn_cmp ) == NULL )
+ entry_dn_cmp ) == NULL )
{
Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n",
0, 0, 0 );
e = cache->c_lrutail;
/* delete from cache and lru q */
+ /* XXX do we need rc ? */
rc = cache_delete_entry_internal( cache, e );
cache_entry_private_destroy( e );
entry_free( e );
#endif
if ( avl_insert( &cache->c_dntree, (caddr_t) e,
- cache_entrydn_cmp, avl_dup_error ) != 0 )
+ entry_dn_cmp, avl_dup_error ) != 0 )
{
Debug( LDAP_DEBUG_TRACE,
- "====> cache_update_entry( %lu ): \"%s\": already in dn cache\n",
+ "====> cache_update_entry( %ld ): \"%s\": already in dn cache\n",
e->e_id, e->e_dn, 0 );
/* free cache mutex */
/* id tree */
if ( avl_insert( &cache->c_idtree, (caddr_t) e,
- cache_entryid_cmp, avl_dup_error ) != 0 )
+ entry_id_cmp, avl_dup_error ) != 0 )
{
Debug( LDAP_DEBUG_ANY,
- "====> cache_update_entry( %lu ): \"%s\": already in id cache\n",
+ "====> cache_update_entry( %ld ): \"%s\": already in id cache\n",
e->e_id, e->e_dn, 0 );
/* delete from dn tree inserted above */
if ( avl_delete( &cache->c_dntree, (caddr_t) e,
- cache_entrydn_cmp ) == NULL )
+ entry_dn_cmp ) == NULL )
{
Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n",
0, 0, 0 );
e = cache->c_lrutail;
/* delete from cache and lru q */
+ /* XXX do we need rc ? */
rc = cache_delete_entry_internal( cache, e );
cache_entry_private_destroy( e );
entry_free( e );
e.e_ndn = dn_normalize_case( ch_strdup( dn ) );
if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
- cache_entrydn_cmp )) != NULL )
+ entry_dn_cmp )) != NULL )
{
/*
* ep now points to an unlocked entry
assert(LEI(ep)->lei_state != CACHE_ENTRY_UNDEFINED);
#endif
Debug(LDAP_DEBUG_TRACE,
- "====> cache_find_entry_dn2id(\"%s\"): %lu (not ready) %d\n",
+ "====> cache_find_entry_dn2id(\"%s\"): %ld (not ready) %d\n",
dn, ep->e_id, LEI(ep)->lei_state);
/* free cache mutex */
}
Debug(LDAP_DEBUG_TRACE,
- "====> cache_find_entry_dn2id(\"%s\"): %lu\n",
+ "====> cache_find_entry_dn2id(\"%s\"): %ld\n",
dn, ep->e_id, 0);
/* lru */
ldap_pvt_thread_mutex_lock( &cache->c_mutex );
if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
- cache_entryid_cmp )) != NULL )
+ entry_id_cmp )) != NULL )
{
#ifdef LDAP_DEBUG
assert( ep->e_private );
assert(LEI(ep)->lei_state != CACHE_ENTRY_UNDEFINED);
#endif
Debug(LDAP_DEBUG_TRACE,
- "====> cache_find_entry_id( %lu ): %lu (not ready) %d\n",
+ "====> cache_find_entry_id( %ld ): %ld (not ready) %d\n",
id, ep->e_id, LEI(ep)->lei_state);
/* free cache mutex */
}
Debug(LDAP_DEBUG_TRACE,
- "====> cache_find_entry_id( %lu, %s ) \"%s\" (found)\n",
+ "====> cache_find_entry_id( %ld, %s ) \"%s\" (found)\n",
id, rw ? "w" : "r", ep->e_dn);
/* acquire reader lock */
assert( e->e_private );
#endif
- Debug( LDAP_DEBUG_TRACE, "====> cache_delete_entry( %lu )\n",
+ Debug( LDAP_DEBUG_TRACE, "====> cache_delete_entry( %ld )\n",
e->e_id, 0, 0 );
rc = cache_delete_entry_internal( cache, e );
int rc = 0; /* return code */
/* dn tree */
- if ( avl_delete( &cache->c_dntree, (caddr_t) e, cache_entrydn_cmp )
+ if ( avl_delete( &cache->c_dntree, (caddr_t) e, entry_dn_cmp )
== NULL )
{
rc = -1;
}
/* id tree */
- if ( avl_delete( &cache->c_idtree, (caddr_t) e, cache_entryid_cmp )
+ if ( avl_delete( &cache->c_idtree, (caddr_t) e, entry_id_cmp )
== NULL )
{
rc = -1;
fprintf( stderr, "LRU queue (head to tail):\n" );
for ( e = cache->c_lruhead; e != NULL; e = LEI(e)->lei_lrunext ) {
- fprintf( stderr, "\tdn \"%20s\" id %lu refcnt %d\n",
+ fprintf( stderr, "\tdn \"%20s\" id %ld refcnt %d\n",
e->e_dn, e->e_id, LEI(e)->lei_refcnt );
}
fprintf( stderr, "LRU queue (tail to head):\n" );
for ( e = cache->c_lrutail; e != NULL; e = LEI(e)->lei_lruprev ) {
- fprintf( stderr, "\tdn \"%20s\" id %lu refcnt %d\n",
+ fprintf( stderr, "\tdn \"%20s\" id %ld refcnt %d\n",
e->e_dn, e->e_id, LEI(e)->lei_refcnt );
}
}