diff --git a/libbitdht/src/bitdht/bdiface.h b/libbitdht/src/bitdht/bdiface.h index 58e53657f..6d826ccb8 100644 --- a/libbitdht/src/bitdht/bdiface.h +++ b/libbitdht/src/bitdht/bdiface.h @@ -154,7 +154,7 @@ class BitDhtCallback virtual int dhtNodeCallback(const bdId * /*id*/, uint32_t /*peerflags*/) { return 0; } // must be implemented. -virtual int dhtPeerCallback(const bdNodeId *id, uint32_t status) = 0; +virtual int dhtPeerCallback(const bdId *id, uint32_t status) = 0; virtual int dhtValueCallback(const bdNodeId *id, std::string key, uint32_t status) = 0; }; diff --git a/libbitdht/src/bitdht/bdmanager.cc b/libbitdht/src/bitdht/bdmanager.cc index 8541b5332..f23ce12eb 100644 --- a/libbitdht/src/bitdht/bdmanager.cc +++ b/libbitdht/src/bitdht/bdmanager.cc @@ -607,29 +607,30 @@ int bdNodeManager::checkStatus() pit->second.mDhtAddr.sin_port = 0; } } - } - /* add successful queries to ping list */ - if (doPing) - { + /* add successful queries to ping list */ + if (doPing) + { #ifdef DEBUG_MGR - std::cerr << "bdNodeManager::checkStatus() Starting Ping (TODO): id: "; - mFns->bdPrintNodeId(std::cerr, &(it->first)); - std::cerr << std::endl; + std::cerr << "bdNodeManager::checkStatus() Starting Ping (TODO): id: "; + mFns->bdPrintNodeId(std::cerr, &(it->first)); + std::cerr << std::endl; #endif - /* add first matching peer */ - //addPeerPing(foundId); - } + /* add first matching peer */ + //addPeerPing(foundId); + } - /* callback on new successful queries */ - if (doCallback) - { + /* callback on new successful queries */ + if (doCallback) + { #ifdef DEBUG_MGR - std::cerr << "bdNodeManager::checkStatus() Doing Callback: id: "; - mFns->bdPrintNodeId(std::cerr, &(it->first)); - std::cerr << std::endl; + std::cerr << "bdNodeManager::checkStatus() Doing Callback: id: "; + mFns->bdPrintNodeId(std::cerr, &(it->first)); + std::cerr << std::endl; #endif - doPeerCallback(&(it->first), callbackStatus); + bdId id(it->first,pit->second.mDhtAddr); + doPeerCallback(&id, callbackStatus); + } } } return 1; @@ -862,7 +863,7 @@ void bdNodeManager::doNodeCallback(const bdId *id, uint32_t peerflags) return; } -void bdNodeManager::doPeerCallback(const bdNodeId *id, uint32_t status) +void bdNodeManager::doPeerCallback(const bdId *id, uint32_t status) { #ifdef DEBUG_MGR @@ -881,7 +882,7 @@ void bdNodeManager::doPeerCallback(const bdNodeId *id, uint32_t status) return; } -void bdNodeManager::doValueCallback(const bdNodeId *id, std::string /*key*/, uint32_t status) +void bdNodeManager::doValueCallback(const bdNodeId *id, std::string key, uint32_t status) { std::cerr << "bdNodeManager::doValueCallback()"; std::cerr << std::endl; @@ -892,7 +893,7 @@ void bdNodeManager::doValueCallback(const bdNodeId *id, std::string /*key*/, uin std::list::iterator it; for(it = mCallbacks.begin(); it != mCallbacks.end(); it++) { - (*it)->dhtPeerCallback(id, status); + (*it)->dhtValueCallback(id, key, status); } return; } diff --git a/libbitdht/src/bitdht/bdmanager.h b/libbitdht/src/bitdht/bdmanager.h index 6d73435b2..67d1cc13a 100644 --- a/libbitdht/src/bitdht/bdmanager.h +++ b/libbitdht/src/bitdht/bdmanager.h @@ -131,7 +131,7 @@ int isBitDhtPacket(char *data, int size, struct sockaddr_in &from); void doNodeCallback(const bdId *id, uint32_t peerflags); -void doPeerCallback(const bdNodeId *id, uint32_t status); +void doPeerCallback(const bdId *id, uint32_t status); void doValueCallback(const bdNodeId *id, std::string key, uint32_t status); int status(); diff --git a/libbitdht/src/bitdht/bdpeer.cc b/libbitdht/src/bitdht/bdpeer.cc index 1a586ed86..54c519120 100644 --- a/libbitdht/src/bitdht/bdpeer.cc +++ b/libbitdht/src/bitdht/bdpeer.cc @@ -993,10 +993,10 @@ bool bdSpace::findRandomPeerWithFlag(bdId &id, uint32_t withFlag) if (it != buckets.end()) { it++; /* skip own bucket! */ + buck++; } for(; it != buckets.end(); it++, buck++) { - int size = 0; std::list::iterator lit; for(lit = it->entries.begin(); lit != it->entries.end(); lit++) { diff --git a/libbitdht/src/util/bdthreads.h b/libbitdht/src/util/bdthreads.h index 1ba260e54..dacbd82d5 100644 --- a/libbitdht/src/util/bdthreads.h +++ b/libbitdht/src/util/bdthreads.h @@ -39,6 +39,7 @@ class bdMutex bdMutex(bool recursive = false) { +#if 0 // TESTING WITHOUT RECURSIVE if(recursive) { pthread_mutexattr_t att ; @@ -51,6 +52,7 @@ class bdMutex else if( pthread_mutex_init(&realMutex, NULL)) std::cerr << "ERROR: Could not initialize mutex !" << std::endl ; +#endif } ~bdMutex() { pthread_mutex_destroy(&realMutex); }