mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-16 00:12:43 +00:00
delete expired unconfirmed tags
This commit is contained in:
parent
667c309b68
commit
2cd8d0c0b7
19
Garlic.cpp
19
Garlic.cpp
@ -51,16 +51,31 @@ namespace garlic
|
|||||||
|
|
||||||
void GarlicRoutingSession::TagsConfirmed (uint32_t msgID)
|
void GarlicRoutingSession::TagsConfirmed (uint32_t msgID)
|
||||||
{
|
{
|
||||||
|
uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||||
auto it = m_UnconfirmedTagsMsgs.find (msgID);
|
auto it = m_UnconfirmedTagsMsgs.find (msgID);
|
||||||
if (it != m_UnconfirmedTagsMsgs.end ())
|
if (it != m_UnconfirmedTagsMsgs.end ())
|
||||||
{
|
{
|
||||||
UnconfirmedTags * tags = it->second;
|
UnconfirmedTags * tags = it->second;
|
||||||
|
if (ts < tags->tagsCreationTime + OUTGOING_TAGS_EXPIRATION_TIMEOUT)
|
||||||
|
{
|
||||||
for (int i = 0; i < tags->numTags; i++)
|
for (int i = 0; i < tags->numTags; i++)
|
||||||
m_SessionTags.push_back (tags->sessionTags[i]);
|
m_SessionTags.push_back (tags->sessionTags[i]);
|
||||||
m_TagsCreationTime = i2p::util::GetSecondsSinceEpoch ();
|
m_TagsCreationTime = ts;
|
||||||
|
}
|
||||||
m_UnconfirmedTagsMsgs.erase (it);
|
m_UnconfirmedTagsMsgs.erase (it);
|
||||||
delete tags;
|
delete tags;
|
||||||
}
|
}
|
||||||
|
// delete expired unconfirmed tags
|
||||||
|
for (auto it = m_UnconfirmedTagsMsgs.begin (); it != m_UnconfirmedTagsMsgs.end ();)
|
||||||
|
{
|
||||||
|
if (ts >= it->second->tagsCreationTime + OUTGOING_TAGS_EXPIRATION_TIMEOUT)
|
||||||
|
{
|
||||||
|
delete it->second;
|
||||||
|
it = m_UnconfirmedTagsMsgs.erase (it);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
it++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
I2NPMessage * GarlicRoutingSession::WrapSingleMessage (I2NPMessage * msg)
|
I2NPMessage * GarlicRoutingSession::WrapSingleMessage (I2NPMessage * msg)
|
||||||
@ -72,7 +87,7 @@ namespace garlic
|
|||||||
// take care about tags
|
// take care about tags
|
||||||
if (m_NumTags > 0)
|
if (m_NumTags > 0)
|
||||||
{
|
{
|
||||||
if (m_TagsCreationTime && i2p::util::GetSecondsSinceEpoch () >= m_TagsCreationTime + TAGS_EXPIRATION_TIMEOUT)
|
if (m_TagsCreationTime && i2p::util::GetSecondsSinceEpoch () >= m_TagsCreationTime + OUTGOING_TAGS_EXPIRATION_TIMEOUT)
|
||||||
{
|
{
|
||||||
// old tags expired create new set
|
// old tags expired create new set
|
||||||
LogPrint ("Garlic tags expired");
|
LogPrint ("Garlic tags expired");
|
||||||
|
3
Garlic.h
3
Garlic.h
@ -37,7 +37,8 @@ namespace garlic
|
|||||||
};
|
};
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
const int TAGS_EXPIRATION_TIMEOUT = 900; // 15 minutes
|
const int INCOMING_TAGS_EXPIRATION_TIMEOUT = 900; // 15 minutes
|
||||||
|
const int OUTGOING_TAGS_EXPIRATION_TIMEOUT = 720; // 12 minutes
|
||||||
|
|
||||||
typedef i2p::data::Tag<32> SessionTag;
|
typedef i2p::data::Tag<32> SessionTag;
|
||||||
class GarlicDestination;
|
class GarlicDestination;
|
||||||
|
Loading…
Reference in New Issue
Block a user