Default to a 30s read timeout during downloads.
This is configurable via a system property -Dread_timeout=N.
This commit is contained in:
@@ -95,6 +95,14 @@ public class SysProps
|
|||||||
return Integer.getInteger("connect_timeout", 0);
|
return Integer.getInteger("connect_timeout", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Specifies the read timeout (in seconds) to use when downloading all files from the server.
|
||||||
|
* The default is 30 seconds, meaning that if a download stalls for more than 30 seconds, the
|
||||||
|
* update process wil fail. Setting the timeout to zero (or a negative value) will disable it.
|
||||||
|
* Usage: {@code -Dread_timeout=N}. */
|
||||||
|
public static int readTimeout () {
|
||||||
|
return Integer.getInteger("read_timeout", 30);
|
||||||
|
}
|
||||||
|
|
||||||
/** Parses a Java version system property using the supplied regular expression. The numbers
|
/** Parses a Java version system property using the supplied regular expression. The numbers
|
||||||
* extracted from the regexp will be placed in each consecutive hundreds position in the
|
* extracted from the regexp will be placed in each consecutive hundreds position in the
|
||||||
* returned value.
|
* returned value.
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import java.util.List;
|
|||||||
import com.samskivert.io.StreamUtil;
|
import com.samskivert.io.StreamUtil;
|
||||||
|
|
||||||
import com.threerings.getdown.data.Resource;
|
import com.threerings.getdown.data.Resource;
|
||||||
|
import com.threerings.getdown.data.SysProps;
|
||||||
import com.threerings.getdown.util.ConnectionUtil;
|
import com.threerings.getdown.util.ConnectionUtil;
|
||||||
|
|
||||||
import static com.threerings.getdown.Log.log;
|
import static com.threerings.getdown.Log.log;
|
||||||
@@ -60,6 +61,10 @@ public class HTTPDownloader extends Downloader
|
|||||||
{
|
{
|
||||||
// download the resource from the specified URL
|
// download the resource from the specified URL
|
||||||
URLConnection conn = ConnectionUtil.open(rsrc.getRemote());
|
URLConnection conn = ConnectionUtil.open(rsrc.getRemote());
|
||||||
|
int rtimeout = SysProps.readTimeout();
|
||||||
|
if (rtimeout > 0) {
|
||||||
|
conn.setReadTimeout(rtimeout * 1000);
|
||||||
|
}
|
||||||
conn.connect();
|
conn.connect();
|
||||||
|
|
||||||
// make sure we got a satisfactory response code
|
// make sure we got a satisfactory response code
|
||||||
|
|||||||
Reference in New Issue
Block a user