From e4e180bbabe6e1f8c864e2ddcce896acd302409b Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 8 Dec 2019 09:14:29 +0100 Subject: [PATCH] Fixed backoff blocking stop --- .../eu/faircode/email/ServiceSynchronize.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 4a9e7329b3..29605909b8 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -313,16 +313,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences queue.submit(new Runnable() { @Override public void run() { - long ago = new Date().getTime() - lastLost; - if (ago < RECONNECT_BACKOFF) - try { - long backoff = RECONNECT_BACKOFF - ago; - EntityLog.log(ServiceSynchronize.this, accountNetworkState + " backoff=" + (backoff / 1000)); - Thread.sleep(backoff); - } catch (InterruptedException ex) { - Log.w(accountNetworkState + " backoff " + ex.toString()); - } - Map crumb = new HashMap<>(); crumb.put("account", accountNetworkState.toString()); crumb.put("connected", Boolean.toString(accountNetworkState.networkState.isConnected())); @@ -691,6 +681,16 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences try { wlAccount.acquire(); + long ago = new Date().getTime() - lastLost; + if (ago < RECONNECT_BACKOFF) + try { + long backoff = RECONNECT_BACKOFF - ago; + EntityLog.log(ServiceSynchronize.this, account.name + " backoff=" + (backoff / 1000)); + state.acquire(backoff); + } catch (InterruptedException ex) { + Log.w(account.name + " backoff " + ex.toString()); + } + final DB db = DB.getInstance(this); int backoff = CONNECT_BACKOFF_START;