mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-21 15:08:52 -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
|
// clear cache before going to idle mode
|
||||||
currentFolder.clearCache();
|
currentFolder.clearCache();
|
||||||
DavGatewayTray.resetIcon();
|
DavGatewayTray.resetIcon();
|
||||||
|
int originalTimeout = client.getSoTimeout();
|
||||||
try {
|
try {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
client.setSoTimeout(1000);
|
||||||
while (in.available() == 0) {
|
while (in.available() == 0) {
|
||||||
if (++count >= imapIdleDelay) {
|
if (++count >= imapIdleDelay) {
|
||||||
count = 0;
|
count = 0;
|
||||||
@ -530,8 +532,15 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
handleRefresh(previousImapFlagMap, currentFolder.getImapFlagMap());
|
handleRefresh(previousImapFlagMap, currentFolder.getImapFlagMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sleep 1 second
|
// wait for input 1 second
|
||||||
Thread.sleep(1000);
|
try {
|
||||||
|
byte[] byteBuffer = new byte[1];
|
||||||
|
if (in.read(byteBuffer) > 0) {
|
||||||
|
in.unread(byteBuffer);
|
||||||
|
}
|
||||||
|
} catch (SocketTimeoutException e) {
|
||||||
|
// ignore, read timed out
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// read DONE line
|
// read DONE line
|
||||||
line = readClient();
|
line = readClient();
|
||||||
@ -543,6 +552,8 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// client connection closed
|
// client connection closed
|
||||||
throw new SocketException(e.getMessage());
|
throw new SocketException(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
client.setSoTimeout(originalTimeout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sendClient(commandId + " NO no folder selected");
|
sendClient(commandId + " NO no folder selected");
|
||||||
|
Loading…
Reference in New Issue
Block a user