diff options
author | antirez <antirez@gmail.com> | 2016-12-13 16:27:13 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2016-12-13 16:27:13 +0100 |
commit | b6f871cf42f5d97e1d6ce81e0429cf4a8f204d31 (patch) | |
tree | 25a4852d44350d94b1c24af33adaffe573e129b5 /src/expire.c | |
parent | d1adc85aa6f53424fec29751cec4bb3042a25359 (diff) | |
download | redis-b6f871cf42f5d97e1d6ce81e0429cf4a8f204d31.tar.gz |
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.
Diffstat (limited to 'src/expire.c')
-rw-r--r-- | src/expire.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/expire.c b/src/expire.c index b05bf9f14..637139f63 100644 --- a/src/expire.c +++ b/src/expire.c @@ -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); |