This commit is contained in:
2025-09-29 11:46:23 -05:00
parent f8f5ccfd2c
commit ab99ae48e7

View File

@@ -315,47 +315,46 @@ auto packet_client::send(std::string_view method, packet &request,
}; };
auto current_client = get_client(); auto current_client = get_client();
if (current_client) { if (not current_client) {
try { retry_after_sleep();
auto current_request = base_request; continue;
current_request.encode_top(current_client->nonce); }
request = current_request;
current_request.encrypt(cfg_.encryption_token); try {
auto current_request = base_request;
current_request.encode_top(current_client->nonce);
request = current_request;
write_all_with_deadline( current_request.encrypt(cfg_.encryption_token);
io_context_, current_client->socket,
boost::asio::buffer(&current_request[0],
current_request.get_size()),
std::chrono::milliseconds(cfg_.send_timeout_ms));
ret = read_packet(*current_client, response); write_all_with_deadline(
io_context_, current_client->socket,
boost::asio::buffer(&current_request[0], current_request.get_size()),
std::chrono::milliseconds(cfg_.send_timeout_ms));
ret = read_packet(*current_client, response);
if (ret == 0) {
ret = response.decode(service_flags);
if (ret == 0) { if (ret == 0) {
ret = response.decode(service_flags); packet::error_type res{};
ret = response.decode(res);
if (ret == 0) { if (ret == 0) {
packet::error_type res{}; ret = res;
ret = response.decode(res); success = true;
if (ret == 0) { put_client(current_client);
ret = res; continue;
success = true;
put_client(current_client);
continue;
}
} }
} }
} catch (const std::exception &e) {
utils::error::raise_error(function_name, e, "send failed");
close(*current_client);
retry_after_sleep();
} }
} else { } catch (const std::exception &e) {
utils::error::raise_error(function_name, e, "send failed");
close(*current_client);
retry_after_sleep(); retry_after_sleep();
} }
}
if (not allow_connections_) { if (not allow_connections_) {
ret = utils::from_api_error(api_error::error); ret = utils::from_api_error(api_error::error);
success = true;
}
} }
return CONVERT_STATUS_NOT_IMPLEMENTED(ret); return CONVERT_STATUS_NOT_IMPLEMENTED(ret);