mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-07-11 15:46:35 -07:00
Deadlock fix...
This commit is contained in:
parent
3857116724
commit
a75a7547b4
2 changed files with 15 additions and 11 deletions
|
@ -73,23 +73,27 @@ bool SimNetSocketManager::send(const InetAddress &to,bool tcp,bool autoConnectTc
|
|||
|
||||
void SimNetSocketManager::poll(unsigned long timeout,void (*handler)(const SharedPtr<Socket> &,void *,const InetAddress &,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> &),void *arg)
|
||||
{
|
||||
std::vector< std::pair< InetAddress,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> > > inb;
|
||||
|
||||
{
|
||||
Mutex::Lock _l(_inbox_m);
|
||||
while (!_inbox.empty()) {
|
||||
handler(_mySocket,arg,_inbox.front().first,_inbox.front().second);
|
||||
_inbox.pop();
|
||||
}
|
||||
inb = _inbox;
|
||||
_inbox.clear();
|
||||
}
|
||||
for(std::vector< std::pair< InetAddress,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> > >::iterator i(inb.begin());i!=inb.end();++i)
|
||||
handler(_mySocket,arg,i->first,i->second);
|
||||
|
||||
if (timeout)
|
||||
_waitCond.wait(timeout);
|
||||
else _waitCond.wait();
|
||||
|
||||
{
|
||||
Mutex::Lock _l(_inbox_m);
|
||||
while (!_inbox.empty()) {
|
||||
handler(_mySocket,arg,_inbox.front().first,_inbox.front().second);
|
||||
_inbox.pop();
|
||||
}
|
||||
inb = _inbox;
|
||||
_inbox.clear();
|
||||
}
|
||||
for(std::vector< std::pair< InetAddress,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> > >::iterator i(inb.begin());i!=inb.end();++i)
|
||||
handler(_mySocket,arg,i->first,i->second);
|
||||
}
|
||||
|
||||
void SimNetSocketManager::whack()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue