refactor
Some checks are pending
BlockStorage/repertory/pipeline/head Build queued...
BlockStorage/repertory/pipeline/pr-master Build queued...

This commit is contained in:
2025-07-23 14:26:04 -05:00
parent fb4bcab510
commit 83fedfeaa5
2 changed files with 10 additions and 7 deletions

View File

@@ -49,6 +49,7 @@ private:
static const write_callback write_data; static const write_callback write_data;
static const write_callback write_headers; static const write_callback write_headers;
static constexpr std::uint8_t retry_request_count{5U};
private: private:
std::optional<host_config> host_config_; std::optional<host_config> host_config_;
@@ -239,7 +240,8 @@ public:
}; };
bool ret{false}; bool ret{false};
for (std::uint8_t retry = 0U; !ret && retry < 5U; ++retry) { for (std::uint8_t retry = 0U; !ret && retry < retry_request_count;
++retry) {
ret = do_request(); ret = do_request();
if (ret) { if (ret) {
break; break;

View File

@@ -44,21 +44,22 @@ void multi_request::get_result(CURLcode &curl_code, long &http_code) {
curl_code = CURLcode::CURLE_ABORTED_BY_CALLBACK; curl_code = CURLcode::CURLE_ABORTED_BY_CALLBACK;
http_code = -1; http_code = -1;
auto error = false; auto error{false};
int running_handles = 0; int running_handles{0};
curl_multi_perform(multi_handle_, &running_handles); curl_multi_perform(multi_handle_, &running_handles);
while (not error && (running_handles > 0) && not get_stop_requested()) { while (not error && (running_handles > 0) && not get_stop_requested()) {
int ignored{}; int ignored{};
curl_multi_wait(multi_handle_, nullptr, 0, timeout_ms, &ignored); curl_multi_wait(multi_handle_, nullptr, 0, timeout_ms, &ignored);
const auto ret = curl_multi_perform(multi_handle_, &running_handles); auto ret = curl_multi_perform(multi_handle_, &running_handles);
error = (ret != CURLM_CALL_MULTI_PERFORM) && (ret != CURLM_OK); error = (ret != CURLM_CALL_MULTI_PERFORM) && (ret != CURLM_OK);
} }
if (not get_stop_requested()) { if (not get_stop_requested()) {
int remaining_messages = 0; int remaining_messages{0};
auto *multi_result = auto *multi_result{
curl_multi_info_read(multi_handle_, &remaining_messages); curl_multi_info_read(multi_handle_, &remaining_messages),
};
if ((multi_result != nullptr) && (multi_result->msg == CURLMSG_DONE)) { if ((multi_result != nullptr) && (multi_result->msg == CURLMSG_DONE)) {
curl_easy_getinfo(multi_result->easy_handle, CURLINFO_RESPONSE_CODE, curl_easy_getinfo(multi_result->easy_handle, CURLINFO_RESPONSE_CODE,
&http_code); &http_code);