summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-08-06 19:01:54 +0200
committerantirez <antirez@gmail.com>2013-08-06 19:01:54 +0200
commit6cbfdd95205cf81b098a48d6331dcc7f04f5680a (patch)
tree730f1c1a04f1c8a54b08b380711f6eb17abca8f5
parentd52c9b6cdb1d885e647cf9be0114d481133ec485 (diff)
downloadredis-6cbfdd95205cf81b098a48d6331dcc7f04f5680a.tar.gz
redis-benchmark: fix db selection when :rand: feature is used.
-rw-r--r--src/redis-benchmark.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c
index a1c7b78b6..f53b333b1 100644
--- a/src/redis-benchmark.c
+++ b/src/redis-benchmark.c
@@ -205,10 +205,16 @@ static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
freeReplyObject(reply);
if (c->selectlen) {
+ int j;
+
/* This is the OK from SELECT. Just discard the SELECT
* from the buffer. */
c->pending--;
sdsrange(c->obuf,c->selectlen,-1);
+ /* We also need to fix the pointers to the strings
+ * we need to randomize. */
+ for (j = 0; j < c->randlen; j++)
+ c->randptr[j] -= c->selectlen;
c->selectlen = 0;
continue;
}