[evolution-data-server] [IMAPx] Incorrect mailbox used for untagged OK/NO/BAD with pending SELECT



commit 95c939ce685c83a191f66496c46e935006d6b863
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 3 18:37:57 2014 +0200

    [IMAPx] Incorrect mailbox used for untagged OK/NO/BAD with pending SELECT
    
    With a pending SELECT command a closing mailbox was used as the one
    to which untagged OK/NO/BAD responses might belong, but it was not
    correct, because for example UIDVALIDITY response belongs to the mailbox
    which was pending the selection. This misinterpretation caused incorrect
    offline cache clean ups.
    
    I guess this also fixes bug 691523, but I only guess it.

 camel/providers/imapx/camel-imapx-server.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 914ed23..9418a42 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -2788,7 +2788,22 @@ imapx_untagged_ok_no_bad (CamelIMAPXServer *is,
                is->priv->context->token,
                is->priv->context->len);
 
-       mailbox = camel_imapx_server_ref_selected (is);
+       /* These untagged responses can belong to ongoing SELECT command, thus
+          to the pending select mailbox, not to the currently selected or closing
+          mailbox, thus prefer the select pending mailbox, from the other two.
+          This makes sure that for example UIDVALIDITY is not incorrectly
+          overwritten with a value from a different mailbox, thus the offline
+          cache will persist, instead of being vanished.
+       */
+       g_mutex_lock (&is->priv->select_lock);
+
+       mailbox = g_weak_ref_get (&is->priv->select_pending);
+       if (!mailbox)
+               mailbox = g_weak_ref_get (&is->priv->select_mailbox);
+       if (!mailbox)
+               mailbox = g_weak_ref_get (&is->priv->select_closing);
+
+       g_mutex_unlock (&is->priv->select_lock);
 
        is->priv->context->sinfo = imapx_parse_status (
                CAMEL_IMAPX_INPUT_STREAM (input_stream),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]