mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-22 00:59:08 +01:00
clean up unconfirmed tags faster
This commit is contained in:
parent
66dafca61a
commit
1da5be2871
2 changed files with 27 additions and 18 deletions
40
Garlic.cpp
40
Garlic.cpp
|
@ -38,9 +38,6 @@ namespace garlic
|
||||||
|
|
||||||
GarlicRoutingSession::~GarlicRoutingSession ()
|
GarlicRoutingSession::~GarlicRoutingSession ()
|
||||||
{
|
{
|
||||||
for (auto it: m_UnconfirmedTagsMsgs)
|
|
||||||
delete it.second;
|
|
||||||
m_UnconfirmedTagsMsgs.clear ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<GarlicRoutingPath> GarlicRoutingSession::GetSharedRoutingPath ()
|
std::shared_ptr<GarlicRoutingPath> GarlicRoutingSession::GetSharedRoutingPath ()
|
||||||
|
@ -94,18 +91,27 @@ namespace garlic
|
||||||
|
|
||||||
void GarlicRoutingSession::TagsConfirmed (uint32_t msgID)
|
void GarlicRoutingSession::TagsConfirmed (uint32_t msgID)
|
||||||
{
|
{
|
||||||
auto it = m_UnconfirmedTagsMsgs.find (msgID);
|
uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||||
if (it != m_UnconfirmedTagsMsgs.end ())
|
for (auto it = m_UnconfirmedTagsMsgs.begin (); it != m_UnconfirmedTagsMsgs.end ();)
|
||||||
{
|
{
|
||||||
uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
|
auto& tags = *it;
|
||||||
UnconfirmedTags * tags = it->second;
|
if (tags->msgID == msgID)
|
||||||
if (ts < tags->tagsCreationTime + OUTGOING_TAGS_EXPIRATION_TIMEOUT)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < tags->numTags; i++)
|
if (ts < tags->tagsCreationTime + OUTGOING_TAGS_EXPIRATION_TIMEOUT)
|
||||||
m_SessionTags.push_back (tags->sessionTags[i]);
|
{
|
||||||
|
for (int i = 0; i < tags->numTags; i++)
|
||||||
|
m_SessionTags.push_back (tags->sessionTags[i]);
|
||||||
|
}
|
||||||
|
it = m_UnconfirmedTagsMsgs.erase (it);
|
||||||
}
|
}
|
||||||
m_UnconfirmedTagsMsgs.erase (it);
|
else if (ts >= tags->tagsCreationTime + OUTGOING_TAGS_CONFIRMATION_TIMEOUT)
|
||||||
delete tags;
|
{
|
||||||
|
if (m_Owner)
|
||||||
|
m_Owner->RemoveDeliveryStatusSession (tags->msgID);
|
||||||
|
it = m_UnconfirmedTagsMsgs.erase (it);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,11 +128,10 @@ namespace garlic
|
||||||
// delete expired unconfirmed tags
|
// delete expired unconfirmed tags
|
||||||
for (auto it = m_UnconfirmedTagsMsgs.begin (); it != m_UnconfirmedTagsMsgs.end ();)
|
for (auto it = m_UnconfirmedTagsMsgs.begin (); it != m_UnconfirmedTagsMsgs.end ();)
|
||||||
{
|
{
|
||||||
if (ts >= it->second->tagsCreationTime + OUTGOING_TAGS_CONFIRMATION_TIMEOUT)
|
if (ts >= (*it)->tagsCreationTime + OUTGOING_TAGS_CONFIRMATION_TIMEOUT)
|
||||||
{
|
{
|
||||||
if (m_Owner)
|
if (m_Owner)
|
||||||
m_Owner->RemoveDeliveryStatusSession (it->first);
|
m_Owner->RemoveDeliveryStatusSession ((*it)->msgID);
|
||||||
delete it->second;
|
|
||||||
it = m_UnconfirmedTagsMsgs.erase (it);
|
it = m_UnconfirmedTagsMsgs.erase (it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -258,7 +263,10 @@ namespace garlic
|
||||||
size += cloveSize;
|
size += cloveSize;
|
||||||
(*numCloves)++;
|
(*numCloves)++;
|
||||||
if (newTags) // new tags created
|
if (newTags) // new tags created
|
||||||
m_UnconfirmedTagsMsgs[msgID] = newTags;
|
{
|
||||||
|
newTags->msgID = msgID;
|
||||||
|
m_UnconfirmedTagsMsgs.emplace_back (newTags);
|
||||||
|
}
|
||||||
m_Owner->DeliveryStatusSent (shared_from_this (), msgID);
|
m_Owner->DeliveryStatusSent (shared_from_this (), msgID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
3
Garlic.h
3
Garlic.h
|
@ -83,6 +83,7 @@ namespace garlic
|
||||||
{
|
{
|
||||||
UnconfirmedTags (int n): numTags (n), tagsCreationTime (0) { sessionTags = new SessionTag[numTags]; };
|
UnconfirmedTags (int n): numTags (n), tagsCreationTime (0) { sessionTags = new SessionTag[numTags]; };
|
||||||
~UnconfirmedTags () { delete[] sessionTags; };
|
~UnconfirmedTags () { delete[] sessionTags; };
|
||||||
|
uint32_t msgID;
|
||||||
int numTags;
|
int numTags;
|
||||||
SessionTag * sessionTags;
|
SessionTag * sessionTags;
|
||||||
uint32_t tagsCreationTime;
|
uint32_t tagsCreationTime;
|
||||||
|
@ -123,7 +124,7 @@ namespace garlic
|
||||||
i2p::crypto::AESKey m_SessionKey;
|
i2p::crypto::AESKey m_SessionKey;
|
||||||
std::list<SessionTag> m_SessionTags;
|
std::list<SessionTag> m_SessionTags;
|
||||||
int m_NumTags;
|
int m_NumTags;
|
||||||
std::map<uint32_t, UnconfirmedTags *> m_UnconfirmedTagsMsgs;
|
std::list<std::unique_ptr<UnconfirmedTags> > m_UnconfirmedTagsMsgs;
|
||||||
|
|
||||||
LeaseSetUpdateStatus m_LeaseSetUpdateStatus;
|
LeaseSetUpdateStatus m_LeaseSetUpdateStatus;
|
||||||
uint32_t m_LeaseSetUpdateMsgID;
|
uint32_t m_LeaseSetUpdateMsgID;
|
||||||
|
|
Loading…
Add table
Reference in a new issue