mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-18 11:29:31 -04:00
Tweaked bitdht interface to remove need for double entry to libbitdht.
* made PeerCallback() pass a bdId rather than a bdNodeId. * disabled recursive mutex to test!. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3857 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
85667a2ae9
commit
ea3311eb2a
5 changed files with 26 additions and 23 deletions
|
@ -154,7 +154,7 @@ class BitDhtCallback
|
||||||
virtual int dhtNodeCallback(const bdId * /*id*/, uint32_t /*peerflags*/) { return 0; }
|
virtual int dhtNodeCallback(const bdId * /*id*/, uint32_t /*peerflags*/) { return 0; }
|
||||||
|
|
||||||
// must be implemented.
|
// 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;
|
virtual int dhtValueCallback(const bdNodeId *id, std::string key, uint32_t status) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -607,7 +607,6 @@ int bdNodeManager::checkStatus()
|
||||||
pit->second.mDhtAddr.sin_port = 0;
|
pit->second.mDhtAddr.sin_port = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* add successful queries to ping list */
|
/* add successful queries to ping list */
|
||||||
if (doPing)
|
if (doPing)
|
||||||
|
@ -629,7 +628,9 @@ int bdNodeManager::checkStatus()
|
||||||
mFns->bdPrintNodeId(std::cerr, &(it->first));
|
mFns->bdPrintNodeId(std::cerr, &(it->first));
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
doPeerCallback(&(it->first), callbackStatus);
|
bdId id(it->first,pit->second.mDhtAddr);
|
||||||
|
doPeerCallback(&id, callbackStatus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -862,7 +863,7 @@ void bdNodeManager::doNodeCallback(const bdId *id, uint32_t peerflags)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bdNodeManager::doPeerCallback(const bdNodeId *id, uint32_t status)
|
void bdNodeManager::doPeerCallback(const bdId *id, uint32_t status)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef DEBUG_MGR
|
#ifdef DEBUG_MGR
|
||||||
|
@ -881,7 +882,7 @@ void bdNodeManager::doPeerCallback(const bdNodeId *id, uint32_t status)
|
||||||
return;
|
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 << "bdNodeManager::doValueCallback()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -892,7 +893,7 @@ void bdNodeManager::doValueCallback(const bdNodeId *id, std::string /*key*/, uin
|
||||||
std::list<BitDhtCallback *>::iterator it;
|
std::list<BitDhtCallback *>::iterator it;
|
||||||
for(it = mCallbacks.begin(); it != mCallbacks.end(); it++)
|
for(it = mCallbacks.begin(); it != mCallbacks.end(); it++)
|
||||||
{
|
{
|
||||||
(*it)->dhtPeerCallback(id, status);
|
(*it)->dhtValueCallback(id, key, status);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ int isBitDhtPacket(char *data, int size, struct sockaddr_in &from);
|
||||||
|
|
||||||
|
|
||||||
void doNodeCallback(const bdId *id, uint32_t peerflags);
|
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);
|
void doValueCallback(const bdNodeId *id, std::string key, uint32_t status);
|
||||||
|
|
||||||
int status();
|
int status();
|
||||||
|
|
|
@ -993,10 +993,10 @@ bool bdSpace::findRandomPeerWithFlag(bdId &id, uint32_t withFlag)
|
||||||
if (it != buckets.end())
|
if (it != buckets.end())
|
||||||
{
|
{
|
||||||
it++; /* skip own bucket! */
|
it++; /* skip own bucket! */
|
||||||
|
buck++;
|
||||||
}
|
}
|
||||||
for(; it != buckets.end(); it++, buck++)
|
for(; it != buckets.end(); it++, buck++)
|
||||||
{
|
{
|
||||||
int size = 0;
|
|
||||||
std::list<bdPeer>::iterator lit;
|
std::list<bdPeer>::iterator lit;
|
||||||
for(lit = it->entries.begin(); lit != it->entries.end(); lit++)
|
for(lit = it->entries.begin(); lit != it->entries.end(); lit++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,6 +39,7 @@ class bdMutex
|
||||||
|
|
||||||
bdMutex(bool recursive = false)
|
bdMutex(bool recursive = false)
|
||||||
{
|
{
|
||||||
|
#if 0 // TESTING WITHOUT RECURSIVE
|
||||||
if(recursive)
|
if(recursive)
|
||||||
{
|
{
|
||||||
pthread_mutexattr_t att ;
|
pthread_mutexattr_t att ;
|
||||||
|
@ -51,6 +52,7 @@ class bdMutex
|
||||||
else
|
else
|
||||||
if( pthread_mutex_init(&realMutex, NULL))
|
if( pthread_mutex_init(&realMutex, NULL))
|
||||||
std::cerr << "ERROR: Could not initialize mutex !" << std::endl ;
|
std::cerr << "ERROR: Could not initialize mutex !" << std::endl ;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
~bdMutex() { pthread_mutex_destroy(&realMutex); }
|
~bdMutex() { pthread_mutex_destroy(&realMutex); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue