File include-gflags-if-they-are-used.patch of Package milvus

From 6fcd412aee01b63320275c9b19983befaa113930 Mon Sep 17 00:00:00 2001
From: Christian Goll <cgoll@suse.com>
Date: Tue, 6 Aug 2024 11:16:40 +0200
Subject: [PATCH] include gflags if they are used

Signed-off-by: Christian Goll <cgoll@suse.com>
---
 internal/core/src/config/ConfigKnowhere.cpp  | 8 +++++---
 internal/core/src/segcore/segcore_init_c.cpp | 4 +---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/internal/core/src/config/ConfigKnowhere.cpp b/internal/core/src/config/ConfigKnowhere.cpp
index 29d0f113..63aae944 100644
--- a/internal/core/src/config/ConfigKnowhere.cpp
+++ b/internal/core/src/config/ConfigKnowhere.cpp
@@ -22,6 +22,10 @@
 #include "log/Log.h"
 #include "knowhere/comp/knowhere_config.h"
 #include "knowhere/version.h"
+#ifndef EMBEDDED_MILVUS
+#include "gflags/gflags.h"
+#endif
+
 
 namespace milvus::config {
 
@@ -33,9 +37,7 @@ KnowhereInitImpl(const char* conf_file) {
         knowhere::KnowhereConfig::SetBlasThreshold(16384);
         knowhere::KnowhereConfig::SetEarlyStopThreshold(0);
         knowhere::KnowhereConfig::ShowVersion();
-        if (!google::IsGoogleLoggingInitialized()) {
-            google::InitGoogleLogging("milvus");
-        }
+        google::InitGoogleLogging("milvus");
 
 #ifdef EMBEDDED_MILVUS
         // always disable all logs for embedded milvus
diff --git a/internal/core/src/segcore/segcore_init_c.cpp b/internal/core/src/segcore/segcore_init_c.cpp
index dbb74db5..af1f086b 100644
--- a/internal/core/src/segcore/segcore_init_c.cpp
+++ b/internal/core/src/segcore/segcore_init_c.cpp
@@ -90,9 +90,7 @@ SegcoreEnableKnowhereScoreConsistency() {
 extern "C" void
 SegcoreCloseGlog() {
     std::call_once(close_glog_once, [&]() {
-        if (google::IsGoogleLoggingInitialized()) {
-            google::ShutdownGoogleLogging();
-        }
+          google::ShutdownGoogleLogging();
     });
 }
 
-- 
2.43.0

openSUSE Build Service is sponsored by