refactor
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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_) {
|
||||
|
Reference in New Issue
Block a user