mirror of
				https://github.com/RetroShare/RetroShare.git
				synced 2025-10-30 14:19:14 -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; }  | ||||
| 
 | ||||
| 		// 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; | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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<BitDhtCallback *>::iterator it; | ||||
|         for(it = mCallbacks.begin(); it != mCallbacks.end(); it++) | ||||
|         { | ||||
|                 (*it)->dhtPeerCallback(id, status); | ||||
|                 (*it)->dhtValueCallback(id, key, status); | ||||
|         } | ||||
|         return; | ||||
| } | ||||
|  |  | |||
|  | @ -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(); | ||||
|  |  | |||
|  | @ -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<bdPeer>::iterator lit; | ||||
| 		for(lit = it->entries.begin(); lit != it->entries.end(); lit++) | ||||
| 		{ | ||||
|  |  | |||
|  | @ -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); } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 drbob
						drbob