mirror of
				https://github.com/RetroShare/RetroShare.git
				synced 2025-10-30 22:29:00 -04:00 
			
		
		
		
	added missing locks
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3841 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
		
							parent
							
								
									b7badd980f
								
							
						
					
					
						commit
						02d228b94b
					
				
					 1 changed files with 16 additions and 2 deletions
				
			
		|  | @ -88,6 +88,7 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, UdpStack *udpstack, std::st | |||
| 	bdStdPrintNodeId(std::cerr, &ownId); | ||||
| 	std::cerr << std::endl; | ||||
| 
 | ||||
| 	RsStackMutex stack(dhtMtx); | ||||
| 
 | ||||
| 	/* standard dht behaviour */ | ||||
| 	bdDhtFunctions *stdfns = new bdStdDht(); | ||||
|  | @ -108,6 +109,7 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, UdpStack *udpstack, std::st | |||
| p3BitDht::~p3BitDht() | ||||
| { | ||||
| 	//udpstack->removeReceiver(mUdpBitDht);
 | ||||
| 	RsStackMutex stack(dhtMtx); | ||||
| 	delete mUdpBitDht; | ||||
| } | ||||
| 
 | ||||
|  | @ -116,6 +118,7 @@ void    p3BitDht::start() | |||
| 	std::cerr << "p3BitDht::start()"; | ||||
| 	std::cerr << std::endl; | ||||
| 
 | ||||
| 	RsStackMutex stack(dhtMtx); | ||||
| 	mUdpBitDht->start(); /* starts up the bitdht thread */ | ||||
| 
 | ||||
| 	/* dht switched on by config later. */ | ||||
|  | @ -129,38 +132,45 @@ void    p3BitDht::enable(bool on) | |||
| 
 | ||||
| 	if (on) | ||||
| 	{ | ||||
| 		RsStackMutex stack(dhtMtx); | ||||
| 		mUdpBitDht->startDht(); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		RsStackMutex stack(dhtMtx); | ||||
| 		mUdpBitDht->stopDht(); | ||||
| 	} | ||||
| } | ||||
| 	 | ||||
| void    p3BitDht::shutdown() /* blocking call */ | ||||
| { | ||||
| 	RsStackMutex stack(dhtMtx); | ||||
| 	mUdpBitDht->stopDht(); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void	p3BitDht::restart() | ||||
| { | ||||
| 	RsStackMutex stack(dhtMtx); | ||||
| 	mUdpBitDht->stopDht(); | ||||
| 	mUdpBitDht->startDht(); | ||||
| } | ||||
| 
 | ||||
| bool    p3BitDht::getEnabled() | ||||
| { | ||||
| 	RsStackMutex stack(dhtMtx); | ||||
| 	return (mUdpBitDht->stateDht() != 0); | ||||
| } | ||||
| 
 | ||||
| bool    p3BitDht::getActive() | ||||
| { | ||||
| 	RsStackMutex stack(dhtMtx); | ||||
| 	return (mUdpBitDht->stateDht() >= BITDHT_MGR_STATE_ACTIVE); | ||||
| } | ||||
| 
 | ||||
| bool    p3BitDht::getNetworkStats(uint32_t &netsize, uint32_t &localnetsize) | ||||
| { | ||||
| 	RsStackMutex stack(dhtMtx); | ||||
| 	netsize = mUdpBitDht->statsNetworkSize(); | ||||
| 	localnetsize = mUdpBitDht->statsBDVersionSize(); | ||||
| 	return true; | ||||
|  | @ -197,6 +207,7 @@ bool 	p3BitDht::findPeer(std::string pid) | |||
| 	bdStdPrintNodeId(std::cerr, &nid); | ||||
| 	std::cerr << std::endl; | ||||
| 
 | ||||
| 	RsStackMutex stack(dhtMtx); | ||||
| 	/* add in peer */ | ||||
| 	mUdpBitDht->addFindNode(&nid, BITDHT_QFLAGS_DO_IDLE); | ||||
| 
 | ||||
|  | @ -223,8 +234,11 @@ bool 	p3BitDht::dropPeer(std::string pid) | |||
| 	bdStdPrintNodeId(std::cerr, &nid); | ||||
| 	std::cerr << std::endl; | ||||
| 
 | ||||
| 	/* remove in peer */ | ||||
| 	mUdpBitDht->removeFindNode(&nid); | ||||
| 	{ | ||||
| 		RsStackMutex stack(dhtMtx); | ||||
| 		/* remove in peer */ | ||||
| 		mUdpBitDht->removeFindNode(&nid); | ||||
| 	} | ||||
| 
 | ||||
| 	/* remove from translation */ | ||||
| 	if (!removeTranslation(pid)) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 csoler
						csoler