Skip to content

Commit

Permalink
make sure we are done with session before remving it
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Sep 25, 2024
1 parent 0912de5 commit 262a803
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions libi2pd/SSU2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ namespace transport
}
}

void SSU2Server::RequestRemoveSession (uint64_t connID)
{
GetService ().post ([connID, this]() { RemoveSession (connID); });
}

void SSU2Server::AddSessionByRouterHash (std::shared_ptr<SSU2Session> session)
{
if (session)
Expand Down
1 change: 1 addition & 0 deletions libi2pd/SSU2.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ namespace transport

void AddSession (std::shared_ptr<SSU2Session> session);
void RemoveSession (uint64_t connID);
void RequestRemoveSession (uint64_t connID);
void AddSessionByRouterHash (std::shared_ptr<SSU2Session> session);
bool AddPendingOutgoingSession (std::shared_ptr<SSU2Session> session);
void RemovePendingOutgoingSession (const boost::asio::ip::udp::endpoint& ep);
Expand Down
6 changes: 3 additions & 3 deletions libi2pd/SSU2Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ namespace transport
// connect
m_State = eSSU2SessionStateTokenReceived;
m_Server.AddPendingOutgoingSession (shared_from_this ());
m_Server.RemoveSession (oldConnID);
m_Server.RequestRemoveSession (oldConnID);
Connect ();
}
}
Expand Down Expand Up @@ -3140,15 +3140,15 @@ namespace transport
SendPeerTest (7, buf + offset, len - offset);
else
LogPrint (eLogWarning, "SSU2: Unknown address for peer test 6");
GetServer ().RemoveSession (GetConnID ());
GetServer ().RequestRemoveSession (GetConnID ());
break;
}
case 7: // Alice from Charlie 2
{
auto addr = GetAddress ();
if (addr && addr->IsV6 ())
i2p::context.SetStatusV6 (eRouterStatusOK); // set status OK for ipv6 even if from SSU2
GetServer ().RemoveSession (GetConnID ());
GetServer ().RequestRemoveSession (GetConnID ());
break;
}
default:
Expand Down

0 comments on commit 262a803

Please sign in to comment.