Skip to content

Commit

Permalink
fixed memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Dec 1, 2014
1 parent bd13406 commit 9539fb8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions HTTPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,17 @@ namespace util

void HTTPConnection::Terminate ()
{
if (!m_Stream || !m_Stream->IsOpen ()) return;
if (m_Stream)
if (!m_Stream) return;
m_Socket->close ();
if (m_Stream->IsOpen ())
m_Stream->Close ();

m_Socket->close ();
m_Socket->get_io_service ().post ([=](void)
{
i2p::stream::DeleteStream (m_Stream);
//delete this;
m_Stream.reset ();
m_Stream = nullptr;
// delete this
});
}

Expand Down Expand Up @@ -604,7 +606,10 @@ namespace util
void HTTPConnection::HandleWriteReply (const boost::system::error_code& ecode)
{
if (ecode != boost::asio::error::operation_aborted)
{
m_Socket->close ();
Terminate ();
}
}

void HTTPConnection::HandleWrite (const boost::system::error_code& ecode)
Expand Down

0 comments on commit 9539fb8

Please sign in to comment.