mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 22:51:02 +00:00
Added stop failsafe
This commit is contained in:
parent
be70d92e73
commit
a013f500f0
1 changed files with 17 additions and 4 deletions
|
@ -136,6 +136,7 @@ class Core {
|
|||
private static final int SYNC_BATCH_SIZE = 20;
|
||||
private static final int DOWNLOAD_BATCH_SIZE = 20;
|
||||
private static final long YIELD_DURATION = 200L; // milliseconds
|
||||
private static final long JOIN_WAIT = 90 * 1000L; // milliseconds
|
||||
private static final long FUTURE_RECEIVED = 30 * 24 * 3600 * 1000L; // milliseconds
|
||||
private static final int LOCAL_RETRY_MAX = 2;
|
||||
private static final long LOCAL_RETRY_DELAY = 5 * 1000L; // milliseconds
|
||||
|
@ -4141,12 +4142,24 @@ class Core {
|
|||
|
||||
void join(Thread thread) {
|
||||
boolean joined = false;
|
||||
boolean interrupted = false;
|
||||
while (!joined)
|
||||
try {
|
||||
Log.i("Joining " + thread.getName());
|
||||
thread.join();
|
||||
joined = true;
|
||||
Log.i("Joined " + thread.getName());
|
||||
Log.i("Joining " + thread.getName() +
|
||||
" state=" + thread.getState() + " alive=" + thread.isAlive());
|
||||
thread.join(JOIN_WAIT);
|
||||
if (thread.isAlive()) {
|
||||
Log.e("Join failed state=" + thread.getState() + " interrupted=" + interrupted);
|
||||
if (interrupted)
|
||||
joined = true; // give up
|
||||
else {
|
||||
thread.interrupt();
|
||||
interrupted = true;
|
||||
}
|
||||
} else {
|
||||
Log.i("Joined " + thread.getName() + " state=" + thread.getState());
|
||||
joined = true;
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
Log.w(thread.getName() + " join " + ex.toString());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue