diff options
author | Joseph Henry <josephjah@gmail.com> | 2018-06-07 12:58:07 -0700 |
---|---|---|
committer | Joseph Henry <josephjah@gmail.com> | 2018-06-07 12:58:07 -0700 |
commit | a9ca26c6985d10d1c86a33c56b06c1ae679cda0f (patch) | |
tree | e9e4bcea77ce3ea14d81f1432a2567781a0a9904 /node | |
parent | 9463d4abe4757a67ec83b01b97e68aa7742eac20 (diff) | |
download | infinitytier-a9ca26c6985d10d1c86a33c56b06c1ae679cda0f.tar.gz infinitytier-a9ca26c6985d10d1c86a33c56b06c1ae679cda0f.zip |
Added TX queue cap for issue #769
Diffstat (limited to 'node')
-rw-r--r-- | node/Constants.hpp | 8 | ||||
-rw-r--r-- | node/Switch.cpp | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/node/Constants.hpp b/node/Constants.hpp index e2a35dce..03b04e68 100644 --- a/node/Constants.hpp +++ b/node/Constants.hpp @@ -194,6 +194,14 @@ #define ZT_RX_QUEUE_SIZE 64 /** + * Size of TX queue + * + * This is about 2mb, and can be decreased for small devices. A queue smaller + * than about 4 is probably going to cause a lot of lost packets. + */ +#define ZT_TX_QUEUE_SIZE 64 + +/** * Length of secret key in bytes -- 256-bit -- do not change */ #define ZT_PEER_SECRET_KEY_LENGTH 32 diff --git a/node/Switch.cpp b/node/Switch.cpp index eb1ebadb..3fa8c31d 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -503,6 +503,9 @@ void Switch::send(void *tPtr,Packet &packet,bool encrypt) if (!_trySend(tPtr,packet,encrypt)) { { Mutex::Lock _l(_txQueue_m); + if (_txQueue.size() >= ZT_TX_QUEUE_SIZE) { + _txQueue.pop_front(); + } _txQueue.push_back(TXQueueEntry(dest,RR->node->now(),packet,encrypt)); } if (!RR->topology->getPeer(tPtr,dest)) |