Browse Source

pass I2NPMessage by move

pull/1698/head
orignal 3 years ago
parent
commit
d310efcb5c
  1. 2
      libi2pd/I2NPProtocol.cpp
  2. 2
      libi2pd/I2NPProtocol.h
  3. 5
      libi2pd/NTCP2.cpp
  4. 2
      libi2pd/SSUData.cpp
  5. 2
      libi2pd/Transports.cpp

2
libi2pd/I2NPProtocol.cpp

@ -860,7 +860,7 @@ namespace i2p
Flush (); Flush ();
} }
void I2NPMessagesHandler::PutNextMessage (std::shared_ptr<I2NPMessage> msg) void I2NPMessagesHandler::PutNextMessage (std::shared_ptr<I2NPMessage>&& msg)
{ {
if (msg) if (msg)
{ {

2
libi2pd/I2NPProtocol.h

@ -301,7 +301,7 @@ namespace tunnel
public: public:
~I2NPMessagesHandler (); ~I2NPMessagesHandler ();
void PutNextMessage (std::shared_ptr<I2NPMessage> msg); void PutNextMessage (std::shared_ptr<I2NPMessage>&& msg);
void Flush (); void Flush ();
private: private:

5
libi2pd/NTCP2.cpp

@ -876,11 +876,12 @@ namespace transport
break; break;
} }
auto nextMsg = NewI2NPMessage (size); auto nextMsg = NewI2NPMessage (size);
nextMsg->Align (12); // for possible tunnel msg nextMsg->Align (6); // for possible tunnel msg
nextMsg->offset += TUNNEL_GATEWAY_HEADER_SIZE; // reserve room for TunnelGateway header
nextMsg->len = nextMsg->offset + size + 7; // 7 more bytes for full I2NP header nextMsg->len = nextMsg->offset + size + 7; // 7 more bytes for full I2NP header
memcpy (nextMsg->GetNTCP2Header (), frame + offset, size); memcpy (nextMsg->GetNTCP2Header (), frame + offset, size);
nextMsg->FromNTCP2 (); nextMsg->FromNTCP2 ();
m_Handler.PutNextMessage (nextMsg); m_Handler.PutNextMessage (std::move (nextMsg));
break; break;
} }
case eNTCP2BlkTermination: case eNTCP2BlkTermination:

2
libi2pd/SSUData.cpp

@ -247,7 +247,7 @@ namespace transport
m_ReceivedMessages.emplace (msgID, m_LastMessageReceivedTime); m_ReceivedMessages.emplace (msgID, m_LastMessageReceivedTime);
if (!msg->IsExpired ()) if (!msg->IsExpired ())
{ {
m_Handler.PutNextMessage (msg); m_Handler.PutNextMessage (std::move (msg));
} }
else else
LogPrint (eLogDebug, "SSU: message expired"); LogPrint (eLogDebug, "SSU: message expired");

2
libi2pd/Transports.cpp

@ -389,7 +389,7 @@ namespace transport
{ {
// we send it to ourself // we send it to ourself
for (auto& it: msgs) for (auto& it: msgs)
m_LoopbackHandler.PutNextMessage (it); m_LoopbackHandler.PutNextMessage (std::move (it));
m_LoopbackHandler.Flush (); m_LoopbackHandler.Flush ();
return; return;
} }

Loading…
Cancel
Save