mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 13:07:55 +00:00
Add some debug code in TRACE mode to catch a bug.
This commit is contained in:
parent
377ccff600
commit
d8dbbf7484
@ -120,10 +120,12 @@ Topology::~Topology()
|
|||||||
|
|
||||||
SharedPtr<Peer> Topology::addPeer(const SharedPtr<Peer> &peer)
|
SharedPtr<Peer> Topology::addPeer(const SharedPtr<Peer> &peer)
|
||||||
{
|
{
|
||||||
if (peer->address() == RR->identity.address()) {
|
#ifdef ZT_TRACE
|
||||||
TRACE("BUG: addPeer() caught and ignored attempt to add peer for self");
|
if ((!peer)||(peer->address() == RR->identity.address())) {
|
||||||
throw std::logic_error("cannot add peer for self");
|
TRACE("BUG: addPeer() caught and ignored attempt to add peer for self or add a NULL peer");
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SharedPtr<Peer> np;
|
SharedPtr<Peer> np;
|
||||||
{
|
{
|
||||||
@ -133,6 +135,7 @@ SharedPtr<Peer> Topology::addPeer(const SharedPtr<Peer> &peer)
|
|||||||
hp = peer;
|
hp = peer;
|
||||||
np = hp;
|
np = hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
np->use(RR->node->now());
|
np->use(RR->node->now());
|
||||||
saveIdentity(np->identity());
|
saveIdentity(np->identity());
|
||||||
|
|
||||||
@ -321,8 +324,7 @@ unsigned long Topology::countActive() const
|
|||||||
Address *a = (Address *)0;
|
Address *a = (Address *)0;
|
||||||
SharedPtr<Peer> *p = (SharedPtr<Peer> *)0;
|
SharedPtr<Peer> *p = (SharedPtr<Peer> *)0;
|
||||||
while (i.next(a,p)) {
|
while (i.next(a,p)) {
|
||||||
if ((*p)->hasActiveDirectPath(now))
|
cnt += (unsigned long)((*p)->hasActiveDirectPath(now));
|
||||||
++cnt;
|
|
||||||
}
|
}
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
@ -234,8 +234,15 @@ public:
|
|||||||
Hashtable< Address,SharedPtr<Peer> >::Iterator i(_peers);
|
Hashtable< Address,SharedPtr<Peer> >::Iterator i(_peers);
|
||||||
Address *a = (Address *)0;
|
Address *a = (Address *)0;
|
||||||
SharedPtr<Peer> *p = (SharedPtr<Peer> *)0;
|
SharedPtr<Peer> *p = (SharedPtr<Peer> *)0;
|
||||||
while (i.next(a,p))
|
while (i.next(a,p)) {
|
||||||
f(*this,*p);
|
#ifdef ZT_TRACE
|
||||||
|
if (!(*p)) {
|
||||||
|
ZT_TRACE("eachPeer() caught NULL peer for %s",a->toString().c_str());
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
f(*this,*((const SharedPtr<Peer> *)p));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user