diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-08-23 16:59:31 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-08-23 16:59:31 -0700 |
commit | 0a9c3b557181a77f059d4b2957f6a02f7cc5bde5 (patch) | |
tree | 96f4d14407cae4697fac270c9aa70522c17d6c9a | |
parent | 180049a27725523e18004769d145ba88a68c799b (diff) | |
download | infinitytier-0a9c3b557181a77f059d4b2957f6a02f7cc5bde5.tar.gz infinitytier-0a9c3b557181a77f059d4b2957f6a02f7cc5bde5.zip |
Fix possible deadlock.
-rw-r--r-- | node/Switch.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp index 388ed672..62c3f450 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -613,6 +613,7 @@ unsigned long Switch::doTimerTasks(void *tPtr,uint64_t now) return (unsigned long)(ZT_WHOIS_RETRY_DELAY - timeSinceLastCheck); _lastCheckedQueues = now; + std::vector<Address> needWhois; { Mutex::Lock _l(_txQueue_m); for(std::list< TXQueueEntry >::iterator txi(_txQueue.begin());txi!=_txQueue.end();) { @@ -621,14 +622,15 @@ unsigned long Switch::doTimerTasks(void *tPtr,uint64_t now) } else if ((now - txi->creationTime) > ZT_TRANSMIT_QUEUE_TIMEOUT) { RR->t->txTimedOut(tPtr,txi->dest); _txQueue.erase(txi++); - } else if (!RR->topology->getPeer(tPtr,txi->dest)) { - requestWhois(tPtr,now,txi->dest); - ++txi; } else { + if (!RR->topology->getPeer(tPtr,txi->dest)) + needWhois.push_back(txi->dest); ++txi; } } } + for(std::vector<Address>::const_iterator i(needWhois.begin());i!=needWhois.end();++i) + requestWhois(tPtr,now,*i); for(unsigned int ptr=0;ptr<ZT_RX_QUEUE_SIZE;++ptr) { RXQueueEntry *const rq = &(_rxQueue[ptr]); |