From 42d938f32ea4b3df5fe0d96d6c7e857786dd4b11 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 21 Sep 2020 07:34:07 +0200 Subject: [PATCH] Revert "Guarantee backoff" This reverts commit 3dfaa44e896e7d561e3542a7b89f34649c25dcb5. --- app/src/main/java/eu/faircode/email/Core.java | 13 ++----------- .../java/eu/faircode/email/ServiceSynchronize.java | 10 +++++----- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index b8f1a4ea77..004b76bd8f 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -4053,7 +4053,6 @@ class Core { static class State { private int backoff; - private boolean backingoff = false; private ConnectionHelper.NetworkState networkState; private Thread thread = new Thread(); private Semaphore semaphore = new Semaphore(0); @@ -4098,19 +4097,11 @@ class Core { return true; } - boolean acquire(long milliseconds, boolean backoff) throws InterruptedException { - try { - backingoff = backoff; - return semaphore.tryAcquire(milliseconds, TimeUnit.MILLISECONDS); - } finally { - backingoff = false; - } + boolean acquire(long milliseconds) throws InterruptedException { + return semaphore.tryAcquire(milliseconds, TimeUnit.MILLISECONDS); } void error(Throwable ex) { - if (backingoff) - return; - if (ex instanceof MessagingException && ("connection failure".equals(ex.getMessage()) || "Not connected".equals(ex.getMessage()) || // POP3 diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 7b9ce02d02..73690d3eaf 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -899,7 +899,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences try { long backoff = RECONNECT_BACKOFF - ago; EntityLog.log(ServiceSynchronize.this, account.name + " reconnect backoff=" + (backoff / 1000)); - state.acquire(backoff, true); + state.acquire(backoff); } catch (InterruptedException ex) { Log.w(account.name + " backoff " + ex.toString()); } @@ -1523,7 +1523,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences try { wlAccount.release(); - state.acquire(2 * duration, false); + state.acquire(2 * duration); Log.i("### " + account.name + " keeping alive"); } catch (InterruptedException ex) { EntityLog.log(this, account.name + " waited state=" + state); @@ -1638,7 +1638,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences if (cbackoff > backoff) { try { EntityLog.log(this, account.name + " reconnect backoff=" + cbackoff); - state.acquire(cbackoff * 1000L, true); + state.acquire(cbackoff * 1000L); } catch (InterruptedException ex) { Log.w(account.name + " cbackoff " + ex.toString()); } @@ -1648,7 +1648,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences if (backoff <= CONNECT_BACKOFF_MAX) { // Short back-off period, keep device awake try { - state.acquire(backoff * 1000L, true); + state.acquire(backoff * 1000L); } catch (InterruptedException ex) { Log.w(account.name + " backoff " + ex.toString()); } @@ -1681,7 +1681,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences try { wlAccount.release(); - state.acquire(2 * backoff * 1000L, true); + state.acquire(2 * backoff * 1000L); Log.i("### " + account.name + " backoff done"); } catch (InterruptedException ex) { Log.w(account.name + " backoff " + ex.toString());