From 95e994e17149b7df0e45b8cd570c627504467dc6 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 2 Feb 2022 17:33:33 -0500 Subject: [PATCH] pass incomplete I2NP message by move --- libi2pd/SSUData.cpp | 7 +++---- libi2pd/SSUData.h | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libi2pd/SSUData.cpp b/libi2pd/SSUData.cpp index 3e564373..1b1b9bab 100644 --- a/libi2pd/SSUData.cpp +++ b/libi2pd/SSUData.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2021, The PurpleI2P Project +* Copyright (c) 2013-2022, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -176,11 +176,10 @@ namespace transport if (it == m_IncompleteMessages.end ()) { // create new message - auto msg = (!fragmentNum && fragmentSize > 0 && buf[I2NP_SHORT_HEADER_TYPEID_OFFSET] == eI2NPTunnelData) ? - NewI2NPTunnelMessage (true) : NewI2NPShortMessage (); + auto msg = NewI2NPShortMessage (); msg->len -= I2NP_SHORT_HEADER_SIZE; it = m_IncompleteMessages.insert (std::make_pair (msgID, - m_Session.GetServer ().GetIncompleteMessagesPool ().AcquireShared (msg))).first; + m_Session.GetServer ().GetIncompleteMessagesPool ().AcquireShared (std::move (msg)))).first; } auto& incompleteMessage = it->second; // mark fragment as received diff --git a/libi2pd/SSUData.h b/libi2pd/SSUData.h index 3fbd6d00..2492c89e 100644 --- a/libi2pd/SSUData.h +++ b/libi2pd/SSUData.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2021, The PurpleI2P Project +* Copyright (c) 2013-2022, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -79,7 +79,7 @@ namespace transport uint64_t receivedFragmentsBits; std::set, FragmentCmp> savedFragments; - IncompleteMessage (std::shared_ptr m): msg (m), nextFragmentNum (0), + IncompleteMessage (std::shared_ptr&& m): msg (m), nextFragmentNum (0), lastFragmentInsertTime (0), receivedFragmentsBits (0) {}; void AttachNextFragment (const uint8_t * fragment, size_t fragmentSize); };