Fix possible deadlock.

This commit is contained in:
Adam Ierymenko 2017-08-23 16:59:31 -07:00
parent 180049a277
commit 0a9c3b5571

View File

@ -613,6 +613,7 @@ unsigned long Switch::doTimerTasks(void *tPtr,uint64_t now)
return (unsigned long)(ZT_WHOIS_RETRY_DELAY - timeSinceLastCheck); return (unsigned long)(ZT_WHOIS_RETRY_DELAY - timeSinceLastCheck);
_lastCheckedQueues = now; _lastCheckedQueues = now;
std::vector<Address> needWhois;
{ {
Mutex::Lock _l(_txQueue_m); Mutex::Lock _l(_txQueue_m);
for(std::list< TXQueueEntry >::iterator txi(_txQueue.begin());txi!=_txQueue.end();) { 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) { } else if ((now - txi->creationTime) > ZT_TRANSMIT_QUEUE_TIMEOUT) {
RR->t->txTimedOut(tPtr,txi->dest); RR->t->txTimedOut(tPtr,txi->dest);
_txQueue.erase(txi++); _txQueue.erase(txi++);
} else if (!RR->topology->getPeer(tPtr,txi->dest)) {
requestWhois(tPtr,now,txi->dest);
++txi;
} else { } else {
if (!RR->topology->getPeer(tPtr,txi->dest))
needWhois.push_back(txi->dest);
++txi; ++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) { for(unsigned int ptr=0;ptr<ZT_RX_QUEUE_SIZE;++ptr) {
RXQueueEntry *const rq = &(_rxQueue[ptr]); RXQueueEntry *const rq = &(_rxQueue[ptr]);