diff --git a/libretroshare/src/dht/p3bitdht.cc b/libretroshare/src/dht/p3bitdht.cc index f4de8c095..0ce9f854a 100644 --- a/libretroshare/src/dht/p3bitdht.cc +++ b/libretroshare/src/dht/p3bitdht.cc @@ -85,7 +85,7 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm, mRelay = NULL; std::string dhtVersion = "RS51"; // should come from elsewhere! - bdNodeId ownId; + mOwnRsId = id; #ifdef DEBUG_BITDHT std::cerr << "p3BitDht::p3BitDht()" << std::endl; @@ -99,12 +99,12 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm, /* setup ownId */ storeTranslation_locked(id); - lookupNodeId_locked(id, &ownId); + lookupNodeId_locked(id, &mOwnDhtId); #ifdef DEBUG_BITDHT std::cerr << "Own NodeId: "; - bdStdPrintNodeId(std::cerr, &ownId); + bdStdPrintNodeId(std::cerr, &mOwnDhtId); std::cerr << std::endl; #endif @@ -117,7 +117,7 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm, #endif /* create dht */ - mUdpBitDht = new UdpBitDht(udpstack, &ownId, dhtVersion, bootstrapfile, stdfns); + mUdpBitDht = new UdpBitDht(udpstack, &mOwnDhtId, dhtVersion, bootstrapfile, stdfns); udpstack->addReceiver(mUdpBitDht); /* setup callback to here */ diff --git a/libretroshare/src/dht/p3bitdht.h b/libretroshare/src/dht/p3bitdht.h index bebb98298..8542ae157 100644 --- a/libretroshare/src/dht/p3bitdht.h +++ b/libretroshare/src/dht/p3bitdht.h @@ -249,6 +249,9 @@ int calculateNodeId(const std::string pid, bdNodeId *id); RsMutex dhtMtx; + std::string mOwnRsId; + bdNodeId mOwnDhtId; + time_t mMinuteTS; /* translation maps */ diff --git a/libretroshare/src/dht/p3bitdht_peernet.cc b/libretroshare/src/dht/p3bitdht_peernet.cc index 3d04a541d..cf1249f86 100644 --- a/libretroshare/src/dht/p3bitdht_peernet.cc +++ b/libretroshare/src/dht/p3bitdht_peernet.cc @@ -186,6 +186,20 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags) * ideally don't pass to both peers... (XXX do later) */ + { + RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/ + if (id->id == mOwnDhtId) + { +#ifdef DEBUG_BITDHT_COMMON + std::cerr << "p3BitDht::NodeCallback() Skipping own id"; + bdStdPrintId(std::cerr, id); + std::cerr << std::endl; +#endif + return 1; + } + } + + if ((mProxyStunner) && (mProxyStunner->needStunPeers())) { #ifdef DEBUG_BITDHT_COMMON