]> git.sur5r.net Git - openldap/commitdiff
ITS#6341 removal of last entry from cache caused corruption in the lru list
authorRalf Haferkamp <ralf@openldap.org>
Tue, 20 Oct 2009 14:41:09 +0000 (14:41 +0000)
committerRalf Haferkamp <ralf@openldap.org>
Tue, 20 Oct 2009 14:41:09 +0000 (14:41 +0000)
servers/slapd/back-bdb/cache.c

index a6ba2b9b369dddd2ce459d10f4c7af88115edab9..bab34701b6d098069621dc9d009ec17c65a69a66 100644 (file)
@@ -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 )