Writable slaves expires: fix leak in key tracking.

We need to use a dictionary type that frees the key, since we copy the
keys in the dictionary we use to track expires created in the slave
side.
This commit is contained in:
antirez 2016-12-13 16:27:13 +01:00
parent d1adc85aa6
commit b6f871cf42
2 changed files with 16 additions and 2 deletions

View File

@ -315,8 +315,17 @@ void expireSlaveKeys(void) {
/* Track keys that received an EXPIRE or similar command in the context
* of a writable slave. */
void rememberSlaveKeyWithExpire(redisDb *db, robj *key) {
if (slaveKeysWithExpire == NULL)
slaveKeysWithExpire = dictCreate(&keyptrDictType,NULL);
if (slaveKeysWithExpire == NULL) {
static dictType dt = {
dictSdsHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL /* val destructor */
};
slaveKeysWithExpire = dictCreate(&dt,NULL);
}
if (db->id > 63) return;
dictEntry *de = dictAddOrFind(slaveKeysWithExpire,key->ptr);

View File

@ -1742,6 +1742,11 @@ void evictionPoolAlloc(void);
unsigned long LFUGetTimeInMinutes(void);
uint8_t LFULogIncr(uint8_t value);
/* Keys hashing / comparison functions for dict.c hash tables. */
unsigned int dictSdsHash(const void *key);
int dictSdsKeyCompare(void *privdata, const void *key1, const void *key2);
void dictSdsDestructor(void *privdata, void *val);
/* Git SHA1 */
char *redisGitSHA1(void);
char *redisGitDirty(void);