Browse Source

More deadlock fixes in new I/O.

Adam Ierymenko 11 years ago
parent
commit
7a45ff460d
2 changed files with 18 additions and 2 deletions
  1. 16 2
      node/PacketDecoder.cpp
  2. 2 0
      node/SocketManager.cpp

+ 16 - 2
node/PacketDecoder.cpp

@@ -41,6 +41,7 @@
 #include "NodeConfig.hpp"
 #include "NodeConfig.hpp"
 #include "Service.hpp"
 #include "Service.hpp"
 #include "SoftwareUpdater.hpp"
 #include "SoftwareUpdater.hpp"
+#include "SHA512.hpp"
 
 
 namespace ZeroTier {
 namespace ZeroTier {
 
 
@@ -50,7 +51,7 @@ bool PacketDecoder::tryDecode(const RuntimeEnvironment *_r)
 		// Unencrypted HELLOs are handled here since they are used to
 		// Unencrypted HELLOs are handled here since they are used to
 		// populate our identity cache in the first place. _doHELLO() is special
 		// populate our identity cache in the first place. _doHELLO() is special
 		// in that it contains its own authentication logic.
 		// in that it contains its own authentication logic.
-		TRACE("<< HELLO from %s(%s) (normal unencrypted HELLO)",source().toString().c_str(),_remoteAddress.toString().c_str());
+		//TRACE("<< HELLO from %s(%s) (normal unencrypted HELLO)",source().toString().c_str(),_remoteAddress.toString().c_str());
 		return _doHELLO(_r);
 		return _doHELLO(_r);
 	}
 	}
 
 
@@ -77,7 +78,7 @@ bool PacketDecoder::tryDecode(const RuntimeEnvironment *_r)
 			return true;
 			return true;
 		}
 		}
 
 
-		TRACE("<< %s from %s(%s)",Packet::verbString(verb()),source().toString().c_str(),_remoteAddress.toString().c_str());
+		//TRACE("<< %s from %s(%s)",Packet::verbString(verb()),source().toString().c_str(),_remoteAddress.toString().c_str());
 
 
 		switch(verb()) {
 		switch(verb()) {
 			case Packet::VERB_NOP:
 			case Packet::VERB_NOP:
@@ -489,6 +490,19 @@ bool PacketDecoder::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Shared
 		const unsigned int signatureLen = at<uint16_t>(ZT_PROTO_VERB_MULTICAST_FRAME_IDX_FRAME + frameLen);
 		const unsigned int signatureLen = at<uint16_t>(ZT_PROTO_VERB_MULTICAST_FRAME_IDX_FRAME + frameLen);
 		const unsigned char *const signature = field(ZT_PROTO_VERB_MULTICAST_FRAME_IDX_FRAME + frameLen + 2,signatureLen);
 		const unsigned char *const signature = field(ZT_PROTO_VERB_MULTICAST_FRAME_IDX_FRAME + frameLen + 2,signatureLen);
 
 
+		/*
+		TRACE("MULTICAST_FRAME %d bytes guid#%.16llx from %s(%s) to %s on network %.16llx",(int)frameLen,(unsigned long long)guid,sourceMac.toString().c_str(),origin.toString().c_str(),dest.toString().c_str(),(unsigned long long)nwid);
+		TRACE("  received from upstream peer: %s(%s)",source().toString().c_str(),_remoteAddress.toString().c_str());
+		TRACE("  restrict prefix: %.8lx / %d",(unsigned long)prefix,(int)prefixBits);
+		TRACE("  ethernet type: %.4x(%s)",etherType,Switch::etherTypeName(etherType));
+		TRACE("  signature length: %d",(int)signatureLen);
+		{
+			unsigned char h[64];
+			SHA512::hash(h,frame,frameLen);
+			TRACE("  frame data SHA-512: %s",Utils::hex(h,64).c_str());
+		}
+		*/
+
 		SharedPtr<Network> network(_r->nc->network(nwid));
 		SharedPtr<Network> network(_r->nc->network(nwid));
 
 
 		/* Grab, verify, and learn certificate of network membership if any -- provided we are
 		/* Grab, verify, and learn certificate of network membership if any -- provided we are

+ 2 - 0
node/SocketManager.cpp

@@ -266,6 +266,7 @@ SocketManager::SocketManager(
 			}
 			}
 
 
 			_udpV6Socket = SharedPtr<Socket>(new UdpSocket(Socket::ZT_SOCKET_TYPE_UDP_V6,s));
 			_udpV6Socket = SharedPtr<Socket>(new UdpSocket(Socket::ZT_SOCKET_TYPE_UDP_V6,s));
+			fcntl(s,F_SETFL,O_NONBLOCK);
 			FD_SET(s,&_readfds);
 			FD_SET(s,&_readfds);
 		}
 		}
 
 
@@ -316,6 +317,7 @@ SocketManager::SocketManager(
 			}
 			}
 
 
 			_udpV4Socket = SharedPtr<Socket>(new UdpSocket(Socket::ZT_SOCKET_TYPE_UDP_V4,s));
 			_udpV4Socket = SharedPtr<Socket>(new UdpSocket(Socket::ZT_SOCKET_TYPE_UDP_V4,s));
+			fcntl(s,F_SETFL,O_NONBLOCK);
 			FD_SET(s,&_readfds);
 			FD_SET(s,&_readfds);
 		}
 		}
 	}
 	}