Browse Source

terminate session in separate task

pull/1786/head
orignal 2 years ago
parent
commit
4b1f5c9c9b
  1. 8
      libi2pd/SSU2.cpp
  2. 12
      libi2pd/SSU2Session.cpp
  3. 2
      libi2pd/SSU2Session.h

8
libi2pd/SSU2.cpp

@ -403,7 +403,7 @@ namespace transport @@ -403,7 +403,7 @@ namespace transport
case eSSU2SessionStateSessionCreatedSent:
if (!m_LastSession->ProcessSessionConfirmed (buf, len))
{
m_LastSession->Terminate ();
m_LastSession->Done ();
m_LastSession = nullptr;
}
break;
@ -416,7 +416,7 @@ namespace transport @@ -416,7 +416,7 @@ namespace transport
{
LogPrint (eLogWarning, "SSU2: HolePunch endpoint ", senderEndpoint,
" doesn't match RelayResponse ", m_LastSession->GetRemoteEndpoint ());
m_LastSession->Terminate ();
m_LastSession->Done ();
m_LastSession = nullptr;
}
break;
@ -678,13 +678,13 @@ namespace transport @@ -678,13 +678,13 @@ namespace transport
{
auto state = it.second->GetState ();
if (state == eSSU2SessionStateTerminated || state == eSSU2SessionStateClosing)
GetService ().post (std::bind (&SSU2Session::Terminate, it.second));
it.second->Done ();
else if (it.second->IsTerminationTimeoutExpired (ts))
{
if (it.second->IsEstablished ())
it.second->RequestTermination (eSSU2TerminationReasonIdleTimeout);
else
GetService ().post (std::bind (&SSU2Session::Terminate, it.second));
it.second->Done ();
}
else
it.second->CleanUp (ts);

12
libi2pd/SSU2Session.cpp

@ -1338,7 +1338,7 @@ namespace transport @@ -1338,7 +1338,7 @@ namespace transport
if (IsEstablished () && buf[11] != eSSU2TerminationReasonTerminationReceived)
RequestTermination (eSSU2TerminationReasonTerminationReceived);
else
Terminate ();
Done ();
break;
case eSSU2BlkRelayRequest:
LogPrint (eLogDebug, "SSU2: RelayRequest");
@ -1696,13 +1696,13 @@ namespace transport @@ -1696,13 +1696,13 @@ namespace transport
else
{
LogPrint (eLogWarning, "SSU2: RelayResponse signature verification failed");
m_Server.GetService ().post (std::bind (&SSU2Session::Terminate, it->second.first));
it->second.first->Done ();
}
}
else
{
LogPrint (eLogInfo, "SSU2: RelayResponse status code=", (int)buf[1]);
m_Server.GetService ().post (std::bind (&SSU2Session::Terminate, it->second.first));
it->second.first->Done ();
}
}
m_RelaySessions.erase (it);
@ -1898,13 +1898,13 @@ namespace transport @@ -1898,13 +1898,13 @@ namespace transport
else
{
LogPrint (eLogWarning, "SSU2: Peer test 4 address not found");
it->second.first->Terminate ();
it->second.first->Done ();
}
}
else
{
LogPrint (eLogWarning, "SSU2: Peer test 4 signature verification failed");
it->second.first->Terminate ();
it->second.first->Done ();
}
}
}
@ -1914,7 +1914,7 @@ namespace transport @@ -1914,7 +1914,7 @@ namespace transport
i2p::data::GetIdentHashAbbreviation (buf[1] < 64 ? GetRemoteIdentity ()->GetIdentHash () : i2p::data::IdentHash (buf + 3)));
if (GetRouterStatus () == eRouterStatusTesting)
SetRouterStatus (eRouterStatusUnknown);
it->second.first->Terminate ();
it->second.first->Done ();
}
m_PeerTests.erase (it);
}

2
libi2pd/SSU2Session.h

@ -222,7 +222,6 @@ namespace transport @@ -222,7 +222,6 @@ namespace transport
void WaitForIntroduction ();
void SendPeerTest (); // Alice, Data message
void SendKeepAlive ();
void Terminate ();
void RequestTermination (SSU2TerminationReason reason);
void CleanUp (uint64_t ts);
void FlushData ();
@ -246,6 +245,7 @@ namespace transport @@ -246,6 +245,7 @@ namespace transport
private:
void Terminate ();
void Established ();
void ScheduleConnectTimer ();
void HandleConnectTimer (const boost::system::error_code& ecode);

Loading…
Cancel
Save