提交 b6f871cf 编写于 作者: A antirez

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.
上级 d1adc85a
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册