Skip to content

Commit

Permalink
Fix shutdown in sync mode
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Sep 25, 2024
1 parent 3547800 commit ef62bc0
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions exporters/otlp/src/otlp_grpc_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -660,13 +660,13 @@ bool OtlpGrpcClient::Shutdown(OtlpGrpcClientReferenceGuard &guard,
return true;
}

#ifdef ENABLE_ASYNC_EXPORT
bool last_reference_removed = RemoveReference(guard);
bool force_flush_result;
if (last_reference_removed && false == is_shutdown_.exchange(true, std::memory_order_acq_rel))
{
force_flush_result = ForceFlush(timeout);

#ifdef ENABLE_ASYNC_EXPORT
std::unordered_set<std::shared_ptr<OtlpGrpcAsyncCallDataBase>> running_calls;
{
std::lock_guard<std::mutex> lock(async_data_->running_calls_lock);
Expand All @@ -679,17 +679,14 @@ bool OtlpGrpcClient::Shutdown(OtlpGrpcClientReferenceGuard &guard,
call_data->grpc_context->TryCancel();
}
}
#endif
}
else
{
force_flush_result = ForceFlush(timeout);
}

return force_flush_result;
#else
RemoveReference(guard);
return true;
#endif
}

} // namespace otlp
Expand Down

0 comments on commit ef62bc0

Please sign in to comment.