diff --git a/libi2pd/Reseed.cpp b/libi2pd/Reseed.cpp index 4759dc31..5adc454d 100644 --- a/libi2pd/Reseed.cpp +++ b/libi2pd/Reseed.cpp @@ -75,9 +75,23 @@ namespace data } else // bootstrap from reseed servers { - int num = ReseedFromServers (); - if (num == 0) - LogPrint (eLogWarning, "Reseed: Failed to reseed from servers"); + auto start = i2p::util::GetMonotonicSeconds (); + int num = 0; + while (!num) + { + num = ReseedFromServers (); + if (num) break; // success + + if (i2p::util::GetMonotonicSeconds () < start + RESEED_GIVEUP_TIMEOUT) + { + LogPrint (eLogWarning, "Reseed: Failed to reseed from servers. Waiting for ", RESEED_WAITING_INTERVAL, " seconds"); + std::this_thread::sleep_for (std::chrono::seconds(RESEED_WAITING_INTERVAL)); + } + else + break; // give up + } + if (!num) + LogPrint (eLogWarning, "Reseed: Failed to reseed from servers. Give up"); } } diff --git a/libi2pd/Reseed.h b/libi2pd/Reseed.h index 53458a04..0cb876a7 100644 --- a/libi2pd/Reseed.h +++ b/libi2pd/Reseed.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2025, The PurpleI2P Project +* Copyright (c) 2013-2026, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -22,6 +22,8 @@ namespace data { constexpr int MAX_NUM_RESEED_ATTEMPTS = 10; constexpr int RESEED_CONNECT_TIMEOUT = 5; // in seconds + constexpr int RESEED_WAITING_INTERVAL = 30; // in second + constexpr int RESEED_GIVEUP_TIMEOUT = 180; // in seconds class Reseeder {