From d6a1868d0a9b1d65417b87a20a4e234903d290f1 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 18 Mar 2016 14:16:07 -0700 Subject: Refactor incoming packet (rxQueue/fragmentQueue) to eliminate variable length queues and merge queues. This is both faster and saves memory. --- node/DeferredPackets.hpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'node/DeferredPackets.hpp') diff --git a/node/DeferredPackets.hpp b/node/DeferredPackets.hpp index 5ba26531..a9855396 100644 --- a/node/DeferredPackets.hpp +++ b/node/DeferredPackets.hpp @@ -19,6 +19,8 @@ #ifndef ZT_DEFERREDPACKETS_HPP #define ZT_DEFERREDPACKETS_HPP +#include + #include "Constants.hpp" #include "SharedPtr.hpp" #include "Mutex.hpp" @@ -28,7 +30,7 @@ /** * Maximum number of deferred packets */ -#define ZT_DEFFEREDPACKETS_MAX 1024 +#define ZT_DEFFEREDPACKETS_MAX 256 namespace ZeroTier { @@ -53,11 +55,6 @@ public: /** * Enqueue a packet * - * Since packets enqueue themselves, they call it with 'this' and we wrap - * them in a SharedPtr<>. This is safe as SharedPtr<> is introspective and - * supports this. This should not be called from any other code outside - * IncomingPacket. - * * @param pkt Packet to process later (possibly in the background) * @return False if queue is full */ @@ -75,10 +72,8 @@ public: int process(); private: - SharedPtr _q[ZT_DEFFEREDPACKETS_MAX]; + std::list _q; const RuntimeEnvironment *const RR; - unsigned long _readPtr; - unsigned long _writePtr; volatile int _waiting; volatile bool _die; Mutex _q_m; -- cgit v1.2.3