]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Fixed assert-crash in mailbox syncing, if mailbox couldn't be opened.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 28 Jan 2016 14:26:53 +0000 (16:26 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 28 Jan 2016 14:26:53 +0000 (16:26 +0200)
Usually meaning that syncing was attempted when IMAP server couldn't be
connected to. Fixes the assert:

Panic: file imapc-client.c: line 439 (imapc_client_get_capabilities):
assertion failed: (conn != NULL)

src/lib-storage/index/imapc/imapc-sync.c

index ba3662d571b56c4f64a73753f9fb9200ba3c41aa..5c4db8bf625faab50c7ec9fa1faa9bc92751b9e6 100644 (file)
@@ -502,12 +502,28 @@ static int imapc_sync(struct imapc_mailbox *mbox)
        return 0;
 }
 
+static void
+imapc_noop_if_needed(struct imapc_mailbox *mbox, enum mailbox_sync_flags flags)
+{
+       enum imapc_capability capabilities;
+
+       capabilities = imapc_client_get_capabilities(mbox->storage->client->client);
+       if ((capabilities & IMAPC_CAPABILITY_IDLE) == 0 ||
+           (flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0) {
+               /* do NOOP to make sure we have the latest changes before
+                  starting sync. this is necessary either because se don't
+                  support IDLE at all, or because we want to be sure that we
+                  have the latest changes (IDLE is started with a small delay,
+                  so we might not actually even be in IDLE right not) */
+               imapc_mailbox_noop(mbox);
+       }
+}
+
 struct mailbox_sync_context *
 imapc_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
 {
        struct imapc_mailbox *mbox = (struct imapc_mailbox *)box;
        struct imapc_mailbox_list *list = mbox->storage->client->_list;
-       enum imapc_capability capabilities;
        bool changes;
        int ret = 0;
 
@@ -522,16 +538,8 @@ imapc_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
                        ret = -1;
        }
 
-       capabilities = imapc_client_get_capabilities(mbox->storage->client->client);
-       if ((capabilities & IMAPC_CAPABILITY_IDLE) == 0 ||
-           (flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0) {
-               /* do NOOP to make sure we have the latest changes before
-                  starting sync. this is necessary either because se don't
-                  support IDLE at all, or because we want to be sure that we
-                  have the latest changes (IDLE is started with a small delay,
-                  so we might not actually even be in IDLE right not) */
-               imapc_mailbox_noop(mbox);
-       }
+       if (ret == 0)
+               imapc_noop_if_needed(mbox, flags);
 
        if (imapc_mailbox_commit_delayed_trans(mbox, &changes) < 0)
                ret = -1;