From b10eddc85e60052ad104da5987eca85b4ae4fc9d Mon Sep 17 00:00:00 2001 From: subtly Date: Wed, 3 Dec 2014 20:12:25 +0100 Subject: [PATCH] static to member in Host::run() --- libp2p/Host.cpp | 9 ++++----- libp2p/Host.h | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index 546d54c00..7d08910aa 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -700,8 +700,7 @@ PeerInfos Host::peers(bool _updatePing) const void Host::run(boost::system::error_code const& error) { - static unsigned s_lastTick = 0; - s_lastTick += c_timerInterval; + m_lastTick += c_timerInterval; if (error || !m_ioService) { @@ -713,11 +712,11 @@ void Host::run(boost::system::error_code const& error) // network running if (m_run) { - if (s_lastTick >= c_timerInterval * 10) + if (m_lastTick >= c_timerInterval * 10) { growPeers(); prunePeers(); - s_lastTick = 0; + m_lastTick = 0; } if (m_hadNewNodes) @@ -783,7 +782,7 @@ void Host::run(boost::system::error_code const& error) m_socket->close(); // m_run is false, so we're stopping; kill timer - s_lastTick = 0; + m_lastTick = 0; // causes parent thread's stop() to continue which calls stopWorking() m_timer.reset(); diff --git a/libp2p/Host.h b/libp2p/Host.h index 9ee2c1b4a..644afeb69 100644 --- a/libp2p/Host.h +++ b/libp2p/Host.h @@ -241,6 +241,7 @@ private: std::unique_ptr m_timer; ///< Timer which, when network is running, calls scheduler() every c_timerInterval ms. static const unsigned c_timerInterval = 100; ///< Interval which m_timer is run when network is connected. + unsigned m_lastTick = 0; ///< Used by run() for scheduling; must not be mutated outside of run(). std::set m_pendingNodeConns; /// Used only by connect(Node&) to limit concurrently connecting to same node. See connect(shared_ptrconst&). Mutex x_pendingNodeConns;