]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts: Tell backends if we're currently in the code because we're syncing.
authorTimo Sirainen <tss@iki.fi>
Thu, 4 Aug 2011 13:44:33 +0000 (16:44 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 4 Aug 2011 13:44:33 +0000 (16:44 +0300)
That basically means it's either indexer process or doveadm index.

src/plugins/fts/fts-api-private.h
src/plugins/fts/fts-storage.c

index 50a30c620170a88dda65b0a0239bb60d059575bf..dfe7d874ecef07d09f39d8768f442ef2e1a3b97f 100644 (file)
@@ -61,6 +61,7 @@ struct fts_backend {
        struct mail_namespace *ns;
 
        unsigned int updating:1;
+       unsigned int syncing:1;
 };
 
 struct fts_backend_update_context {
index 3a687f9fe5dec4175915e58b039e02e6a8ffb580..2071f061bc548f60d5981a8d84b54ed6e8f8b926 100644 (file)
@@ -421,6 +421,7 @@ static int fts_sync_deinit(struct mailbox_sync_context *ctx,
        struct fts_mailbox *fbox = FTS_CONTEXT(box);
        struct fts_mailbox_list *flist = FTS_LIST_CONTEXT(box->list);
        bool precache, force_resync;
+       int ret = 0;
 
        precache = (ctx->flags & MAILBOX_SYNC_FLAG_PRECACHE) != 0;
        force_resync = (ctx->flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0;
@@ -428,11 +429,13 @@ static int fts_sync_deinit(struct mailbox_sync_context *ctx,
                return -1;
        ctx = NULL;
 
+       flist->backend->syncing = TRUE;
        if (force_resync) {
                if (fts_backend_optimize(flist->backend) < 0) {
                        mail_storage_set_critical(box->storage,
                                "FTS optimize for mailbox %s failed",
                                box->vname);
+                       ret = -1;
                }
        }
        if (precache) {
@@ -440,10 +443,11 @@ static int fts_sync_deinit(struct mailbox_sync_context *ctx,
                        mail_storage_set_critical(box->storage,
                                "FTS index update for mailbox %s failed",
                                box->vname);
-                       return -1;
+                       ret = -1;
                }
        }
-       return 0;
+       flist->backend->syncing = FALSE;
+       return ret;
 }
 
 void fts_mailbox_allocated(struct mailbox *box)