Skip async errors for inactive sessions

This commit is contained in:
M66B 2020-09-21 09:50:43 +02:00
parent ed63d035ee
commit 26d2b86eca
2 changed files with 18 additions and 3 deletions

View File

@ -4052,7 +4052,8 @@ class Core {
}
static class State {
private int session;
private int session = -1;
private boolean active = false;
private int backoff;
private ConnectionHelper.NetworkState networkState;
private Thread thread = new Thread();
@ -4103,11 +4104,16 @@ class Core {
}
void error(Throwable ex, int session) {
if (session != this.session) {
Log.i("Ignoring session=" + session + "/" + this.session + " ex=" + ex);
if (!this.active || session != this.session) {
Log.i("Ignoring" +
" active=" + active +
" session=" + session + "/" + this.session +
" ex=" + ex);
return;
}
active = false;
if (ex instanceof MessagingException &&
("connection failure".equals(ex.getMessage()) ||
"Not connected".equals(ex.getMessage()) || // POP3
@ -4140,11 +4146,16 @@ class Core {
void reset(int run) {
session = run;
active = true;
recoverable = true;
lastActivity = null;
resetBatches();
}
void setActive(boolean whether) {
this.active = whether;
}
void resetBatches() {
synchronized (this) {
for (FolderPriority key : sequence.keySet()) {

View File

@ -1543,6 +1543,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
Log.i(account.name + " done state=" + state);
} catch (Throwable ex) {
state.setActive(false);
Log.e(account.name, ex);
EntityLog.log(
ServiceSynchronize.this,
@ -1587,6 +1589,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
}
}
} finally {
state.setActive(false);
// Update state
EntityLog.log(this, account.name + " closing");
db.account().setAccountState(account.id, "closing");