Browse Source

use deadline_timer for bandwidth calculation timer

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/1827/head
R4SAS 2 years ago
parent
commit
3471e6fe16
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 6
      libi2pd/Transports.cpp
  2. 3
      libi2pd/Transports.h

6
libi2pd/Transports.cpp

@ -168,7 +168,7 @@ namespace transport
m_Work = new boost::asio::io_service::work (*m_Service); m_Work = new boost::asio::io_service::work (*m_Service);
m_PeerCleanupTimer = new boost::asio::deadline_timer (*m_Service); m_PeerCleanupTimer = new boost::asio::deadline_timer (*m_Service);
m_PeerTestTimer = new boost::asio::deadline_timer (*m_Service); m_PeerTestTimer = new boost::asio::deadline_timer (*m_Service);
m_UpdateBandwidthTimer = new boost::asio::steady_timer (*m_Service); m_UpdateBandwidthTimer = new boost::asio::deadline_timer (*m_Service);
} }
bool ipv4; i2p::config::GetOption("ipv4", ipv4); bool ipv4; i2p::config::GetOption("ipv4", ipv4);
@ -306,7 +306,7 @@ namespace transport
m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(5 * SESSION_CREATION_TIMEOUT)); m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(5 * SESSION_CREATION_TIMEOUT));
m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1)); m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1));
m_UpdateBandwidthTimer->expires_from_now (std::chrono::seconds(1)); m_UpdateBandwidthTimer->expires_from_now (boost::posix_time::seconds(1));
m_UpdateBandwidthTimer->async_wait (std::bind (&Transports::HandleUpdateBandwidthTimer, this, std::placeholders::_1)); m_UpdateBandwidthTimer->async_wait (std::bind (&Transports::HandleUpdateBandwidthTimer, this, std::placeholders::_1));
if (m_IsNAT) if (m_IsNAT)
@ -393,7 +393,7 @@ namespace transport
m_LastTransitBandwidth15sUpdateBytes = m_TotalTransitTransmittedBytes; m_LastTransitBandwidth15sUpdateBytes = m_TotalTransitTransmittedBytes;
} }
m_UpdateBandwidthTimer->expires_from_now (std::chrono::seconds(1)); m_UpdateBandwidthTimer->expires_from_now (boost::posix_time::seconds(1));
m_UpdateBandwidthTimer->async_wait (std::bind (&Transports::HandleUpdateBandwidthTimer, this, std::placeholders::_1)); m_UpdateBandwidthTimer->async_wait (std::bind (&Transports::HandleUpdateBandwidthTimer, this, std::placeholders::_1));
} }
} }

3
libi2pd/Transports.h

@ -169,8 +169,7 @@ namespace transport
std::thread * m_Thread; std::thread * m_Thread;
boost::asio::io_service * m_Service; boost::asio::io_service * m_Service;
boost::asio::io_service::work * m_Work; boost::asio::io_service::work * m_Work;
boost::asio::deadline_timer * m_PeerCleanupTimer, * m_PeerTestTimer; boost::asio::deadline_timer * m_PeerCleanupTimer, * m_PeerTestTimer, * m_UpdateBandwidthTimer;
boost::asio::steady_timer * m_UpdateBandwidthTimer;
SSU2Server * m_SSU2Server; SSU2Server * m_SSU2Server;
NTCP2Server * m_NTCP2Server; NTCP2Server * m_NTCP2Server;

Loading…
Cancel
Save