Browse Source

send outstanding data on close

pull/163/head
orignal 10 years ago
parent
commit
c0043e5098
  1. 13
      Streaming.cpp

13
Streaming.cpp

@ -201,9 +201,9 @@ namespace stream
if (flags & PACKET_FLAG_CLOSE) if (flags & PACKET_FLAG_CLOSE)
{ {
LogPrint (eLogInfo, "Closed"); LogPrint (eLogInfo, "Closed");
Close ();
m_IsOpen = false; m_IsOpen = false;
m_IsReset = true; m_IsReset = true;
Close ();
} }
} }
@ -261,6 +261,8 @@ namespace stream
m_ResendTimer.cancel (); m_ResendTimer.cancel ();
if (acknowledged) if (acknowledged)
SendBuffer (); SendBuffer ();
if (!m_IsOpen)
Close (); // all outgoing messages have been sent
} }
size_t Stream::Send (const uint8_t * buf, size_t len) size_t Stream::Send (const uint8_t * buf, size_t len)
@ -463,9 +465,16 @@ namespace stream
m_Service.post (std::bind (&Stream::SendPacket, shared_from_this (), p)); m_Service.post (std::bind (&Stream::SendPacket, shared_from_this (), p));
LogPrint ("FIN sent"); LogPrint ("FIN sent");
} }
if (m_IsReset || (m_SentPackets.empty () && m_SendBuffer.eof ()))
{
// no more outgoing data or closed by peer
m_ReceiveTimer.cancel (); m_ReceiveTimer.cancel ();
m_LocalDestination.DeleteStream (shared_from_this ()); m_LocalDestination.DeleteStream (shared_from_this ());
} }
else
LogPrint (eLogInfo, "Trying to send stream data before closing");
}
size_t Stream::ConcatenatePackets (uint8_t * buf, size_t len) size_t Stream::ConcatenatePackets (uint8_t * buf, size_t len)
{ {
@ -584,7 +593,7 @@ namespace stream
LogPrint (eLogWarning, "Packet ", it->GetSeqn (), " was not ACKed after ", MAX_NUM_RESEND_ATTEMPTS, " attempts. Terminate"); LogPrint (eLogWarning, "Packet ", it->GetSeqn (), " was not ACKed after ", MAX_NUM_RESEND_ATTEMPTS, " attempts. Terminate");
m_IsOpen = false; m_IsOpen = false;
m_IsReset = true; m_IsReset = true;
m_ReceiveTimer.cancel (); Close ();
return; return;
} }
} }

Loading…
Cancel
Save