mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-24 15:16:40 +00:00
Deadlock fix...
This commit is contained in:
parent
3857116724
commit
a75a7547b4
@ -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)
|
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);
|
Mutex::Lock _l(_inbox_m);
|
||||||
while (!_inbox.empty()) {
|
inb = _inbox;
|
||||||
handler(_mySocket,arg,_inbox.front().first,_inbox.front().second);
|
_inbox.clear();
|
||||||
_inbox.pop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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)
|
if (timeout)
|
||||||
_waitCond.wait(timeout);
|
_waitCond.wait(timeout);
|
||||||
else _waitCond.wait();
|
else _waitCond.wait();
|
||||||
|
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_inbox_m);
|
Mutex::Lock _l(_inbox_m);
|
||||||
while (!_inbox.empty()) {
|
inb = _inbox;
|
||||||
handler(_mySocket,arg,_inbox.front().first,_inbox.front().second);
|
_inbox.clear();
|
||||||
_inbox.pop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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()
|
void SimNetSocketManager::whack()
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <queue>
|
#include <vector>
|
||||||
|
|
||||||
#include "../node/Constants.hpp"
|
#include "../node/Constants.hpp"
|
||||||
#include "../node/SocketManager.hpp"
|
#include "../node/SocketManager.hpp"
|
||||||
@ -98,7 +98,7 @@ public:
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_inbox_m);
|
Mutex::Lock _l(_inbox_m);
|
||||||
_inbox.push(std::pair< InetAddress,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> >(from,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN>(data,len)));
|
_inbox.push_back(std::pair< InetAddress,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> >(from,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN>(data,len)));
|
||||||
}
|
}
|
||||||
_waitCond.signal();
|
_waitCond.signal();
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ private:
|
|||||||
SharedPtr<Socket> _mySocket;
|
SharedPtr<Socket> _mySocket;
|
||||||
TransferStats _totals;
|
TransferStats _totals;
|
||||||
|
|
||||||
std::queue< std::pair< InetAddress,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> > > _inbox;
|
std::vector< std::pair< InetAddress,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> > > _inbox;
|
||||||
Mutex _inbox_m;
|
Mutex _inbox_m;
|
||||||
|
|
||||||
std::map< InetAddress,TransferStats > _stats;
|
std::map< InetAddress,TransferStats > _stats;
|
||||||
|
Loading…
Reference in New Issue
Block a user