summaryrefslogtreecommitdiff
path: root/src/redis-benchmark.c
diff options
context:
space:
mode:
authorvattezhang <vattezhang@163.com>2019-04-26 19:47:07 +0800
committervattezhang <vattezhang@163.com>2019-04-26 19:47:07 +0800
commit4e38ced4886446efb70f96685a6a6dfa344095d4 (patch)
tree93d03aa1f914e8ef99138dec9b4166f1dc4c206f /src/redis-benchmark.c
parentbc36404c79b50e80583d4a98a7211bd239fc88f9 (diff)
downloadredis-4e38ced4886446efb70f96685a6a6dfa344095d4.tar.gz
fix: benchmark auth fails when server have requirepass
Diffstat (limited to 'src/redis-benchmark.c')
-rw-r--r--src/redis-benchmark.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c
index 4e2662f21..e4134c9ea 100644
--- a/src/redis-benchmark.c
+++ b/src/redis-benchmark.c
@@ -254,6 +254,19 @@ static redisConfig *getRedisConfig(const char *ip, int port,
else fprintf(stderr,"%s: %s\n",hostsocket,err);
goto fail;
}
+
+ if(config.auth){
+ void *authReply = NULL;
+ redisAppendCommand(c, "AUTH %s", config.auth);
+ if (REDIS_OK != redisGetReply(c, &authReply)) goto fail;
+ if (reply) freeReplyObject(reply);
+ reply = ((redisReply *) authReply);
+ if (reply->type == REDIS_REPLY_ERROR) {
+ fprintf(stderr, "ERROR: %s\n", reply->str);
+ goto fail;
+ }
+ }
+
redisAppendCommand(c, "CONFIG GET %s", "save");
redisAppendCommand(c, "CONFIG GET %s", "appendonly");
int i = 0;