diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2012-04-30 10:16:20 -0700 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2012-05-01 10:52:27 +0200 |
commit | f2ffb592947407a54e4a1f915f1593aa84eb2295 (patch) | |
tree | 28df4370e11283954a09c4071a9e19ed0589482d | |
parent | 9cb09c4d2c248dc0f9b31314b3127be228476633 (diff) | |
download | redis-f2ffb592947407a54e4a1f915f1593aa84eb2295.tar.gz |
Use safe dictionary iterator from KEYS
Every matched key in a KEYS call is checked for expiration. When the key
is set to expire, the call to `getExpire` will assert that the key also
exists in the main dictionary. This in turn causes a rehashing step to
be executed. Rehashing a dictionary when there is an iterator active may
result in the iterator emitting duplicate entries, or not emitting some
entries at all. By using a safe iterator, the rehash step is omitted.
-rw-r--r-- | src/db.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -273,7 +273,7 @@ void keysCommand(redisClient *c) { unsigned long numkeys = 0; void *replylen = addDeferredMultiBulkLength(c); - di = dictGetIterator(c->db->dict); + di = dictGetSafeIterator(c->db->dict); allkeys = (pattern[0] == '*' && pattern[1] == '\0'); while((de = dictNext(di)) != NULL) { sds key = dictGetEntryKey(de); |