diff options
| author | zhengchao <[email protected]> | 2018-05-23 22:38:27 +0800 |
|---|---|---|
| committer | zhengchao <[email protected]> | 2018-05-23 22:38:27 +0800 |
| commit | 3e07461a20999a3e6f4fd1eee9952fd0f3a31684 (patch) | |
| tree | 46186a930d827d9f68b622249b10866d8df8e842 /tools | |
| parent | 1cef03375abd275284c1c3930c05e750430e9867 (diff) | |
增加redis不可达的错误处理。
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/maat_redis_tool.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/maat_redis_tool.cpp b/tools/maat_redis_tool.cpp index cff62d2..9fae08f 100644 --- a/tools/maat_redis_tool.cpp +++ b/tools/maat_redis_tool.cpp @@ -46,9 +46,9 @@ static redisContext * connect_redis(const char*redis_ip, int redis_port, int red redisContext * ctx; ctx=redisConnectWithTimeout(redis_ip, redis_port,connect_timeout); - if(ctx==NULL) + if(ctx==NULL||ctx->err) { - printf("Unable to connect %s:%d db%d\n",redis_ip,redis_port,redis_db); + printf("Unable to connect %s:%d db%d : %s\n",redis_ip,redis_port,redis_db, ctx==NULL?"Unknown":ctx->errstr); return NULL; } reply=_wrap_redisCommand(ctx, "select %d",redis_db); |
