1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 09:08:49 -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
{
private String mName;
protected int mMessageCount = -1;
protected int uidNext = -1;
protected ImapConnection mConnection;
protected volatile int mMessageCount = -1;
protected volatile int uidNext = -1;
protected volatile ImapConnection mConnection;
private OpenMode mMode;
private boolean mExists;
private volatile boolean mExists;
private ImapStore store = null;
Map<Integer, String> msgSeqUidMap = new ConcurrentHashMap<Integer, String>();
@ -2850,6 +2850,10 @@ public class ImapStore extends Store
processUntaggedResponses(untaggedResponses);
receiver.syncFolder(ImapFolderPusher.this);
}
if (stop.get() == true)
{
continue;
}
int startUid = oldUidNext;
int newUidNext = uidNext;
@ -2898,18 +2902,17 @@ public class ImapStore extends Store
}
else
{
if (stop.get() == false)
{
List<ImapResponse> untaggedResponses = null;
if (storedUntaggedResponses.size() > 0)
while (storedUntaggedResponses.size() > 0)
{
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "Processing " + storedUntaggedResponses.size() + " from previous commands for " + getLogId());
Log.i(K9.LOG_TAG, "Processing " + storedUntaggedResponses.size() + " untagged responses from previous commands for " + getLogId());
untaggedResponses = new ArrayList<ImapResponse>(storedUntaggedResponses);
storedUntaggedResponses.clear();
processUntaggedResponses(untaggedResponses);
}
else
{
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "About to IDLE for " + getLogId());
@ -2920,17 +2923,11 @@ public class ImapStore extends Store
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);
}
}
}
catch (Exception e)
{
wakeLock.acquire(K9.PUSH_WAKE_LOCK_TIMEOUT);