Issue 129 fixed merged from the sister project

This commit is contained in:
mom040267 2014-06-18 17:47:39 +00:00
parent 495d7940b6
commit 14ef08b182
2 changed files with 38 additions and 11 deletions

View File

@ -1,5 +1,6 @@
06/13/2014 Oleg Moskalenko <mom040267@gmail.com>
Version 4.0.1.3 'Severard':
- Redis DB connection status fixed (Issue 129).
- Logfile reset on SIGHUP
(Gustavo Garcia suggestion).
- Log reset CLi command.

View File

@ -879,19 +879,45 @@ static redisContext *get_redis_connection(void)
redisconnection = redisConnect(ip, port);
}
if (!redisconnection) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot initialize Redis DB connection\n");
} else {
if (co->password) {
turnFreeRedisReply(redisCommand(redisconnection, "AUTH %s", co->password));
}
if (co->dbname) {
turnFreeRedisReply(redisCommand(redisconnection, "select %s", co->dbname));
}
if (!donot_print_connection_success) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Redis DB sync connection success: %s\n", pud->userdb);
if (redisconnection) {
if(redisconnection->err) {
if(redisconnection->errstr[0]) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Redis: %s\n",redisconnection->errstr);
}
redisFree(redisconnection);
redisconnection = NULL;
} else if (co->password) {
void *reply = redisCommand(redisconnection, "AUTH %s", co->password);
if(!reply) {
if(redisconnection->err && redisconnection->errstr[0]) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Redis: %s\n",redisconnection->errstr);
}
redisFree(redisconnection);
redisconnection = NULL;
} else {
turnFreeRedisReply(reply);
if (co->dbname) {
reply = redisCommand(redisconnection, "select %s", co->dbname);
if(!reply) {
if(redisconnection->err && redisconnection->errstr[0]) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Redis: %s\n",redisconnection->errstr);
}
redisFree(redisconnection);
redisconnection = NULL;
} else {
turnFreeRedisReply(reply);
}
}
}
}
}
if (!redisconnection) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot initialize Redis DB connection\n");
} else if (!donot_print_connection_success) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Redis DB sync connection success: %s\n", pud->userdb);
}
RyconninfoFree(co);
}
pud->connection = redisconnection;