diff --git a/CHANGELOG.md b/CHANGELOG.md index 469726701..673cfea18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,9 @@ Increment the: request body on a 32-bit build [#4630](https://github.com/open-telemetry/opentelemetry-cpp/pull/4630) +* [BUG] Fix a data race on the curl operation's last result code + [#4618](https://github.com/open-telemetry/opentelemetry-cpp/pull/4618) + ## [1.29.0] 2026-09-13 * [RELEASE] Bump main branch to 1.29.0-dev (#4259) diff --git a/ext/src/http/client/curl/http_operation_curl.cc b/ext/src/http/client/curl/http_operation_curl.cc index a92299597..483e8fbc0 100644 --- a/ext/src/http/client/curl/http_operation_curl.cc +++ b/ext/src/http/client/curl/http_operation_curl.cc @@ -508,8 +508,8 @@ HttpOperation::~HttpOperation() { if (HttpOperationAccessor::GetThreadId(*async_data_) != std::this_thread::get_id()) { - async_data_->result_future.wait(); - last_curl_result_ = async_data_->result_future.get(); + // PerformCurlMessage() stores this, then calls the Cleanup() that sets the promise. + static_cast(async_data_->result_future.get()); } } break; @@ -533,8 +533,8 @@ void HttpOperation::Finish() // We should not wait in callback from Cleanup() if (HttpOperationAccessor::GetThreadId(*async_data_) != std::this_thread::get_id()) { - async_data_->result_future.wait(); - last_curl_result_ = async_data_->result_future.get(); + // PerformCurlMessage() stores this, then calls the Cleanup() that sets the promise. + static_cast(async_data_->result_future.get()); } } }