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 +7 −4 Original line number Diff line number Diff line Loading @@ -153,12 +153,15 @@ internal class RealImapFolderIdler( 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
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 +7 −4 Original line number Diff line number Diff line Loading @@ -153,12 +153,15 @@ internal class RealImapFolderIdler( 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