diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2016-04-06 16:28:40 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2016-04-06 16:28:40 -0700 |
| commit | 56096be8b6e3f67e3bdce25bee73d0fc0534b0d5 (patch) | |
| tree | 05288b7bab2ebb52b3df2811fd4c39acb62fc236 /node/Switch.hpp | |
| parent | 8ef78e7e7db53c190071034cc4c8e1bbbe70c619 (diff) | |
| download | infinitytier-56096be8b6e3f67e3bdce25bee73d0fc0534b0d5.tar.gz infinitytier-56096be8b6e3f67e3bdce25bee73d0fc0534b0d5.zip | |
Tweak new RX queue algorithm to "expire" old entries to prevent always needing to traverse the whole queue array.
Diffstat (limited to 'node/Switch.hpp')
| -rw-r--r-- | node/Switch.hpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/node/Switch.hpp b/node/Switch.hpp index 219bfb41..ce4f00a1 100644 --- a/node/Switch.hpp +++ b/node/Switch.hpp @@ -184,7 +184,7 @@ private: /* Returns the matching or oldest entry. Caller must check timestamp and * packet ID to determine which. */ - inline RXQueueEntry *_findRXQueueEntry(uint64_t packetId) + inline RXQueueEntry *_findRXQueueEntry(uint64_t now,uint64_t packetId) { RXQueueEntry *rq; RXQueueEntry *oldest = &(_rxQueue[ZT_RX_QUEUE_SIZE - 1]); @@ -193,6 +193,8 @@ private: rq = &(_rxQueue[--i]); if ((rq->packetId == packetId)&&(rq->timestamp)) return rq; + if ((now - rq->timestamp) >= ZT_RX_QUEUE_EXPIRE) + rq->timestamp = 0; if (rq->timestamp < oldest->timestamp) oldest = rq; } |
