Browse Source

delete stream from inside

pull/113/head
orignal 10 years ago
parent
commit
4e54fbec08
  1. 10
      Destination.cpp
  2. 2
      HTTPServer.cpp
  3. 1
      I2PTunnel.cpp
  4. 1
      SAM.cpp
  5. 11
      Streaming.cpp
  6. 2
      Streaming.h
  7. 3
      api/api.cpp

10
Destination.cpp

@ -65,10 +65,20 @@ namespace client @@ -65,10 +65,20 @@ namespace client
}
void ClientDestination::Run ()
{
while (m_IsRunning)
{
try
{
if (m_Service)
m_Service->run ();
}
catch (std::exception& ex)
{
LogPrint ("Destination: ", ex.what ());
}
}
}
void ClientDestination::Start ()
{

2
HTTPServer.cpp

@ -516,12 +516,10 @@ namespace util @@ -516,12 +516,10 @@ namespace util
{
if (!m_Stream) return;
m_Socket->close ();
if (m_Stream->IsOpen ())
m_Stream->Close ();
m_Socket->get_io_service ().post ([=](void)
{
i2p::stream::DeleteStream (m_Stream);
m_Stream.reset ();
m_Stream = nullptr;
// delete this

1
I2PTunnel.cpp

@ -46,7 +46,6 @@ namespace client @@ -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

@ -32,7 +32,6 @@ namespace client @@ -32,7 +32,6 @@ namespace client
if (m_Stream)
{
m_Stream->Close ();
i2p::stream::DeleteStream (m_Stream);
m_Stream.reset ();
}
}

11
Streaming.cpp

@ -207,6 +207,7 @@ namespace stream @@ -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 @@ -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 @@ -715,11 +718,5 @@ namespace stream
delete uncompressed;
}
}
void DeleteStream (std::shared_ptr<Stream> stream)
{
if (stream)
stream->GetLocalDestination ().DeleteStream (stream);
}
}
}

2
Streaming.h

@ -190,8 +190,6 @@ namespace 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>

3
api/api.cpp

@ -99,10 +99,7 @@ namespace api @@ -99,10 +99,7 @@ namespace api
void DestroyStream (std::shared_ptr<i2p::stream::Stream> stream)
{
if (stream)
{
stream->Close ();
i2p::stream::DeleteStream (stream);
}
}
}
}

Loading…
Cancel
Save