Browse Source

don't send termination again if termination received block received

pull/1825/head
orignal 2 years ago
parent
commit
8ad5696e50
  1. 3
      libi2pd/SSU2.cpp
  2. 15
      libi2pd/SSU2Session.cpp
  3. 1
      libi2pd/SSU2Session.h

3
libi2pd/SSU2.cpp

@ -496,9 +496,10 @@ namespace transport
break; break;
case eSSU2SessionStateClosing: case eSSU2SessionStateClosing:
m_LastSession->ProcessData (buf, len, senderEndpoint); // we might receive termintaion block m_LastSession->ProcessData (buf, len, senderEndpoint); // we might receive termintaion block
if (m_LastSession && m_LastSession->GetState () != eSSU2SessionStateTerminated) if (m_LastSession && m_LastSession->GetState () == eSSU2SessionStateClosing)
m_LastSession->RequestTermination (eSSU2TerminationReasonIdleTimeout); // send termination again m_LastSession->RequestTermination (eSSU2TerminationReasonIdleTimeout); // send termination again
break; break;
case eSSU2SessionStateClosingConfirmed:
case eSSU2SessionStateTerminated: case eSSU2SessionStateTerminated:
m_LastSession = nullptr; m_LastSession = nullptr;
break; break;

15
libi2pd/SSU2Session.cpp

@ -1462,12 +1462,19 @@ namespace transport
m_IsDataReceived = true; m_IsDataReceived = true;
break; break;
case eSSU2BlkTermination: case eSSU2BlkTermination:
LogPrint (eLogDebug, "SSU2: Termination reason=", (int)buf[11]); {
if (IsEstablished () && buf[11] != eSSU2TerminationReasonTerminationReceived) uint8_t rsn = buf[11]; // reason
LogPrint (eLogDebug, "SSU2: Termination reason=", (int)rsn);
if (IsEstablished () && rsn != eSSU2TerminationReasonTerminationReceived)
RequestTermination (eSSU2TerminationReasonTerminationReceived); RequestTermination (eSSU2TerminationReasonTerminationReceived);
else else if (m_State != eSSU2SessionStateTerminated)
{
if (m_State == eSSU2SessionStateClosing && rsn == eSSU2TerminationReasonTerminationReceived)
m_State = eSSU2SessionStateClosingConfirmed;
Done (); Done ();
break; }
break;
}
case eSSU2BlkRelayRequest: case eSSU2BlkRelayRequest:
LogPrint (eLogDebug, "SSU2: RelayRequest"); LogPrint (eLogDebug, "SSU2: RelayRequest");
HandleRelayRequest (buf + offset, size); HandleRelayRequest (buf + offset, size);

1
libi2pd/SSU2Session.h

@ -100,6 +100,7 @@ namespace transport
eSSU2SessionStateSessionConfirmedSent, eSSU2SessionStateSessionConfirmedSent,
eSSU2SessionStateEstablished, eSSU2SessionStateEstablished,
eSSU2SessionStateClosing, eSSU2SessionStateClosing,
eSSU2SessionStateClosingConfirmed,
eSSU2SessionStateTerminated, eSSU2SessionStateTerminated,
eSSU2SessionStateFailed, eSSU2SessionStateFailed,
eSSU2SessionStateIntroduced, eSSU2SessionStateIntroduced,

Loading…
Cancel
Save