[dovecot-cvs] dovecot/src/plugins/fts fts-storage.c,1.10,1.11
tss at dovecot.org
tss at dovecot.org
Sat Dec 9 21:08:30 UTC 2006
- Previous message: [dovecot-cvs] dovecot/src/lib file-lock.c,1.10,1.11
- Next message: [dovecot-cvs] dovecot/src/plugins/fts-squat fts-backend-squat.c, 1.3, 1.4 squat-trie.c, 1.3, 1.4 squat-uidlist.c, 1.3, 1.4 squat-uidlist.h, 1.3, 1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/plugins/fts
In directory talvi:/tmp/cvs-serv17533/fts
Modified Files:
fts-storage.c
Log Message:
Delay calling fts_backend_init() until first transaction is created. By that
time the mailbox has been synced and things like uidvalidity can be looked
up.
Index: fts-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-storage.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- fts-storage.c 6 Dec 2006 15:45:15 -0000 1.10
+++ fts-storage.c 9 Dec 2006 21:08:27 -0000 1.11
@@ -20,6 +20,9 @@
struct fts_mailbox {
struct mailbox_vfuncs super;
struct fts_backend *backend;
+
+ const char *env;
+ unsigned int backend_failed:1;
};
struct fts_search_context {
@@ -45,7 +48,8 @@
struct fts_mailbox *fbox = FTS_CONTEXT(box);
int ret;
- fts_backend_deinit(fbox->backend);
+ if (fbox->backend != NULL)
+ fts_backend_deinit(fbox->backend);
ret = fbox->super.close(box);
i_free(fbox);
@@ -281,6 +285,9 @@
fctx = i_new(struct fts_search_context, 1);
array_idx_set(&ctx->module_contexts, fts_storage_module_id, &fctx);
+ if (fbox->backend == NULL)
+ return ctx;
+
/* FIXME: handle AND/OR. Maybe also header lookups? */
while (args != NULL &&
args->type != SEARCH_BODY &&
@@ -393,10 +400,12 @@
struct mail_private *mail = (struct mail_private *)_mail;
struct fts_mail *fmail = FTS_CONTEXT(mail);
struct fts_mailbox *fbox = FTS_CONTEXT(_mail->box);
+ struct fts_transaction_context *ft = FTS_CONTEXT(_mail->transaction);
if (fmail->super.expunge(_mail) < 0)
return -1;
+ ft->expunges = TRUE;
fts_backend_expunge(fbox->backend, _mail);
return 0;
}
@@ -407,21 +416,21 @@
struct mailbox_header_lookup_ctx *wanted_headers)
{
struct fts_mailbox *fbox = FTS_CONTEXT(t->box);
- struct fts_transaction_context *ft = FTS_CONTEXT(t);
struct fts_mail *fmail;
struct mail *_mail;
struct mail_private *mail;
_mail = fbox->super.mail_alloc(t, wanted_fields, wanted_headers);
- mail = (struct mail_private *)_mail;
-
- ft->expunges = TRUE;
+ if (fbox->backend != NULL) {
+ mail = (struct mail_private *)_mail;
- fmail = p_new(mail->pool, struct fts_mail, 1);
- fmail->super = mail->v;
+ fmail = p_new(mail->pool, struct fts_mail, 1);
+ fmail->super = mail->v;
- mail->v.expunge = fts_mail_expunge;
- array_idx_set(&mail->module_contexts, fts_storage_module_id, &fmail);
+ mail->v.expunge = fts_mail_expunge;
+ array_idx_set(&mail->module_contexts,
+ fts_storage_module_id, &fmail);
+ }
return _mail;
}
@@ -435,6 +444,14 @@
ft = i_new(struct fts_transaction_context, 1);
+ /* the backend creation is delayed until the first transaction is
+ started. at that point the mailbox has been synced at least once. */
+ if (fbox->backend == NULL && !fbox->backend_failed) {
+ fbox->backend = fts_backend_init(fbox->env, box);
+ if (fbox->backend == NULL)
+ fbox->backend_failed = TRUE;
+ }
+
t = fbox->super.transaction_begin(box, flags);
array_idx_set(&t->module_contexts, fts_storage_module_id, &ft);
return t;
@@ -470,7 +487,6 @@
void fts_mailbox_opened(struct mailbox *box)
{
struct fts_mailbox *fbox;
- struct fts_backend *backend;
const char *env;
if (fts_next_hook_mailbox_opened != NULL)
@@ -480,13 +496,9 @@
if (env == NULL)
return;
- backend = fts_backend_init(env, box);
- if (backend == NULL)
- return;
-
fbox = i_new(struct fts_mailbox, 1);
+ fbox->env = env;
fbox->super = box->v;
- fbox->backend = backend;
box->v.close = fts_mailbox_close;
box->v.search_init = fts_mailbox_search_init;
box->v.search_next_update_seq = fts_mailbox_search_next_update_seq;
- Previous message: [dovecot-cvs] dovecot/src/lib file-lock.c,1.10,1.11
- Next message: [dovecot-cvs] dovecot/src/plugins/fts-squat fts-backend-squat.c, 1.3, 1.4 squat-trie.c, 1.3, 1.4 squat-uidlist.c, 1.3, 1.4 squat-uidlist.h, 1.3, 1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list