Browse Source

post I2NP messages to NTCP2 thread

pull/1221/head
orignal 6 years ago
parent
commit
5bedfc1c84
  1. 9
      libi2pd/NTCP2.cpp
  2. 1
      libi2pd/NTCP2.h

9
libi2pd/NTCP2.cpp

@ -748,9 +748,16 @@ namespace transport
void NTCP2Session::SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs) void NTCP2Session::SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs)
{ {
m_Server.GetService ().post (std::bind (&NTCP2Session::PostI2NPMessages, shared_from_this (), msgs));
}
void NTCP2Session::PostI2NPMessages (std::vector<std::shared_ptr<I2NPMessage> > msgs)
{
if (m_IsTerminated) return;
for (auto it: msgs) for (auto it: msgs)
m_SendQueue.push_back (it); m_SendQueue.push_back (it);
if (!m_IsSending) SendQueue (); if (!m_IsSending)
SendQueue ();
} }
NTCP2Server::NTCP2Server (): NTCP2Server::NTCP2Server ():

1
libi2pd/NTCP2.h

@ -109,6 +109,7 @@ namespace transport
void SendNextFrame (const uint8_t * payload, size_t len); void SendNextFrame (const uint8_t * payload, size_t len);
void HandleNextFrameSent (const boost::system::error_code& ecode, std::size_t bytes_transferred); void HandleNextFrameSent (const boost::system::error_code& ecode, std::size_t bytes_transferred);
void SendQueue (); void SendQueue ();
void PostI2NPMessages (std::vector<std::shared_ptr<I2NPMessage> > msgs);
private: private:

Loading…
Cancel
Save