|
|
@ -66,18 +66,20 @@ redis_connect(cfg_t *cfg) { |
|
|
|
} |
|
|
|
} |
|
|
|
freeReplyObject(reply); |
|
|
|
freeReplyObject(reply); |
|
|
|
} |
|
|
|
} |
|
|
|
timeout.tv_sec = 0; |
|
|
|
if ((reply = redisCommand(conn, "SUBSCRIBE %s", cfg->hash)) == NULL) { |
|
|
|
timeout.tv_usec = 10000; /* 0.01s */ |
|
|
|
log_msg(cfg, error, "can't subscribe: %s", conn->errstr); |
|
|
|
if (redisSetTimeout(conn, timeout) != REDIS_OK) { |
|
|
|
|
|
|
|
log_msg(cfg, error, "can't enable nonblocking mode"); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if ((reply = redisCommand(conn, "SUBSCRIBE %s", cfg->hash)) == NULL) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
if (reply->type == REDIS_REPLY_ERROR) { |
|
|
|
if (reply->type == REDIS_REPLY_ERROR) { |
|
|
|
log_msg(cfg, error, "can't subscribe: %s", reply->str); |
|
|
|
log_msg(cfg, error, "can't subscribe: %s", reply->str); |
|
|
|
break; |
|
|
|
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); |
|
|
|
freeReplyObject(reply); |
|
|
|
if (cfg->conn) |
|
|
|
if (cfg->conn) |
|
|
|
redisFree(cfg->conn); |
|
|
|
redisFree(cfg->conn); |
|
|
|