Browse Source

connection reset event from stream

pull/102/head
orignal 10 years ago
parent
commit
0e6b7712a9
  1. 9
      Streaming.cpp
  2. 5
      Streaming.h

9
Streaming.cpp

@ -13,7 +13,7 @@ namespace stream @@ -13,7 +13,7 @@ namespace stream
Stream::Stream (boost::asio::io_service& service, StreamingDestination& local,
const i2p::data::LeaseSet& remote): m_Service (service), m_SendStreamID (0),
m_SequenceNumber (0), m_LastReceivedSequenceNumber (-1), m_IsOpen (false),
m_LocalDestination (local), m_RemoteLeaseSet (&remote),
m_IsReset (false), m_LocalDestination (local), m_RemoteLeaseSet (&remote),
m_RoutingSession (nullptr), m_ReceiveTimer (m_Service), m_ResendTimer (m_Service)
{
m_RecvStreamID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 ();
@ -22,7 +22,8 @@ namespace stream @@ -22,7 +22,8 @@ namespace stream
Stream::Stream (boost::asio::io_service& service, StreamingDestination& local):
m_Service (service), m_SendStreamID (0), m_SequenceNumber (0), m_LastReceivedSequenceNumber (-1),
m_IsOpen (false), m_LocalDestination (local), m_RemoteLeaseSet (nullptr), m_RoutingSession (nullptr),
m_IsOpen (false), m_IsReset (false), m_LocalDestination (local),
m_RemoteLeaseSet (nullptr), m_RoutingSession (nullptr),
m_ReceiveTimer (m_Service), m_ResendTimer (m_Service)
{
m_RecvStreamID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 ();
@ -184,6 +185,7 @@ namespace stream @@ -184,6 +185,7 @@ namespace stream
LogPrint ("Closed");
SendQuickAck (); // send ack for close explicitly?
m_IsOpen = false;
m_IsReset = true;
m_ReceiveTimer.cancel ();
m_ResendTimer.cancel ();
}
@ -252,7 +254,7 @@ namespace stream @@ -252,7 +254,7 @@ namespace stream
if (!m_IsOpen)
{
// initial packet
m_IsOpen = true;
m_IsOpen = true; m_IsReset = false;
uint16_t flags = PACKET_FLAG_SYNCHRONIZE | PACKET_FLAG_FROM_INCLUDED |
PACKET_FLAG_SIGNATURE_INCLUDED | PACKET_FLAG_MAX_PACKET_SIZE_INCLUDED;
if (isNoAck) flags |= PACKET_FLAG_NO_ACK;
@ -453,6 +455,7 @@ namespace stream @@ -453,6 +455,7 @@ namespace stream
else
{
Close ();
m_IsReset = true;
m_ReceiveTimer.cancel ();
return;
}

5
Streaming.h

@ -121,7 +121,7 @@ namespace stream @@ -121,7 +121,7 @@ namespace stream
boost::asio::io_service& m_Service;
uint32_t m_SendStreamID, m_RecvStreamID, m_SequenceNumber;
int32_t m_LastReceivedSequenceNumber;
bool m_IsOpen;
bool m_IsOpen, m_IsReset;
StreamingDestination& m_LocalDestination;
i2p::data::IdentityEx m_RemoteIdentity;
const i2p::data::LeaseSet * m_RemoteLeaseSet;
@ -170,7 +170,8 @@ namespace stream @@ -170,7 +170,8 @@ namespace stream
handler (boost::system::error_code (), received);
else
// socket closed
handler (boost::asio::error::make_error_code (boost::asio::error::operation_aborted), 0);
handler (m_IsReset ? boost::asio::error::make_error_code (boost::asio::error::connection_reset) :
boost::asio::error::make_error_code (boost::asio::error::operation_aborted), 0);
}
else
// timeout expired

Loading…
Cancel
Save