From 2ad30e5776933f5353c0abe7eb7b4c8abaa850d5 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 12 Jan 2026 22:30:44 -0500 Subject: [PATCH] replace deadline_timer by steady_timer --- libi2pd/NTCP2.cpp | 15 ++++++++------- libi2pd/NTCP2.h | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libi2pd/NTCP2.cpp b/libi2pd/NTCP2.cpp index 95818394..da7ab90a 100644 --- a/libi2pd/NTCP2.cpp +++ b/libi2pd/NTCP2.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "Log.h" #include "I2PEndian.h" #include "Crypto.h" @@ -1869,10 +1870,10 @@ namespace transport { if (this->AddNTCP2Session (conn)) { - auto timer = std::make_shared(GetService ()); + auto timer = std::make_shared(GetService ()); auto timeout = NTCP2_CONNECT_TIMEOUT * 5; conn->SetTerminationTimeout(timeout * 2); - timer->expires_from_now (boost::posix_time::seconds(timeout)); + timer->expires_after (std::chrono::seconds(timeout)); timer->async_wait ([conn, timeout](const boost::system::error_code& ecode) { if (ecode != boost::asio::error::operation_aborted) @@ -1910,7 +1911,7 @@ namespace transport }); } - void NTCP2Server::HandleConnect (const boost::system::error_code& ecode, std::shared_ptr conn, std::shared_ptr timer) + void NTCP2Server::HandleConnect (const boost::system::error_code& ecode, std::shared_ptr conn, std::shared_ptr timer) { timer->cancel (); if (ecode) @@ -2023,7 +2024,7 @@ namespace transport void NTCP2Server::ScheduleTermination () { - m_TerminationTimer.expires_from_now (boost::posix_time::seconds( + m_TerminationTimer.expires_after (std::chrono::seconds( NTCP2_TERMINATION_CHECK_TIMEOUT + m_Rng () % NTCP2_TERMINATION_CHECK_TIMEOUT_VARIANCE)); m_TerminationTimer.async_wait (std::bind (&NTCP2Server::HandleTerminationTimer, this, std::placeholders::_1)); @@ -2090,10 +2091,10 @@ namespace transport { if (this->AddNTCP2Session (conn)) { - auto timer = std::make_shared(GetService()); + auto timer = std::make_shared(GetService()); auto timeout = NTCP2_CONNECT_TIMEOUT * 5; conn->SetTerminationTimeout(timeout * 2); - timer->expires_from_now (boost::posix_time::seconds(timeout)); + timer->expires_after (std::chrono::seconds(timeout)); timer->async_wait ([conn, timeout](const boost::system::error_code& ecode) { if (ecode != boost::asio::error::operation_aborted) @@ -2117,7 +2118,7 @@ namespace transport m_ProxyAuthorization = i2p::http::CreateBasicAuthorizationString (user, pass); } - void NTCP2Server::HandleProxyConnect(const boost::system::error_code& ecode, std::shared_ptr conn, std::shared_ptr timer) + void NTCP2Server::HandleProxyConnect(const boost::system::error_code& ecode, std::shared_ptr conn, std::shared_ptr timer) { if (ecode) { diff --git a/libi2pd/NTCP2.h b/libi2pd/NTCP2.h index 512e0e83..dcd80949 100644 --- a/libi2pd/NTCP2.h +++ b/libi2pd/NTCP2.h @@ -311,8 +311,8 @@ namespace transport void HandleAccept (std::shared_ptr conn, const boost::system::error_code& error); void HandleAcceptV6 (std::shared_ptr conn, const boost::system::error_code& error); - void HandleConnect (const boost::system::error_code& ecode, std::shared_ptr conn, std::shared_ptr timer); - void HandleProxyConnect(const boost::system::error_code& ecode, std::shared_ptr conn, std::shared_ptr timer); + void HandleConnect (const boost::system::error_code& ecode, std::shared_ptr conn, std::shared_ptr timer); + void HandleProxyConnect(const boost::system::error_code& ecode, std::shared_ptr conn, std::shared_ptr timer); // timer void ScheduleTermination (); @@ -320,7 +320,7 @@ namespace transport private: - boost::asio::deadline_timer m_TerminationTimer; + boost::asio::steady_timer m_TerminationTimer; std::unique_ptr m_NTCP2Acceptor, m_NTCP2V6Acceptor; std::map > m_NTCP2Sessions; std::map > m_PendingIncomingSessions;