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

View File

@@ -50,7 +50,7 @@ using namespace net_load_tests;
namespace
{
const size_t CONNECTION_COUNT = 100000;
const size_t CONNECTION_TIMEOUT = 10000;
constexpr const std::chrono::seconds CONNECTION_TIMEOUT{10};
const size_t DEFAULT_OPERATION_TIMEOUT = 30000;
const size_t RESERVED_CONN_CNT = 1;

View File

@@ -28,6 +28,7 @@
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#include <boost/asio/steady_timer.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
@@ -189,10 +190,10 @@ namespace
if (0 < count)
{
// Perhaps not all connections were closed, try to close it after 7 seconds
boost::shared_ptr<boost::asio::deadline_timer> sh_deadline(new boost::asio::deadline_timer(m_tcp_server.get_io_context(), boost::posix_time::seconds(7)));
std::shared_ptr<boost::asio::steady_timer> sh_deadline(std::make_shared<boost::asio::steady_timer>(m_tcp_server.get_io_context(), std::chrono::seconds(7)));
sh_deadline->async_wait([=](const boost::system::error_code& ec)
{
boost::shared_ptr<boost::asio::deadline_timer> t = sh_deadline; // Capture sh_deadline
std::shared_ptr<boost::asio::steady_timer> t = sh_deadline; // Capture sh_deadline
if (!ec)
{
close_connections(cmd_conn_id);
@@ -229,7 +230,7 @@ int main(int argc, char** argv)
srv_levin_commands_handler *commands_handler = new srv_levin_commands_handler(tcp_server);
tcp_server.get_config_object().set_handler(commands_handler, [](epee::levin::levin_commands_handler<test_connection_context> *handler) { delete handler; });
tcp_server.get_config_object().m_invoke_timeout = 10000;
tcp_server.get_config_object().m_invoke_timeout = std::chrono::seconds{10};
//tcp_server.get_config_object().m_max_packet_size = max_packet_size;
if (!tcp_server.run_server(thread_count, true))

View File

@@ -282,7 +282,7 @@ TEST(test_epee_connection, test_lifetime)
while (shared_state->sock_count);
ASSERT_TRUE(shared_state->get_connections_count() == 0);
constexpr auto DELAY = 30;
constexpr auto TIMEOUT = 1;
constexpr std::chrono::milliseconds TIMEOUT{1};
while (server.get_connections_count()) {
server.get_config_shared()->del_in_connections(
server.get_config_shared()->get_in_connections_count()

View File

@@ -185,7 +185,7 @@ namespace
class async_protocol_handler_test : public ::testing::Test
{
public:
const static uint64_t invoke_timeout = 5 * 1000;
constexpr const static std::chrono::seconds invoke_timeout{5};
const static size_t max_packet_size = 10 * 1024 * 1024;
typedef std::unique_ptr<test_connection> test_connection_ptr;

View File

@@ -690,7 +690,7 @@ TEST(cryptonote_protocol_handler, race_condition)
net_node.core_protocol->process_payload_sync_data(msg.payload_data, context, true);
handshaked.raise();
},
P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT
std::chrono::milliseconds{P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT}
);
return true;
}
@@ -1202,7 +1202,7 @@ TEST(node_server, race_condition)
EXPECT_TRUE(code >= 0);
handshaked.raise();
},
P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT
std::chrono::milliseconds{P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT}
);
handshaked.wait();
boost::asio::post(conn->strand_, [conn]{