From 0c2f75c6d809a1658a244e74ef209dabb19fb4c7 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 11 Nov 2010 13:19:17 +0100 Subject: [PATCH] volatile-lru maxmemory policy segfault fixed, thanks to Anthony Lauzon for reporting the problem with the patch. Original patch modified a bit in order to avoid the double lookup if the policy is allkeys-lru --- src/redis.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/redis.c b/src/redis.c index fe656de9b..cf5673a3a 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1372,6 +1372,10 @@ void freeMemoryIfNeeded(void) { de = dictGetRandomKey(dict); thiskey = dictGetEntryKey(de); + /* When policy is volatile-lru we need an additonal lookup + * to locate the real key, as dict is set to db->expires. */ + if (server.maxmemory_policy == REDIS_MAXMEMORY_VOLATILE_LRU) + de = dictFind(db->dict, thiskey); o = dictGetEntryVal(de); thisval = estimateObjectIdleTime(o); -- GitLab