From 96ce821037b0f4957c8657a89b2e2f4c62dd2172 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Tue, 20 Oct 2009 14:41:09 +0000 Subject: [PATCH] ITS#6341 removal of last entry from cache caused corruption in the lru list --- servers/slapd/back-bdb/cache.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index a6ba2b9b36..bab34701b6 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -106,10 +106,14 @@ bdb_cache_entryinfo_free( Cache *cache, EntryInfo *ei ) } #define LRU_DEL( c, e ) do { \ - if ( e == (c)->c_lruhead ) (c)->c_lruhead = e->bei_lruprev; \ - if ( e == (c)->c_lrutail ) (c)->c_lrutail = e->bei_lruprev; \ - e->bei_lrunext->bei_lruprev = e->bei_lruprev; \ - e->bei_lruprev->bei_lrunext = e->bei_lrunext; \ + if ( e == e->bei_lruprev ) { \ + (c)->c_lruhead = (c)->c_lrutail = NULL; \ + } else { \ + if ( e == (c)->c_lruhead ) (c)->c_lruhead = e->bei_lruprev; \ + if ( e == (c)->c_lrutail ) (c)->c_lrutail = e->bei_lruprev; \ + e->bei_lrunext->bei_lruprev = e->bei_lruprev; \ + e->bei_lruprev->bei_lrunext = e->bei_lrunext; \ + } \ e->bei_lruprev = NULL; \ } while ( 0 ) -- 2.39.5