From d5a4c3e84203f7febc17bd935d55d51538a246b5 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 6 Aug 2013 19:01:54 +0200 Subject: [PATCH] redis-benchmark: fix db selection when :rand: feature is used. --- src/redis-benchmark.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index 20255448..8eb3666b 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -204,10 +204,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; }