Browse Source

fix naming

cl-refactor
subtly 10 years ago
parent
commit
8005012f6c
  1. 18
      libp2p/Host.cpp
  2. 4
      libp2p/Host.h

18
libp2p/Host.cpp

@ -228,7 +228,7 @@ void Host::stop()
{
{
// prevent m_run from being set to false at same time as set to true by start()
Guard l(x_runtimer);
Guard l(x_runTimer);
// once m_run is false the scheduler will shutdown network and stopWorking()
m_run = false;
}
@ -541,7 +541,7 @@ void Host::connect(std::shared_ptr<Node> const& _n)
// prevent concurrently connecting to a node; todo: better abstraction
Node *nptr = _n.get();
{
Guard l(x_pendingNodeConnsMutex);
Guard l(x_pendingNodeConns);
if (m_pendingNodeConns.count(nptr))
return;
m_pendingNodeConns.insert(nptr);
@ -569,7 +569,7 @@ void Host::connect(std::shared_ptr<Node> const& _n)
p->start();
}
delete s;
Guard l(x_pendingNodeConnsMutex);
Guard l(x_pendingNodeConns);
m_pendingNodeConns.erase(nptr);
});
}
@ -700,8 +700,8 @@ PeerInfos Host::peers(bool _updatePing) const
void Host::run(boost::system::error_code const& error)
{
static unsigned s_lasttick = 0;
s_lasttick += c_timerInterval;
static unsigned s_lastTick = 0;
s_lastTick += c_timerInterval;
if (error || !m_ioService)
{
@ -713,11 +713,11 @@ void Host::run(boost::system::error_code const& error)
// network running
if (m_run)
{
if (s_lasttick >= c_timerInterval * 10)
if (s_lastTick >= c_timerInterval * 10)
{
growPeers();
prunePeers();
s_lasttick = 0;
s_lastTick = 0;
}
if (m_hadNewNodes)
@ -783,7 +783,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;
s_lastTick = 0;
// causes parent thread's stop() to continue which calls stopWorking()
m_timer.reset();
@ -806,7 +806,7 @@ void Host::startedWorking()
// prevent m_run from being set to true at same time as set to false by stop()
// don't release mutex until m_timer is set so in case stop() is called at same
// time, stop will wait on m_timer and graceful network shutdown.
Guard l(x_runtimer);
Guard l(x_runTimer);
// reset io service and create deadline timer
m_timer.reset(new boost::asio::deadline_timer(*m_ioService));
m_run = true;

4
libp2p/Host.h

@ -224,7 +224,7 @@ private:
Nodes potentialPeers(RangeMask<unsigned> const& _known);
bool m_run = false; ///< Whether network is running.
std::mutex x_runtimer; ///< Start/stop mutex.
std::mutex x_runTimer; ///< Start/stop mutex.
std::string m_clientVersion; ///< Our version string.
@ -243,7 +243,7 @@ private:
static const unsigned c_timerInterval = 100; ///< Interval which m_timer is run when network is connected.
std::set<Node*> m_pendingNodeConns; /// Used only by connect(Node&) to limit concurrently connecting to same node. See connect(shared_ptr<Node>const&).
std::mutex x_pendingNodeConnsMutex;
Mutex x_pendingNodeConns;
bi::tcp::endpoint m_public; ///< Our public listening endpoint.
KeyPair m_key; ///< Our unique ID.

Loading…
Cancel
Save