Browse Source

More work on connection reset stuff...

Adam Ierymenko 11 years ago
parent
commit
6e076e77d8
3 changed files with 8 additions and 4 deletions
  1. 1 0
      node/Node.cpp
  2. 2 2
      node/Switch.cpp
  3. 5 2
      node/Topology.hpp

+ 1 - 0
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");
 	}
 

+ 2 - 2
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) {

+ 5 - 2
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<Peer> &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);