mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-28 11:55:20 +01:00
Cancel empty pool on close
This commit is contained in:
@@ -1459,6 +1459,28 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
}
|
||||
});
|
||||
|
||||
final Runnable purge = new RunnableEx("purge") {
|
||||
@Override
|
||||
public void delegate() {
|
||||
executor.submit(new RunnableEx("purge#exec") {
|
||||
@Override
|
||||
public void delegate() {
|
||||
try {
|
||||
wlAccount.acquire();
|
||||
|
||||
// Close cached connections
|
||||
Log.i(account.name + " Empty connection pool");
|
||||
((IMAPStore) iservice.getStore()).emptyConnectionPool(false);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
} finally {
|
||||
wlAccount.release();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
final Map<EntityFolder, IMAPFolder> mapFolders = new LinkedHashMap<>();
|
||||
List<Thread> idlers = new ArrayList<>();
|
||||
try {
|
||||
@@ -1834,28 +1856,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
|
||||
forced = true;
|
||||
|
||||
final Runnable purge = new RunnableEx("purge") {
|
||||
@Override
|
||||
public void delegate() {
|
||||
executor.submit(new RunnableEx("purge#exec") {
|
||||
@Override
|
||||
public void delegate() {
|
||||
try {
|
||||
wlAccount.acquire();
|
||||
|
||||
// Close cached connections
|
||||
Log.i(account.name + " Empty connection pool");
|
||||
((IMAPStore) istore).emptyConnectionPool(false);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
} finally {
|
||||
wlAccount.release();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
final long serial = state.getSerial();
|
||||
|
||||
Log.i(account.name + " observing operations");
|
||||
@@ -2314,6 +2314,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
EntityLog.log(this, EntityLog.Type.Account, account,
|
||||
account.name + " closing");
|
||||
|
||||
getMainHandler().removeCallbacks(purge);
|
||||
|
||||
// Stop watching operations
|
||||
Log.i(account.name + " stop watching operations");
|
||||
final TwoStateOwner _owner = cowner.value;
|
||||
|
||||
Reference in New Issue
Block a user