1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-25 01:06:04 +00:00

Removed fast error handling

This commit is contained in:
M66B 2020-10-28 20:09:38 +01:00
parent a8690f58cb
commit 7aea1370ca
2 changed files with 20 additions and 34 deletions

View file

@ -373,6 +373,15 @@ public class ConnectionHelper {
return false;
}
static boolean isMaxConnections(Throwable ex) {
while (ex != null) {
if (isMaxConnections(ex.getMessage()))
return true;
ex = ex.getCause();
}
return false;
}
static boolean isMaxConnections(String message) {
return (message != null &&
(message.contains("Too many simultaneous connections") /* Gmail */ ||

View file

@ -117,8 +117,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private static final int ACCOUNT_ERROR_AFTER = 60; // minutes
private static final int ACCOUNT_ERROR_AFTER_POLL = 4; // times
private static final int BACKOFF_ERROR_AFTER = 16; // seconds
private static final int FAST_ERROR_COUNT = 3;
private static final int FAST_ERROR_BACKOFF = CONNECT_BACKOFF_ALARM_START;
private static final String ACTION_NEW_MESSAGE_COUNT = BuildConfig.APPLICATION_ID + ".NEW_MESSAGE_COUNT";
@ -903,7 +901,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
account.deleteNotificationChannel(ServiceSynchronize.this);
}
int errors = 0;
state.setBackoff(CONNECT_BACKOFF_START);
while (state.isRunning() &&
currentThread != null && currentThread.equals(thread)) {
@ -1479,9 +1476,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
Log.i(folder.name + " poll count=" + folder.poll_count);
}
}
if (!first)
errors = 0;
} catch (Throwable ex) {
if (tune) {
account.keep_alive_failed++;
@ -1499,6 +1493,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
" interval=" + account.poll_interval +
" idle=" + idleTime);
}
throw ex;
}
@ -1598,23 +1593,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
account.name + " " + Log.formatThrowable(ex, false));
db.account().setAccountError(account.id, Log.formatThrowable(ex));
long now = new Date().getTime();
// Check for fast account errors
if (account.last_connected != null &&
now - account.last_connected < account.poll_interval * 60 * 1000L / 2) {
errors++;
EntityLog.log(ServiceSynchronize.this,
account.name + " fast errors=" + errors +
" last connected: " + new Date(account.last_connected));
if (errors >= FAST_ERROR_COUNT)
state.setBackoff(FAST_ERROR_BACKOFF * 60);
boolean auto_optimize = prefs.getBoolean("auto_optimize", false);
if (auto_optimize) {
Throwable e = ex;
while (e != null) {
if (ConnectionHelper.isMaxConnections(e.getMessage())) {
if (auto_optimize && ConnectionHelper.isMaxConnections(ex)) {
for (int i = 0; i < EntityFolder.SYSTEM_FOLDER_SYNC.size(); i++)
if (EntityFolder.SYSTEM_FOLDER_POLL.get(i)) {
String ft = EntityFolder.SYSTEM_FOLDER_SYNC.get(i);
@ -1625,16 +1605,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
}
}
}
e = e.getCause();
}
}
}
// Report account connection error
if (account.last_connected != null && !ConnectionHelper.airplaneMode(this)) {
EntityLog.log(this, account.name + " last connected: " + new Date(account.last_connected));
int pollInterval = prefs.getInt("poll_interval", DEFAULT_POLL_INTERVAL);
long now = new Date().getTime();
long delayed = now - account.last_connected - account.poll_interval * 60 * 1000L;
long maxDelayed = (pollInterval > 0 && !account.poll_exempted
? pollInterval * ACCOUNT_ERROR_AFTER_POLL : ACCOUNT_ERROR_AFTER) * 60 * 1000L;