Loading app/core/src/main/java/com/fsck/k9/controller/push/AccountPushController.kt +1 −2 Original line number Diff line number Diff line Loading @@ -82,8 +82,7 @@ internal class AccountPushController( private fun updatePushFolders(folderServerIds: List<String>) { Timber.v("AccountPushController(%s).updatePushFolders(): %s", account.uuid, folderServerIds) val backendPusher = this.backendPusher ?: error("BackendPusher not initialized") backendPusher.updateFolders(folderServerIds) backendPusher?.updateFolders(folderServerIds) } private fun syncFolders(folderServerId: String) { Loading mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/RealImapConnection.java +15 −11 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ class RealImapConnection implements ImapConnection { } @Override public void open() throws IOException, MessagingException { public synchronized void open() throws IOException, MessagingException { if (open) { return; } else if (stacktraceForClose != null) { Loading Loading @@ -190,7 +190,7 @@ class RealImapConnection implements ImapConnection { } @Override public boolean isConnected() { public synchronized boolean isConnected() { return inputStream != null && outputStream != null && socket != null && socket.isConnected() && !socket.isClosed(); } Loading Loading @@ -260,9 +260,11 @@ class RealImapConnection implements ImapConnection { } @Override public void setSocketReadTimeout(int timeout) throws SocketException { public synchronized void setSocketReadTimeout(int timeout) throws SocketException { if (socket != null) { socket.setSoTimeout(timeout); } } private void setUpStreamsAndParserFromSocket() throws IOException { setUpStreamsAndParser(socket.getInputStream(), socket.getOutputStream()); Loading Loading @@ -731,7 +733,7 @@ class RealImapConnection implements ImapConnection { } @Override public void close() { public synchronized void close() { if (!open) { return; } Loading @@ -750,7 +752,7 @@ class RealImapConnection implements ImapConnection { @Override @NotNull public OutputStream getOutputStream() { public synchronized OutputStream getOutputStream() { return outputStream; } Loading @@ -762,7 +764,8 @@ class RealImapConnection implements ImapConnection { @Override @NotNull public List<ImapResponse> executeSimpleCommand(@NotNull String command) throws IOException, MessagingException { public synchronized List<ImapResponse> executeSimpleCommand(@NotNull String command) throws IOException, MessagingException { return executeSimpleCommand(command, false); } Loading @@ -786,8 +789,8 @@ class RealImapConnection implements ImapConnection { @Override @NotNull public List<ImapResponse> executeCommandWithIdSet(@NotNull String commandPrefix, @NotNull String commandSuffix, @NotNull Set<Long> ids) throws IOException, MessagingException { public synchronized List<ImapResponse> executeCommandWithIdSet(@NotNull String commandPrefix, @NotNull String commandSuffix, @NotNull Set<Long> ids) throws IOException, MessagingException { GroupedIds groupedIds = IdGrouper.groupIds(ids); List<String> splitCommands = ImapCommandSplitter.splitCommand( Loading Loading @@ -828,7 +831,8 @@ class RealImapConnection implements ImapConnection { @Override @NotNull public String sendCommand(@NotNull String command, boolean sensitive) throws MessagingException, IOException { public synchronized String sendCommand(@NotNull String command, boolean sensitive) throws MessagingException, IOException { try { open(); Loading @@ -853,7 +857,7 @@ class RealImapConnection implements ImapConnection { } @Override public void sendContinuation(@NotNull String continuation) throws IOException { public synchronized void sendContinuation(@NotNull String continuation) throws IOException { outputStream.write(continuation.getBytes()); outputStream.write('\r'); outputStream.write('\n'); Loading mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/RealImapFolderIdler.kt +19 −6 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package com.fsck.k9.mail.store.imap import com.fsck.k9.mail.MessagingException import com.fsck.k9.mail.power.WakeLock import java.io.IOException import timber.log.Timber private const val SOCKET_EXTRA_TIMEOUT_MS = 2 * 60 * 1000L Loading Loading @@ -59,7 +60,12 @@ internal class RealImapFolderIdler( private fun endIdle() { if (idleSent && !doneSent) { idleRefreshTimer?.cancel() try { sendDone() } catch (e: IOException) { Timber.v(e, "%s: IOException while sending DONE", logTag) } } } Loading Loading @@ -136,19 +142,26 @@ internal class RealImapFolderIdler( return } try { sendDone() } catch (e: IOException) { Timber.v(e, "%s: IOException while sending DONE", logTag) } } @Synchronized private fun sendDone() { val folder = folder ?: return val connection = connectionProvider.getConnection(folder) ?: return synchronized(connection) { if (connection.isConnected) { doneSent = true connection.setSocketDefaultReadTimeout() connection.sendContinuation("DONE") } } } private fun ImapConnection.setSocketIdleReadTimeout() { setSocketReadTimeout((idleRefreshTimeoutProvider.idleRefreshTimeoutMs + SOCKET_EXTRA_TIMEOUT_MS).toInt()) Loading Loading
app/core/src/main/java/com/fsck/k9/controller/push/AccountPushController.kt +1 −2 Original line number Diff line number Diff line Loading @@ -82,8 +82,7 @@ internal class AccountPushController( private fun updatePushFolders(folderServerIds: List<String>) { Timber.v("AccountPushController(%s).updatePushFolders(): %s", account.uuid, folderServerIds) val backendPusher = this.backendPusher ?: error("BackendPusher not initialized") backendPusher.updateFolders(folderServerIds) backendPusher?.updateFolders(folderServerIds) } private fun syncFolders(folderServerId: String) { Loading
mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/RealImapConnection.java +15 −11 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ class RealImapConnection implements ImapConnection { } @Override public void open() throws IOException, MessagingException { public synchronized void open() throws IOException, MessagingException { if (open) { return; } else if (stacktraceForClose != null) { Loading Loading @@ -190,7 +190,7 @@ class RealImapConnection implements ImapConnection { } @Override public boolean isConnected() { public synchronized boolean isConnected() { return inputStream != null && outputStream != null && socket != null && socket.isConnected() && !socket.isClosed(); } Loading Loading @@ -260,9 +260,11 @@ class RealImapConnection implements ImapConnection { } @Override public void setSocketReadTimeout(int timeout) throws SocketException { public synchronized void setSocketReadTimeout(int timeout) throws SocketException { if (socket != null) { socket.setSoTimeout(timeout); } } private void setUpStreamsAndParserFromSocket() throws IOException { setUpStreamsAndParser(socket.getInputStream(), socket.getOutputStream()); Loading Loading @@ -731,7 +733,7 @@ class RealImapConnection implements ImapConnection { } @Override public void close() { public synchronized void close() { if (!open) { return; } Loading @@ -750,7 +752,7 @@ class RealImapConnection implements ImapConnection { @Override @NotNull public OutputStream getOutputStream() { public synchronized OutputStream getOutputStream() { return outputStream; } Loading @@ -762,7 +764,8 @@ class RealImapConnection implements ImapConnection { @Override @NotNull public List<ImapResponse> executeSimpleCommand(@NotNull String command) throws IOException, MessagingException { public synchronized List<ImapResponse> executeSimpleCommand(@NotNull String command) throws IOException, MessagingException { return executeSimpleCommand(command, false); } Loading @@ -786,8 +789,8 @@ class RealImapConnection implements ImapConnection { @Override @NotNull public List<ImapResponse> executeCommandWithIdSet(@NotNull String commandPrefix, @NotNull String commandSuffix, @NotNull Set<Long> ids) throws IOException, MessagingException { public synchronized List<ImapResponse> executeCommandWithIdSet(@NotNull String commandPrefix, @NotNull String commandSuffix, @NotNull Set<Long> ids) throws IOException, MessagingException { GroupedIds groupedIds = IdGrouper.groupIds(ids); List<String> splitCommands = ImapCommandSplitter.splitCommand( Loading Loading @@ -828,7 +831,8 @@ class RealImapConnection implements ImapConnection { @Override @NotNull public String sendCommand(@NotNull String command, boolean sensitive) throws MessagingException, IOException { public synchronized String sendCommand(@NotNull String command, boolean sensitive) throws MessagingException, IOException { try { open(); Loading @@ -853,7 +857,7 @@ class RealImapConnection implements ImapConnection { } @Override public void sendContinuation(@NotNull String continuation) throws IOException { public synchronized void sendContinuation(@NotNull String continuation) throws IOException { outputStream.write(continuation.getBytes()); outputStream.write('\r'); outputStream.write('\n'); Loading
mail/protocols/imap/src/main/java/com/fsck/k9/mail/store/imap/RealImapFolderIdler.kt +19 −6 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package com.fsck.k9.mail.store.imap import com.fsck.k9.mail.MessagingException import com.fsck.k9.mail.power.WakeLock import java.io.IOException import timber.log.Timber private const val SOCKET_EXTRA_TIMEOUT_MS = 2 * 60 * 1000L Loading Loading @@ -59,7 +60,12 @@ internal class RealImapFolderIdler( private fun endIdle() { if (idleSent && !doneSent) { idleRefreshTimer?.cancel() try { sendDone() } catch (e: IOException) { Timber.v(e, "%s: IOException while sending DONE", logTag) } } } Loading Loading @@ -136,19 +142,26 @@ internal class RealImapFolderIdler( return } try { sendDone() } catch (e: IOException) { Timber.v(e, "%s: IOException while sending DONE", logTag) } } @Synchronized private fun sendDone() { val folder = folder ?: return val connection = connectionProvider.getConnection(folder) ?: return synchronized(connection) { if (connection.isConnected) { doneSent = true connection.setSocketDefaultReadTimeout() connection.sendContinuation("DONE") } } } private fun ImapConnection.setSocketIdleReadTimeout() { setSocketReadTimeout((idleRefreshTimeoutProvider.idleRefreshTimeoutMs + SOCKET_EXTRA_TIMEOUT_MS).toInt()) Loading