mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
memory poll for RouterProfile
This commit is contained in:
parent
662a59d0fd
commit
c112276eea
@ -175,6 +175,7 @@ namespace data
|
|||||||
if (ts - lastProfilesCleanup >= (uint64_t)(i2p::data::PEER_PROFILE_AUTOCLEAN_TIMEOUT + profilesCleanupVariance) ||
|
if (ts - lastProfilesCleanup >= (uint64_t)(i2p::data::PEER_PROFILE_AUTOCLEAN_TIMEOUT + profilesCleanupVariance) ||
|
||||||
ts + i2p::data::PEER_PROFILE_AUTOCLEAN_TIMEOUT < lastProfilesCleanup)
|
ts + i2p::data::PEER_PROFILE_AUTOCLEAN_TIMEOUT < lastProfilesCleanup)
|
||||||
{
|
{
|
||||||
|
m_RouterProfilesPool.CleanUpMt ();
|
||||||
if (m_PersistProfiles) PersistProfiles ();
|
if (m_PersistProfiles) PersistProfiles ();
|
||||||
DeleteObsoleteProfiles ();
|
DeleteObsoleteProfiles ();
|
||||||
lastProfilesCleanup = ts;
|
lastProfilesCleanup = ts;
|
||||||
|
@ -128,6 +128,7 @@ namespace data
|
|||||||
};
|
};
|
||||||
std::shared_ptr<Lease> NewLease (const Lease& lease) { return m_LeasesPool.AcquireSharedMt (lease); };
|
std::shared_ptr<Lease> NewLease (const Lease& lease) { return m_LeasesPool.AcquireSharedMt (lease); };
|
||||||
std::shared_ptr<IdentityEx> NewIdentity (const uint8_t * buf, size_t len) { return m_IdentitiesPool.AcquireSharedMt (buf, len); };
|
std::shared_ptr<IdentityEx> NewIdentity (const uint8_t * buf, size_t len) { return m_IdentitiesPool.AcquireSharedMt (buf, len); };
|
||||||
|
std::shared_ptr<RouterProfile> NewRouterProfile () { return m_RouterProfilesPool.AcquireSharedMt (); };
|
||||||
|
|
||||||
uint32_t GetPublishReplyToken () const { return m_PublishReplyToken; };
|
uint32_t GetPublishReplyToken () const { return m_PublishReplyToken; };
|
||||||
|
|
||||||
@ -185,6 +186,7 @@ namespace data
|
|||||||
i2p::util::MemoryPoolMt<RouterInfo::Addresses> m_RouterInfoAddressVectorsPool;
|
i2p::util::MemoryPoolMt<RouterInfo::Addresses> m_RouterInfoAddressVectorsPool;
|
||||||
i2p::util::MemoryPoolMt<Lease> m_LeasesPool;
|
i2p::util::MemoryPoolMt<Lease> m_LeasesPool;
|
||||||
i2p::util::MemoryPoolMt<IdentityEx> m_IdentitiesPool;
|
i2p::util::MemoryPoolMt<IdentityEx> m_IdentitiesPool;
|
||||||
|
i2p::util::MemoryPoolMt<RouterProfile> m_RouterProfilesPool;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern NetDb netdb;
|
extern NetDb netdb;
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "FS.h"
|
#include "FS.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Timestamp.h"
|
#include "Timestamp.h"
|
||||||
|
#include "NetDb.hpp"
|
||||||
#include "Profiling.h"
|
#include "Profiling.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
@ -237,7 +238,7 @@ namespace data
|
|||||||
if (it != g_Profiles.end ())
|
if (it != g_Profiles.end ())
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
auto profile = std::make_shared<RouterProfile> ();
|
auto profile = netdb.NewRouterProfile ();
|
||||||
profile->Load (identHash); // if possible
|
profile->Load (identHash); // if possible
|
||||||
std::unique_lock<std::mutex> l(g_ProfilesMutex);
|
std::unique_lock<std::mutex> l(g_ProfilesMutex);
|
||||||
g_Profiles.emplace (identHash, profile);
|
g_Profiles.emplace (identHash, profile);
|
||||||
|
@ -31,7 +31,7 @@ namespace data
|
|||||||
const char PEER_PROFILE_USAGE_CONNECTED[] = "connected";
|
const char PEER_PROFILE_USAGE_CONNECTED[] = "connected";
|
||||||
|
|
||||||
const int PEER_PROFILE_EXPIRATION_TIMEOUT = 36; // in hours (1.5 days)
|
const int PEER_PROFILE_EXPIRATION_TIMEOUT = 36; // in hours (1.5 days)
|
||||||
const int PEER_PROFILE_AUTOCLEAN_TIMEOUT = 6 * 3600; // in seconds (6 hours)
|
const int PEER_PROFILE_AUTOCLEAN_TIMEOUT = 3 * 3600; // in seconds (3 hours)
|
||||||
const int PEER_PROFILE_AUTOCLEAN_VARIANCE = 3600; // in seconds (1 hour)
|
const int PEER_PROFILE_AUTOCLEAN_VARIANCE = 3600; // in seconds (1 hour)
|
||||||
const int PEER_PROFILE_DECLINED_RECENTLY_INTERVAL = 150; // in seconds (2.5 minutes)
|
const int PEER_PROFILE_DECLINED_RECENTLY_INTERVAL = 150; // in seconds (2.5 minutes)
|
||||||
const int PEER_PROFILE_PERSIST_INTERVAL = 3300; // in seconds (55 minutes)
|
const int PEER_PROFILE_PERSIST_INTERVAL = 3300; // in seconds (55 minutes)
|
||||||
@ -43,7 +43,6 @@ namespace data
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
RouterProfile ();
|
RouterProfile ();
|
||||||
RouterProfile& operator= (const RouterProfile& ) = default;
|
|
||||||
|
|
||||||
void Save (const IdentHash& identHash);
|
void Save (const IdentHash& identHash);
|
||||||
void Load (const IdentHash& identHash);
|
void Load (const IdentHash& identHash);
|
||||||
|
Loading…
Reference in New Issue
Block a user