|
|
@ -23,11 +23,7 @@ namespace transport |
|
|
|
SSUData::~SSUData () |
|
|
|
SSUData::~SSUData () |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (auto it: m_IncomleteMessages) |
|
|
|
for (auto it: m_IncomleteMessages) |
|
|
|
if (it.second) |
|
|
|
delete it.second; |
|
|
|
{ |
|
|
|
|
|
|
|
DeleteI2NPMessage (it.second->msg); |
|
|
|
|
|
|
|
delete it.second; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (auto it: m_SentMessages) |
|
|
|
for (auto it: m_SentMessages) |
|
|
|
delete it.second; |
|
|
|
delete it.second; |
|
|
|
} |
|
|
|
} |
|
|
@ -182,7 +178,7 @@ namespace transport |
|
|
|
// try saved fragments
|
|
|
|
// try saved fragments
|
|
|
|
for (auto it1 = incompleteMessage->savedFragments.begin (); it1 != incompleteMessage->savedFragments.end ();) |
|
|
|
for (auto it1 = incompleteMessage->savedFragments.begin (); it1 != incompleteMessage->savedFragments.end ();) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto savedFragment = *it1; |
|
|
|
auto& savedFragment = *it1; |
|
|
|
if (savedFragment->fragmentNum == incompleteMessage->nextFragmentNum) |
|
|
|
if (savedFragment->fragmentNum == incompleteMessage->nextFragmentNum) |
|
|
|
{ |
|
|
|
{ |
|
|
|
memcpy (msg->buf + msg->len, savedFragment->buf, savedFragment->len); |
|
|
|
memcpy (msg->buf + msg->len, savedFragment->buf, savedFragment->len); |
|
|
@ -190,7 +186,6 @@ namespace transport |
|
|
|
isLast = savedFragment->isLast; |
|
|
|
isLast = savedFragment->isLast; |
|
|
|
incompleteMessage->nextFragmentNum++; |
|
|
|
incompleteMessage->nextFragmentNum++; |
|
|
|
incompleteMessage->savedFragments.erase (it1++); |
|
|
|
incompleteMessage->savedFragments.erase (it1++); |
|
|
|
delete savedFragment; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
break; |
|
|
|
break; |
|
|
@ -209,11 +204,8 @@ namespace transport |
|
|
|
// missing fragment
|
|
|
|
// missing fragment
|
|
|
|
LogPrint (eLogWarning, "Missing fragments from ", (int)incompleteMessage->nextFragmentNum, " to ", fragmentNum - 1, " of message ", msgID); |
|
|
|
LogPrint (eLogWarning, "Missing fragments from ", (int)incompleteMessage->nextFragmentNum, " to ", fragmentNum - 1, " of message ", msgID); |
|
|
|
auto savedFragment = new Fragment (fragmentNum, buf, fragmentSize, isLast); |
|
|
|
auto savedFragment = new Fragment (fragmentNum, buf, fragmentSize, isLast); |
|
|
|
if (!incompleteMessage->savedFragments.insert (savedFragment).second) |
|
|
|
if (!incompleteMessage->savedFragments.insert (std::unique_ptr<Fragment>(savedFragment)).second) |
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint (eLogWarning, "Fragment ", (int)fragmentNum, " of message ", msgID, " already saved"); |
|
|
|
LogPrint (eLogWarning, "Fragment ", (int)fragmentNum, " of message ", msgID, " already saved"); |
|
|
|
delete savedFragment; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
isLast = false; |
|
|
|
isLast = false; |
|
|
|
} |
|
|
|
} |
|
|
@ -221,6 +213,7 @@ namespace transport |
|
|
|
if (isLast) |
|
|
|
if (isLast) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// delete incomplete message
|
|
|
|
// delete incomplete message
|
|
|
|
|
|
|
|
incompleteMessage->msg = nullptr; |
|
|
|
delete incompleteMessage; |
|
|
|
delete incompleteMessage; |
|
|
|
m_IncomleteMessages.erase (msgID); |
|
|
|
m_IncomleteMessages.erase (msgID); |
|
|
|
// process message
|
|
|
|
// process message
|
|
|
|