From ee12b9d4aba63916b1acf0ccf0b9ea83b71ef5a6 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Fri, 19 Feb 2021 10:23:10 +1000 Subject: [PATCH] * source/redis : fix connect error --- src/sources/redis.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/sources/redis.c b/src/sources/redis.c index 09b754e..a3df9ff 100644 --- a/src/sources/redis.c +++ b/src/sources/redis.c @@ -66,18 +66,20 @@ redis_connect(cfg_t *cfg) { } freeReplyObject(reply); } - timeout.tv_sec = 0; - timeout.tv_usec = 10000; /* 0.01s */ - if (redisSetTimeout(conn, timeout) != REDIS_OK) { - log_msg(cfg, error, "can't enable nonblocking mode"); + if ((reply = redisCommand(conn, "SUBSCRIBE %s", cfg->hash)) == NULL) { + log_msg(cfg, error, "can't subscribe: %s", conn->errstr); break; } - if ((reply = redisCommand(conn, "SUBSCRIBE %s", cfg->hash)) == NULL) - break; if (reply->type == REDIS_REPLY_ERROR) { log_msg(cfg, error, "can't subscribe: %s", reply->str); break; } + timeout.tv_sec = 0; + timeout.tv_usec = 10000; /* 0.01s */ + if (redisSetTimeout(conn, timeout) != REDIS_OK) { + log_msg(cfg, error, "can't enable nonblocking mode"); + break; + } freeReplyObject(reply); if (cfg->conn) redisFree(cfg->conn);