Deferred decode for HELLO to prevent HELLOcalypse under high load of new peers.

This commit is contained in:
Adam Ierymenko 2015-11-05 12:22:58 -08:00
parent a95ff21aaf
commit 8ef4edebbf
12 changed files with 463 additions and 73 deletions

View file

@ -32,6 +32,7 @@
#include "Constants.hpp"
#include "Identity.hpp"
#include "Mutex.hpp"
namespace ZeroTier {
@ -44,6 +45,7 @@ class AntiRecursion;
class NetworkController;
class SelfAwareness;
class Cluster;
class DeferredPackets;
/**
* Holds global state for an instance of ZeroTier::Node
@ -55,6 +57,7 @@ public:
node(n)
,identity()
,localNetworkController((NetworkController *)0)
,dp((DeferredPackets *)0)
,sw((Switch *)0)
,mc((Multicaster *)0)
,antiRec((AntiRecursion *)0)
@ -77,6 +80,10 @@ public:
// This is set externally to an instance of this base class
NetworkController *localNetworkController;
// This is created if background threads call Node::backgroundThreadMain().
DeferredPackets *volatile dp; // can be read without lock but not written
Mutex dpSetLock;
/*
* Order matters a bit here. These are constructed in this order
* and then deleted in the opposite order on Node exit. The order ensures