Browse Source

close stream is SYN has not been received

pull/167/head
orignal 10 years ago
parent
commit
7f91c9e63e
  1. 31
      Streaming.cpp

31
Streaming.cpp

@ -21,6 +21,7 @@ namespace stream
m_LastWindowSizeIncreaseTime (0), m_NumResendAttempts (0) m_LastWindowSizeIncreaseTime (0), m_NumResendAttempts (0)
{ {
m_RecvStreamID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 (); m_RecvStreamID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 ();
m_RemoteIdentity = remote->GetIdentity ();
UpdateCurrentRemoteLease (); UpdateCurrentRemoteLease ();
} }
@ -130,13 +131,24 @@ namespace stream
LogPrint (eLogWarning, "Missing messages from ", m_LastReceivedSequenceNumber + 1, " to ", receivedSeqn - 1); LogPrint (eLogWarning, "Missing messages from ", m_LastReceivedSequenceNumber + 1, " to ", receivedSeqn - 1);
// save message and wait for missing message again // save message and wait for missing message again
SavePacket (packet); SavePacket (packet);
// send NACKs for missing messages ASAP if (m_LastReceivedSequenceNumber >= 0)
if (m_IsAckSendScheduled) {
// send NACKs for missing messages ASAP
if (m_IsAckSendScheduled)
{
m_IsAckSendScheduled = false;
m_AckSendTimer.cancel ();
}
SendQuickAck ();
}
else
{ {
m_IsAckSendScheduled = false; // wait for SYN
m_AckSendTimer.cancel (); m_IsAckSendScheduled = true;
} m_AckSendTimer.expires_from_now (boost::posix_time::milliseconds(ACK_SEND_TIMEOUT));
SendQuickAck (); m_AckSendTimer.async_wait (std::bind (&Stream::HandleAckSendTimer,
shared_from_this (), std::placeholders::_1));
}
} }
} }
} }
@ -676,6 +688,13 @@ namespace stream
{ {
if (m_IsAckSendScheduled) if (m_IsAckSendScheduled)
{ {
if (m_LastReceivedSequenceNumber < 0)
{
LogPrint (eLogWarning, "SYN has not been recived after ", ACK_SEND_TIMEOUT, " milliseconds after follow on. Terminate");
m_Status = eStreamStatusReset;
Close ();
return;
}
if (m_Status == eStreamStatusOpen) if (m_Status == eStreamStatusOpen)
SendQuickAck (); SendQuickAck ();
m_IsAckSendScheduled = false; m_IsAckSendScheduled = false;

Loading…
Cancel
Save