Browse Source

close stream is SYN has not been received

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

19
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,6 +131,8 @@ 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);
if (m_LastReceivedSequenceNumber >= 0)
{
// send NACKs for missing messages ASAP // send NACKs for missing messages ASAP
if (m_IsAckSendScheduled) if (m_IsAckSendScheduled)
{ {
@ -138,6 +141,15 @@ namespace stream
} }
SendQuickAck (); SendQuickAck ();
} }
else
{
// wait for SYN
m_IsAckSendScheduled = true;
m_AckSendTimer.expires_from_now (boost::posix_time::milliseconds(ACK_SEND_TIMEOUT));
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