From 6e076e77d82ef78d407fab66b235fe936c02d13a Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 29 Jan 2014 22:04:23 -0800 Subject: [PATCH] More work on connection reset stuff... --- node/Node.cpp | 1 + node/Switch.cpp | 4 ++-- node/Topology.hpp | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/node/Node.cpp b/node/Node.cpp index 106c508d2..323e8b210 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -641,6 +641,7 @@ Node::ReasonForTermination Node::run() } } } catch ( ... ) { + LOG("FATAL: unexpected exception in core loop: unknown exception"); return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"unexpected exception during outer main I/O loop"); } diff --git a/node/Switch.cpp b/node/Switch.cpp index 77a056c24..9ec15411e 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -67,10 +67,10 @@ Switch::~Switch() void Switch::onRemotePacket(Demarc::Port localPort,const InetAddress &fromAddr,const Buffer<4096> &data) { try { - if (data.size() > ZT_PROTO_MIN_FRAGMENT_LENGTH) { + if (data.size() >= ZT_PROTO_MIN_FRAGMENT_LENGTH) { if (data[ZT_PACKET_FRAGMENT_IDX_FRAGMENT_INDICATOR] == ZT_PACKET_FRAGMENT_INDICATOR) _handleRemotePacketFragment(localPort,fromAddr,data); - else if (data.size() > ZT_PROTO_MIN_PACKET_LENGTH) + else if (data.size() >= ZT_PROTO_MIN_PACKET_LENGTH) _handleRemotePacketHead(localPort,fromAddr,data); } } catch (std::exception &ex) { diff --git a/node/Topology.hpp b/node/Topology.hpp index 4ebc72934..505cf10e8 100644 --- a/node/Topology.hpp +++ b/node/Topology.hpp @@ -43,6 +43,7 @@ #include "InetAddress.hpp" #include "Utils.hpp" #include "Packet.hpp" +#include "Logger.hpp" namespace ZeroTier { @@ -250,16 +251,18 @@ public: public: ResetActivePeers(const RuntimeEnvironment *renv,uint64_t now) throw() : _now(now), - _supernode(_r->topology->getBestSupernode()), - _supernodeAddresses(_r->topology->supernodeAddresses()), + _supernode(renv->topology->getBestSupernode()), + _supernodeAddresses(renv->topology->supernodeAddresses()), _r(renv) {} inline void operator()(Topology &t,const SharedPtr &p) { if (_supernodeAddresses.count(p->address())) return; // skip supernodes + TRACE(">> %s",p->address().toString().c_str()); p->forgetDirectPaths(false); // false means don't forget 'fixed' paths e.g. supernodes if (((_now - p->lastFrame()) < ZT_PEER_LINK_ACTIVITY_TIMEOUT)&&(_supernode)) { + TRACE("sending NOP to %s",p->address().toString().c_str()); Packet outp(p->address(),_r->identity.address(),Packet::VERB_NOP); outp.armor(p->key(),false); // no need to encrypt a NOP _supernode->send(_r,outp.data(),outp.size(),_now);