mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
don't create same incoming stream twice
This commit is contained in:
parent
d708e7f682
commit
2dcb91b284
|
@ -844,6 +844,7 @@ namespace stream
|
|||
|
||||
StreamingDestination::StreamingDestination (std::shared_ptr<i2p::client::ClientDestination> owner, uint16_t localPort, bool gzip):
|
||||
m_Owner (owner), m_LocalPort (localPort), m_Gzip (gzip),
|
||||
m_LastIncomingReceiveStreamID (0),
|
||||
m_PendingIncomingTimer (m_Owner->GetService ()),
|
||||
m_ConnTrackTimer(m_Owner->GetService()),
|
||||
m_ConnsPerMinute(DEFAULT_MAX_CONNS_PER_MIN),
|
||||
|
@ -899,8 +900,15 @@ namespace stream
|
|||
{
|
||||
if (packet->IsSYN () && !packet->GetSeqn ()) // new incoming stream
|
||||
{
|
||||
auto incomingStream = CreateNewIncomingStream ();
|
||||
uint32_t receiveStreamID = packet->GetReceiveStreamID ();
|
||||
if (receiveStreamID == m_LastIncomingReceiveStreamID)
|
||||
{
|
||||
// already pending
|
||||
LogPrint(eLogWarning, "Streaming: Incoming streaming with rSID=", receiveStreamID, " already exists");
|
||||
delete packet; // drop it, because previous should be connected
|
||||
return;
|
||||
}
|
||||
auto incomingStream = CreateNewIncomingStream ();
|
||||
incomingStream->HandleNextPacket (packet); // SYN
|
||||
auto ident = incomingStream->GetRemoteIdentity();
|
||||
if(ident)
|
||||
|
@ -914,6 +922,8 @@ namespace stream
|
|||
return;
|
||||
}
|
||||
}
|
||||
m_LastIncomingReceiveStreamID = receiveStreamID;
|
||||
|
||||
// handle saved packets if any
|
||||
{
|
||||
auto it = m_SavedPackets.find (receiveStreamID);
|
||||
|
|
|
@ -253,6 +253,7 @@ namespace stream
|
|||
std::mutex m_StreamsMutex;
|
||||
std::map<uint32_t, std::shared_ptr<Stream> > m_Streams; // sendStreamID->stream
|
||||
Acceptor m_Acceptor;
|
||||
uint32_t m_LastIncomingReceiveStreamID;
|
||||
std::list<std::shared_ptr<Stream> > m_PendingIncomingStreams;
|
||||
boost::asio::deadline_timer m_PendingIncomingTimer;
|
||||
std::map<uint32_t, std::list<Packet *> > m_SavedPackets; // receiveStreamID->packets, arrived before SYN
|
||||
|
|
Loading…
Reference in a new issue