]> granicus.if.org Git - icinga2/commitdiff
Merge DEL queries into one query
authorGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 16 Mar 2017 14:05:44 +0000 (15:05 +0100)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 16 Mar 2017 14:09:41 +0000 (15:09 +0100)
refs #4991

lib/redis/rediswriter-config.cpp

index 964abffc20f3628bd845dca7be21d3944d70748b..53baf55cbdb220a6ee2fb243ce2d67cba4605226 100644 (file)
@@ -65,45 +65,25 @@ void RedisWriter::UpdateAllConfigObjects(void)
                String typeName = type->GetName();
 
                /* replace into aka delete insert is faster than a full diff */
-               redisReply *reply1 = reinterpret_cast<redisReply *>(redisCommand(m_Context, "DEL icinga:config:%s", typeName.CStr()));
+               redisReply *reply = reinterpret_cast<redisReply *>(redisCommand(m_Context, "DEL icinga:config:%s icinga:status:%s", typeName.CStr(), typeName.CStr()));
 
-               if (!reply1) {
+               if (!reply) {
                        redisFree(m_Context);
                        m_Context = NULL;
                        return;
                }
 
-               if (reply1->type == REDIS_REPLY_STATUS || reply1->type == REDIS_REPLY_ERROR) {
+               if (reply->type == REDIS_REPLY_STATUS || reply->type == REDIS_REPLY_ERROR) {
                        Log(LogInformation, "RedisWriter")
-                           << "DEL icinga:config:" << typeName << ": " << reply1->str;
+                           << "DEL icinga:config:" << typeName << ": " << reply->str;
                }
 
-               if (reply1->type == REDIS_REPLY_ERROR) {
-                       freeReplyObject(reply1);
+               if (reply->type == REDIS_REPLY_ERROR) {
+                       freeReplyObject(reply);
                        return;
                }
 
-               freeReplyObject(reply1);
-
-               redisReply *reply2 = reinterpret_cast<redisReply *>(redisCommand(m_Context, "DEL icinga:status:%s", typeName.CStr()));
-
-               if (!reply2) {
-                       redisFree(m_Context);
-                       m_Context = NULL;
-                       return;
-               }
-
-               if (reply2->type == REDIS_REPLY_STATUS || reply2->type == REDIS_REPLY_ERROR) {
-                       Log(LogInformation, "RedisWriter")
-                           << "DEL icinga:status:" << typeName << ": " << reply2->str;
-               }
-
-               if (reply2->type == REDIS_REPLY_ERROR) {
-                       freeReplyObject(reply2);
-                       return;
-               }
-
-               freeReplyObject(reply2);
+               freeReplyObject(reply);
 
                /* fetch all objects and dump them */
                ConfigType *ctype = dynamic_cast<ConfigType *>(type.get());