mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
delete stream from inside
This commit is contained in:
parent
38ee813e41
commit
4e54fbec08
@ -66,8 +66,18 @@ namespace client
|
||||
|
||||
void ClientDestination::Run ()
|
||||
{
|
||||
if (m_Service)
|
||||
m_Service->run ();
|
||||
while (m_IsRunning)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_Service)
|
||||
m_Service->run ();
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
LogPrint ("Destination: ", ex.what ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClientDestination::Start ()
|
||||
|
@ -516,12 +516,10 @@ namespace util
|
||||
{
|
||||
if (!m_Stream) return;
|
||||
m_Socket->close ();
|
||||
if (m_Stream->IsOpen ())
|
||||
m_Stream->Close ();
|
||||
m_Stream->Close ();
|
||||
|
||||
m_Socket->get_io_service ().post ([=](void)
|
||||
{
|
||||
i2p::stream::DeleteStream (m_Stream);
|
||||
m_Stream.reset ();
|
||||
m_Stream = nullptr;
|
||||
// delete this
|
||||
|
@ -46,7 +46,6 @@ namespace client
|
||||
if (m_Stream)
|
||||
{
|
||||
m_Stream->Close ();
|
||||
i2p::stream::DeleteStream (m_Stream);
|
||||
m_Stream.reset ();
|
||||
}
|
||||
m_Socket->close ();
|
||||
|
1
SAM.cpp
1
SAM.cpp
@ -32,7 +32,6 @@ namespace client
|
||||
if (m_Stream)
|
||||
{
|
||||
m_Stream->Close ();
|
||||
i2p::stream::DeleteStream (m_Stream);
|
||||
m_Stream.reset ();
|
||||
}
|
||||
}
|
||||
|
@ -207,6 +207,7 @@ namespace stream
|
||||
m_IsOpen = false;
|
||||
m_IsReset = true;
|
||||
m_ReceiveTimer.cancel ();
|
||||
m_LocalDestination.DeleteStream (shared_from_this ());
|
||||
}
|
||||
}
|
||||
|
||||
@ -549,9 +550,11 @@ namespace stream
|
||||
packets.push_back (it);
|
||||
else
|
||||
{
|
||||
Close ();
|
||||
LogPrint (eLogWarning, "Packet ", it->GetSeqn (), "was not ACKed after ", MAX_NUM_RESEND_ATTEMPTS, " attempts. Terminate");
|
||||
m_IsOpen = false;
|
||||
m_IsReset = true;
|
||||
m_ReceiveTimer.cancel ();
|
||||
m_LocalDestination.DeleteStream (shared_from_this ());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -715,11 +718,5 @@ namespace stream
|
||||
delete uncompressed;
|
||||
}
|
||||
}
|
||||
|
||||
void DeleteStream (std::shared_ptr<Stream> stream)
|
||||
{
|
||||
if (stream)
|
||||
stream->GetLocalDestination ().DeleteStream (stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -190,8 +190,6 @@ namespace stream
|
||||
const decltype(m_Streams)& GetStreams () const { return m_Streams; };
|
||||
};
|
||||
|
||||
void DeleteStream (std::shared_ptr<Stream> stream);
|
||||
|
||||
//-------------------------------------------------
|
||||
|
||||
template<typename Buffer, typename ReceiveHandler>
|
||||
|
@ -99,10 +99,7 @@ namespace api
|
||||
void DestroyStream (std::shared_ptr<i2p::stream::Stream> stream)
|
||||
{
|
||||
if (stream)
|
||||
{
|
||||
stream->Close ();
|
||||
i2p::stream::DeleteStream (stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user