diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-10-30 14:11:10 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-10-30 14:11:10 -0700 |
| commit | d8dbbf7484f5df16a3e36b35da31383cc9589081 (patch) | |
| tree | 3271fcaa23dec111e56ef7fd3b6cd2ea3cb16cc7 /node/Topology.cpp | |
| parent | 377ccff600859da2d0e7ecd65a38953bd471d04d (diff) | |
| download | infinitytier-d8dbbf7484f5df16a3e36b35da31383cc9589081.tar.gz infinitytier-d8dbbf7484f5df16a3e36b35da31383cc9589081.zip | |
Add some debug code in TRACE mode to catch a bug.
Diffstat (limited to 'node/Topology.cpp')
| -rw-r--r-- | node/Topology.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/node/Topology.cpp b/node/Topology.cpp index 031c0b1b..5e086116 100644 --- a/node/Topology.cpp +++ b/node/Topology.cpp @@ -120,10 +120,12 @@ Topology::~Topology() SharedPtr<Peer> Topology::addPeer(const SharedPtr<Peer> &peer) { - if (peer->address() == RR->identity.address()) { - TRACE("BUG: addPeer() caught and ignored attempt to add peer for self"); - throw std::logic_error("cannot add peer for self"); +#ifdef ZT_TRACE + if ((!peer)||(peer->address() == RR->identity.address())) { + TRACE("BUG: addPeer() caught and ignored attempt to add peer for self or add a NULL peer"); + abort(); } +#endif SharedPtr<Peer> np; { @@ -133,6 +135,7 @@ SharedPtr<Peer> Topology::addPeer(const SharedPtr<Peer> &peer) hp = peer; np = hp; } + np->use(RR->node->now()); saveIdentity(np->identity()); @@ -321,8 +324,7 @@ unsigned long Topology::countActive() const Address *a = (Address *)0; SharedPtr<Peer> *p = (SharedPtr<Peer> *)0; while (i.next(a,p)) { - if ((*p)->hasActiveDirectPath(now)) - ++cnt; + cnt += (unsigned long)((*p)->hasActiveDirectPath(now)); } return cnt; } |
