From e3186f0ab4b728b8d44aa8298c2c2cc37532f0c4 Mon Sep 17 00:00:00 2001 From: Damien Mehala Date: Mon, 4 Aug 2025 23:32:46 +0200 Subject: [PATCH] revert: 290cc2780482318e6c7aa44b70063ad5eb19b361 Commit `290cc278` introduced a concurrency issue when cleaning requests in-flight. --- src/datadog/curl.cpp | 3 +-- src/datadog/curl.h | 2 -- test/test_curl.cpp | 25 ------------------------- 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/datadog/curl.cpp b/src/datadog/curl.cpp index 72d2f72c..e8f40783 100644 --- a/src/datadog/curl.cpp +++ b/src/datadog/curl.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -19,6 +18,7 @@ #include #include +#include "json.hpp" #include "string_util.h" namespace datadog { @@ -428,7 +428,6 @@ void CurlImpl::drain(std::chrono::steady_clock::time_point deadline) { }); log_on_error(curl_.multi_wakeup(multi_handle_)); - clear_requests(); } std::size_t CurlImpl::on_read_header(char *data, std::size_t, diff --git a/src/datadog/curl.h b/src/datadog/curl.h index 5c684990..bbaf380a 100644 --- a/src/datadog/curl.h +++ b/src/datadog/curl.h @@ -19,8 +19,6 @@ #include #include -#include "json.hpp" - namespace datadog { namespace tracing { diff --git a/test/test_curl.cpp b/test/test_curl.cpp index 9f90c91b..96ba1591 100644 --- a/test/test_curl.cpp +++ b/test/test_curl.cpp @@ -156,31 +156,6 @@ const auto ignore = [](auto &&...) {}; using namespace std::chrono_literals; -CURL_TEST("API") { - const auto clock = default_clock; - const auto logger = std::make_shared(); - SingleRequestMockCurlLibrary library; - const auto client = std::make_shared(logger, clock, library); - - SECTION("drain remove requests in-flight") { - /// Prevent to process the request. - library.on_multi_perform = [] { return CURLM_OK; }; - - const HTTPClient::URL url = {"http", "whatever", ""}; - - const auto result = client->post(url, ignore, "whatever", ignore, ignore, - clock().tick + 60min); - - REQUIRE(result); - REQUIRE(library.created_handles_.size() == 1); - REQUIRE(library.destroyed_handles_.size() == 0); - - client->drain(clock().tick + 1s); - CHECK(library.created_handles_.size() == 1); - CHECK(library.destroyed_handles_.size() == 1); - } -} - CURL_TEST("parse response headers and body") { const auto clock = default_clock; const auto logger = std::make_shared();