diff --git a/ext/test/http/curl_http_test.cc b/ext/test/http/curl_http_test.cc index 72d0530a21..f8d248bae4 100644 --- a/ext/test/http/curl_http_test.cc +++ b/ext/test/http/curl_http_test.cc @@ -291,7 +291,7 @@ TEST_F(BasicCurlHttpTests, SendGetRequestSyncTimeout) auto result = http_client.Get("http://222.222.222.200:19000/get/", m1); EXPECT_EQ(result, false); - // When network is under proxy, it may cennect success but closed by peer when send data + // When network is under proxy, it may connect success but closed by peer when send data EXPECT_TRUE(result.GetSessionState() == http_client::SessionState::ConnectFailed || result.GetSessionState() == http_client::SessionState::SendFailed); } diff --git a/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h b/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h index 6d5d7fde3c..1b6d443c8a 100644 --- a/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h @@ -108,7 +108,7 @@ class BatchLogProcessor : public LogProcessor /* Synchronization primitives */ std::condition_variable cv_, force_flush_cv_; - std::mutex cv_m_, force_flush_cv_m_; + std::mutex cv_m_, force_flush_cv_m_, shutdown_m_; /* The buffer/queue to which the ended logs are added */ common::CircularBuffer buffer_; diff --git a/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h b/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h index 6b47d993d8..d25ff2d950 100644 --- a/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h +++ b/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h @@ -139,7 +139,7 @@ class BatchSpanProcessor : public SpanProcessor /* Synchronization primitives */ std::condition_variable cv_, force_flush_cv_; - std::mutex cv_m_, force_flush_cv_m_; + std::mutex cv_m_, force_flush_cv_m_, shutdown_m_; /* The buffer/queue to which the ended spans are added */ common::CircularBuffer buffer_; diff --git a/sdk/src/logs/batch_log_processor.cc b/sdk/src/logs/batch_log_processor.cc index 8b6597eb50..9b20705b0a 100644 --- a/sdk/src/logs/batch_log_processor.cc +++ b/sdk/src/logs/batch_log_processor.cc @@ -176,6 +176,7 @@ void BatchLogProcessor::DrainQueue() bool BatchLogProcessor::Shutdown(std::chrono::microseconds timeout) noexcept { + std::lock_guard shutdown_guard{shutdown_m_}; bool already_shutdown = is_shutdown_.exchange(true); if (worker_thread_.joinable()) diff --git a/sdk/src/trace/batch_span_processor.cc b/sdk/src/trace/batch_span_processor.cc index c3f20737c5..0ab042b9ab 100644 --- a/sdk/src/trace/batch_span_processor.cc +++ b/sdk/src/trace/batch_span_processor.cc @@ -180,6 +180,7 @@ void BatchSpanProcessor::DrainQueue() bool BatchSpanProcessor::Shutdown(std::chrono::microseconds timeout) noexcept { + std::lock_guard shutdown_guard{shutdown_m_}; bool already_shutdown = is_shutdown_.exchange(true); if (worker_thread_.joinable())