socket leak fix
* fix socket leak in "DownloadRunnable" * in "DownloadInitializer" close the HTTP body after doing range-request checks * in "DownloadRunnableFallback" fix typo in comment * in "DownloadDialog" fix regression, using one thread for audios instead of subtitles
This commit is contained in:
parent
e529b16956
commit
d9b042d9e3
4 changed files with 31 additions and 20 deletions
|
|
@ -49,7 +49,6 @@ public class DownloadRunnable extends Thread {
|
|||
}
|
||||
|
||||
SharpStream f;
|
||||
InputStream is = null;
|
||||
|
||||
try {
|
||||
f = mMission.storage.getStream();
|
||||
|
|
@ -114,16 +113,16 @@ public class DownloadRunnable extends Thread {
|
|||
|
||||
f.seek(mMission.offsets[mMission.current] + start);
|
||||
|
||||
is = mConn.getInputStream();
|
||||
try (InputStream is = mConn.getInputStream()) {
|
||||
byte[] buf = new byte[DownloadMission.BUFFER_SIZE];
|
||||
int len;
|
||||
|
||||
byte[] buf = new byte[DownloadMission.BUFFER_SIZE];
|
||||
int len;
|
||||
|
||||
while (start < end && mMission.running && (len = is.read(buf, 0, buf.length)) != -1) {
|
||||
f.write(buf, 0, len);
|
||||
start += len;
|
||||
block.done += len;
|
||||
mMission.notifyProgress(len);
|
||||
while (start < end && mMission.running && (len = is.read(buf, 0, buf.length)) != -1) {
|
||||
f.write(buf, 0, len);
|
||||
start += len;
|
||||
block.done += len;
|
||||
mMission.notifyProgress(len);
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG && mMission.running) {
|
||||
|
|
@ -143,12 +142,6 @@ public class DownloadRunnable extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (is != null) is.close();
|
||||
} catch (Exception err) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
try {
|
||||
f.close();
|
||||
} catch (Exception err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue