Permalink
Browse files

fix infinite loop by randomkey if the slave only has expired key.

  • Loading branch information...
1 parent fdf50e1 commit c1234e46755c9c81d19752ef9c4c29ad942fbdb1 Minsu Choi committed Dec 31, 2013
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/db.c
View
4 src/db.c
@@ -150,6 +150,10 @@ robj *dbRandomKey(redisDb *db) {
if (dictFind(db->expires,key)) {
if (expireIfNeeded(db,keyobj)) {
decrRefCount(keyobj);
+ /* Escaping from infinite loop by RANDOMKEY if slave has only expired key. */
+ if (server.masterhost != NULL && dictSize(db->dict) == dictSize(db->expires)) {
+ return NULL;
+ }
continue; /* search for another key. This expired. */
}
}

1 comment on commit c1234e4

Please sign in to comment.