diff --git a/daemon/I2PControl.cpp b/daemon/I2PControl.cpp index 95badb8a..bcb6ea03 100644 --- a/daemon/I2PControl.cpp +++ b/daemon/I2PControl.cpp @@ -405,7 +405,7 @@ namespace client { LogPrint (eLogInfo, "I2PControl: Shutdown requested"); InsertParam (results, "Shutdown", ""); - m_ShutdownTimer.expires_from_now (boost::posix_time::seconds(1)); // 1 second to make sure response has been sent + m_ShutdownTimer.expires_after (std::chrono::seconds(1)); // 1 second to make sure response has been sent m_ShutdownTimer.async_wait ( [](const boost::system::error_code& ecode) { @@ -419,7 +419,7 @@ namespace client int timeout = i2p::tunnel::tunnels.GetTransitTunnelsExpirationTimeout (); LogPrint (eLogInfo, "I2PControl: Graceful shutdown requested, ", timeout, " seconds remains"); InsertParam (results, "ShutdownGraceful", ""); - m_ShutdownTimer.expires_from_now (boost::posix_time::seconds(timeout + 1)); // + 1 second + m_ShutdownTimer.expires_after (std::chrono::seconds(timeout + 1)); // + 1 second m_ShutdownTimer.async_wait ( [](const boost::system::error_code& ecode) { diff --git a/daemon/I2PControl.h b/daemon/I2PControl.h index 83dd6549..2c1c1b65 100644 --- a/daemon/I2PControl.h +++ b/daemon/I2PControl.h @@ -94,7 +94,7 @@ namespace client std::unique_ptr m_LocalAcceptor; #endif boost::asio::ssl::context m_SSLContext; - boost::asio::deadline_timer m_ShutdownTimer; + boost::asio::steady_timer m_ShutdownTimer; std::set m_Tokens; std::map m_MethodHandlers; diff --git a/daemon/UPnP.cpp b/daemon/UPnP.cpp index 8e6dbcf6..1e8cd73e 100644 --- a/daemon/UPnP.cpp +++ b/daemon/UPnP.cpp @@ -178,7 +178,7 @@ namespace transport if (address && !address->host.is_v6 () && address->port) TryPortMapping (address); } - m_Timer.expires_from_now (boost::posix_time::minutes(UPNP_PORT_FORWARDING_INTERVAL)); // every 20 minutes + m_Timer.expires_after (std::chrono::minutes(UPNP_PORT_FORWARDING_INTERVAL)); // every 20 minutes m_Timer.async_wait ([this](const boost::system::error_code& ecode) { if (ecode != boost::asio::error::operation_aborted) diff --git a/daemon/UPnP.h b/daemon/UPnP.h index 2a5fe9f3..10d8c70d 100644 --- a/daemon/UPnP.h +++ b/daemon/UPnP.h @@ -68,7 +68,7 @@ namespace transport std::condition_variable m_Started; std::mutex m_StartedMutex; boost::asio::io_context m_Service; - boost::asio::deadline_timer m_Timer; + boost::asio::steady_timer m_Timer; bool m_upnpUrlsInitialized = false; struct UPNPUrls m_upnpUrls; struct IGDdatas m_upnpData; diff --git a/libi2pd/Destination.cpp b/libi2pd/Destination.cpp index fca21de8..d923ea4f 100644 --- a/libi2pd/Destination.cpp +++ b/libi2pd/Destination.cpp @@ -140,7 +140,7 @@ namespace client LoadTags (); m_Pool->SetLocalDestination (shared_from_this ()); m_Pool->SetActive (true); - m_CleanupTimer.expires_from_now (boost::posix_time::seconds (DESTINATION_CLEANUP_TIMEOUT)); + m_CleanupTimer.expires_after (std::chrono::seconds (DESTINATION_CLEANUP_TIMEOUT)); m_CleanupTimer.async_wait (std::bind (&LeaseSetDestination::HandleCleanupTimer, shared_from_this (), std::placeholders::_1)); } @@ -580,7 +580,7 @@ namespace client m_ExcludedFloodfills.clear (); m_PublishReplyToken = 0; // schedule verification - m_PublishVerificationTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_VERIFICATION_TIMEOUT + + m_PublishVerificationTimer.expires_after (std::chrono::seconds(PUBLISH_VERIFICATION_TIMEOUT + GetRng ()() % PUBLISH_VERIFICATION_TIMEOUT_VARIANCE)); m_PublishVerificationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishVerificationTimer, shared_from_this (), std::placeholders::_1)); @@ -615,7 +615,7 @@ namespace client { LogPrint (eLogDebug, "Destination: Publishing LeaseSet is too fast. Wait for ", PUBLISH_MIN_INTERVAL, " seconds"); m_PublishDelayTimer.cancel (); - m_PublishDelayTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_MIN_INTERVAL)); + m_PublishDelayTimer.expires_after (std::chrono::seconds(PUBLISH_MIN_INTERVAL)); m_PublishDelayTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishDelayTimer, shared_from_this (), std::placeholders::_1)); return; @@ -661,7 +661,7 @@ namespace client m_PublishReplyToken = 1; // dummy non-zero value // try again after a while LogPrint (eLogInfo, "Destination: Can't publish LeasetSet because destination is not ready. Try publishing again after ", PUBLISH_CONFIRMATION_TIMEOUT, " milliseconds"); - m_PublishConfirmationTimer.expires_from_now (boost::posix_time::milliseconds(PUBLISH_CONFIRMATION_TIMEOUT)); + m_PublishConfirmationTimer.expires_after (std::chrono::milliseconds(PUBLISH_CONFIRMATION_TIMEOUT)); m_PublishConfirmationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishConfirmationTimer, shared_from_this (), std::placeholders::_1)); return; @@ -680,7 +680,7 @@ namespace client s->HandlePublishConfirmationTimer (boost::system::error_code()); }); }; - m_PublishConfirmationTimer.expires_from_now (boost::posix_time::milliseconds(PUBLISH_CONFIRMATION_TIMEOUT)); + m_PublishConfirmationTimer.expires_after (std::chrono::milliseconds(PUBLISH_CONFIRMATION_TIMEOUT)); m_PublishConfirmationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishConfirmationTimer, shared_from_this (), std::placeholders::_1)); outbound->SendTunnelDataMsgTo (floodfill->GetIdentHash (), 0, msg); @@ -720,7 +720,7 @@ namespace client { // we got latest LeasetSet LogPrint (eLogDebug, "Destination: Published LeaseSet verified for ", s->GetIdentHash().ToBase32()); - s->m_PublishVerificationTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_REGULAR_VERIFICATION_INTERNAL)); + s->m_PublishVerificationTimer.expires_after (std::chrono::seconds(PUBLISH_REGULAR_VERIFICATION_INTERNAL)); s->m_PublishVerificationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishVerificationTimer, s, std::placeholders::_1)); return; } @@ -887,7 +887,7 @@ namespace client nextFloodfill->GetIdentHash (), 0, msg } }); - request->requestTimeoutTimer.expires_from_now (boost::posix_time::milliseconds(LEASESET_REQUEST_TIMEOUT)); + request->requestTimeoutTimer.expires_after (std::chrono::milliseconds(LEASESET_REQUEST_TIMEOUT)); request->requestTimeoutTimer.async_wait (std::bind (&LeaseSetDestination::HandleRequestTimoutTimer, shared_from_this (), std::placeholders::_1, dest)); } @@ -941,7 +941,7 @@ namespace client CleanupExpiredTags (); CleanupRemoteLeaseSets (); CleanupDestination (); - m_CleanupTimer.expires_from_now (boost::posix_time::seconds (DESTINATION_CLEANUP_TIMEOUT + + m_CleanupTimer.expires_after (std::chrono::seconds (DESTINATION_CLEANUP_TIMEOUT + GetRng ()() % DESTINATION_CLEANUP_TIMEOUT_VARIANCE)); m_CleanupTimer.async_wait (std::bind (&LeaseSetDestination::HandleCleanupTimer, shared_from_this (), std::placeholders::_1)); diff --git a/libi2pd/Destination.h b/libi2pd/Destination.h index b1f667fc..3e5e789b 100644 --- a/libi2pd/Destination.h +++ b/libi2pd/Destination.h @@ -121,7 +121,7 @@ namespace client LeaseSetRequest (boost::asio::io_context& service): requestTime (0), requestTimeoutTimer (service) {}; std::unordered_set excluded; uint64_t requestTime; - boost::asio::deadline_timer requestTimeoutTimer; + boost::asio::steady_timer requestTimeoutTimer; std::list requestComplete; std::shared_ptr outboundTunnel; std::shared_ptr replyTunnel; @@ -223,7 +223,7 @@ namespace client uint64_t m_LastSubmissionTime; // in seconds std::unordered_set m_ExcludedFloodfills; // for publishing - boost::asio::deadline_timer m_PublishConfirmationTimer, m_PublishVerificationTimer, + boost::asio::steady_timer m_PublishConfirmationTimer, m_PublishVerificationTimer, m_PublishDelayTimer, m_CleanupTimer; std::string m_Nickname; int m_LeaseSetType, m_AuthType; @@ -333,7 +333,7 @@ namespace client int m_RefCounter; // how many clients(tunnels) use this destination uint64_t m_LastPublishedTimestamp; - boost::asio::deadline_timer m_ReadyChecker; + boost::asio::steady_timer m_ReadyChecker; std::shared_ptr > m_AuthKeys; // we don't need them for I2CP diff --git a/libi2pd/NetDbRequests.cpp b/libi2pd/NetDbRequests.cpp index 94633e10..88ee6f7e 100644 --- a/libi2pd/NetDbRequests.cpp +++ b/libi2pd/NetDbRequests.cpp @@ -142,7 +142,7 @@ namespace data void NetDbRequests::ScheduleCleanup () { - m_CleanupTimer.expires_from_now (boost::posix_time::seconds(REQUESTED_DESTINATIONS_POOL_CLEANUP_INTERVAL)); + m_CleanupTimer.expires_after (std::chrono::seconds(REQUESTED_DESTINATIONS_POOL_CLEANUP_INTERVAL)); m_CleanupTimer.async_wait (std::bind (&NetDbRequests::HandleCleanupTimer, this, std::placeholders::_1)); } @@ -333,7 +333,7 @@ namespace data void NetDbRequests::ScheduleManageRequests () { - m_ManageRequestsTimer.expires_from_now (boost::posix_time::milliseconds(MANAGE_REQUESTS_INTERVAL + + m_ManageRequestsTimer.expires_after (std::chrono::milliseconds(MANAGE_REQUESTS_INTERVAL + m_Rng () % MANAGE_REQUESTS_INTERVAL_VARIANCE)); m_ManageRequestsTimer.async_wait (std::bind (&NetDbRequests::HandleManageRequestsTimer, this, std::placeholders::_1)); @@ -508,7 +508,7 @@ namespace data void NetDbRequests::ScheduleExploratory (uint64_t interval) { - m_ExploratoryTimer.expires_from_now (boost::posix_time::seconds(interval)); + m_ExploratoryTimer.expires_after (std::chrono::seconds(interval)); m_ExploratoryTimer.async_wait (std::bind (&NetDbRequests::HandleExploratoryTimer, this, std::placeholders::_1)); } @@ -539,7 +539,7 @@ namespace data void NetDbRequests::ScheduleDiscoveredRoutersRequest () { - m_DiscoveredRoutersTimer.expires_from_now (boost::posix_time::milliseconds( + m_DiscoveredRoutersTimer.expires_after (std::chrono::milliseconds( DISCOVERED_REQUEST_INTERVAL + m_Rng () % DISCOVERED_REQUEST_INTERVAL_VARIANCE)); m_DiscoveredRoutersTimer.async_wait (std::bind (&NetDbRequests::HandleDiscoveredRoutersTimer, this, std::placeholders::_1)); diff --git a/libi2pd/NetDbRequests.h b/libi2pd/NetDbRequests.h index 53af2c6a..3dec46df 100644 --- a/libi2pd/NetDbRequests.h +++ b/libi2pd/NetDbRequests.h @@ -121,7 +121,7 @@ namespace data i2p::util::MemoryPoolMt m_RequestedDestinationsPool; std::unordered_map > m_RequestedDestinations; std::list m_DiscoveredRouterHashes; - boost::asio::deadline_timer m_ManageRequestsTimer, m_ExploratoryTimer, + boost::asio::steady_timer m_ManageRequestsTimer, m_ExploratoryTimer, m_CleanupTimer, m_DiscoveredRoutersTimer; std::mt19937 m_Rng; }; diff --git a/libi2pd/RouterContext.cpp b/libi2pd/RouterContext.cpp index 77debd33..3407b71e 100644 --- a/libi2pd/RouterContext.cpp +++ b/libi2pd/RouterContext.cpp @@ -61,11 +61,11 @@ namespace i2p { m_Service.reset (new RouterService); m_Service->Start (); - m_PublishTimer.reset (new boost::asio::deadline_timer (m_Service->GetService ())); + m_PublishTimer.reset (new boost::asio::steady_timer (m_Service->GetService ())); ScheduleInitialPublish (); - m_CongestionUpdateTimer.reset (new boost::asio::deadline_timer (m_Service->GetService ())); + m_CongestionUpdateTimer.reset (new boost::asio::steady_timer (m_Service->GetService ())); ScheduleCongestionUpdate (); - m_CleanupTimer.reset (new boost::asio::deadline_timer (m_Service->GetService ())); + m_CleanupTimer.reset (new boost::asio::steady_timer (m_Service->GetService ())); ScheduleCleanupTimer (); } } @@ -1426,7 +1426,7 @@ namespace i2p { if (m_PublishTimer) { - m_PublishTimer->expires_from_now (boost::posix_time::seconds(ROUTER_INFO_INITIAL_PUBLISH_INTERVAL)); + m_PublishTimer->expires_after (std::chrono::seconds(ROUTER_INFO_INITIAL_PUBLISH_INTERVAL)); m_PublishTimer->async_wait (std::bind (&RouterContext::HandleInitialPublishTimer, this, std::placeholders::_1)); } @@ -1456,7 +1456,7 @@ namespace i2p if (m_PublishTimer) { m_PublishTimer->cancel (); - m_PublishTimer->expires_from_now (boost::posix_time::seconds(ROUTER_INFO_PUBLISH_INTERVAL + + m_PublishTimer->expires_after (std::chrono::seconds(ROUTER_INFO_PUBLISH_INTERVAL + GetRng ()() % ROUTER_INFO_PUBLISH_INTERVAL_VARIANCE)); m_PublishTimer->async_wait (std::bind (&RouterContext::HandlePublishTimer, this, std::placeholders::_1)); @@ -1547,7 +1547,7 @@ namespace i2p if (m_PublishTimer) { m_PublishTimer->cancel (); - m_PublishTimer->expires_from_now (boost::posix_time::milliseconds(ROUTER_INFO_CONFIRMATION_TIMEOUT)); + m_PublishTimer->expires_after (std::chrono::milliseconds(ROUTER_INFO_CONFIRMATION_TIMEOUT)); m_PublishTimer->async_wait (std::bind (&RouterContext::HandlePublishResendTimer, this, std::placeholders::_1)); } @@ -1570,7 +1570,7 @@ namespace i2p if (m_CongestionUpdateTimer) { m_CongestionUpdateTimer->cancel (); - m_CongestionUpdateTimer->expires_from_now (boost::posix_time::seconds( + m_CongestionUpdateTimer->expires_after (std::chrono::seconds( ROUTER_INFO_CONGESTION_UPDATE_INTERVAL + GetRng ()() % ROUTER_INFO_CONGESTION_UPDATE_INTERVAL_VARIANCE)); m_CongestionUpdateTimer->async_wait (std::bind (&RouterContext::HandleCongestionUpdateTimer, this, std::placeholders::_1)); @@ -1610,7 +1610,7 @@ namespace i2p if (m_CleanupTimer) { m_CleanupTimer->cancel (); - m_CleanupTimer->expires_from_now (boost::posix_time::seconds(ROUTER_INFO_CLEANUP_INTERVAL)); + m_CleanupTimer->expires_after (std::chrono::seconds(ROUTER_INFO_CLEANUP_INTERVAL)); m_CleanupTimer->async_wait (std::bind (&RouterContext::HandleCleanupTimer, this, std::placeholders::_1)); } diff --git a/libi2pd/RouterContext.h b/libi2pd/RouterContext.h index 04d40668..2600f4d2 100644 --- a/libi2pd/RouterContext.h +++ b/libi2pd/RouterContext.h @@ -264,7 +264,7 @@ namespace garlic i2p::crypto::NoiseSymmetricState m_InitialNoiseState, m_CurrentNoiseState; // publish std::unique_ptr m_Service; - std::unique_ptr m_PublishTimer, m_CongestionUpdateTimer, m_CleanupTimer; + std::unique_ptr m_PublishTimer, m_CongestionUpdateTimer, m_CleanupTimer; std::unordered_set m_PublishExcluded; uint32_t m_PublishReplyToken; bool m_IsHiddenMode; // not publish diff --git a/libi2pd/SSU2.cpp b/libi2pd/SSU2.cpp index e2b2aa56..895a585e 100644 --- a/libi2pd/SSU2.cpp +++ b/libi2pd/SSU2.cpp @@ -1085,7 +1085,7 @@ namespace transport void SSU2Server::ScheduleTermination () { - m_TerminationTimer.expires_from_now (boost::posix_time::seconds( + m_TerminationTimer.expires_after (std::chrono::seconds( SSU2_TERMINATION_CHECK_TIMEOUT + m_Rng () % SSU2_TERMINATION_CHECK_TIMEOUT_VARIANCE)); m_TerminationTimer.async_wait (std::bind (&SSU2Server::HandleTerminationTimer, this, std::placeholders::_1)); @@ -1133,7 +1133,7 @@ namespace transport void SSU2Server::ScheduleCleanup () { - m_CleanupTimer.expires_from_now (boost::posix_time::seconds(SSU2_CLEANUP_INTERVAL)); + m_CleanupTimer.expires_after (std::chrono::seconds(SSU2_CLEANUP_INTERVAL)); m_CleanupTimer.async_wait (std::bind (&SSU2Server::HandleCleanupTimer, this, std::placeholders::_1)); } @@ -1215,7 +1215,7 @@ namespace transport void SSU2Server::ScheduleResend (bool more) { - m_ResendTimer.expires_from_now (boost::posix_time::milliseconds (more ? + m_ResendTimer.expires_after (std::chrono::milliseconds (more ? (SSU2_RESEND_CHECK_MORE_TIMEOUT + m_Rng () % SSU2_RESEND_CHECK_MORE_TIMEOUT_VARIANCE): (SSU2_RESEND_CHECK_TIMEOUT + m_Rng () % SSU2_RESEND_CHECK_TIMEOUT_VARIANCE))); m_ResendTimer.async_wait (std::bind (&SSU2Server::HandleResendTimer, @@ -1442,7 +1442,7 @@ namespace transport { if (m_IsPublished) { - m_IntroducersUpdateTimer.expires_from_now (boost::posix_time::seconds( + m_IntroducersUpdateTimer.expires_after (std::chrono::seconds( SSU2_KEEP_ALIVE_INTERVAL + m_Rng () % SSU2_KEEP_ALIVE_INTERVAL_VARIANCE)); m_IntroducersUpdateTimer.async_wait (std::bind (&SSU2Server::HandleIntroducersUpdateTimer, this, std::placeholders::_1, true)); @@ -1456,7 +1456,7 @@ namespace transport m_IntroducersUpdateTimer.cancel (); i2p::context.ClearSSU2Introducers (true); m_Introducers.clear (); - m_IntroducersUpdateTimer.expires_from_now (boost::posix_time::seconds( + m_IntroducersUpdateTimer.expires_after (std::chrono::seconds( (SSU2_KEEP_ALIVE_INTERVAL + m_Rng () % SSU2_KEEP_ALIVE_INTERVAL_VARIANCE)/2)); m_IntroducersUpdateTimer.async_wait (std::bind (&SSU2Server::HandleIntroducersUpdateTimer, this, std::placeholders::_1, true)); @@ -1467,7 +1467,7 @@ namespace transport { if (m_IsPublished) { - m_IntroducersUpdateTimerV6.expires_from_now (boost::posix_time::seconds( + m_IntroducersUpdateTimerV6.expires_after (std::chrono::seconds( SSU2_KEEP_ALIVE_INTERVAL + m_Rng () % SSU2_KEEP_ALIVE_INTERVAL_VARIANCE)); m_IntroducersUpdateTimerV6.async_wait (std::bind (&SSU2Server::HandleIntroducersUpdateTimer, this, std::placeholders::_1, false)); @@ -1481,7 +1481,7 @@ namespace transport m_IntroducersUpdateTimerV6.cancel (); i2p::context.ClearSSU2Introducers (false); m_IntroducersV6.clear (); - m_IntroducersUpdateTimerV6.expires_from_now (boost::posix_time::seconds( + m_IntroducersUpdateTimerV6.expires_after (std::chrono::seconds( (SSU2_KEEP_ALIVE_INTERVAL + m_Rng () % SSU2_KEEP_ALIVE_INTERVAL_VARIANCE)/2)); m_IntroducersUpdateTimerV6.async_wait (std::bind (&SSU2Server::HandleIntroducersUpdateTimer, this, std::placeholders::_1, false)); @@ -1789,8 +1789,8 @@ namespace transport if (m_ProxyConnectRetryTimer) m_ProxyConnectRetryTimer->cancel (); else - m_ProxyConnectRetryTimer.reset (new boost::asio::deadline_timer (m_ReceiveService.GetService ())); - m_ProxyConnectRetryTimer->expires_from_now (boost::posix_time::seconds (SSU2_PROXY_CONNECT_RETRY_TIMEOUT)); + m_ProxyConnectRetryTimer.reset (new boost::asio::steady_timer (m_ReceiveService.GetService ())); + m_ProxyConnectRetryTimer->expires_after (std::chrono::seconds (SSU2_PROXY_CONNECT_RETRY_TIMEOUT)); m_ProxyConnectRetryTimer->async_wait ( [this](const boost::system::error_code& ecode) { diff --git a/libi2pd/SSU2.h b/libi2pd/SSU2.h index 3af93608..d1ec2aaa 100644 --- a/libi2pd/SSU2.h +++ b/libi2pd/SSU2.h @@ -198,7 +198,7 @@ namespace transport i2p::util::MemoryPool m_SentPacketsPool; i2p::util::MemoryPool m_IncompleteMessagesPool; i2p::util::MemoryPool m_FragmentsPool; - boost::asio::deadline_timer m_TerminationTimer, m_CleanupTimer, m_ResendTimer, + boost::asio::steady_timer m_TerminationTimer, m_CleanupTimer, m_ResendTimer, m_IntroducersUpdateTimer, m_IntroducersUpdateTimerV6; std::shared_ptr m_LastSession; bool m_IsPublished; // if we maintain introducers @@ -222,7 +222,7 @@ namespace transport std::unique_ptr m_ProxyEndpoint; std::unique_ptr m_UDPAssociateSocket; std::unique_ptr m_ProxyRelayEndpoint; - std::unique_ptr m_ProxyConnectRetryTimer; + std::unique_ptr m_ProxyConnectRetryTimer; public: diff --git a/libi2pd/SSU2OutOfSession.cpp b/libi2pd/SSU2OutOfSession.cpp index bed3dabe..1c699a37 100644 --- a/libi2pd/SSU2OutOfSession.cpp +++ b/libi2pd/SSU2OutOfSession.cpp @@ -227,7 +227,7 @@ namespace transport { if (m_NumResends < SSU2_PEER_TEST_MAX_NUM_RESENDS) { - m_PeerTestResendTimer.expires_from_now (boost::posix_time::milliseconds( + m_PeerTestResendTimer.expires_after (std::chrono::milliseconds( SSU2_PEER_TEST_RESEND_INTERVAL + GetServer ().GetRng ()() % SSU2_PEER_TEST_RESEND_INTERVAL_VARIANCE)); std::weak_ptr s(std::static_pointer_cast(shared_from_this ())); m_PeerTestResendTimer.async_wait ([s, msg](const boost::system::error_code& ecode) @@ -322,7 +322,7 @@ namespace transport { if (m_NumResends < SSU2_HOLE_PUNCH_MAX_NUM_RESENDS) { - m_HolePunchResendTimer.expires_from_now (boost::posix_time::milliseconds( + m_HolePunchResendTimer.expires_after (std::chrono::milliseconds( SSU2_HOLE_PUNCH_RESEND_INTERVAL + GetServer ().GetRng ()() % SSU2_HOLE_PUNCH_RESEND_INTERVAL_VARIANCE)); std::weak_ptr s(std::static_pointer_cast(shared_from_this ())); m_HolePunchResendTimer.async_wait ([s](const boost::system::error_code& ecode) diff --git a/libi2pd/SSU2OutOfSession.h b/libi2pd/SSU2OutOfSession.h index e8c55c3c..fb4f8d86 100644 --- a/libi2pd/SSU2OutOfSession.h +++ b/libi2pd/SSU2OutOfSession.h @@ -50,7 +50,7 @@ namespace transport uint8_t m_MsgNumReceived, m_NumResends; bool m_IsConnectedRecently, m_IsStatusChanged; std::vector m_SignedData; // for resends - boost::asio::deadline_timer m_PeerTestResendTimer; + boost::asio::steady_timer m_PeerTestResendTimer; boost::asio::ip::udp::endpoint m_OurEndpoint; // as seen by peer }; @@ -78,7 +78,7 @@ namespace transport int m_NumResends; std::vector m_RelayResponseBlock; - boost::asio::deadline_timer m_HolePunchResendTimer; + boost::asio::steady_timer m_HolePunchResendTimer; }; } } diff --git a/libi2pd/Streaming.cpp b/libi2pd/Streaming.cpp index ac18cabf..b6cfa3fd 100644 --- a/libi2pd/Streaming.cpp +++ b/libi2pd/Streaming.cpp @@ -443,7 +443,7 @@ namespace stream if (delayRequested < m_RTT) { m_IsAckSendScheduled = true; - m_AckSendTimer.expires_from_now (boost::posix_time::milliseconds(delayRequested)); + m_AckSendTimer.expires_after (std::chrono::milliseconds(delayRequested)); m_AckSendTimer.async_wait (std::bind (&Stream::HandleAckSendTimer, shared_from_this (), std::placeholders::_1)); } @@ -1601,7 +1601,7 @@ namespace stream m_SendTimer.cancel (); uint64_t interval = SEND_INTERVAL + m_LocalDestination.GetRandom () % SEND_INTERVAL_VARIANCE; if (interval < m_PacingTime) interval = m_PacingTime; - m_SendTimer.expires_from_now (boost::posix_time::microseconds(interval)); + m_SendTimer.expires_after (std::chrono::microseconds(interval)); m_SendTimer.async_wait (std::bind (&Stream::HandleSendTimer, shared_from_this (), std::placeholders::_1)); } @@ -1694,7 +1694,7 @@ namespace stream m_ResendTimer.cancel (); // check for invalid value if (m_RTO <= 0) m_RTO = INITIAL_RTO; - m_ResendTimer.expires_from_now (boost::posix_time::milliseconds(m_RTO)); + m_ResendTimer.expires_after (std::chrono::milliseconds(m_RTO)); m_ResendTimer.async_wait (std::bind (&Stream::HandleResendTimer, shared_from_this (), std::placeholders::_1)); } @@ -1843,7 +1843,7 @@ namespace stream m_AckSendTimer.cancel (); m_IsAckSendScheduled = true; if (timeout < MIN_SEND_ACK_TIMEOUT) timeout = MIN_SEND_ACK_TIMEOUT; - m_AckSendTimer.expires_from_now (boost::posix_time::milliseconds(timeout)); + m_AckSendTimer.expires_after (std::chrono::milliseconds(timeout)); m_AckSendTimer.async_wait (std::bind (&Stream::HandleAckSendTimer, shared_from_this (), std::placeholders::_1)); } @@ -2209,7 +2209,7 @@ namespace stream { m_PendingIncomingStreams.push_back (incomingStream); m_PendingIncomingTimer.cancel (); - m_PendingIncomingTimer.expires_from_now (boost::posix_time::seconds(PENDING_INCOMING_TIMEOUT)); + m_PendingIncomingTimer.expires_after (std::chrono::seconds(PENDING_INCOMING_TIMEOUT)); m_PendingIncomingTimer.async_wait (std::bind (&StreamingDestination::HandlePendingIncomingTimer, shared_from_this (), std::placeholders::_1)); LogPrint (eLogDebug, "Streaming: Pending incoming stream added, rSID=", receiveStreamID); @@ -2238,8 +2238,8 @@ namespace stream else { m_SavedPackets[receiveStreamID] = std::list{ packet }; - auto timer = std::make_shared (m_Owner->GetService ()); - timer->expires_from_now (boost::posix_time::seconds(PENDING_INCOMING_TIMEOUT)); + auto timer = std::make_shared (m_Owner->GetService ()); + timer->expires_after (std::chrono::seconds(PENDING_INCOMING_TIMEOUT)); auto s = shared_from_this (); timer->async_wait ([s,timer,receiveStreamID](const boost::system::error_code& ecode) { diff --git a/libi2pd/Streaming.h b/libi2pd/Streaming.h index 176e9ecb..4ace59ab 100644 --- a/libi2pd/Streaming.h +++ b/libi2pd/Streaming.h @@ -290,7 +290,7 @@ namespace stream std::set m_SavedPackets; std::set m_SentPackets; std::set m_NACKedPackets; - boost::asio::deadline_timer m_ReceiveTimer, m_SendTimer, m_ResendTimer, m_AckSendTimer; + boost::asio::steady_timer m_ReceiveTimer, m_SendTimer, m_ResendTimer, m_AckSendTimer; size_t m_NumSentBytes, m_NumReceivedBytes; uint16_t m_Port; @@ -369,7 +369,7 @@ namespace stream Acceptor m_Acceptor; PongHandler m_PongHandler; std::list > m_PendingIncomingStreams; - boost::asio::deadline_timer m_PendingIncomingTimer; + boost::asio::steady_timer m_PendingIncomingTimer; std::unordered_map > m_SavedPackets; // receiveStreamID->packets, arrived before SYN uint64_t m_LastCleanupTime; // in seconds @@ -397,7 +397,7 @@ namespace stream else { int t = (timeout > MAX_RECEIVE_TIMEOUT) ? MAX_RECEIVE_TIMEOUT : timeout; - s->m_ReceiveTimer.expires_from_now (boost::posix_time::seconds(t)); + s->m_ReceiveTimer.expires_after (std::chrono::seconds(t)); int left = timeout - t; s->m_ReceiveTimer.async_wait ( [s, buffer, handler, left](const boost::system::error_code & ec) diff --git a/libi2pd/Timestamp.cpp b/libi2pd/Timestamp.cpp index a22e9bde..edd890b9 100644 --- a/libi2pd/Timestamp.cpp +++ b/libi2pd/Timestamp.cpp @@ -200,7 +200,7 @@ namespace util if (m_IsRunning) { - m_Timer.expires_from_now (boost::posix_time::hours (m_SyncInterval)); + m_Timer.expires_after (std::chrono::hours (m_SyncInterval)); m_Timer.async_wait ([this](const boost::system::error_code& ecode) { if (ecode != boost::asio::error::operation_aborted) diff --git a/libi2pd/Timestamp.h b/libi2pd/Timestamp.h index 6b224685..6cd50507 100644 --- a/libi2pd/Timestamp.h +++ b/libi2pd/Timestamp.h @@ -14,7 +14,7 @@ #include #include #include -#include // for boost 1.89 +#include // for boost 1.89 namespace i2p { @@ -54,7 +54,7 @@ namespace util bool m_IsRunning; std::unique_ptr m_Thread; boost::asio::io_context m_Service; - boost::asio::deadline_timer m_Timer; + boost::asio::steady_timer m_Timer; int m_SyncInterval; std::vector m_NTPServersList; }; diff --git a/libi2pd/Transports.cpp b/libi2pd/Transports.cpp index 8090f0dd..0d920b80 100644 --- a/libi2pd/Transports.cpp +++ b/libi2pd/Transports.cpp @@ -184,9 +184,9 @@ namespace transport { m_Service = new boost::asio::io_context (); m_Work = new boost::asio::executor_work_guard (m_Service->get_executor ()); - m_PeerCleanupTimer = new boost::asio::deadline_timer (*m_Service); - m_PeerTestTimer = new boost::asio::deadline_timer (*m_Service); - m_UpdateBandwidthTimer = new boost::asio::deadline_timer (*m_Service); + m_PeerCleanupTimer = new boost::asio::steady_timer (*m_Service); + m_PeerTestTimer = new boost::asio::steady_timer (*m_Service); + m_UpdateBandwidthTimer = new boost::asio::steady_timer (*m_Service); m_BanListCleanupTimer = std::make_unique(*m_Service); } @@ -327,7 +327,7 @@ namespace transport if (m_SSU2Server) m_SSU2Server->Start (); if (m_SSU2Server) DetectExternalIP (); - m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(5 * SESSION_CREATION_TIMEOUT)); + m_PeerCleanupTimer->expires_after (std::chrono::seconds(5 * SESSION_CREATION_TIMEOUT)); m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1)); uint64_t ts = i2p::util::GetMillisecondsSinceEpoch(); @@ -340,12 +340,12 @@ namespace transport } m_TrafficSamplePtr = TRAFFIC_SAMPLE_COUNT - 1; - m_UpdateBandwidthTimer->expires_from_now (boost::posix_time::seconds(1)); + m_UpdateBandwidthTimer->expires_after (std::chrono::seconds(1)); m_UpdateBandwidthTimer->async_wait (std::bind (&Transports::HandleUpdateBandwidthTimer, this, std::placeholders::_1)); if (m_IsNAT) { - m_PeerTestTimer->expires_from_now (boost::posix_time::seconds(PEER_TEST_INTERVAL + m_Rng() % PEER_TEST_INTERVAL_VARIANCE)); + m_PeerTestTimer->expires_after (std::chrono::seconds(PEER_TEST_INTERVAL + m_Rng() % PEER_TEST_INTERVAL_VARIANCE)); m_PeerTestTimer->async_wait (std::bind (&Transports::HandlePeerTestTimer, this, std::placeholders::_1)); } m_BanListCleanupTimer->expires_after (std::chrono::seconds(BAN_LIST_CLEANUP_INTERVAL + m_Rng () % BAN_LIST_CLEANUP_INTERVAL_VARIANCE)); @@ -434,7 +434,7 @@ namespace transport UpdateBandwidthValues (15, m_InBandwidth15s, m_OutBandwidth15s, m_TransitBandwidth15s); UpdateBandwidthValues (300, m_InBandwidth5m, m_OutBandwidth5m, m_TransitBandwidth5m); - m_UpdateBandwidthTimer->expires_from_now (boost::posix_time::seconds(1)); + m_UpdateBandwidthTimer->expires_after (std::chrono::seconds(1)); m_UpdateBandwidthTimer->async_wait (std::bind (&Transports::HandleUpdateBandwidthTimer, this, std::placeholders::_1)); } } @@ -828,8 +828,8 @@ namespace transport testDelay += PEER_TEST_DELAY_INTERVAL + m_Rng() % PEER_TEST_DELAY_INTERVAL_VARIANCE; if (m_Service) { - auto delayTimer = std::make_shared(*m_Service); - delayTimer->expires_from_now (boost::posix_time::milliseconds (testDelay)); + auto delayTimer = std::make_shared(*m_Service); + delayTimer->expires_after (std::chrono::milliseconds (testDelay)); delayTimer->async_wait ( [this, router, delayTimer](const boost::system::error_code& ecode) { @@ -866,8 +866,8 @@ namespace transport testDelay += PEER_TEST_DELAY_INTERVAL + m_Rng() % PEER_TEST_DELAY_INTERVAL_VARIANCE; if (m_Service) { - auto delayTimer = std::make_shared(*m_Service); - delayTimer->expires_from_now (boost::posix_time::milliseconds (testDelay)); + auto delayTimer = std::make_shared(*m_Service); + delayTimer->expires_after (std::chrono::milliseconds (testDelay)); delayTimer->async_wait ( [this, router, delayTimer](const boost::system::error_code& ecode) { @@ -1078,7 +1078,7 @@ namespace transport // if still testing or unknown, repeat peer test if (ipv4Testing || ipv6Testing) PeerTest (ipv4Testing, ipv6Testing); - m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(2 * SESSION_CREATION_TIMEOUT + m_Rng() % SESSION_CREATION_TIMEOUT)); + m_PeerCleanupTimer->expires_after (std::chrono::seconds(2 * SESSION_CREATION_TIMEOUT + m_Rng() % SESSION_CREATION_TIMEOUT)); m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1)); } } @@ -1088,7 +1088,7 @@ namespace transport if (ecode != boost::asio::error::operation_aborted) { PeerTest (); - m_PeerTestTimer->expires_from_now (boost::posix_time::seconds(PEER_TEST_INTERVAL + m_Rng() % PEER_TEST_INTERVAL_VARIANCE)); + m_PeerTestTimer->expires_after (std::chrono::seconds(PEER_TEST_INTERVAL + m_Rng() % PEER_TEST_INTERVAL_VARIANCE)); m_PeerTestTimer->async_wait (std::bind (&Transports::HandlePeerTestTimer, this, std::placeholders::_1)); } } diff --git a/libi2pd/Transports.h b/libi2pd/Transports.h index de09a32c..b0c5bee4 100644 --- a/libi2pd/Transports.h +++ b/libi2pd/Transports.h @@ -224,7 +224,7 @@ namespace transport std::thread * m_Thread; boost::asio::io_context * m_Service; boost::asio::executor_work_guard * m_Work; - boost::asio::deadline_timer * m_PeerCleanupTimer, * m_PeerTestTimer, * m_UpdateBandwidthTimer; + boost::asio::steady_timer * m_PeerCleanupTimer, * m_PeerTestTimer, * m_UpdateBandwidthTimer; SSU2Server * m_SSU2Server; NTCP2Server * m_NTCP2Server; diff --git a/libi2pd_client/BOB.cpp b/libi2pd_client/BOB.cpp index d46aa612..d147d69f 100644 --- a/libi2pd_client/BOB.cpp +++ b/libi2pd_client/BOB.cpp @@ -866,8 +866,8 @@ namespace client SendReplyError ("No streaming destination"); return; } - auto timer = std::make_shared(localDestination->GetService ()); - timer->expires_from_now (boost::posix_time::milliseconds(BOB_PING_TIMEOUT)); + auto timer = std::make_shared(localDestination->GetService ()); + timer->expires_after (std::chrono::milliseconds(BOB_PING_TIMEOUT)); timer->async_wait ([streamingDestination, s = shared_from_this ()](const boost::system::error_code& ecode) { if (ecode != boost::asio::error::operation_aborted) diff --git a/libi2pd_client/ClientContext.cpp b/libi2pd_client/ClientContext.cpp index 969f9eb9..e881aa7b 100644 --- a/libi2pd_client/ClientContext.cpp +++ b/libi2pd_client/ClientContext.cpp @@ -123,7 +123,7 @@ namespace client // start UDP cleanup if (!m_ServerForwards.empty ()) { - m_CleanupUDPTimer.reset (new boost::asio::deadline_timer(m_SharedLocalDestination->GetService ())); + m_CleanupUDPTimer.reset (new boost::asio::steady_timer(m_SharedLocalDestination->GetService ())); ScheduleCleanupUDP(); } } @@ -1043,7 +1043,7 @@ namespace client if (m_CleanupUDPTimer) { // schedule cleanup in 17 seconds - m_CleanupUDPTimer->expires_from_now (boost::posix_time::seconds (17)); + m_CleanupUDPTimer->expires_after (std::chrono::seconds (17)); m_CleanupUDPTimer->async_wait(std::bind(&ClientContext::CleanupUDP, this, std::placeholders::_1)); } } diff --git a/libi2pd_client/ClientContext.h b/libi2pd_client/ClientContext.h index e328ab28..546e669b 100644 --- a/libi2pd_client/ClientContext.h +++ b/libi2pd_client/ClientContext.h @@ -154,7 +154,7 @@ namespace client BOBCommandChannel * m_BOBCommandChannel; I2CPServer * m_I2CPServer; - std::unique_ptr m_CleanupUDPTimer; + std::unique_ptr m_CleanupUDPTimer; // i18n std::shared_ptr m_Language; diff --git a/libi2pd_client/I2CP.cpp b/libi2pd_client/I2CP.cpp index 11bb966a..4bd60b19 100644 --- a/libi2pd_client/I2CP.cpp +++ b/libi2pd_client/I2CP.cpp @@ -186,7 +186,7 @@ namespace client if (!pool || pool->GetOutboundTunnels ().empty ()) { // try again later - m_ReadinessCheckTimer.expires_from_now (boost::posix_time::seconds(I2CP_DESTINATION_READINESS_CHECK_INTERVAL)); + m_ReadinessCheckTimer.expires_after (std::chrono::seconds(I2CP_DESTINATION_READINESS_CHECK_INTERVAL)); m_ReadinessCheckTimer.async_wait( [s=GetSharedFromThis (), tunnels=std::move(tunnels)](const boost::system::error_code& ecode) { @@ -209,7 +209,7 @@ namespace client htobe16buf (leases - 3, sessionID); size_t l = 2/*sessionID*/ + 1/*num leases*/ + i2p::data::LEASE_SIZE*numLeases; m_Owner->SendI2CPMessage (I2CP_REQUEST_VARIABLE_LEASESET_MESSAGE, leases - 3, l); - m_LeaseSetCreationTimer.expires_from_now (boost::posix_time::seconds (I2CP_LEASESET_CREATION_TIMEOUT)); + m_LeaseSetCreationTimer.expires_after (std::chrono::seconds (I2CP_LEASESET_CREATION_TIMEOUT)); auto s = GetSharedFromThis (); m_LeaseSetCreationTimer.async_wait ([s](const boost::system::error_code& ecode) { diff --git a/libi2pd_client/I2CP.h b/libi2pd_client/I2CP.h index 1c50f846..f12fa1b2 100644 --- a/libi2pd_client/I2CP.h +++ b/libi2pd_client/I2CP.h @@ -135,7 +135,7 @@ namespace client std::map > m_EncryptionKeys; // last is most preferable uint64_t m_LeaseSetExpirationTime; bool m_IsCreatingLeaseSet, m_IsSameThread; - boost::asio::deadline_timer m_LeaseSetCreationTimer, m_ReadinessCheckTimer; + boost::asio::steady_timer m_LeaseSetCreationTimer, m_ReadinessCheckTimer; i2p::util::MemoryPoolMt > m_I2NPMsgsPool; }; diff --git a/libi2pd_client/I2PTunnel.cpp b/libi2pd_client/I2PTunnel.cpp index c02a8ee0..b62e6e2c 100644 --- a/libi2pd_client/I2PTunnel.cpp +++ b/libi2pd_client/I2PTunnel.cpp @@ -693,7 +693,7 @@ namespace client { m_KeepAliveInterval = keepAliveInterval; if (m_KeepAliveInterval) - m_KeepAliveTimer.reset (new boost::asio::deadline_timer (GetLocalDestination ()->GetService ())); + m_KeepAliveTimer.reset (new boost::asio::steady_timer (GetLocalDestination ()->GetService ())); } /* HACK: maybe we should create a caching IdentHash provider in AddressBook */ @@ -721,7 +721,7 @@ namespace client { if (m_KeepAliveTimer) { - m_KeepAliveTimer->expires_from_now (boost::posix_time::seconds (m_KeepAliveInterval)); + m_KeepAliveTimer->expires_after (std::chrono::seconds (m_KeepAliveInterval)); m_KeepAliveTimer->async_wait (std::bind (&I2PClientTunnel::HandleKeepAliveTimer, this, std::placeholders::_1)); } diff --git a/libi2pd_client/I2PTunnel.h b/libi2pd_client/I2PTunnel.h index a6096f20..90d37e76 100644 --- a/libi2pd_client/I2PTunnel.h +++ b/libi2pd_client/I2PTunnel.h @@ -180,7 +180,7 @@ namespace client std::shared_ptr m_Address; uint16_t m_DestinationPort; uint32_t m_KeepAliveInterval; - std::unique_ptr m_KeepAliveTimer; + std::unique_ptr m_KeepAliveTimer; }; class I2PServerTunnel: public I2PService diff --git a/libi2pd_client/MatchedDestination.cpp b/libi2pd_client/MatchedDestination.cpp index 934b882d..f7599afc 100644 --- a/libi2pd_client/MatchedDestination.cpp +++ b/libi2pd_client/MatchedDestination.cpp @@ -46,7 +46,7 @@ namespace client } else { - m_ResolveTimer->expires_from_now(boost::posix_time::seconds(1)); + m_ResolveTimer->expires_after(std::chrono::seconds(1)); m_ResolveTimer->async_wait([&](const boost::system::error_code & ec) { if(!ec) ResolveCurrentLeaseSet(); }); @@ -57,7 +57,7 @@ namespace client void MatchedTunnelDestination::Start() { ClientDestination::Start(); - m_ResolveTimer = std::make_shared(GetService()); + m_ResolveTimer = std::make_shared(GetService()); GetTunnelPool()->SetCustomPeerSelector(this); ResolveCurrentLeaseSet(); } diff --git a/libi2pd_client/MatchedDestination.h b/libi2pd_client/MatchedDestination.h index f1b30b3d..72e6a209 100644 --- a/libi2pd_client/MatchedDestination.h +++ b/libi2pd_client/MatchedDestination.h @@ -39,7 +39,7 @@ namespace client std::string m_RemoteName; i2p::data::IdentHash m_RemoteIdent; std::shared_ptr m_RemoteLeaseSet; - std::shared_ptr m_ResolveTimer; + std::shared_ptr m_ResolveTimer; }; } } diff --git a/libi2pd_client/SAM.cpp b/libi2pd_client/SAM.cpp index 1ad279e7..24917625 100644 --- a/libi2pd_client/SAM.cpp +++ b/libi2pd_client/SAM.cpp @@ -475,7 +475,7 @@ namespace client SendSessionCreateReplyOk (); else { - m_Timer.expires_from_now (boost::posix_time::seconds(SAM_SESSION_READINESS_CHECK_INTERVAL)); + m_Timer.expires_after (std::chrono::seconds(SAM_SESSION_READINESS_CHECK_INTERVAL)); m_Timer.async_wait (std::bind (&SAMSocket::HandleSessionReadinessCheckTimer, shared_from_this (), std::placeholders::_1)); } @@ -497,7 +497,7 @@ namespace client SendSessionCreateReplyOk (); else { - m_Timer.expires_from_now (boost::posix_time::seconds(SAM_SESSION_READINESS_CHECK_INTERVAL)); + m_Timer.expires_after (std::chrono::seconds(SAM_SESSION_READINESS_CHECK_INTERVAL)); m_Timer.async_wait (std::bind (&SAMSocket::HandleSessionReadinessCheckTimer, shared_from_this (), std::placeholders::_1)); } @@ -1591,13 +1591,13 @@ namespace client void SAMBridge::ScheduleSessionCleanupTimer (std::shared_ptr session) { - auto timer = std::make_shared(GetService ()); - timer->expires_from_now (boost::posix_time::seconds(5)); // postpone destination clean for 5 seconds + auto timer = std::make_shared(GetService ()); + timer->expires_after (std::chrono::seconds(5)); // postpone destination clean for 5 seconds timer->async_wait (std::bind (&SAMBridge::HandleSessionCleanupTimer, this, std::placeholders::_1, session, timer)); } void SAMBridge::HandleSessionCleanupTimer (const boost::system::error_code& ecode, - std::shared_ptr session, std::shared_ptr timer) + std::shared_ptr session, std::shared_ptr timer) { if (ecode != boost::asio::error::operation_aborted && session) { diff --git a/libi2pd_client/SAM.h b/libi2pd_client/SAM.h index a71fae91..fa6841db 100644 --- a/libi2pd_client/SAM.h +++ b/libi2pd_client/SAM.h @@ -185,7 +185,7 @@ namespace client SAMBridge& m_Owner; Socket_t m_Socket; - boost::asio::deadline_timer m_Timer; + boost::asio::steady_timer m_Timer; char m_Buffer[SAM_SOCKET_BUFFER_SIZE + 1]; size_t m_BufferOffset; // for session only uint8_t m_StreamBuffer[SAM_STREAM_BUFFER_SIZE]; @@ -294,7 +294,7 @@ namespace client void ScheduleSessionCleanupTimer (std::shared_ptr session); void HandleSessionCleanupTimer (const boost::system::error_code& ecode, - std::shared_ptr session, std::shared_ptr timer); + std::shared_ptr session, std::shared_ptr timer); private: diff --git a/libi2pd_client/UDPTunnel.cpp b/libi2pd_client/UDPTunnel.cpp index cf2705fe..75b53697 100644 --- a/libi2pd_client/UDPTunnel.cpp +++ b/libi2pd_client/UDPTunnel.cpp @@ -195,7 +195,7 @@ namespace client if (!m_AckTimerSeqn) { m_AckTimerSeqn = seqn; - m_AckTimer.expires_from_now (boost::posix_time::milliseconds (m_RTT ? 2*m_RTT : I2P_UDP_MAX_UNACKED_DATAGRAM_TIME)); + m_AckTimer.expires_after (std::chrono::milliseconds (m_RTT ? 2*m_RTT : I2P_UDP_MAX_UNACKED_DATAGRAM_TIME)); m_AckTimer.async_wait ([this](const boost::system::error_code& ecode) { if (ecode != boost::asio::error::operation_aborted) diff --git a/libi2pd_client/UDPTunnel.h b/libi2pd_client/UDPTunnel.h index 36524fe5..972c0a06 100644 --- a/libi2pd_client/UDPTunnel.h +++ b/libi2pd_client/UDPTunnel.h @@ -47,7 +47,7 @@ namespace client std::list > m_UnackedDatagrams; // list of sent but not acked repliable datagrams(seqn, timestamp) in ascending order uint64_t m_RTT = 0; // milliseconds - boost::asio::deadline_timer m_AckTimer; + boost::asio::steady_timer m_AckTimer; uint32_t m_AckTimerSeqn = 0; bool m_IsSendingAllowed = true; bool m_IsFirstPacket = true;