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

This commit is contained in:
antirez 2010-11-11 13:19:17 +01:00
parent 0c95631468
commit eef979cb95

View File

@ -1372,6 +1372,10 @@ void freeMemoryIfNeeded(void) {
de = dictGetRandomKey(dict); de = dictGetRandomKey(dict);
thiskey = dictGetEntryKey(de); 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); o = dictGetEntryVal(de);
thisval = estimateObjectIdleTime(o); thisval = estimateObjectIdleTime(o);