|
@@ -60,6 +60,7 @@
|
|
#include <iostream>
|
|
#include <iostream>
|
|
#include <unordered_map>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include <vector>
|
|
|
|
+#include <atomic>
|
|
|
|
|
|
using namespace ZeroTier;
|
|
using namespace ZeroTier;
|
|
|
|
|
|
@@ -72,6 +73,7 @@ struct PeerInfo
|
|
struct AddressHasher { ZT_ALWAYS_INLINE std::size_t operator()(const Address &a) const { return (std::size_t)a.toInt(); } };
|
|
struct AddressHasher { ZT_ALWAYS_INLINE std::size_t operator()(const Address &a) const { return (std::size_t)a.toInt(); } };
|
|
struct InetAddressHasher { ZT_ALWAYS_INLINE std::size_t operator()(const InetAddress &ip) const { return (std::size_t)ip.hashCode(); } };
|
|
struct InetAddressHasher { ZT_ALWAYS_INLINE std::size_t operator()(const InetAddress &ip) const { return (std::size_t)ip.hashCode(); } };
|
|
|
|
|
|
|
|
+static std::atomic_bool run;
|
|
static std::unordered_map< Address,std::map< Identity,PeerInfo >,AddressHasher > peersByVirtAddr;
|
|
static std::unordered_map< Address,std::map< Identity,PeerInfo >,AddressHasher > peersByVirtAddr;
|
|
static std::unordered_map< InetAddress,std::map< Identity,PeerInfo >,InetAddressHasher > peersByPhysAddr;
|
|
static std::unordered_map< InetAddress,std::map< Identity,PeerInfo >,InetAddressHasher > peersByPhysAddr;
|
|
static Mutex peersByVirtAddr_l;
|
|
static Mutex peersByVirtAddr_l;
|
|
@@ -133,6 +135,8 @@ int main(int argc,char **argv)
|
|
unsigned int ncores = std::thread::hardware_concurrency();
|
|
unsigned int ncores = std::thread::hardware_concurrency();
|
|
if (ncores == 0) ncores = 1;
|
|
if (ncores == 0) ncores = 1;
|
|
|
|
|
|
|
|
+ run = true;
|
|
|
|
+
|
|
std::vector<int> sockets;
|
|
std::vector<int> sockets;
|
|
std::vector<std::thread> threads;
|
|
std::vector<std::thread> threads;
|
|
for(unsigned int tn=0;tn<ncores;++tn) {
|
|
for(unsigned int tn=0;tn<ncores;++tn) {
|
|
@@ -198,5 +202,9 @@ int main(int argc,char **argv)
|
|
}));
|
|
}));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ while (run) {
|
|
|
|
+ sleep(1);
|
|
|
|
+ }
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|