Browse Source

change shared local destination upon reload

pull/1076/head
orignal 7 years ago
parent
commit
85fa728d41
  1. 20
      libi2pd_client/ClientContext.cpp
  2. 2
      libi2pd_client/ClientContext.h

20
libi2pd_client/ClientContext.cpp

@ -36,13 +36,7 @@ namespace client @@ -36,13 +36,7 @@ namespace client
void ClientContext::Start ()
{
if (!m_SharedLocalDestination)
{
m_SharedLocalDestination = CreateNewLocalDestination (); // non-public, DSA
m_SharedLocalDestination->Acquire ();
m_Destinations[m_SharedLocalDestination->GetIdentity ()->GetIdentHash ()] = m_SharedLocalDestination;
m_SharedLocalDestination->Start ();
}
CreateNewSharedLocalDestination ();
m_AddressBook.Start ();
@ -267,6 +261,10 @@ namespace client @@ -267,6 +261,10 @@ namespace client
// delete not updated tunnels (not in config anymore)
VisitTunnels ([](I2PService * s)->bool { return s->isUpdated; });
// change shared local destination
m_SharedLocalDestination->Release ();
CreateNewSharedLocalDestination ();
// delete unused destinations
std::unique_lock<std::mutex> l(m_DestinationsMutex);
for (auto it = m_Destinations.begin (); it != m_Destinations.end ();)
@ -407,6 +405,14 @@ namespace client @@ -407,6 +405,14 @@ namespace client
return localDestination;
}
void ClientContext::CreateNewSharedLocalDestination ()
{
m_SharedLocalDestination = CreateNewLocalDestination (); // non-public, DSA
m_SharedLocalDestination->Acquire ();
m_Destinations[m_SharedLocalDestination->GetIdentity ()->GetIdentHash ()] = m_SharedLocalDestination;
m_SharedLocalDestination->Start ();
}
std::shared_ptr<ClientDestination> ClientContext::FindLocalDestination (const i2p::data::IdentHash& destination) const
{
auto it = m_Destinations.find (destination);

2
libi2pd_client/ClientContext.h

@ -99,6 +99,8 @@ namespace client @@ -99,6 +99,8 @@ namespace client
template<typename Visitor>
void VisitTunnels (Visitor v); // Visitor: (I2PService *) -> bool, true means retain
void CreateNewSharedLocalDestination ();
private:
std::mutex m_DestinationsMutex;

Loading…
Cancel
Save