mirror of
				https://github.com/PurpleI2P/i2pd.git
				synced 2025-11-04 08:30:46 +00:00 
			
		
		
		
	session closing state
This commit is contained in:
		
							parent
							
								
									ca4414d15a
								
							
						
					
					
						commit
						2f44d99a74
					
				
					 3 changed files with 25 additions and 18 deletions
				
			
		| 
						 | 
				
			
			@ -239,6 +239,8 @@ namespace transport
 | 
			
		|||
			auto ident = it->second->GetRemoteIdentity ();
 | 
			
		||||
			if (ident)
 | 
			
		||||
				m_SessionsByRouterHash.erase (ident->GetIdentHash ());
 | 
			
		||||
			if (m_LastSession == it->second)
 | 
			
		||||
				m_LastSession = nullptr;
 | 
			
		||||
			m_Sessions.erase (it);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -385,6 +387,9 @@ namespace transport
 | 
			
		|||
					m_LastSession->SetRemoteEndpoint (senderEndpoint);
 | 
			
		||||
					m_LastSession->ProcessPeerTest (buf, len);
 | 
			
		||||
				break;
 | 
			
		||||
				case eSSU2SessionStateClosing:
 | 
			
		||||
					m_LastSession->RequestTermination (); // send termination again
 | 
			
		||||
				break;	
 | 
			
		||||
				case eSSU2SessionStateTerminated:
 | 
			
		||||
					m_LastSession = nullptr;
 | 
			
		||||
				break;	
 | 
			
		||||
| 
						 | 
				
			
			@ -617,22 +622,20 @@ namespace transport
 | 
			
		|||
					it++;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			for (auto it = m_Sessions.begin (); it != m_Sessions.end ();)
 | 
			
		||||
			for (auto it: m_Sessions)
 | 
			
		||||
			{
 | 
			
		||||
				if (it->second->GetState () == eSSU2SessionStateTerminated ||
 | 
			
		||||
					it->second->IsTerminationTimeoutExpired (ts))
 | 
			
		||||
				auto state = it.second->GetState ();
 | 
			
		||||
				if (state == eSSU2SessionStateTerminated || state == eSSU2SessionStateClosing)
 | 
			
		||||
					GetService ().post (std::bind (&SSU2Session::Terminate, it.second));
 | 
			
		||||
				else if (it.second->IsTerminationTimeoutExpired (ts))
 | 
			
		||||
				{
 | 
			
		||||
					if (it->second->IsEstablished ())
 | 
			
		||||
						it->second->TerminateByTimeout ();
 | 
			
		||||
					if (it->second == m_LastSession)
 | 
			
		||||
						m_LastSession = nullptr;
 | 
			
		||||
					it = m_Sessions.erase (it);
 | 
			
		||||
					if (it.second->IsEstablished ())
 | 
			
		||||
						it.second->RequestTermination ();
 | 
			
		||||
					else
 | 
			
		||||
						GetService ().post (std::bind (&SSU2Session::Terminate, it.second));
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					it->second->CleanUp (ts);
 | 
			
		||||
					it++;
 | 
			
		||||
				}
 | 
			
		||||
					it.second->CleanUp (ts);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			for (auto it = m_IncomingTokens.begin (); it != m_IncomingTokens.end (); )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -168,10 +168,13 @@ namespace transport
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void SSU2Session::TerminateByTimeout ()
 | 
			
		||||
	void SSU2Session::RequestTermination ()
 | 
			
		||||
	{
 | 
			
		||||
		SendTermination ();
 | 
			
		||||
		m_Server.GetService ().post (std::bind (&SSU2Session::Terminate, shared_from_this ()));
 | 
			
		||||
		if (m_State == eSSU2SessionStateEstablished || m_State == eSSU2SessionStateClosing)
 | 
			
		||||
		{
 | 
			
		||||
			m_State = eSSU2SessionStateClosing;
 | 
			
		||||
			SendTermination ();
 | 
			
		||||
		}	
 | 
			
		||||
	}	
 | 
			
		||||
		
 | 
			
		||||
	void SSU2Session::Established ()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -86,6 +86,7 @@ namespace transport
 | 
			
		|||
		eSSU2SessionStateSessionCreatedSent,
 | 
			
		||||
		eSSU2SessionStateSessionConfirmedSent,
 | 
			
		||||
		eSSU2SessionStateEstablished,
 | 
			
		||||
		eSSU2SessionStateClosing,
 | 
			
		||||
		eSSU2SessionStateTerminated,
 | 
			
		||||
		eSSU2SessionStateFailed,
 | 
			
		||||
		eSSU2SessionStateIntroduced,
 | 
			
		||||
| 
						 | 
				
			
			@ -188,7 +189,7 @@ namespace transport
 | 
			
		|||
			void WaitForIntroduction ();
 | 
			
		||||
			void SendPeerTest (); // Alice, Data message
 | 
			
		||||
			void Terminate ();
 | 
			
		||||
			void TerminateByTimeout ();
 | 
			
		||||
			void RequestTermination ();
 | 
			
		||||
			void CleanUp (uint64_t ts);
 | 
			
		||||
			void FlushData ();
 | 
			
		||||
			void Done () override;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue