Skip to content

Commit

Permalink
Fix glog thread-safe bug for standalone mode (#27703)
Browse files Browse the repository at this point in the history
Signed-off-by: luzhang <[email protected]>
Co-authored-by: luzhang <[email protected]>
  • Loading branch information
zhagnlu and luzhang authored Oct 14, 2023
1 parent 75343b2 commit c5ea313
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/core/src/segcore/segcore_init_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include "segcore/segcore_init_c.h"

namespace milvus::segcore {

std::once_flag close_glog_once;

extern "C" void
SegcoreInit(const char* conf_file) {
milvus::config::KnowhereInitImpl(conf_file);
Expand Down Expand Up @@ -72,9 +75,11 @@ SegcoreSetSimdType(const char* value) {

extern "C" void
SegcoreCloseGlog() {
if (google::IsGoogleLoggingInitialized()) {
google::ShutdownGoogleLogging();
}
std::call_once(close_glog_once, [&]() {
if (google::IsGoogleLoggingInitialized()) {
google::ShutdownGoogleLogging();
}
});
}

extern "C" int32_t
Expand Down

0 comments on commit c5ea313

Please sign in to comment.