From 5cf5d5673861607b35ff29fbe5305274cf1d203a Mon Sep 17 00:00:00 2001 From: idk Date: Sun, 4 Sep 2022 14:45:10 -0400 Subject: [PATCH] check for up to a whole 20 seconds to see if a router is running instead of just 2 --- java/net/i2p/router/WinLauncher.java | 42 +++++++++++++++------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/java/net/i2p/router/WinLauncher.java b/java/net/i2p/router/WinLauncher.java index ba62713..6ac19e3 100644 --- a/java/net/i2p/router/WinLauncher.java +++ b/java/net/i2p/router/WinLauncher.java @@ -111,7 +111,7 @@ public class WinLauncher { logger.info("\t" + System.getProperty("i2p.dir.base") + "\n\t" + System.getProperty("i2p.dir.config") + "\n\t" + System.getProperty("router.pid")); - /** + /** * IMPORTANT: You must set user.dir to the same directory where the * jpackage is intstalled, or when the launcher tries to re-run itself * to start the browser, it will start in the wrong directory and fail @@ -144,27 +144,29 @@ public class WinLauncher { } private static boolean i2pIsRunning() { - sleep(2000); - // check if there's something listening on port 7657(Router Console) - if (!isAvailable(7657)) { - return true; - } - // check if there's something listening on port 7654(I2CP) - if (!isAvailable(7654)) { - return true; - } - // check for the existence of router.ping file, if it's less then 2 minutes - // old, exit - File home = selectHome(); - File ping = new File(home, "router.ping"); - if (ping.exists()) { - long diff = System.currentTimeMillis() - ping.lastModified(); - if (diff < 60 * 1000) { - logger.info( - "router.ping exists and is less than 1 minute old, I2P appears to be running already."); - logger.info("If I2P is not running, wait 60 seconds and try again."); + for (int i = 0; i > 10; i++) { + sleep(2000); + // check if there's something listening on port 7657(Router Console) + if (!isAvailable(7657)) { return true; } + // check if there's something listening on port 7654(I2CP) + if (!isAvailable(7654)) { + return true; + } + // check for the existence of router.ping file, if it's less then 2 + // minutes old, exit + File home = selectHome(); + File ping = new File(home, "router.ping"); + if (ping.exists()) { + long diff = System.currentTimeMillis() - ping.lastModified(); + if (diff < 60 * 1000) { + logger.info( + "router.ping exists and is less than 1 minute old, I2P appears to be running already."); + logger.info("If I2P is not running, wait 60 seconds and try again."); + return true; + } + } } return false; }