summaryrefslogtreecommitdiff
path: root/src/redis-benchmark.c
diff options
context:
space:
mode:
authorartix <artix2@gmail.com>2019-03-07 11:30:09 +0100
committerartix <artix2@gmail.com>2019-03-07 11:30:09 +0100
commitc389ad0d52d7770f2b1b1e48608bbbd171bc5a3e (patch)
tree6bc26b1e7914635e3607e6a92015b9da3ba87b1e /src/redis-benchmark.c
parent0e963e068d15e56254987c12e5aba9162e208099 (diff)
downloadredis-c389ad0d52d7770f2b1b1e48608bbbd171bc5a3e.tar.gz
Redis Benchmark: fix key randomization with zero keyspacelen
Diffstat (limited to 'src/redis-benchmark.c')
-rw-r--r--src/redis-benchmark.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c
index 89245132b..83574f26c 100644
--- a/src/redis-benchmark.c
+++ b/src/redis-benchmark.c
@@ -345,7 +345,9 @@ static void randomizeClientKey(client c) {
for (i = 0; i < c->randlen; i++) {
char *p = c->randptr[i]+11;
- size_t r = random() % config.randomkeys_keyspacelen;
+ size_t r = 0;
+ if (config.randomkeys_keyspacelen != 0)
+ r = random() % config.randomkeys_keyspacelen;
size_t j;
for (j = 0; j < 12; j++) {
@@ -1288,6 +1290,11 @@ int parseOptions(int argc, const char **argv) {
if (config.pipeline <= 0) config.pipeline=1;
} else if (!strcmp(argv[i],"-r")) {
if (lastarg) goto invalid;
+ const char *next = argv[++i], *p = next;
+ if (*p == '-') {
+ p++;
+ if (*p < '0' || *p > '9') goto invalid;
+ }
config.randomkeys = 1;
config.randomkeys_keyspacelen = atoi(argv[++i]);
if (config.randomkeys_keyspacelen < 0)