diff --git a/apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateChecker.java b/apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateChecker.java index 98ad9f603..235bf3731 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateChecker.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateChecker.java @@ -158,7 +158,7 @@ public class PluginUpdateChecker extends UpdateHandler { try { _get = new PartialEepGet(_context, proxyHost, proxyPort, _baos, _xpi2pURL, TrustedUpdate.HEADER_BYTES); _get.addStatusListener(PluginUpdateCheckerRunner.this); - _get.fetch(); + _get.fetch(CONNECT_TIMEOUT); } catch (Throwable t) { _log.error("Error checking update for plugin", t); } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateHandler.java index ce6017036..25514992c 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateHandler.java @@ -149,7 +149,7 @@ public class PluginUpdateHandler extends UpdateHandler { else _get = new EepGet(_context, 1, _updateFile, _xpi2pURL, false); _get.addStatusListener(PluginUpdateRunner.this); - _get.fetch(); + _get.fetch(CONNECT_TIMEOUT, -1, shouldProxy ? INACTIVITY_TIMEOUT : NOPROXY_INACTIVITY_TIMEOUT); } catch (Throwable t) { _log.error("Error downloading plugin", t); } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/UnsignedUpdateHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/UnsignedUpdateHandler.java index f72878375..4725f62b1 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/UnsignedUpdateHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/UnsignedUpdateHandler.java @@ -75,7 +75,7 @@ public class UnsignedUpdateHandler extends UpdateHandler { // 40 retries!! _get = new EepGet(_context, proxyHost, proxyPort, 40, _updateFile, _zipURL, false); _get.addStatusListener(UnsignedUpdateRunner.this); - _get.fetch(); + _get.fetch(CONNECT_TIMEOUT, -1, INACTIVITY_TIMEOUT); } catch (Throwable t) { _log.error("Error updating", t); } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/UpdateHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/UpdateHandler.java index 6ebb2a469..c7a1f695f 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/UpdateHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/UpdateHandler.java @@ -45,6 +45,10 @@ public class UpdateHandler { static final String PROP_UPDATE_IN_PROGRESS = "net.i2p.router.web.UpdateHandler.updateInProgress"; protected static final String PROP_LAST_UPDATE_TIME = "router.updateLastDownloaded"; + protected static final long CONNECT_TIMEOUT = 55*1000; + protected static final long INACTIVITY_TIMEOUT = 5*60*1000; + protected static final long NOPROXY_INACTIVITY_TIMEOUT = 60*1000; + public UpdateHandler() { this(ContextHelper.getContext(null)); } @@ -193,7 +197,7 @@ public class UpdateHandler { // no retries _get = new PartialEepGet(_context, proxyHost, proxyPort, _baos, updateURL, TrustedUpdate.HEADER_BYTES); _get.addStatusListener(UpdateRunner.this); - _get.fetch(); + _get.fetch(CONNECT_TIMEOUT); } catch (Throwable t) { _isNewer = false; } @@ -210,7 +214,7 @@ public class UpdateHandler { else _get = new EepGet(_context, 1, _updateFile, updateURL, false); _get.addStatusListener(UpdateRunner.this); - _get.fetch(); + _get.fetch(CONNECT_TIMEOUT, -1, shouldProxy ? INACTIVITY_TIMEOUT : NOPROXY_INACTIVITY_TIMEOUT); } catch (Throwable t) { _log.error("Error updating", t); } diff --git a/core/java/src/net/i2p/util/EepGet.java b/core/java/src/net/i2p/util/EepGet.java index cbe4b42e7..af6055129 100644 --- a/core/java/src/net/i2p/util/EepGet.java +++ b/core/java/src/net/i2p/util/EepGet.java @@ -458,19 +458,32 @@ public class EepGet { } public void stopFetching() { _keepFetching = false; } + /** - * Blocking fetch, returning true if the URL was retrieved, false if all retries failed + * Blocking fetch, returning true if the URL was retrieved, false if all retries failed. * + * Header timeout default 45 sec, total timeout default none, inactivity timeout default 60 sec. */ public boolean fetch() { return fetch(_fetchHeaderTimeout); } + /** * Blocking fetch, timing out individual attempts if the HTTP response headers * don't come back in the time given. If the timeout is zero or less, this will * wait indefinitely. + * + * Total timeout default none, inactivity timeout default 60 sec. */ public boolean fetch(long fetchHeaderTimeout) { return fetch(fetchHeaderTimeout, -1, -1); } + + /** + * Blocking fetch. + * + * @param fetchHeaderTimeout <= 0 for none (proxy will timeout if none, none isn't recommended if no proxy) + * @param totalTimeout <= 0 for default none + * @param inactivityTimeout <= 0 for default 60 sec + */ public boolean fetch(long fetchHeaderTimeout, long totalTimeout, long inactivityTimeout) { _fetchHeaderTimeout = fetchHeaderTimeout; _fetchEndTime = (totalTimeout > 0 ? System.currentTimeMillis() + totalTimeout : -1); diff --git a/history.txt b/history.txt index a06d63851..1456fa838 100644 --- a/history.txt +++ b/history.txt @@ -18,6 +18,7 @@ - Cancel flusher timer in MessageOutputStream when closed - Move some createRateStats to ConnectionManager to reduce repeated calls - Cleanups, javadocs, logging, volatile, finals + * Update: Increase eepget timeouts 2012-06-24 zzz * ElGamalAESEngine: Fix bad size estimate when tags are included,