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