diff --git a/lib/redis/rediswriter.cpp b/lib/redis/rediswriter.cpp index 619855fa8..31ed83cfe 100644 --- a/lib/redis/rediswriter.cpp +++ b/lib/redis/rediswriter.cpp @@ -112,6 +112,25 @@ void RedisWriter::TryToReconnect(void) freeReplyObject(reply); } + int dbIndex = GetDbIndex(); + + if (dbIndex != 0) { + redisReply *reply = reinterpret_cast(redisCommand(m_Context, "SELECT %d", dbIndex)); + + if (!reply) { + redisFree(m_Context); + m_Context = NULL; + return; + } + + if (reply->type == REDIS_REPLY_STATUS || reply->type == REDIS_REPLY_ERROR) { + Log(LogInformation, "RedisWriter") + << "SELECT " << dbIndex << ": " << reply->str; + } + + freeReplyObject(reply); + } + /* Config dump */ UpdateAllConfigObjects(); } diff --git a/lib/redis/rediswriter.ti b/lib/redis/rediswriter.ti index 964e08960..0aa76c9c0 100644 --- a/lib/redis/rediswriter.ti +++ b/lib/redis/rediswriter.ti @@ -34,6 +34,7 @@ class RedisWriter : ConfigObject }; [config] String path; [config] String password; + [config] int db_index; }; }