MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / Stop

Method Stop

libi2pd_client/AddressBook.cpp:391–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389 }
390
391 void AddressBook::Stop ()
392 {
393 StopLookups ();
394 StopSubscriptions ();
395 if (m_SubscriptionsUpdateTimer)
396 {
397 m_SubscriptionsUpdateTimer->cancel ();
398 m_SubscriptionsUpdateTimer = nullptr;
399 }
400 if (m_AddressCacheUpdateTimer)
401 {
402 m_AddressCacheUpdateTimer->cancel ();
403 m_AddressCacheUpdateTimer = nullptr;
404 }
405 bool isDownloading = m_Downloading.valid ();
406 if (isDownloading)
407 {
408 if (m_Downloading.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
409 isDownloading = false;
410 else
411 {
412 LogPrint (eLogInfo, "Addressbook: Subscriptions are downloading, abort");
413 for (int i = 0; i < 30; i++)
414 {
415 if (m_Downloading.wait_for(std::chrono::seconds(1)) == std::future_status::ready) // wait for 1 seconds
416 {
417 isDownloading = false;
418 LogPrint (eLogInfo, "Addressbook: Subscriptions download complete");
419 break;
420 }
421 }
422 }
423 if (!isDownloading)
424 m_Downloading.get ();
425 else
426 LogPrint (eLogError, "Addressbook: Subscription download timeout");
427 }
428 if (m_Storage)
429 {
430 m_Storage->Save (m_Addresses);
431 delete m_Storage;
432 m_Storage = nullptr;
433 }
434 m_DefaultSubscription = nullptr;
435 m_Subscriptions.clear ();
436 }
437
438 std::shared_ptr<const Address> AddressBook::GetAddress (std::string_view address)
439 {

Callers

nothing calls this directly

Calls 2

LogPrintFunction · 0.85
SaveMethod · 0.45

Tested by

no test coverage detected