1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-26 01:28:50 -05:00

Fixes Issue 1643

Fixes Issue 1664

Issue 1643: Some servers respond with an untagged EXISTS to every
NOOP.  This change parses through all untagged responses in a loop
until no more are being generated, avoiding calling internalOpen each
time.

Issue 1664: I have never personally seen this error, and the log looks
like a thread safety problem.  mMessageCount is being set in one
thread (the IDLE thread) but not properly visible in another thread
(the check mail thread).  mMessageCount and other ImapFolder private
variables are now volatile in hopes of correcting this problem.
This commit is contained in:
Daniel Applebaum 2010-05-26 03:24:33 +00:00
parent 0d649da82f
commit 291f6d18a2

View File

@ -446,11 +446,11 @@ public class ImapStore extends Store
class ImapFolder extends Folder class ImapFolder extends Folder
{ {
private String mName; private String mName;
protected int mMessageCount = -1; protected volatile int mMessageCount = -1;
protected int uidNext = -1; protected volatile int uidNext = -1;
protected ImapConnection mConnection; protected volatile ImapConnection mConnection;
private OpenMode mMode; private OpenMode mMode;
private boolean mExists; private volatile boolean mExists;
private ImapStore store = null; private ImapStore store = null;
Map<Integer, String> msgSeqUidMap = new ConcurrentHashMap<Integer, String>(); Map<Integer, String> msgSeqUidMap = new ConcurrentHashMap<Integer, String>();
@ -2850,6 +2850,10 @@ public class ImapStore extends Store
processUntaggedResponses(untaggedResponses); processUntaggedResponses(untaggedResponses);
receiver.syncFolder(ImapFolderPusher.this); receiver.syncFolder(ImapFolderPusher.this);
} }
if (stop.get() == true)
{
continue;
}
int startUid = oldUidNext; int startUid = oldUidNext;
int newUidNext = uidNext; int newUidNext = uidNext;
@ -2899,36 +2903,29 @@ public class ImapStore extends Store
} }
else else
{ {
if (stop.get() == false) List<ImapResponse> untaggedResponses = null;
while (storedUntaggedResponses.size() > 0)
{ {
List<ImapResponse> untaggedResponses = null; if (K9.DEBUG)
if (storedUntaggedResponses.size() > 0) Log.i(K9.LOG_TAG, "Processing " + storedUntaggedResponses.size() + " untagged responses from previous commands for " + getLogId());
{ untaggedResponses = new ArrayList<ImapResponse>(storedUntaggedResponses);
if (K9.DEBUG) storedUntaggedResponses.clear();
Log.i(K9.LOG_TAG, "Processing " + storedUntaggedResponses.size() + " from previous commands for " + getLogId()); processUntaggedResponses(untaggedResponses);
untaggedResponses = new ArrayList<ImapResponse>(storedUntaggedResponses);
}
else
{
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "About to IDLE for " + getLogId());
receiver.setPushActive(getName(), true);
idling.set(true);
doneSent.set(false);
mConnection.setReadTimeout((getAccount().getIdleRefreshMinutes() * 60 * 1000) + IDLE_READ_TIMEOUT_INCREMENT);
untaggedResponses = executeSimpleCommand(COMMAND_IDLE, false, ImapFolderPusher.this);
idling.set(false);
}
if (stop.get() == false)
{
storedUntaggedResponses.clear();
processUntaggedResponses(untaggedResponses);
}
delayTime.set(NORMAL_DELAY_TIME);
idleFailureCount.set(0);
} }
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "About to IDLE for " + getLogId());
receiver.setPushActive(getName(), true);
idling.set(true);
doneSent.set(false);
mConnection.setReadTimeout((getAccount().getIdleRefreshMinutes() * 60 * 1000) + IDLE_READ_TIMEOUT_INCREMENT);
untaggedResponses = executeSimpleCommand(COMMAND_IDLE, false, ImapFolderPusher.this);
idling.set(false);
delayTime.set(NORMAL_DELAY_TIME);
idleFailureCount.set(0);
} }
} }
catch (Exception e) catch (Exception e)