1 /* cache.c - routines to maintain an in-core cache of entries */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/string.h>
14 #include <ac/socket.h>
20 /* BDB backend specific entry info -- visible only to the cache */
21 typedef struct bdb_entry_info {
22 ldap_pvt_thread_rdwr_t bei_rdwr; /* reader/writer lock */
25 * remaining fields require backend cache lock to access
26 * These items are specific to the BDB backend and should
29 int bei_state; /* for the cache */
30 #define CACHE_ENTRY_UNDEFINED 0
31 #define CACHE_ENTRY_CREATING 1
32 #define CACHE_ENTRY_READY 2
33 #define CACHE_ENTRY_DELETED 3
34 #define CACHE_ENTRY_COMMITTED 4
36 int bei_refcnt; /* # threads ref'ing this entry */
37 Entry *bei_lrunext; /* for cache lru list */
41 #define BEI(e) ((EntryInfo *) ((e)->e_private))
43 static int bdb_cache_delete_entry_internal(Cache *cache, Entry *e);
45 static void bdb_lru_print(Cache *cache);
49 bdb_cache_entry_rdwr_lock(Entry *e, int rw)
52 LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
53 "bdb_cache_entry_rdwr_lock: %s lock on ID %ld\n",
54 rw ? "w" : "r", e->e_id ));
56 Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%slock: ID: %ld\n",
57 rw ? "w" : "r", e->e_id, 0);
61 return ldap_pvt_thread_rdwr_wlock(&BEI(e)->bei_rdwr);
63 return ldap_pvt_thread_rdwr_rlock(&BEI(e)->bei_rdwr);
67 bdb_cache_entry_rdwr_trylock(Entry *e, int rw)
70 LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
71 "bdb_cache_entry_rdwr_trylock: try %s lock on ID: %ld.\n",
72 rw ? "w" : "r", e->e_id ));
74 Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%strylock: ID: %ld\n",
75 rw ? "w" : "r", e->e_id, 0);
79 return ldap_pvt_thread_rdwr_wtrylock(&BEI(e)->bei_rdwr);
81 return ldap_pvt_thread_rdwr_rtrylock(&BEI(e)->bei_rdwr);
85 bdb_cache_entry_rdwr_unlock(Entry *e, int rw)
88 LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
89 "bdb_cache_entry_rdwr_unlock: remove %s lock on ID %ld.\n",
90 rw ? "w" : "r", e->e_id ));
92 Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%sunlock: ID: %ld\n",
93 rw ? "w" : "r", e->e_id, 0);
97 return ldap_pvt_thread_rdwr_wunlock(&BEI(e)->bei_rdwr);
99 return ldap_pvt_thread_rdwr_runlock(&BEI(e)->bei_rdwr);
103 bdb_cache_entry_rdwr_init(Entry *e)
105 return ldap_pvt_thread_rdwr_init( &BEI(e)->bei_rdwr );
109 bdb_cache_entry_rdwr_destroy(Entry *e)
111 return ldap_pvt_thread_rdwr_destroy( &BEI(e)->bei_rdwr );
115 bdb_cache_entry_private_init( Entry *e )
117 assert( e->e_private == NULL );
119 if( e->e_private != NULL ) {
120 /* this should never happen */
124 e->e_private = ch_calloc(1, sizeof(struct bdb_entry_info));
126 if( bdb_cache_entry_rdwr_init( e ) != 0 ) {
136 * marks an entry in CREATING state as committed, so it is really returned
137 * to the cache. Otherwise an entry in CREATING state is removed.
138 * Makes e_private be destroyed at the following cache_return_entry_w,
139 * but lets the entry untouched (owned by someone else)
142 bdb_cache_entry_commit( Entry *e )
145 assert( e->e_private );
146 assert( BEI(e)->bei_state == CACHE_ENTRY_CREATING );
147 /* assert( BEI(e)->bei_refcnt == 1 ); */
149 BEI(e)->bei_state = CACHE_ENTRY_COMMITTED;
153 bdb_cache_entry_private_destroy( Entry *e )
155 assert( e->e_private );
157 bdb_cache_entry_rdwr_destroy( e );
159 free( e->e_private );
165 bdb_cache_return_entry_rw( Cache *cache, Entry *e, int rw )
168 int refcnt, freeit = 1;
170 /* set cache mutex */
171 ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
173 assert( e->e_private );
175 bdb_cache_entry_rdwr_unlock(e, rw);
178 refcnt = --BEI(e)->bei_refcnt;
181 * if the entry is returned when in CREATING state, it is deleted
182 * but not freed because it may belong to someone else (do_add,
185 if ( BEI(e)->bei_state == CACHE_ENTRY_CREATING ) {
186 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
187 bdb_cache_delete_entry_internal( cache, e );
188 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
190 /* now the entry is in DELETED state */
193 if ( BEI(e)->bei_state == CACHE_ENTRY_COMMITTED ) {
194 BEI(e)->bei_state = CACHE_ENTRY_READY;
196 /* free cache mutex */
197 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
200 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
201 "bdb_cache_return_entry_rw: return (%ld):%s, refcnt=%d\n",
202 id, rw ? "w" : "r", refcnt ));
204 Debug( LDAP_DEBUG_TRACE,
205 "====> bdb_cache_return_entry_%s( %ld ): created (%d)\n",
206 rw ? "w" : "r", id, refcnt );
210 } else if ( BEI(e)->bei_state == CACHE_ENTRY_DELETED ) {
212 /* free cache mutex */
213 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
216 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
217 "bdb_cache_return_entry_rw: %ld, delete pending (%d).\n",
220 Debug( LDAP_DEBUG_TRACE,
221 "====> bdb_cache_return_entry_%s( %ld ): delete pending (%d)\n",
222 rw ? "w" : "r", id, refcnt );
226 bdb_cache_entry_private_destroy( e );
228 bdb_entry_return( e );
231 /* free cache mutex */
232 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
235 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
236 "bdb_cache_return_entry_rw: (%ld): deleted (%d)\n",
239 Debug( LDAP_DEBUG_TRACE,
240 "====> bdb_cache_return_entry_%s( %ld ): deleted (%d)\n",
241 rw ? "w" : "r", id, refcnt );
246 /* free cache mutex */
247 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
250 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
251 "bdb_cache_return_entry_rw: ID %ld:%s returned (%d)\n",
252 id, rw ? "w": "r", refcnt ));
254 Debug( LDAP_DEBUG_TRACE,
255 "====> bdb_cache_return_entry_%s( %ld ): returned (%d)\n",
256 rw ? "w" : "r", id, refcnt);
261 #define LRU_DELETE( cache, e ) do { \
262 if ( BEI(e)->bei_lruprev != NULL ) { \
263 BEI(BEI(e)->bei_lruprev)->bei_lrunext = BEI(e)->bei_lrunext; \
265 (cache)->c_lruhead = BEI(e)->bei_lrunext; \
267 if ( BEI(e)->bei_lrunext != NULL ) { \
268 BEI(BEI(e)->bei_lrunext)->bei_lruprev = BEI(e)->bei_lruprev; \
270 (cache)->c_lrutail = BEI(e)->bei_lruprev; \
274 #define LRU_ADD( cache, e ) do { \
275 BEI(e)->bei_lrunext = (cache)->c_lruhead; \
276 if ( BEI(e)->bei_lrunext != NULL ) { \
277 BEI(BEI(e)->bei_lrunext)->bei_lruprev = (e); \
279 (cache)->c_lruhead = (e); \
280 BEI(e)->bei_lruprev = NULL; \
281 if ( (cache)->c_lrutail == NULL ) { \
282 (cache)->c_lrutail = (e); \
287 * cache_add_entry_rw - create and lock an entry in the cache
288 * returns: 0 entry has been created and locked
289 * 1 entry already existed
290 * -1 something bad happened
293 bdb_cache_add_entry_rw(
303 LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
304 "bdb_cache_add_entry_rw: add (%s):%s to cache\n",
305 e->e_dn, rw ? "w" : "r" ));
307 /* set cache mutex */
308 ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
310 assert( e->e_private == NULL );
312 if( bdb_cache_entry_private_init(e) != 0 ) {
313 /* free cache mutex */
314 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
317 LDAP_LOG(( "cache", LDAP_LEVEL_ERR,
318 "bdb_cache_add_entry_rw: add (%s):%ld private init failed!\n",
321 Debug( LDAP_DEBUG_ANY,
322 "====> bdb_cache_add_entry( %ld ): \"%s\": private init failed!\n",
323 e->e_id, e->e_dn, 0 );
330 if ( avl_insert( &cache->c_dntree, (caddr_t) e,
331 (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 )
333 /* free cache mutex */
334 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
337 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
338 "bdb_cache_add_entry: (%s):%ld already in cache.\n",
341 Debug( LDAP_DEBUG_TRACE,
342 "====> bdb_cache_add_entry( %ld ): \"%s\": already in dn cache\n",
343 e->e_id, e->e_dn, 0 );
346 bdb_cache_entry_private_destroy(e);
352 if ( avl_insert( &cache->c_idtree, (caddr_t) e,
353 (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 )
356 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
357 "bdb_cache_add_entry: (%s):%ls already in cache.\n",
360 Debug( LDAP_DEBUG_ANY,
361 "====> bdb_cache_add_entry( %ld ): \"%s\": already in id cache\n",
362 e->e_id, e->e_dn, 0 );
365 /* delete from dn tree inserted above */
366 if ( avl_delete( &cache->c_dntree, (caddr_t) e,
367 (AVL_CMP) entry_dn_cmp ) == NULL )
370 LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
371 "bdb_cache_add_entry: can't delete (%s) from cache.\n",
374 Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n",
379 bdb_cache_entry_private_destroy(e);
381 /* free cache mutex */
382 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
386 bdb_cache_entry_rdwr_lock( e, rw );
388 /* put the entry into 'CREATING' state */
389 /* will be marked after when entry is returned */
390 BEI(e)->bei_state = CACHE_ENTRY_CREATING;
391 BEI(e)->bei_refcnt = 1;
393 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
396 if ( ++cache->c_cursize > cache->c_maxsize ) {
398 * find the lru entry not currently in use and delete it.
399 * in case a lot of entries are in use, only look at the
400 * first 10 on the tail of the list.
403 while ( cache->c_lrutail != NULL &&
404 BEI(cache->c_lrutail)->bei_refcnt != 0 &&
407 /* move this in-use entry to the front of the q */
408 ee = cache->c_lrutail;
409 LRU_DELETE( cache, ee );
410 LRU_ADD( cache, ee );
415 * found at least one to delete - try to get back under
416 * the max cache size.
418 while ( cache->c_lrutail != NULL &&
419 BEI(cache->c_lrutail)->bei_refcnt == 0 &&
420 cache->c_cursize > cache->c_maxsize )
422 e = cache->c_lrutail;
424 /* delete from cache and lru q */
425 /* XXX do we need rc ? */
426 rc = bdb_cache_delete_entry_internal( cache, e );
427 bdb_cache_entry_private_destroy( e );
428 bdb_entry_return( e );
432 /* free cache mutex */
433 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
434 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
439 * cache_update_entry - update a LOCKED entry which has been deleted.
440 * returns: 0 entry has been created and locked
441 * 1 entry already existed
442 * -1 something bad happened
445 bdb_cache_update_entry(
453 /* set cache mutex */
454 ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
456 assert( e->e_private );
458 if ( avl_insert( &cache->c_dntree, (caddr_t) e,
459 (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 )
462 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
463 "bdb_cache_update_entry: (%s):%ld already in dn cache\n",
466 Debug( LDAP_DEBUG_TRACE,
467 "====> bdb_cache_update_entry( %ld ): \"%s\": already in dn cache\n",
468 e->e_id, e->e_dn, 0 );
471 /* free cache mutex */
472 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
477 if ( avl_insert( &cache->c_idtree, (caddr_t) e,
478 (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 )
481 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
482 "bdb_cache_update_entry: (%s)%ld already in id cache\n",
485 Debug( LDAP_DEBUG_ANY,
486 "====> bdb_cache_update_entry( %ld ): \"%s\": already in id cache\n",
487 e->e_id, e->e_dn, 0 );
490 /* delete from dn tree inserted above */
491 if ( avl_delete( &cache->c_dntree, (caddr_t) e,
492 (AVL_CMP) entry_dn_cmp ) == NULL )
495 LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
496 "bdb_cache_update_entry: can't delete (%s)%ld from dn cache.\n",
499 Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n",
504 /* free cache mutex */
505 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
510 /* put the entry into 'CREATING' state */
511 /* will be marked after when entry is returned */
512 BEI(e)->bei_state = CACHE_ENTRY_CREATING;
514 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
517 if ( ++cache->c_cursize > cache->c_maxsize ) {
519 * find the lru entry not currently in use and delete it.
520 * in case a lot of entries are in use, only look at the
521 * first 10 on the tail of the list.
524 while ( cache->c_lrutail != NULL &&
525 BEI(cache->c_lrutail)->bei_refcnt != 0 &&
528 /* move this in-use entry to the front of the q */
529 ee = cache->c_lrutail;
530 LRU_DELETE( cache, ee );
531 LRU_ADD( cache, ee );
536 * found at least one to delete - try to get back under
537 * the max cache size.
539 while ( cache->c_lrutail != NULL &&
540 BEI(cache->c_lrutail)->bei_refcnt == 0 &&
541 cache->c_cursize > cache->c_maxsize )
543 e = cache->c_lrutail;
545 /* delete from cache and lru q */
546 /* XXX do we need rc ? */
547 rc = bdb_cache_delete_entry_internal( cache, e );
548 bdb_cache_entry_private_destroy( e );
549 bdb_entry_return( e );
553 /* free cache mutex */
554 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
555 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
560 bdb_cache_find_entry_ndn2id(
570 /* this function is always called with normalized DN */
574 /* set cache mutex */
575 ldap_pvt_thread_rdwr_rlock( &cache->c_rwlock );
577 if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
578 (AVL_CMP) entry_dn_cmp )) != NULL )
584 * ep now points to an unlocked entry
585 * we do not need to lock the entry if we only
586 * check the state, refcnt, LRU, and id.
589 assert( ep->e_private );
593 state = BEI(ep)->bei_state;
596 * entry is deleted or not fully created yet
598 if ( state != CACHE_ENTRY_READY ) {
599 assert(state != CACHE_ENTRY_UNDEFINED);
601 /* free cache mutex */
602 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
605 LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
606 "bdb_cache_find_entry_dn2id: (%s) %ld not ready: %d\n",
607 ndn->bv_val, id, state ));
609 Debug(LDAP_DEBUG_TRACE,
610 "====> bdb_cache_find_entry_dn2id(\"%s\"): %ld (not ready) %d\n",
611 ndn->bv_val, id, state);
615 ldap_pvt_thread_yield();
619 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
621 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
624 LRU_DELETE( cache, ep );
625 LRU_ADD( cache, ep );
627 /* free cache mutex */
628 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
631 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
632 "bdb_cache_find_entry_dn2id: (%s): %ld %d tries\n",
633 ndn->bv_val, id, count ));
635 Debug(LDAP_DEBUG_TRACE,
636 "====> bdb_cache_find_entry_dn2id(\"%s\"): %ld (%d tries)\n",
637 ndn->bv_val, id, count);
641 /* free cache mutex */
642 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
651 * cache_find_entry_id - find an entry in the cache, given id
655 bdb_cache_find_entry_id(
668 /* set cache mutex */
669 ldap_pvt_thread_rdwr_rlock( &cache->c_rwlock );
671 if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
672 (AVL_CMP) entry_id_cmp )) != NULL )
679 assert( ep->e_private );
682 state = BEI(ep)->bei_state;
685 * entry is deleted or not fully created yet
687 if ( state != CACHE_ENTRY_READY ) {
689 assert(state != CACHE_ENTRY_UNDEFINED);
691 /* free cache mutex */
692 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
695 LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
696 "bdb_cache_find_entry_id: (%ld)->%ld not ready (%d).\n",
700 Debug(LDAP_DEBUG_TRACE,
701 "====> bdb_cache_find_entry_id( %ld ): %ld (not ready) %d\n",
705 ldap_pvt_thread_yield();
709 /* acquire reader lock */
710 if ( bdb_cache_entry_rdwr_trylock(ep, rw) == LDAP_PVT_THREAD_EBUSY ) {
711 /* could not acquire entry lock...
712 * owner cannot free as we have the cache locked.
713 * so, unlock the cache, yield, and try again.
716 /* free cache mutex */
717 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
720 LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
721 "bdb_cache_find_entry_id: %ld -> %ld (busy) %d.\n",
724 Debug(LDAP_DEBUG_TRACE,
725 "====> bdb_cache_find_entry_id( %ld ): %ld (busy) %d\n",
729 ldap_pvt_thread_yield();
733 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
734 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
736 LRU_DELETE( cache, ep );
737 LRU_ADD( cache, ep );
739 BEI(ep)->bei_refcnt++;
741 /* free cache mutex */
742 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
745 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
746 "bdb_cache_find_entry_id: %ld -> %s found %d tries.\n",
747 ep_id, ep->e_dn, count ));
749 Debug(LDAP_DEBUG_TRACE,
750 "====> bdb_cache_find_entry_id( %ld ) \"%s\" (found) (%d tries)\n",
751 ep_id, ep->e_dn, count);
758 /* free cache mutex */
759 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
765 * cache_delete_entry - delete the entry e from the cache. the caller
766 * should have obtained e (increasing its ref count) via a call to one
767 * of the cache_find_* routines. the caller should *not* call the
768 * cache_return_entry() routine prior to calling cache_delete_entry().
769 * it performs this function.
771 * returns: 0 e was deleted ok
772 * 1 e was not in the cache
773 * -1 something bad happened
776 bdb_cache_delete_entry(
783 /* set cache mutex */
784 ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
786 assert( e->e_private );
789 LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
790 "bdb_cache_delete_entry: delete %ld.\n", e->e_id ));
792 Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_delete_entry( %ld )\n",
796 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
797 rc = bdb_cache_delete_entry_internal( cache, e );
798 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
800 /* free cache mutex */
801 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
806 bdb_cache_delete_entry_internal(
811 int rc = 0; /* return code */
814 if ( avl_delete( &cache->c_dntree, (caddr_t) e, (AVL_CMP) entry_dn_cmp )
821 if ( avl_delete( &cache->c_idtree, (caddr_t) e, (AVL_CMP) entry_id_cmp )
832 LRU_DELETE( cache, e );
836 * flag entry to be freed later by a call to cache_return_entry()
838 BEI(e)->bei_state = CACHE_ENTRY_DELETED;
844 bdb_cache_release_all( Cache *cache )
849 /* set cache mutex */
850 ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
851 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
854 LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
855 "bdb_cache_release_all: enter\n" ));
857 Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_release_all\n", 0, 0, 0 );
860 while ( (e = cache->c_lrutail) != NULL && BEI(e)->bei_refcnt == 0 ) {
861 #ifdef LDAP_RDWR_DEBUG
862 assert(!ldap_pvt_thread_rdwr_active(&BEI(e)->bei_rdwr));
865 /* delete from cache and lru q */
866 /* XXX do we need rc ? */
867 rc = bdb_cache_delete_entry_internal( cache, e );
868 bdb_cache_entry_private_destroy( e );
869 bdb_entry_return( e );
872 if ( cache->c_cursize ) {
874 LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
875 "bdb_cache_release_all: Entry cache could not be emptied.\n" ));
877 Debug( LDAP_DEBUG_TRACE, "Entry-cache could not be emptied\n", 0, 0, 0 );
882 /* free cache mutex */
883 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
884 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
889 bdb_lru_print( Cache *cache )
893 fprintf( stderr, "LRU queue (head to tail):\n" );
894 for ( e = cache->c_lruhead; e != NULL; e = BEI(e)->bei_lrunext ) {
895 fprintf( stderr, "\tdn \"%20s\" id %ld refcnt %d\n",
896 e->e_dn, e->e_id, BEI(e)->bei_refcnt );
898 fprintf( stderr, "LRU queue (tail to head):\n" );
899 for ( e = cache->c_lrutail; e != NULL; e = BEI(e)->bei_lruprev ) {
900 fprintf( stderr, "\tdn \"%20s\" id %ld refcnt %d\n",
901 e->e_dn, e->e_id, BEI(e)->bei_refcnt );