Browse Source

delete stream from inside

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

14
Destination.cpp

@ -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 ()

4
HTTPServer.cpp

@ -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

1
I2PTunnel.cpp

@ -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

@ -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 ();
} }
} }

11
Streaming.cpp

@ -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);
}
} }
} }

2
Streaming.h

@ -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>

3
api/api.cpp

@ -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…
Cancel
Save