mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-21 16:49:10 +01:00
shut down socket and don't allocate buffer for each write in WriteI2PData
This commit is contained in:
parent
b7a67b4b03
commit
60463fdafa
1 changed files with 13 additions and 8 deletions
|
@ -25,8 +25,7 @@ namespace client
|
||||||
|
|
||||||
SAMSocket::~SAMSocket ()
|
SAMSocket::~SAMSocket ()
|
||||||
{
|
{
|
||||||
m_Stream.reset ();
|
m_Stream.reset ();
|
||||||
if (m_Socket.is_open()) m_Socket.close ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMSocket::Terminate (const char* reason)
|
void SAMSocket::Terminate (const char* reason)
|
||||||
|
@ -59,7 +58,11 @@ namespace client
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
m_SocketType = eSAMSocketTypeTerminated;
|
m_SocketType = eSAMSocketTypeTerminated;
|
||||||
if (m_Socket.is_open()) m_Socket.close ();
|
if (m_Socket.is_open ())
|
||||||
|
{
|
||||||
|
m_Socket.shutdown ();
|
||||||
|
m_Socket.close ();
|
||||||
|
}
|
||||||
m_Owner.RemoveSocket(this);
|
m_Owner.RemoveSocket(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,9 +745,11 @@ namespace client
|
||||||
|
|
||||||
void SAMSocket::WriteI2PData(size_t sz)
|
void SAMSocket::WriteI2PData(size_t sz)
|
||||||
{
|
{
|
||||||
uint8_t * sendbuff = new uint8_t[sz];
|
boost::asio::async_write (
|
||||||
memcpy(sendbuff, m_StreamBuffer, sz);
|
m_Socket,
|
||||||
WriteI2PDataImmediate(sendbuff, sz);
|
boost::asio::buffer (m_StreamBuffer, sz),
|
||||||
|
boost::asio::transfer_all(),
|
||||||
|
std::bind(&SAMSocket::HandleWriteI2PData, shared_from_this(), std::placeholders::_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMSocket::HandleI2PReceive (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
void SAMSocket::HandleI2PReceive (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
||||||
|
@ -778,7 +783,8 @@ namespace client
|
||||||
{
|
{
|
||||||
WriteI2PData(bytes_transferred);
|
WriteI2PData(bytes_transferred);
|
||||||
}
|
}
|
||||||
I2PReceive();
|
else
|
||||||
|
I2PReceive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -897,7 +903,6 @@ namespace client
|
||||||
|
|
||||||
SAMSession::~SAMSession ()
|
SAMSession::~SAMSession ()
|
||||||
{
|
{
|
||||||
CloseStreams();
|
|
||||||
i2p::client::context.DeleteLocalDestination (localDestination);
|
i2p::client::context.DeleteLocalDestination (localDestination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue