]> git.saurik.com Git - redis.git/commitdiff
if /dev/urandom is not available use rand() to get a random node name
authorantirez <antirez@metal.(none)>
Wed, 4 May 2011 08:30:22 +0000 (10:30 +0200)
committerantirez <antirez@metal.(none)>
Wed, 4 May 2011 08:30:22 +0000 (10:30 +0200)
src/cluster.c
src/t_zset.c

index c4a56f4d4bf5eef32d57f4d2af1bed3ad5a6a4f7..9588920121ec55f2072dd1ed0b9a6f0bc6bbf5d5 100644 (file)
@@ -24,12 +24,10 @@ void clusterGetRandomName(char *p) {
     char *charset = "0123456789abcdef";
     int j;
 
-    if (!fp) {
-        redisLog(REDIS_WARNING,
-            "Unrecovarable error: can't open /dev/urandom:%s" ,strerror(errno));
-        exit(1);
+    if (fp == NULL || fread(p,REDIS_CLUSTER_NAMELEN,1,fp) == 0) {
+        for (j = 0; j < REDIS_CLUSTER_NAMELEN; j++)
+            p[j] = rand();
     }
-    fread(p,REDIS_CLUSTER_NAMELEN,1,fp);
     for (j = 0; j < REDIS_CLUSTER_NAMELEN; j++)
         p[j] = charset[p[j] & 0x0F];
     fclose(fp);
index e9da9fdb223f035f36e1672bc526f8a9ca219dae..3e76ebd1517c1c690ee4a53c16d0d6988dd179ec 100644 (file)
@@ -1233,7 +1233,7 @@ int zuiNext(zsetopsrc *op, zsetopval *val) {
     if (op->type == REDIS_SET) {
         iterset *it = &op->iter.set;
         if (op->encoding == REDIS_ENCODING_INTSET) {
-            if (!intsetGet(it->is.is,it->is.ii,&val->ell))
+            if (!intsetGet(it->is.is,it->is.ii,(int64_t*)&val->ell))
                 return 0;
             val->score = 1.0;