]> granicus.if.org Git - icinga2/commitdiff
Implement the db_index property for the RedisWriter class
authorGunnar Beutner <gunnar.beutner@icinga.com>
Mon, 20 Mar 2017 12:47:37 +0000 (13:47 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Wed, 29 Mar 2017 08:17:03 +0000 (10:17 +0200)
fixes #5081

lib/redis/rediswriter.cpp
lib/redis/rediswriter.ti

index 619855fa8f1eaf1298a4773a30103826f7520581..31ed83cfe81ee2b6c76cc08ce14f742797cef00c 100644 (file)
@@ -112,6 +112,25 @@ void RedisWriter::TryToReconnect(void)
                freeReplyObject(reply);
        }
 
                freeReplyObject(reply);
        }
 
+       int dbIndex = GetDbIndex();
+
+       if (dbIndex != 0) {
+               redisReply *reply = reinterpret_cast<redisReply *>(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();
 }
        /* Config dump */
        UpdateAllConfigObjects();
 }
index 964e08960ee2b5baeb8ffccb536f91e4c7e4566e..0aa76c9c0f17ec019ffebce57fd8f342b9c2210b 100644 (file)
@@ -34,6 +34,7 @@ class RedisWriter : ConfigObject
        };
        [config] String path;
        [config] String password;
        };
        [config] String path;
        [config] String password;
+       [config] int db_index;
 };
 
 }
 };
 
 }