]> git.saurik.com Git - redis.git/blobdiff - dict.c
dictGetRandomKey bug fixed, RANDOMKEY will not block the server anymore
[redis.git] / dict.c
diff --git a/dict.c b/dict.c
index 2d186c1d021ac87c2d738b509f78f5ab79f11b37..9360d52ebeac482cae8f1d092fa3273fc22d525f 100644 (file)
--- a/dict.c
+++ b/dict.c
@@ -33,6 +33,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "fmacros.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -375,7 +377,7 @@ dictEntry *dictGetRandomKey(dict *ht)
     unsigned int h;
     int listlen, listele;
 
-    if (ht->size == 0) return NULL;
+    if (ht->used == 0) return NULL;
     do {
         h = random() & ht->sizemask;
         he = ht->table[h];