recreate addressbook timers when shared destination is replaced

This commit is contained in:
PobreGato
2026-08-20 02:18:20 +03:00
parent 561958ee32
commit 0850b0fc56
3 changed files with 27 additions and 0 deletions
+25
View File
@@ -781,6 +781,31 @@ namespace client
m_SubscriptionsUpdateTimer->cancel ();
}
void AddressBook::ResetTimers ()
{
// both timers run on the shared local destination's service, so they must be
// created anew when that destination is replaced
auto dest = i2p::client::context.GetSharedLocalDestination ();
if (m_SubscriptionsUpdateTimer)
{
m_SubscriptionsUpdateTimer->cancel ();
m_SubscriptionsUpdateTimer = nullptr;
if (dest)
{
m_SubscriptionsUpdateTimer = std::make_unique<boost::asio::steady_timer>(dest->GetService ());
m_SubscriptionsUpdateTimer->expires_after (std::chrono::minutes(INITIAL_SUBSCRIPTION_UPDATE_TIMEOUT));
m_SubscriptionsUpdateTimer->async_wait (std::bind (&AddressBook::HandleSubscriptionsUpdateTimer,
this, std::placeholders::_1));
}
}
if (m_AddressCacheUpdateTimer)
{
m_AddressCacheUpdateTimer->cancel ();
m_AddressCacheUpdateTimer = nullptr;
ScheduleCacheUpdate (); // creates it again on the current destination
}
}
void AddressBook::HandleSubscriptionsUpdateTimer (const boost::system::error_code& ecode)
{
if (ecode != boost::asio::error::operation_aborted)
+1
View File
@@ -89,6 +89,7 @@ namespace client
AddressBook ();
~AddressBook ();
void Start ();
void ResetTimers (); // after the shared local destination is replaced
void StartResolvers ();
void Stop ();
std::shared_ptr<const Address> GetAddress (std::string_view address);
+1
View File
@@ -250,6 +250,7 @@ namespace client
// change shared local destination
m_SharedLocalDestination->Release ();
CreateNewSharedLocalDestination ();
m_AddressBook.ResetTimers (); // its timers are left on a destination about to go
// recreate HTTP proxy
auto httpProxy = DetachHttpProxy ();