summaryrefslogtreecommitdiff
path: root/node/Topology.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-07-25 13:24:39 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-07-25 13:24:39 -0400
commit9cf734b74a750b8af0c628809c16be57eef1ff21 (patch)
tree30170edf778919d7097fd007e1a0ff73cdfa9c32 /node/Topology.cpp
parent083ae2d0974394862735bf1ceff6a71f5e4dac64 (diff)
downloadinfinitytier-9cf734b74a750b8af0c628809c16be57eef1ff21.tar.gz
infinitytier-9cf734b74a750b8af0c628809c16be57eef1ff21.zip
Sane-ify Address, get rid of goofy union thingy.
Diffstat (limited to 'node/Topology.cpp')
-rw-r--r--node/Topology.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/node/Topology.cpp b/node/Topology.cpp
index 43c5303e..7d770930 100644
--- a/node/Topology.cpp
+++ b/node/Topology.cpp
@@ -132,9 +132,12 @@ SharedPtr<Peer> Topology::getPeer(const Address &zta)
return ap->second;
}
+ unsigned char ztatmp[ZT_ADDRESS_LENGTH];
+ zta.copyTo(ztatmp);
+
Buffer<ZT_KISSDB_VALUE_SIZE> b(ZT_KISSDB_VALUE_SIZE);
_dbm_m.lock();
- if (!KISSDB_get(&_dbm,zta.data(),b.data())) {
+ if (!KISSDB_get(&_dbm,ztatmp,b.data())) {
_dbm_m.unlock();
SharedPtr<Peer> p(new Peer());
@@ -305,11 +308,13 @@ void Topology::main()
for(std::map< Address,SharedPtr<Peer> >::iterator p(_activePeers.begin());p!=_activePeers.end();++p) {
if (p->second->getAndResetDirty()) {
try {
+ uint64_t atmp[ZT_ADDRESS_LENGTH];
+ p->second->identity().address().copyTo(atmp);
Buffer<ZT_PEER_MAX_SERIALIZED_LENGTH> b;
p->second->serialize(b);
b.zeroUnused();
_dbm_m.lock();
- if (KISSDB_put(&_dbm,p->second->identity().address().data(),b.data())) {
+ if (KISSDB_put(&_dbm,atmp,b.data())) {
TRACE("error writing %s to peer.db",p->second->identity().address().toString().c_str());
}
_dbm_m.unlock();
@@ -334,11 +339,13 @@ void Topology::_reallyAddPeer(const SharedPtr<Peer> &p)
_activePeers[p->identity().address()] = p;
}
try {
+ uint64_t atmp[ZT_ADDRESS_LENGTH];
+ p->address().copyTo(atmp);
Buffer<ZT_PEER_MAX_SERIALIZED_LENGTH> b;
p->serialize(b);
b.zeroUnused();
_dbm_m.lock();
- if (KISSDB_put(&_dbm,p->identity().address().data(),b.data())) {
+ if (KISSDB_put(&_dbm,atmp,b.data())) {
TRACE("error writing %s to peerdb",p->address().toString().c_str());
} else p->getAndResetDirty();
_dbm_m.unlock();