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 write lock */
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 ) {
187 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
188 bdb_cache_delete_entry_internal( cache, e );
190 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
192 /* now the entry is in DELETED state */
195 if ( BEI(e)->bei_state == CACHE_ENTRY_COMMITTED ) {
196 BEI(e)->bei_state = CACHE_ENTRY_READY;
198 /* free cache write lock */
199 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
202 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
203 "bdb_cache_return_entry_rw: return (%ld):%s, refcnt=%d\n",
204 id, rw ? "w" : "r", refcnt ));
206 Debug( LDAP_DEBUG_TRACE,
207 "====> bdb_cache_return_entry_%s( %ld ): created (%d)\n",
208 rw ? "w" : "r", id, refcnt );
212 } else if ( BEI(e)->bei_state == CACHE_ENTRY_DELETED ) {
214 /* free cache write lock */
215 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
218 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
219 "bdb_cache_return_entry_rw: %ld, delete pending (%d).\n",
222 Debug( LDAP_DEBUG_TRACE,
223 "====> bdb_cache_return_entry_%s( %ld ): delete pending (%d)\n",
224 rw ? "w" : "r", id, refcnt );
228 bdb_cache_entry_private_destroy( e );
230 bdb_entry_return( e );
233 /* free cache write lock */
234 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
237 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
238 "bdb_cache_return_entry_rw: (%ld): deleted (%d)\n",
241 Debug( LDAP_DEBUG_TRACE,
242 "====> bdb_cache_return_entry_%s( %ld ): deleted (%d)\n",
243 rw ? "w" : "r", id, refcnt );
248 /* free cache write lock */
249 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
252 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
253 "bdb_cache_return_entry_rw: ID %ld:%s returned (%d)\n",
254 id, rw ? "w": "r", refcnt ));
256 Debug( LDAP_DEBUG_TRACE,
257 "====> bdb_cache_return_entry_%s( %ld ): returned (%d)\n",
258 rw ? "w" : "r", id, refcnt);
263 #define LRU_DELETE( cache, e ) do { \
264 if ( BEI(e)->bei_lruprev != NULL ) { \
265 BEI(BEI(e)->bei_lruprev)->bei_lrunext = BEI(e)->bei_lrunext; \
267 (cache)->c_lruhead = BEI(e)->bei_lrunext; \
269 if ( BEI(e)->bei_lrunext != NULL ) { \
270 BEI(BEI(e)->bei_lrunext)->bei_lruprev = BEI(e)->bei_lruprev; \
272 (cache)->c_lrutail = BEI(e)->bei_lruprev; \
276 #define LRU_ADD( cache, e ) do { \
277 BEI(e)->bei_lrunext = (cache)->c_lruhead; \
278 if ( BEI(e)->bei_lrunext != NULL ) { \
279 BEI(BEI(e)->bei_lrunext)->bei_lruprev = (e); \
281 (cache)->c_lruhead = (e); \
282 BEI(e)->bei_lruprev = NULL; \
283 if ( (cache)->c_lrutail == NULL ) { \
284 (cache)->c_lrutail = (e); \
289 * cache_add_entry_rw - create and lock an entry in the cache
290 * returns: 0 entry has been created and locked
291 * 1 entry already existed
292 * -1 something bad happened
295 bdb_cache_add_entry_rw(
305 LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
306 "bdb_cache_add_entry_rw: add (%s):%s to cache\n",
307 e->e_dn, rw ? "w" : "r" ));
309 /* set cache write lock */
310 ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
312 assert( e->e_private == NULL );
314 if( bdb_cache_entry_private_init(e) != 0 ) {
315 /* free cache write lock */
316 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
319 LDAP_LOG(( "cache", LDAP_LEVEL_ERR,
320 "bdb_cache_add_entry_rw: add (%s):%ld private init failed!\n",
323 Debug( LDAP_DEBUG_ANY,
324 "====> bdb_cache_add_entry( %ld ): \"%s\": private init failed!\n",
325 e->e_id, e->e_dn, 0 );
332 if ( avl_insert( &cache->c_dntree, (caddr_t) e,
333 (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 )
335 /* free cache write lock */
336 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
339 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
340 "bdb_cache_add_entry: (%s):%ld already in cache.\n",
343 Debug( LDAP_DEBUG_TRACE,
344 "====> bdb_cache_add_entry( %ld ): \"%s\": already in dn cache\n",
345 e->e_id, e->e_dn, 0 );
348 bdb_cache_entry_private_destroy(e);
354 if ( avl_insert( &cache->c_idtree, (caddr_t) e,
355 (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 )
358 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
359 "bdb_cache_add_entry: (%s):%ls already in cache.\n",
362 Debug( LDAP_DEBUG_ANY,
363 "====> bdb_cache_add_entry( %ld ): \"%s\": already in id cache\n",
364 e->e_id, e->e_dn, 0 );
367 /* delete from dn tree inserted above */
368 if ( avl_delete( &cache->c_dntree, (caddr_t) e,
369 (AVL_CMP) entry_dn_cmp ) == NULL )
372 LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
373 "bdb_cache_add_entry: can't delete (%s) from cache.\n",
376 Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n",
381 bdb_cache_entry_private_destroy(e);
383 /* free cache write lock */
384 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
388 bdb_cache_entry_rdwr_lock( e, rw );
390 /* put the entry into 'CREATING' state */
391 /* will be marked after when entry is returned */
392 BEI(e)->bei_state = CACHE_ENTRY_CREATING;
393 BEI(e)->bei_refcnt = 1;
396 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
399 if ( ++cache->c_cursize > cache->c_maxsize ) {
401 * find the lru entry not currently in use and delete it.
402 * in case a lot of entries are in use, only look at the
403 * first 10 on the tail of the list.
406 while ( cache->c_lrutail != NULL &&
407 BEI(cache->c_lrutail)->bei_refcnt != 0 &&
410 /* move this in-use entry to the front of the q */
411 ee = cache->c_lrutail;
412 LRU_DELETE( cache, ee );
413 LRU_ADD( cache, ee );
418 * found at least one to delete - try to get back under
419 * the max cache size.
421 while ( cache->c_lrutail != NULL &&
422 BEI(cache->c_lrutail)->bei_refcnt == 0 &&
423 cache->c_cursize > cache->c_maxsize )
425 e = cache->c_lrutail;
427 /* delete from cache and lru q */
428 /* XXX do we need rc ? */
429 rc = bdb_cache_delete_entry_internal( cache, e );
430 bdb_cache_entry_private_destroy( e );
431 bdb_entry_return( e );
436 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
437 /* free cache write lock */
438 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
443 * cache_update_entry - update a LOCKED entry which has been deleted.
444 * returns: 0 entry has been created and locked
445 * 1 entry already existed
446 * -1 something bad happened
449 bdb_cache_update_entry(
457 /* set cache write lock */
458 ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
460 assert( e->e_private );
462 if ( avl_insert( &cache->c_dntree, (caddr_t) e,
463 (AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 )
466 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
467 "bdb_cache_update_entry: (%s):%ld already in dn cache\n",
470 Debug( LDAP_DEBUG_TRACE,
471 "====> bdb_cache_update_entry( %ld ): \"%s\": already in dn cache\n",
472 e->e_id, e->e_dn, 0 );
475 /* free cache write lock */
476 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
481 if ( avl_insert( &cache->c_idtree, (caddr_t) e,
482 (AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 )
485 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
486 "bdb_cache_update_entry: (%s)%ld already in id cache\n",
489 Debug( LDAP_DEBUG_ANY,
490 "====> bdb_cache_update_entry( %ld ): \"%s\": already in id cache\n",
491 e->e_id, e->e_dn, 0 );
494 /* delete from dn tree inserted above */
495 if ( avl_delete( &cache->c_dntree, (caddr_t) e,
496 (AVL_CMP) entry_dn_cmp ) == NULL )
499 LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
500 "bdb_cache_update_entry: can't delete (%s)%ld from dn cache.\n",
503 Debug( LDAP_DEBUG_ANY, "====> can't delete from dn cache\n",
508 /* free cache write lock */
509 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
514 /* put the entry into 'CREATING' state */
515 /* will be marked after when entry is returned */
516 BEI(e)->bei_state = CACHE_ENTRY_CREATING;
519 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
522 if ( ++cache->c_cursize > cache->c_maxsize ) {
524 * find the lru entry not currently in use and delete it.
525 * in case a lot of entries are in use, only look at the
526 * first 10 on the tail of the list.
529 while ( cache->c_lrutail != NULL &&
530 BEI(cache->c_lrutail)->bei_refcnt != 0 &&
533 /* move this in-use entry to the front of the q */
534 ee = cache->c_lrutail;
535 LRU_DELETE( cache, ee );
536 LRU_ADD( cache, ee );
541 * found at least one to delete - try to get back under
542 * the max cache size.
544 while ( cache->c_lrutail != NULL &&
545 BEI(cache->c_lrutail)->bei_refcnt == 0 &&
546 cache->c_cursize > cache->c_maxsize )
548 e = cache->c_lrutail;
550 /* delete from cache and lru q */
551 /* XXX do we need rc ? */
552 rc = bdb_cache_delete_entry_internal( cache, e );
553 bdb_cache_entry_private_destroy( e );
554 bdb_entry_return( e );
559 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
560 /* free cache write lock */
561 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
566 bdb_cache_find_entry_ndn2id(
576 /* this function is always called with normalized DN */
580 /* set cache read lock */
581 ldap_pvt_thread_rdwr_rlock( &cache->c_rwlock );
583 if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
584 (AVL_CMP) entry_dn_cmp )) != NULL )
590 * ep now points to an unlocked entry
591 * we do not need to lock the entry if we only
592 * check the state, refcnt, LRU, and id.
595 assert( ep->e_private );
599 state = BEI(ep)->bei_state;
602 * entry is deleted or not fully created yet
604 if ( state != CACHE_ENTRY_READY ) {
605 assert(state != CACHE_ENTRY_UNDEFINED);
607 /* free cache read lock */
608 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
611 LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
612 "bdb_cache_find_entry_dn2id: (%s) %ld not ready: %d\n",
613 ndn->bv_val, id, state ));
615 Debug(LDAP_DEBUG_TRACE,
616 "====> bdb_cache_find_entry_dn2id(\"%s\"): %ld (not ready) %d\n",
617 ndn->bv_val, id, state);
621 ldap_pvt_thread_yield();
625 /* free cache read lock */
626 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
629 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
632 LRU_DELETE( cache, ep );
633 LRU_ADD( cache, ep );
636 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
639 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
640 "bdb_cache_find_entry_dn2id: (%s): %ld %d tries\n",
641 ndn->bv_val, id, count ));
643 Debug(LDAP_DEBUG_TRACE,
644 "====> bdb_cache_find_entry_dn2id(\"%s\"): %ld (%d tries)\n",
645 ndn->bv_val, id, count);
649 /* free cache read lock */
650 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
659 * cache_find_entry_id - find an entry in the cache, given id
663 bdb_cache_find_entry_id(
676 /* set cache read lock */
677 ldap_pvt_thread_rdwr_rlock( &cache->c_rwlock );
679 if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
680 (AVL_CMP) entry_id_cmp )) != NULL )
687 assert( ep->e_private );
690 state = BEI(ep)->bei_state;
693 * entry is deleted or not fully created yet
695 if ( state != CACHE_ENTRY_READY ) {
697 assert(state != CACHE_ENTRY_UNDEFINED);
699 /* free cache read lock */
700 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
703 LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
704 "bdb_cache_find_entry_id: (%ld)->%ld not ready (%d).\n",
708 Debug(LDAP_DEBUG_TRACE,
709 "====> bdb_cache_find_entry_id( %ld ): %ld (not ready) %d\n",
713 ldap_pvt_thread_yield();
717 /* acquire reader lock */
718 if ( bdb_cache_entry_rdwr_trylock(ep, rw) == LDAP_PVT_THREAD_EBUSY ) {
719 /* could not acquire entry lock...
720 * owner cannot free as we have the cache locked.
721 * so, unlock the cache, yield, and try again.
724 /* free cache read lock */
725 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
728 LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
729 "bdb_cache_find_entry_id: %ld -> %ld (busy) %d.\n",
732 Debug(LDAP_DEBUG_TRACE,
733 "====> bdb_cache_find_entry_id( %ld ): %ld (busy) %d\n",
737 ldap_pvt_thread_yield();
741 /* free cache read lock */
742 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
744 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
746 LRU_DELETE( cache, ep );
747 LRU_ADD( cache, ep );
749 BEI(ep)->bei_refcnt++;
752 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
755 LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
756 "bdb_cache_find_entry_id: %ld -> %s found %d tries.\n",
757 ep_id, ep->e_dn, count ));
759 Debug(LDAP_DEBUG_TRACE,
760 "====> bdb_cache_find_entry_id( %ld ) \"%s\" (found) (%d tries)\n",
761 ep_id, ep->e_dn, count);
768 /* free cache read lock */
769 ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
775 * cache_delete_entry - delete the entry e from the cache. the caller
776 * should have obtained e (increasing its ref count) via a call to one
777 * of the cache_find_* routines. the caller should *not* call the
778 * cache_return_entry() routine prior to calling cache_delete_entry().
779 * it performs this function.
781 * returns: 0 e was deleted ok
782 * 1 e was not in the cache
783 * -1 something bad happened
786 bdb_cache_delete_entry(
793 /* set cache write lock */
794 ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
796 assert( e->e_private );
799 LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
800 "bdb_cache_delete_entry: delete %ld.\n", e->e_id ));
802 Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_delete_entry( %ld )\n",
807 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
808 rc = bdb_cache_delete_entry_internal( cache, e );
810 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
812 /* free cache write lock */
813 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
818 bdb_cache_delete_entry_internal(
823 int rc = 0; /* return code */
826 if ( avl_delete( &cache->c_dntree, (caddr_t) e, (AVL_CMP) entry_dn_cmp )
833 if ( avl_delete( &cache->c_idtree, (caddr_t) e, (AVL_CMP) entry_id_cmp )
844 LRU_DELETE( cache, e );
848 * flag entry to be freed later by a call to cache_return_entry()
850 BEI(e)->bei_state = CACHE_ENTRY_DELETED;
856 bdb_cache_release_all( Cache *cache )
861 /* set cache write lock */
862 ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
864 ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
867 LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
868 "bdb_cache_release_all: enter\n" ));
870 Debug( LDAP_DEBUG_TRACE, "====> bdb_cache_release_all\n", 0, 0, 0 );
873 while ( (e = cache->c_lrutail) != NULL && BEI(e)->bei_refcnt == 0 ) {
874 #ifdef LDAP_RDWR_DEBUG
875 assert(!ldap_pvt_thread_rdwr_active(&BEI(e)->bei_rdwr));
878 /* delete from cache and lru q */
879 /* XXX do we need rc ? */
880 rc = bdb_cache_delete_entry_internal( cache, e );
881 bdb_cache_entry_private_destroy( e );
882 bdb_entry_return( e );
885 if ( cache->c_cursize ) {
887 LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
888 "bdb_cache_release_all: Entry cache could not be emptied.\n" ));
890 Debug( LDAP_DEBUG_TRACE, "Entry-cache could not be emptied\n", 0, 0, 0 );
896 ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
897 /* free cache write lock */
898 ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
903 bdb_lru_print( Cache *cache )
907 fprintf( stderr, "LRU queue (head to tail):\n" );
908 for ( e = cache->c_lruhead; e != NULL; e = BEI(e)->bei_lrunext ) {
909 fprintf( stderr, "\tdn \"%20s\" id %ld refcnt %d\n",
910 e->e_dn, e->e_id, BEI(e)->bei_refcnt );
912 fprintf( stderr, "LRU queue (tail to head):\n" );
913 for ( e = cache->c_lrutail; e != NULL; e = BEI(e)->bei_lruprev ) {
914 fprintf( stderr, "\tdn \"%20s\" id %ld refcnt %d\n",
915 e->e_dn, e->e_id, BEI(e)->bei_refcnt );