From 74305b85359a2340206ddcecfd2be19e6002e8fb Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 5 Jun 2023 14:04:06 +0200 Subject: [PATCH] Fixes #2175 --- .../http/client/curl/http_operation_curl.h | 2 ++ .../http/client/curl/http_operation_curl.cc | 22 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h b/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h index 65355a05cd..b711ac8445 100644 --- a/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h +++ b/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h @@ -269,6 +269,8 @@ class HttpOperation CURLcode SetCurlLongOption(CURLoption option, long value); + CURLcode SetCurlOffOption(CURLoption option, curl_off_t value); + const char *GetCurlErrorMessage(CURLcode code); std::atomic is_aborted_; // Set to 'true' when async callback is aborted diff --git a/ext/src/http/client/curl/http_operation_curl.cc b/ext/src/http/client/curl/http_operation_curl.cc index dcb1ec9042..22b2565e6f 100644 --- a/ext/src/http/client/curl/http_operation_curl.cc +++ b/ext/src/http/client/curl/http_operation_curl.cc @@ -556,6 +556,26 @@ CURLcode HttpOperation::SetCurlLongOption(CURLoption option, long value) return rc; } +CURLcode HttpOperation::SetCurlOffOption(CURLoption option, curl_off_t value) +{ + CURLcode rc; + + /* + curl_easy_setopt() is a macro with variadic arguments, type unsafe. + SetCurlOffOption() ensures it is called with a curl_off_t. + */ + rc = curl_easy_setopt(curl_resource_.easy_handle, option, value); + + if (rc != CURLE_OK) + { + const char *message = GetCurlErrorMessage(rc); + OTEL_INTERNAL_LOG_ERROR("CURL, set option <" << std::to_string(option) << "> failed: <" + << message << ">"); + } + + return rc; +} + CURLcode HttpOperation::Setup() { if (!curl_resource_.easy_handle) @@ -980,7 +1000,7 @@ CURLcode HttpOperation::Setup() return rc; } - rc = SetCurlLongOption(CURLOPT_POSTFIELDSIZE_LARGE, req_size); + rc = SetCurlOffOption(CURLOPT_POSTFIELDSIZE_LARGE, req_size); if (rc != CURLE_OK) { return rc;