mirror of
				https://github.com/PurpleI2P/i2pd.git
				synced 2025-11-04 00:20:46 +00:00 
			
		
		
		
	skip failed and expiring tunnels for peer tests
This commit is contained in:
		
							parent
							
								
									d8be5b8ce1
								
							
						
					
					
						commit
						def404b61a
					
				
					 1 changed files with 6 additions and 18 deletions
				
			
		| 
						 | 
				
			
			@ -364,6 +364,7 @@ namespace tunnel
 | 
			
		|||
		{
 | 
			
		||||
			std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
 | 
			
		||||
			for (auto& it: m_OutboundTunnels)
 | 
			
		||||
				if (it->IsEstablished () || it->GetState () == eTunnelStateTestFailed)
 | 
			
		||||
					outboundTunnels.push_back (it);
 | 
			
		||||
		}
 | 
			
		||||
		std::shuffle (outboundTunnels.begin(), outboundTunnels.end(), m_Rng);
 | 
			
		||||
| 
						 | 
				
			
			@ -371,30 +372,17 @@ namespace tunnel
 | 
			
		|||
		{
 | 
			
		||||
			std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
 | 
			
		||||
			for (auto& it: m_InboundTunnels)
 | 
			
		||||
				if (it->IsEstablished () || it->GetState () == eTunnelStateTestFailed)
 | 
			
		||||
					inboundTunnels.push_back (it);
 | 
			
		||||
		}
 | 
			
		||||
		std::shuffle (inboundTunnels.begin(), inboundTunnels.end(), m_Rng);
 | 
			
		||||
		auto it1 = outboundTunnels.begin ();
 | 
			
		||||
		auto it2 = inboundTunnels.begin ();
 | 
			
		||||
		while (it1 != outboundTunnels.end () && it2 != inboundTunnels.end ())
 | 
			
		||||
		{
 | 
			
		||||
			bool failed = false;
 | 
			
		||||
			if ((*it1)->IsFailed ())
 | 
			
		||||
			{
 | 
			
		||||
				failed = true;
 | 
			
		||||
				++it1;
 | 
			
		||||
			}
 | 
			
		||||
			if ((*it2)->IsFailed ())
 | 
			
		||||
			{
 | 
			
		||||
				failed = true;
 | 
			
		||||
				++it2;
 | 
			
		||||
			}
 | 
			
		||||
			if (!failed)
 | 
			
		||||
		{
 | 
			
		||||
			newTests.push_back(std::make_pair (*it1, *it2));
 | 
			
		||||
			++it1; ++it2;
 | 
			
		||||
		}
 | 
			
		||||
		}
 | 
			
		||||
		for (auto& it: newTests)
 | 
			
		||||
		{
 | 
			
		||||
			uint32_t msgID;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue