Browse Source

* source/redis : fix connect error

master
Alex 'AdUser' Z 3 years ago
parent
commit
ee12b9d4ab
  1. 14
      src/sources/redis.c

14
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);

Loading…
Cancel
Save