Merge pull request #10320

4486925 Transition asio::deadline_timer to asio::steady_timer (Lee *!* Clagett)
This commit is contained in:
tobtoht
2026-02-22 13:01:04 +00:00
19 changed files with 67 additions and 67 deletions
+1 -1
View File
@@ -72,7 +72,7 @@ int main(int argc, char* argv[])
SL(boost::thread);
SL(boost::asio::io_context);
SL(boost::asio::executor_work_guard<boost::asio::io_context::executor_type>);
SL(boost::asio::deadline_timer);
SL(boost::asio::steady_timer);
SL(cryptonote::DB_ERROR);
SL(cryptonote::mdb_txn_safe);
+6 -6
View File
@@ -571,7 +571,7 @@ namespace trezor{
return ping_int();
}
bool UdpTransport::ping_int(boost::posix_time::time_duration timeout){
bool UdpTransport::ping_int(boost::asio::steady_timer::duration timeout){
require_socket();
try {
std::string req = "PINGPING";
@@ -619,7 +619,7 @@ namespace trezor{
m_socket.reset(new udp::socket(m_io_service));
m_socket->open(udp::v4());
m_deadline.expires_at(boost::posix_time::pos_infin);
m_deadline.expires_after(boost::asio::steady_timer::duration::max());
check_deadline();
m_proto->session_begin(*this);
@@ -701,14 +701,14 @@ namespace trezor{
return static_cast<size_t>(len);
}
ssize_t UdpTransport::receive(void * buff, size_t size, boost::system::error_code * error_code, bool no_throw, boost::posix_time::time_duration timeout){
ssize_t UdpTransport::receive(void * buff, size_t size, boost::system::error_code * error_code, bool no_throw, const boost::asio::steady_timer::duration timeout){
boost::system::error_code ec;
boost::asio::mutable_buffer buffer = boost::asio::buffer(buff, size);
require_socket();
// Set a deadline for the asynchronous operation.
m_deadline.expires_from_now(timeout);
m_deadline.expires_after(timeout);
// Set up the variables that receive the result of the asynchronous
// operation. The error code is set to would_block to signal that the
@@ -766,7 +766,7 @@ namespace trezor{
// Check whether the deadline has passed. We compare the deadline against
// the current time since a new asynchronous operation may have moved the
// deadline before this actor had a chance to run.
if (m_deadline.expires_at() <= boost::asio::deadline_timer::traits_type::now())
if (m_deadline.expiry() <= boost::asio::steady_timer::clock_type::now())
{
// The deadline has passed. The outstanding asynchronous operation needs
// to be cancelled so that the blocked receive() function will return.
@@ -778,7 +778,7 @@ namespace trezor{
// There is no longer an active deadline. The expiry is set to positive
// infinity so that the actor takes no action until a new deadline is set.
m_deadline.expires_at(boost::posix_time::pos_infin);
m_deadline.expires_after(boost::asio::steady_timer::duration::max());
}
// Put the actor back to sleep.
+4 -4
View File
@@ -32,7 +32,7 @@
#include <boost/asio.hpp>
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/array.hpp>
#include <boost/utility/string_ref.hpp>
@@ -233,11 +233,11 @@ namespace trezor {
private:
void require_socket();
ssize_t receive(void * buff, size_t size, boost::system::error_code * error_code=nullptr, bool no_throw=false, boost::posix_time::time_duration timeout=boost::posix_time::seconds(10));
ssize_t receive(void * buff, size_t size, boost::system::error_code * error_code=nullptr, bool no_throw=false, boost::asio::steady_timer::duration timeout = std::chrono::seconds(10));
void check_deadline();
static void handle_receive(const boost::system::error_code& ec, std::size_t length,
boost::system::error_code* out_ec, std::size_t* out_length);
bool ping_int(boost::posix_time::time_duration timeout=boost::posix_time::milliseconds(1500));
bool ping_int(boost::asio::steady_timer::duration = std::chrono::milliseconds(1500));
std::shared_ptr<Protocol> m_proto;
std::string m_device_host;
@@ -245,7 +245,7 @@ namespace trezor {
std::unique_ptr<udp::socket> m_socket;
boost::asio::io_context m_io_service;
boost::asio::deadline_timer m_deadline;
boost::asio::steady_timer m_deadline;
udp::endpoint m_endpoint;
};
+1 -1
View File
@@ -230,7 +230,7 @@ namespace nodetool
m_config.m_net_config.packet_max_size = P2P_DEFAULT_PACKET_MAX_SIZE;
m_config.m_net_config.config_id = 0;
m_config.m_net_config.connection_timeout = P2P_DEFAULT_CONNECTION_TIMEOUT;
m_config.m_net_config.ping_connection_timeout = P2P_DEFAULT_PING_CONNECTION_TIMEOUT;
m_config.m_net_config.ping_connection_timeout = std::chrono::milliseconds{P2P_DEFAULT_PING_CONNECTION_TIMEOUT};
m_config.m_net_config.send_peerlist_sz = P2P_DEFAULT_PEERS_IN_HANDSHAKE;
m_config.m_support_flags = 0; // only set in public zone
}
+5 -5
View File
@@ -988,7 +988,7 @@ namespace nodetool
for (auto& zone : m_network_zones)
{
zone.second.m_net_server.get_config_object().set_handler(this);
zone.second.m_net_server.get_config_object().m_invoke_timeout = P2P_DEFAULT_INVOKE_TIMEOUT;
zone.second.m_net_server.get_config_object().m_invoke_timeout = std::chrono::milliseconds{P2P_DEFAULT_INVOKE_TIMEOUT};
if (!zone.second.m_bind_ip.empty())
{
@@ -1073,8 +1073,8 @@ namespace nodetool
})); // lambda
network_zone& public_zone = m_network_zones.at(epee::net_utils::zone::public_);
public_zone.m_net_server.add_idle_handler(boost::bind(&node_server<t_payload_net_handler>::idle_worker, this), 1000);
public_zone.m_net_server.add_idle_handler(boost::bind(&t_payload_net_handler::on_idle, &m_payload_handler), 1000);
public_zone.m_net_server.add_idle_handler(boost::bind(&node_server<t_payload_net_handler>::idle_worker, this), std::chrono::seconds{1});
public_zone.m_net_server.add_idle_handler(boost::bind(&t_payload_net_handler::on_idle, &m_payload_handler), std::chrono::seconds{1});
//here you can set worker threads count
int thrds_count = 10;
@@ -1234,7 +1234,7 @@ namespace nodetool
LOG_DEBUG_CC(context, " COMMAND_HANDSHAKE(AND CLOSE) INVOKED OK");
}
context_ = context;
}, P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT);
}, std::chrono::milliseconds{P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT});
if(r)
{
@@ -2563,7 +2563,7 @@ namespace nodetool
f(context_, rsp.support_flags);
},
P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT
std::chrono::milliseconds{P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT}
);
return r;
+1 -1
View File
@@ -136,10 +136,10 @@ namespace nodetool
KV_SERIALIZE(config_id)
END_KV_SERIALIZE_MAP()
std::chrono::milliseconds ping_connection_timeout;
uint32_t max_out_connection_count;
uint32_t max_in_connection_count;
uint32_t connection_timeout;
uint32_t ping_connection_timeout;
uint32_t handshake_interval;
uint32_t packet_max_size;
uint32_t config_id;
+1 -1
View File
@@ -350,7 +350,7 @@ namespace cryptonote
http_login.emplace(std::move(rpc_config->login->username), std::move(rpc_config->login->password).password());
if (m_rpc_payment)
m_net_server.add_idle_handler([this](){ return m_rpc_payment->on_idle(); }, 60 * 1000);
m_net_server.add_idle_handler([this](){ return m_rpc_payment->on_idle(); }, std::chrono::minutes{1});
bool store_ssl_key = !restricted && rpc_config->ssl_options && rpc_config->ssl_options.auth.certificate_path.empty();
const auto ssl_base_path = (boost::filesystem::path{data_dir} / "rpc_ssl").string();
+2 -2
View File
@@ -267,7 +267,7 @@ namespace tools
}
}
return true;
}, auto_refresh_evaluation_ms.count());
}, auto_refresh_evaluation_ms);
m_net_server.add_idle_handler([this](){
if (m_stop.load(std::memory_order_relaxed))
{
@@ -275,7 +275,7 @@ namespace tools
return false;
}
return true;
}, 500);
}, std::chrono::milliseconds{500});
//DO NOT START THIS SERVER IN MORE THEN 1 THREADS WITHOUT REFACTORING
return epee::http_server_impl_base<wallet_rpc_server, connection_context>::run(1, true);