From 5bedfc1c84a987339d826de7c5e789c5c146ccbb Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 19 Jul 2018 12:46:19 -0400 Subject: [PATCH] post I2NP messages to NTCP2 thread --- libi2pd/NTCP2.cpp | 9 ++++++++- libi2pd/NTCP2.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libi2pd/NTCP2.cpp b/libi2pd/NTCP2.cpp index 61d20ed8..94f0641e 100644 --- a/libi2pd/NTCP2.cpp +++ b/libi2pd/NTCP2.cpp @@ -748,9 +748,16 @@ namespace transport void NTCP2Session::SendI2NPMessages (const std::vector >& msgs) { + m_Server.GetService ().post (std::bind (&NTCP2Session::PostI2NPMessages, shared_from_this (), msgs)); + } + + void NTCP2Session::PostI2NPMessages (std::vector > msgs) + { + if (m_IsTerminated) return; for (auto it: msgs) m_SendQueue.push_back (it); - if (!m_IsSending) SendQueue (); + if (!m_IsSending) + SendQueue (); } NTCP2Server::NTCP2Server (): diff --git a/libi2pd/NTCP2.h b/libi2pd/NTCP2.h index 34d8b943..c14c6876 100644 --- a/libi2pd/NTCP2.h +++ b/libi2pd/NTCP2.h @@ -109,6 +109,7 @@ namespace transport void SendNextFrame (const uint8_t * payload, size_t len); void HandleNextFrameSent (const boost::system::error_code& ecode, std::size_t bytes_transferred); void SendQueue (); + void PostI2NPMessages (std::vector > msgs); private: