mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-21 06:58:51 -05:00
Fix #36 Endless loop when using IMAP IDLE feature with SSL sockets, replaced thread sleep with a short timeout on socket read
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2334 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
b0ea531d3a
commit
9420c6cb17
@ -520,8 +520,10 @@ public class ImapConnection extends AbstractConnection {
|
||||
// clear cache before going to idle mode
|
||||
currentFolder.clearCache();
|
||||
DavGatewayTray.resetIcon();
|
||||
int originalTimeout = client.getSoTimeout();
|
||||
try {
|
||||
int count = 0;
|
||||
client.setSoTimeout(1000);
|
||||
while (in.available() == 0) {
|
||||
if (++count >= imapIdleDelay) {
|
||||
count = 0;
|
||||
@ -530,8 +532,15 @@ public class ImapConnection extends AbstractConnection {
|
||||
handleRefresh(previousImapFlagMap, currentFolder.getImapFlagMap());
|
||||
}
|
||||
}
|
||||
// sleep 1 second
|
||||
Thread.sleep(1000);
|
||||
// wait for input 1 second
|
||||
try {
|
||||
byte[] byteBuffer = new byte[1];
|
||||
if (in.read(byteBuffer) > 0) {
|
||||
in.unread(byteBuffer);
|
||||
}
|
||||
} catch (SocketTimeoutException e) {
|
||||
// ignore, read timed out
|
||||
}
|
||||
}
|
||||
// read DONE line
|
||||
line = readClient();
|
||||
@ -543,6 +552,8 @@ public class ImapConnection extends AbstractConnection {
|
||||
} catch (IOException e) {
|
||||
// client connection closed
|
||||
throw new SocketException(e.getMessage());
|
||||
} finally {
|
||||
client.setSoTimeout(originalTimeout);
|
||||
}
|
||||
} else {
|
||||
sendClient(commandId + " NO no folder selected");
|
||||
|
Loading…
Reference in New Issue
Block a user