Skip to content

Commit

Permalink
cleanup messages to send if session was terminated
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Oct 29, 2024
1 parent 361f364 commit f040487
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion libi2pd/NTCP2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,11 @@ namespace transport

void NTCP2Session::SendI2NPMessages (std::list<std::shared_ptr<I2NPMessage> >& msgs)
{
if (m_IsTerminated || msgs.empty ()) return;
if (m_IsTerminated || msgs.empty ())
{
msgs.clear ();
return;
}
bool empty = false;
{
std::lock_guard<std::mutex> l(m_IntermediateQueueMutex);
Expand Down
6 changes: 5 additions & 1 deletion libi2pd/SSU2Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,11 @@ namespace transport

void SSU2Session::SendI2NPMessages (std::list<std::shared_ptr<I2NPMessage> >& msgs)
{
if (m_State == eSSU2SessionStateTerminated || msgs.empty ()) return;
if (m_State == eSSU2SessionStateTerminated || msgs.empty ())
{
msgs.clear ();
return;
}
bool empty = false;
{
std::lock_guard<std::mutex> l(m_IntermediateQueueMutex);
Expand Down

0 comments on commit f040487

Please sign in to comment.