From cf189511e35001ffd77d8bf7bb8058a27e297b68 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 23 May 2019 16:38:53 +0200 Subject: [PATCH] Serialize account operations, increase IMAP connection pool size to 2 --- .../main/java/eu/faircode/email/MessageHelper.java | 2 ++ .../java/eu/faircode/email/ServiceSynchronize.java | 12 +----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 49f39feac6..cdfdc795ac 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -119,6 +119,7 @@ public class MessageHelper { props.put("mail.imaps.timeout", Integer.toString(READ_TIMEOUT)); props.put("mail.imaps.connectionpool.debug", "true"); + props.put("mail.imaps.connectionpoolsize", "2"); props.put("mail.imaps.connectionpooltimeout", Integer.toString(POOL_TIMEOUT)); props.put("mail.imaps.finalizecleanclose", "false"); @@ -146,6 +147,7 @@ public class MessageHelper { props.put("mail.imap.timeout", Integer.toString(READ_TIMEOUT)); props.put("mail.imap.connectionpool.debug", "true"); + props.put("mail.imap.connectionpoolsize", "2"); props.put("mail.imap.connectionpooltimeout", Integer.toString(POOL_TIMEOUT)); props.put("mail.imap.finalizecleanclose", "false"); diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 3ce86520ae..8b22918b3c 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -96,7 +96,6 @@ public class ServiceSynchronize extends LifecycleService { private long lastLost = 0; private TupleAccountStats lastStats = new TupleAccountStats(); private ExecutorService queue = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory); - private ExecutorService initExecutor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory); private static boolean booted = false; private static boolean oneshot = false; @@ -697,7 +696,7 @@ public class ServiceSynchronize extends LifecycleService { Core.onSynchronizeFolders(this, account, istore, state); // Open synchronizing folders - final ExecutorService pollExecutor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory); + final ExecutorService executor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory); for (final EntityFolder folder : folders) { if (folder.synchronize && !folder.poll && capIdle) { Log.i(account.name + " sync folder " + folder.name); @@ -916,7 +915,6 @@ public class ServiceSynchronize extends LifecycleService { db.operation().liveOperations(folder.id).observe(cowner, new Observer>() { private List handling = new ArrayList<>(); - private final ExecutorService folderExecutor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory); private final PowerManager.WakeLock wlFolder = pm.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":folder." + folder.id); @@ -935,14 +933,6 @@ public class ServiceSynchronize extends LifecycleService { Log.i(folder.name + " operations=" + operations.size() + " init=" + folder.initialize + " poll=" + folder.poll); - ExecutorService executor; - if (folder.initialize) - executor = initExecutor; - else if (folder.poll) - executor = pollExecutor; - else - executor = folderExecutor; - executor.submit(new Runnable() { @Override public void run() {