This commit is contained in:
2025-09-29 11:43:55 -05:00
parent d6b38b9df0
commit f8f5ccfd2c
2 changed files with 11 additions and 4 deletions

View File

@@ -34,7 +34,7 @@ non_blocking_guard::~non_blocking_guard() {
}
boost::system::error_code err;
[[maybe_unused]] auto ret = sock.non_blocking(non_blocking, err);
[[maybe_unused]] auto res = sock.non_blocking(non_blocking, err);
}
auto is_socket_still_alive(boost::asio::ip::tcp::socket &sock) -> bool {

View File

@@ -308,6 +308,12 @@ auto packet_client::send(std::string_view method, packet &request,
for (std::uint8_t retry = 1U;
allow_connections_ && not success && (retry <= max_read_attempts);
++retry) {
const auto retry_after_sleep = [&]() {
if (allow_connections_ && (retry < max_read_attempts)) {
std::this_thread::sleep_for(1s);
}
};
auto current_client = get_client();
if (current_client) {
try {
@@ -333,16 +339,17 @@ auto packet_client::send(std::string_view method, packet &request,
ret = res;
success = true;
put_client(current_client);
continue;
}
}
}
} catch (const std::exception &e) {
utils::error::raise_error(function_name, e, "send failed");
close(*current_client);
if (allow_connections_ && (retry < max_read_attempts)) {
std::this_thread::sleep_for(1s);
}
retry_after_sleep();
}
} else {
retry_after_sleep();
}
if (not allow_connections_) {