Skip to content

Commit acfa7b2

Browse files
committed
fix: amend review changes
1 parent 0ff2795 commit acfa7b2

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

onnxruntime/core/providers/openvino/ov_telemetry.cc

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,25 @@ OVTelemetry::OVTelemetry() {
4646
}
4747

4848
OVTelemetry::~OVTelemetry() {
49-
std::lock_guard<std::mutex> lock(mutex_);
50-
if (global_register_count_ > 0) {
51-
global_register_count_ -= 1;
52-
if (global_register_count_ == 0) {
53-
TraceLoggingUnregister(ov_telemetry_provider_handle);
49+
// Clean up TraceLogging, only hold mutex_
50+
{
51+
std::lock_guard<std::mutex> lock(mutex_);
52+
if (global_register_count_ > 0) {
53+
global_register_count_ -= 1;
54+
if (global_register_count_ == 0) {
55+
TraceLoggingUnregister(ov_telemetry_provider_handle);
56+
}
5457
}
5558
}
56-
std::lock_guard<std::mutex> lock_callbacks(callbacks_mutex_);
57-
callbacks_.clear();
59+
60+
// Clean up callbacks, only hold callbacks_mutex_
61+
{
62+
std::lock_guard<std::mutex> lock_callbacks(callbacks_mutex_);
63+
callbacks_.clear();
64+
}
5865
}
5966

67+
6068
OVTelemetry& OVTelemetry::Instance() {
6169
static OVTelemetry instance;
6270
return instance;
@@ -84,6 +92,8 @@ void AddOptionalValue(std::ostringstream& json, const std::string& key, const T&
8492
json << "\"" << key << "\":";
8593
if constexpr (std::is_same_v<T, std::string>) {
8694
json << "\"" << value << "\"";
95+
} else if constexpr (std::is_same_v<T, std::filesystem::path>) {
96+
json << "\"" << value.string() << "\"";
8797
} else if constexpr (std::is_same_v<T, bool>) {
8898
json << (value ? "true" : "false");
8999
} else {
@@ -317,13 +327,8 @@ void OVTelemetry::LogAllSessionOptions(uint32_t session_id, const SessionContext
317327
AddOptionalValue(sopts, "ep.context_enable", ctx.so_context_enable, false, first);
318328
AddOptionalValue(sopts, "session.disable_cpu_ep_fallback", ctx.so_disable_cpu_ep_fallback, false, first);
319329
AddOptionalValue(sopts, "ep.context_embed_mode", ctx.so_context_embed_mode, false, first);
320-
AddOptionalValue(sopts, "ep.context_file_path", ctx.so_share_ep_contexts, false, first);
321-
322-
if (!ctx.so_context_file_path.empty()) {
323-
if (!first) sopts << ",";
324-
sopts << "\"ep.context_file_path\":\"" << ctx.so_context_file_path.string() << "\"";
325-
first = false;
326-
}
330+
AddOptionalValue(sopts, "ep.share_ep_contexts", ctx.so_share_ep_contexts, false, first);
331+
AddOptionalValue(sopts, "ep.context_file_path", ctx.so_context_file_path, std::filesystem::path(), first);
327332

328333
sopts << "}";
329334

0 commit comments

Comments
 (0)