mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
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:
parent
d1adc85aa6
commit
b6f871cf42
13
src/expire.c
13
src/expire.c
@ -315,8 +315,17 @@ void expireSlaveKeys(void) {
|
|||||||
/* Track keys that received an EXPIRE or similar command in the context
|
/* Track keys that received an EXPIRE or similar command in the context
|
||||||
* of a writable slave. */
|
* of a writable slave. */
|
||||||
void rememberSlaveKeyWithExpire(redisDb *db, robj *key) {
|
void rememberSlaveKeyWithExpire(redisDb *db, robj *key) {
|
||||||
if (slaveKeysWithExpire == NULL)
|
if (slaveKeysWithExpire == NULL) {
|
||||||
slaveKeysWithExpire = dictCreate(&keyptrDictType,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;
|
if (db->id > 63) return;
|
||||||
|
|
||||||
dictEntry *de = dictAddOrFind(slaveKeysWithExpire,key->ptr);
|
dictEntry *de = dictAddOrFind(slaveKeysWithExpire,key->ptr);
|
||||||
|
@ -1742,6 +1742,11 @@ void evictionPoolAlloc(void);
|
|||||||
unsigned long LFUGetTimeInMinutes(void);
|
unsigned long LFUGetTimeInMinutes(void);
|
||||||
uint8_t LFULogIncr(uint8_t value);
|
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 */
|
/* Git SHA1 */
|
||||||
char *redisGitSHA1(void);
|
char *redisGitSHA1(void);
|
||||||
char *redisGitDirty(void);
|
char *redisGitDirty(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user