1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-04 06:20:26 +00:00

Increased join wait time

This commit is contained in:
M66B 2021-11-27 10:09:43 +01:00
parent d321ede8ac
commit 8b19bceb7a
2 changed files with 13 additions and 11 deletions

View file

@ -149,7 +149,8 @@ class Core {
private static final int DOWNLOAD_YIELD_COUNT = 25; private static final int DOWNLOAD_YIELD_COUNT = 25;
private static final long DOWNLOAD_YIELD_DURATION = 1000; // milliseconds private static final long DOWNLOAD_YIELD_DURATION = 1000; // milliseconds
private static final long YIELD_DURATION = 200L; // milliseconds private static final long YIELD_DURATION = 200L; // milliseconds
private static final long JOIN_WAIT = 180 * 1000L; // milliseconds private static final long JOIN_WAIT_ALIVE = 5 * 60 * 1000L; // milliseconds
private static final long JOIN_WAIT_INTERRUPT = 1 * 60 * 1000L; // milliseconds
private static final long FUTURE_RECEIVED = 30 * 24 * 3600 * 1000L; // milliseconds private static final long FUTURE_RECEIVED = 30 * 24 * 3600 * 1000L; // milliseconds
private static final int LOCAL_RETRY_MAX = 2; private static final int LOCAL_RETRY_MAX = 2;
private static final long LOCAL_RETRY_DELAY = 5 * 1000L; // milliseconds private static final long LOCAL_RETRY_DELAY = 5 * 1000L; // milliseconds
@ -5472,8 +5473,8 @@ class Core {
semaphore.release(); semaphore.release();
} }
void join() { void join(Context context) {
join(thread); join(context, thread);
} }
void ensureRunning(String reason) { void ensureRunning(String reason) {
@ -5495,7 +5496,7 @@ class Core {
return unrecoverable; return unrecoverable;
} }
void join(Thread thread) { void join(Context context, Thread thread) {
boolean joined = false; boolean joined = false;
boolean interrupted = false; boolean interrupted = false;
String name = thread.getName(); String name = thread.getName();
@ -5503,15 +5504,16 @@ class Core {
try { try {
Log.i("Joining " + name + Log.i("Joining " + name +
" alive=" + thread.isAlive() + " alive=" + thread.isAlive() +
" state=" + thread.getState()); " state=" + thread.getState() +
" interrupted=" + interrupted);
thread.join(JOIN_WAIT); thread.join(interrupted ? JOIN_WAIT_INTERRUPT : JOIN_WAIT_ALIVE);
// https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.State.html // https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.State.html
Thread.State state = thread.getState(); Thread.State state = thread.getState();
if (thread.isAlive()) { if (thread.isAlive()) {
if (interrupted) EntityLog.log(context, "Join " + name + " failed" +
Log.w("Join " + name + " failed state=" + state + " interrupted=" + interrupted); " state=" + state + " interrupted=" + interrupted);
if (interrupted) if (interrupted)
joined = true; // give up joined = true; // give up
else { else {
@ -5523,7 +5525,7 @@ class Core {
joined = true; joined = true;
} }
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Log.w(thread.getName() + " join " + ex.toString()); EntityLog.log(context, "Join " + name + " error " + ex.toString());
} }
} }

View file

@ -507,7 +507,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
Log.i("### stop=" + accountNetworkState); Log.i("### stop=" + accountNetworkState);
db.account().setAccountThread(accountNetworkState.accountState.id, null); db.account().setAccountThread(accountNetworkState.accountState.id, null);
state.stop(); state.stop();
state.join(); state.join(ServiceSynchronize.this);
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling, EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
"### stopped=" + accountNetworkState); "### stopped=" + accountNetworkState);
} catch (Throwable ex) { } catch (Throwable ex) {
@ -2207,7 +2207,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
// Stop idlers // Stop idlers
for (Thread idler : idlers) for (Thread idler : idlers)
state.join(idler); state.join(this, idler);
idlers.clear(); idlers.clear();
} }