Skip to content

Commit

Permalink
Fix tsan of OtlpHttpClient .
Browse files Browse the repository at this point in the history
Signed-off-by: owent <[email protected]>
  • Loading branch information
owent committed Sep 5, 2022
1 parent f2466bd commit 9dfe401
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions exporters/otlp/src/otlp_http_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -847,20 +847,20 @@ void OtlpHttpClient::ReleaseSession(
{
bool has_session = false;

{
std::lock_guard<std::recursive_mutex> guard{session_manager_lock_};
std::lock_guard<std::recursive_mutex> guard{session_manager_lock_};

auto session_iter = running_sessions_.find(&session);
if (session_iter != running_sessions_.end())
{
// Move session and handle into gc list, and they will be destroyed later
gc_sessions_.emplace_back(std::move(session_iter->second));
running_sessions_.erase(session_iter);
auto session_iter = running_sessions_.find(&session);
if (session_iter != running_sessions_.end())
{
// Move session and handle into gc list, and they will be destroyed later
gc_sessions_.emplace_back(std::move(session_iter->second));
running_sessions_.erase(session_iter);

has_session = true;
}
has_session = true;
}

// Call session_waker_.notify_all() with session_manager_lock_ locked to keep session_waker_
// available when destroying OtlpHttpClient
if (has_session)
{
session_waker_.notify_all();
Expand Down

0 comments on commit 9dfe401

Please sign in to comment.