|
|
|
@ -359,6 +359,8 @@ namespace stream
@@ -359,6 +359,8 @@ namespace stream
|
|
|
|
|
m_SentPackets.insert (it); |
|
|
|
|
} |
|
|
|
|
SendPackets (packets); |
|
|
|
|
if (!m_IsOpen && m_SendBuffer.eof ()) |
|
|
|
|
SendClose (); |
|
|
|
|
if (isEmpty) |
|
|
|
|
ScheduleResend (); |
|
|
|
|
} |
|
|
|
@ -438,6 +440,22 @@ namespace stream
@@ -438,6 +440,22 @@ namespace stream
|
|
|
|
|
if (m_IsOpen) |
|
|
|
|
{ |
|
|
|
|
m_IsOpen = false; |
|
|
|
|
if (m_SendBuffer.eof ()) // nothing to send
|
|
|
|
|
SendClose (); |
|
|
|
|
} |
|
|
|
|
if (m_IsReset || m_SentPackets.empty ()) |
|
|
|
|
{ |
|
|
|
|
// closed by peer or everything has been acknowledged
|
|
|
|
|
m_ReceiveTimer.cancel (); |
|
|
|
|
m_LocalDestination.DeleteStream (shared_from_this ()); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
LogPrint (eLogInfo, "Trying to send stream data before closing"); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Stream::SendClose () |
|
|
|
|
{ |
|
|
|
|
Packet * p = new Packet (); |
|
|
|
|
uint8_t * packet = p->GetBuffer (); |
|
|
|
|
size_t size = 0; |
|
|
|
@ -466,16 +484,6 @@ namespace stream
@@ -466,16 +484,6 @@ namespace stream
|
|
|
|
|
m_Service.post (std::bind (&Stream::SendPacket, shared_from_this (), p)); |
|
|
|
|
LogPrint ("FIN sent"); |
|
|
|
|
} |
|
|
|
|
if (m_IsReset || (m_SentPackets.empty () && m_SendBuffer.eof ())) |
|
|
|
|
{ |
|
|
|
|
// no more outgoing data or closed by peer
|
|
|
|
|
m_ReceiveTimer.cancel (); |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
|