Skip async errors for inactive sessions

pull/185/head
M66B 5 years ago
parent ed63d035ee
commit 26d2b86eca

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

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

Loading…
Cancel
Save