This commit is contained in:
orignal 2017-01-19 09:58:55 -05:00
parent 280407a553
commit a25ce2296a
2 changed files with 8 additions and 10 deletions

16
SSU.cpp
View File

@ -187,14 +187,14 @@ namespace transport
void SSUServer::Receive ()
{
SSUPacket * packet = m_Packets.AcquireMt ();
SSUPacket * packet = new SSUPacket ();
m_Socket.async_receive_from (boost::asio::buffer (packet->buf, SSU_MTU_V4), packet->from,
std::bind (&SSUServer::HandleReceivedFrom, this, std::placeholders::_1, std::placeholders::_2, packet));
}
void SSUServer::ReceiveV6 ()
{
SSUPacket * packet = m_Packets.AcquireMt ();
SSUPacket * packet = new SSUPacket ();
m_SocketV6.async_receive_from (boost::asio::buffer (packet->buf, SSU_MTU_V6), packet->from,
std::bind (&SSUServer::HandleReceivedFromV6, this, std::placeholders::_1, std::placeholders::_2, packet));
}
@ -213,7 +213,7 @@ namespace transport
{
while (moreBytes && packets.size () < 25)
{
packet = m_Packets.AcquireMt ();
packet = new SSUPacket ();
packet->len = m_Socket.receive_from (boost::asio::buffer (packet->buf, SSU_MTU_V4), packet->from, 0, ec);
if (!ec)
{
@ -224,7 +224,7 @@ namespace transport
else
{
LogPrint (eLogError, "SSU: receive_from error: ", ec.message ());
m_Packets.ReleaseMt (packet);
delete packet;
break;
}
}
@ -260,7 +260,7 @@ namespace transport
{
while (moreBytes && packets.size () < 25)
{
packet = m_Packets.AcquireMt ();
packet = new SSUPacket ();
packet->len = m_SocketV6.receive_from (boost::asio::buffer (packet->buf, SSU_MTU_V6), packet->from, 0, ec);
if (!ec)
{
@ -271,7 +271,7 @@ namespace transport
else
{
LogPrint (eLogError, "SSU: v6 receive_from error: ", ec.message ());
m_Packets.ReleaseMt (packet);
delete packet;
break;
}
}
@ -282,7 +282,7 @@ namespace transport
}
else
{
m_Packets.ReleaseMt (packet);
delete packet;
if (ecode != boost::asio::error::operation_aborted)
{
LogPrint (eLogError, "SSU: v6 receive error: ", ecode.message ());
@ -323,8 +323,8 @@ namespace transport
if (session) session->FlushData ();
session = nullptr;
}
delete packet;
}
m_Packets.ReleaseMt (packets);
if (session) session->FlushData ();
}

2
SSU.h
View File

@ -15,7 +15,6 @@
#include "RouterInfo.h"
#include "I2NPProtocol.h"
#include "SSUSession.h"
#include "util.h" // for MemoryPool
namespace i2p
{
@ -123,7 +122,6 @@ namespace transport
std::map<boost::asio::ip::udp::endpoint, std::shared_ptr<SSUSession> > m_Sessions, m_SessionsV6;
std::map<uint32_t, std::shared_ptr<SSUSession> > m_Relays; // we are introducer
std::map<uint32_t, PeerTest> m_PeerTests; // nonce -> creation time in milliseconds
i2p::util::MemoryPoolMt<SSUPacket> m_Packets;
public:
// for HTTP only