diff --git a/src/main/java/com/threerings/getdown/data/Application.java b/src/main/java/com/threerings/getdown/data/Application.java index af152a3..b2fd964 100644 --- a/src/main/java/com/threerings/getdown/data/Application.java +++ b/src/main/java/com/threerings/getdown/data/Application.java @@ -1509,6 +1509,11 @@ public class Application // about it; turning off caches is not a performance concern, because when Getdown asks // to download a file, it expects it to come over the wire, not from a cache uconn.setUseCaches(false); + // configure a connect timeout if requested + int ctimeout = SysProps.connectTimeout(); + if (ctimeout > 0) { + uconn.setConnectTimeout(ctimeout * 1000); + } fin = uconn.getInputStream(); fout = new FileOutputStream(target); StreamUtil.copy(fin, fout); diff --git a/src/main/java/com/threerings/getdown/data/SysProps.java b/src/main/java/com/threerings/getdown/data/SysProps.java index 671bf11..858cc26 100644 --- a/src/main/java/com/threerings/getdown/data/SysProps.java +++ b/src/main/java/com/threerings/getdown/data/SysProps.java @@ -65,4 +65,12 @@ public class SysProps public static boolean direct () { return Boolean.getBoolean("direct"); } + + /** Specifies the connection timeout (in seconds) to use when downloading control files from + * the server. This is chiefly useful when you are running in versionless mode and want Getdown + * to more quickly timeout its startup update check if the server with which it is + * communicating is not available. Usage: {@code -Dconnect_timeout=N}. */ + public static int connectTimeout () { + return Integer.getInteger("connect_timeout", 0); + } }