# HG changeset patch # User Timo Sirainen # Date 1265550273 -7200 # Node ID e7f066508299062271d73a4ed6ccdffe18511285 # Parent 9d3b5cbef2224d4fdb10ffb231c802a717da640b lib-storage: Moved struct mail_index_* from index_mailbox to mailbox. We're relying more and more of all mailboxes being used via lib-index, and this change makes accessing the indexes easier. diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/cydir/cydir-save.c --- a/src/lib-storage/index/cydir/cydir-save.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/cydir/cydir-save.c Sun Feb 07 15:44:33 2010 +0200 @@ -85,7 +85,7 @@ enum mail_flags save_flags; struct istream *crlf_input; - if (mail_index_is_deleted(ctx->mbox->ibox.index)) { + if (mail_index_is_deleted(trans->box->index)) { mailbox_set_deleted(trans->box); return -1; } diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/cydir/cydir-storage.c --- a/src/lib-storage/index/cydir/cydir-storage.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/cydir/cydir-storage.c Sun Feb 07 15:44:33 2010 +0200 @@ -65,7 +65,7 @@ mbox->ibox.box.pool = pool; mbox->ibox.box.storage = storage; mbox->ibox.box.list = list; - mbox->ibox.mail_vfuncs = &cydir_mail_vfuncs; + mbox->ibox.box.mail_vfuncs = &cydir_mail_vfuncs; mbox->ibox.save_commit_pre = cydir_transaction_save_commit_pre; mbox->ibox.save_commit_post = cydir_transaction_save_commit_post; @@ -73,7 +73,7 @@ index_storage_mailbox_alloc(&mbox->ibox, name, input, flags, CYDIR_INDEX_PREFIX); - mail_index_set_fsync_types(mbox->ibox.index, + mail_index_set_fsync_types(mbox->ibox.box.index, MAIL_INDEX_SYNC_TYPE_APPEND | MAIL_INDEX_SYNC_TYPE_EXPUNGE); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/cydir/cydir-sync.c --- a/src/lib-storage/index/cydir/cydir-sync.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/cydir/cydir-sync.c Sun Feb 07 15:44:33 2010 +0200 @@ -122,12 +122,12 @@ if (!force) sync_flags |= MAIL_INDEX_SYNC_FLAG_REQUIRE_CHANGES; - ret = mail_index_sync_begin(mbox->ibox.index, &ctx->index_sync_ctx, + ret = mail_index_sync_begin(mbox->ibox.box.index, &ctx->index_sync_ctx, &ctx->sync_view, &ctx->trans, sync_flags); if (ret <= 0) { if (ret < 0) - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(&mbox->ibox.box); i_free(ctx); *ctx_r = NULL; return ret; @@ -146,7 +146,7 @@ *_ctx = NULL; if (success) { if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) { - mail_storage_set_index_error(&ctx->mbox->ibox); + mail_storage_set_index_error(&ctx->mbox->ibox.box); ret = -1; } } else { diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/dbox-common/dbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c Sun Feb 07 15:44:33 2010 +0200 @@ -99,7 +99,7 @@ ctx->trans = trans; mail_index_reset(ctx->trans); index_mailbox_reset_uidvalidity(ibox); - mail_index_ext_lookup(ibox->index, "cache", &ctx->cache_ext_id); + mail_index_ext_lookup(box->index, "cache", &ctx->cache_ext_id); /* if backup index file exists, try to use it */ index_dir = mailbox_list_get_path(box->list, box->name, diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/dbox-multi/mdbox-mail.c --- a/src/lib-storage/index/dbox-multi/mdbox-mail.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-mail.c Sun Feb 07 15:44:33 2010 +0200 @@ -61,8 +61,8 @@ struct mdbox_mailbox *mbox = (struct mdbox_mailbox *)mail->imail.ibox; struct mail *_mail = &mail->imail.mail.mail; - (void)mail_index_refresh(mbox->ibox.index); - if (mail_index_is_expunged(mbox->ibox.view, _mail->seq)) { + (void)mail_index_refresh(_mail->box->index); + if (mail_index_is_expunged(_mail->box->view, _mail->seq)) { mail_set_expunged(_mail); return; } @@ -112,8 +112,8 @@ if (mail->open_file != NULL) { /* already open */ } else if (_mail->uid != 0) { - if (mdbox_mail_lookup(mbox, mbox->ibox.view, _mail->seq, - &map_uid) < 0) + if (mdbox_mail_lookup(mbox, _mail->box->view, + _mail->seq, &map_uid) < 0) return -1; if (dbox_mail_open_init(mail, map_uid) < 0) return -1; @@ -160,7 +160,7 @@ const void *data; bool expunged; - mail_index_lookup_ext(mbox->ibox.view, mail->seq, + mail_index_lookup_ext(mail->box->view, mail->seq, mbox->ext_id, &data, &expunged); dbox_rec = data; if (dbox_rec == NULL || dbox_rec->map_uid == 0) { diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/dbox-multi/mdbox-save.c --- a/src/lib-storage/index/dbox-multi/mdbox-save.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c Sun Feb 07 15:44:33 2010 +0200 @@ -97,7 +97,7 @@ struct dbox_save_mail *save_mail; uoff_t mail_size, append_offset; - if (mail_index_is_deleted(ctx->mbox->ibox.index)) { + if (mail_index_is_deleted(_ctx->transaction->box->index)) { mailbox_set_deleted(_ctx->transaction->box); return -1; } @@ -344,7 +344,7 @@ memset(&rec, 0, sizeof(rec)); rec.save_date = ioloop_time; - if (mdbox_mail_lookup(src_mbox, src_mbox->ibox.view, mail->seq, + if (mdbox_mail_lookup(src_mbox, mail->box->view, mail->seq, &rec.map_uid) < 0) return -1; @@ -358,7 +358,7 @@ mail_index_update_ext(ctx->ctx.trans, ctx->ctx.seq, ctx->mbox->ext_id, &rec, NULL); - mail_index_lookup_ext(src_mbox->ibox.view, mail->seq, + mail_index_lookup_ext(mail->box->view, mail->seq, src_mbox->guid_ext_id, &data, &expunged); if (data != NULL) { mail_index_update_ext(ctx->ctx.trans, ctx->ctx.seq, diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Sun Feb 07 15:44:33 2010 +0200 @@ -420,11 +420,11 @@ } mbox = (struct mdbox_mailbox *)box; - ret = mail_index_sync_begin(mbox->ibox.index, &sync_ctx, &view, &trans, + ret = mail_index_sync_begin(box->index, &sync_ctx, &view, &trans, MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES); if (ret <= 0) { i_assert(ret != 0); - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(box); mailbox_close(&box); return -1; } @@ -434,7 +434,7 @@ dbox_sync_index_rebuild_deinit(&rebuild_ctx); if (mail_index_sync_commit(&sync_ctx) < 0) { - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(box); ret = -1; } @@ -580,13 +580,13 @@ return -1; } if (ctx->prev_msg.box == NULL) { - ret = mail_index_sync_begin(mbox->ibox.index, + ret = mail_index_sync_begin(box->index, &ctx->prev_msg.sync_ctx, &ctx->prev_msg.view, &ctx->prev_msg.trans, 0); if (ret <= 0) { i_assert(ret != 0); - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(box); mailbox_close(&box); return -1; } diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/dbox-multi/mdbox-storage.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c Sun Feb 07 15:44:33 2010 +0200 @@ -116,7 +116,7 @@ mbox->ibox.box.pool = pool; mbox->ibox.box.storage = storage; mbox->ibox.box.list = list; - mbox->ibox.mail_vfuncs = &mdbox_mail_vfuncs; + mbox->ibox.box.mail_vfuncs = &mdbox_mail_vfuncs; mbox->ibox.save_commit_pre = mdbox_transaction_save_commit_pre; mbox->ibox.save_commit_post = mdbox_transaction_save_commit_post; @@ -124,7 +124,7 @@ index_storage_mailbox_alloc(&mbox->ibox, name, input, flags, DBOX_INDEX_PREFIX); - mail_index_set_fsync_types(mbox->ibox.index, + mail_index_set_fsync_types(mbox->ibox.box.index, MAIL_INDEX_SYNC_TYPE_APPEND | MAIL_INDEX_SYNC_TYPE_EXPUNGE); @@ -133,14 +133,14 @@ mbox->storage = (struct mdbox_storage *)storage; mbox->ext_id = - mail_index_ext_register(mbox->ibox.index, "mdbox", 0, + mail_index_ext_register(mbox->ibox.box.index, "mdbox", 0, sizeof(struct mdbox_mail_index_record), sizeof(uint32_t)); mbox->hdr_ext_id = - mail_index_ext_register(mbox->ibox.index, "mdbox-hdr", + mail_index_ext_register(mbox->ibox.box.index, "mdbox-hdr", sizeof(struct mdbox_index_header), 0, 0); mbox->guid_ext_id = - mail_index_ext_register(mbox->ibox.index, "guid", + mail_index_ext_register(mbox->ibox.box.index, "guid", 0, MAIL_GUID_128_SIZE, 1); return &mbox->ibox.box; } @@ -151,7 +151,7 @@ const void *data; size_t data_size; - mail_index_get_header_ext(mbox->ibox.view, mbox->hdr_ext_id, + mail_index_get_header_ext(mbox->ibox.box.view, mbox->hdr_ext_id, &data, &data_size); if (data_size < MDBOX_INDEX_HEADER_MIN_SIZE && (!mbox->creating || data_size != 0)) { @@ -202,8 +202,8 @@ if (dbox_map_open(mbox->storage->map, TRUE) < 0) return -1; - hdr = mail_index_get_header(mbox->ibox.view); - trans = mail_index_transaction_begin(mbox->ibox.view, 0); + hdr = mail_index_get_header(box->view); + trans = mail_index_transaction_begin(box->view, 0); mdbox_update_header(mbox, trans, update); uid_validity = hdr->uid_validity; @@ -226,7 +226,7 @@ &uid_next, sizeof(uid_next), TRUE); } if (update != NULL && update->min_highest_modseq != 0 && - mail_index_modseq_get_highest(mbox->ibox.view) < + mail_index_modseq_get_highest(box->view) < update->min_highest_modseq) { mail_index_update_highest_modseq(trans, update->min_highest_modseq); @@ -234,7 +234,7 @@ if (mail_index_transaction_commit(&trans) < 0) { mail_storage_set_internal_error(box->storage); - mail_index_reset_error(mbox->ibox.index); + mail_index_reset_error(box->index); return -1; } return 0; @@ -326,9 +326,9 @@ /* get a list of all map_uids in this mailbox */ i_array_init(&map_uids, 128); - hdr = mail_index_get_header(mbox->ibox.view); + hdr = mail_index_get_header(box->view); for (seq = 1; seq <= hdr->messages_count; seq++) { - mail_index_lookup_ext(mbox->ibox.view, seq, mbox->ext_id, + mail_index_lookup_ext(box->view, seq, mbox->ext_id, &data, &expunged); dbox_rec = data; if (dbox_rec == NULL) { diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/dbox-multi/mdbox-sync.c --- a/src/lib-storage/index/dbox-multi/mdbox-sync.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-sync.c Sun Feb 07 15:44:33 2010 +0200 @@ -167,14 +167,14 @@ struct mdbox_index_header hdr; int ret; - view = mail_index_view_open(mbox->ibox.index); + view = mail_index_view_open(mbox->ibox.box.index); ret = mdbox_read_header(mbox, &hdr); mail_index_view_close(&view); if (ret == 0) { ret = mbox->storage->storage.files_corrupted ? -1 : 0; } else if (retry) { - (void)mail_index_refresh(mbox->ibox.index); + (void)mail_index_refresh(mbox->ibox.box.index); return mdbox_refresh_header(mbox, FALSE); } return ret; @@ -213,13 +213,13 @@ sync_flags |= MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES; for (i = 0;; i++) { - ret = mail_index_sync_begin(mbox->ibox.index, + ret = mail_index_sync_begin(mbox->ibox.box.index, &ctx->index_sync_ctx, &ctx->sync_view, &ctx->trans, sync_flags); if (ret <= 0) { if (ret < 0) - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(&mbox->ibox.box); i_free(ctx); *ctx_r = NULL; return ret; @@ -269,7 +269,7 @@ if (success) { if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) { - mail_storage_set_index_error(&ctx->mbox->ibox); + mail_storage_set_index_error(&ctx->mbox->ibox.box); ret = -1; } } else { diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/dbox-single/sdbox-mail.c --- a/src/lib-storage/index/dbox-single/sdbox-mail.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-mail.c Sun Feb 07 15:44:33 2010 +0200 @@ -17,8 +17,8 @@ struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)mail->imail.ibox; struct mail *_mail = &mail->imail.mail.mail; - (void)mail_index_refresh(mbox->ibox.index); - if (mail_index_is_expunged(mbox->ibox.view, _mail->seq)) { + (void)mail_index_refresh(_mail->box->index); + if (mail_index_is_expunged(_mail->box->view, _mail->seq)) { mail_set_expunged(_mail); return; } diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/dbox-single/sdbox-save.c --- a/src/lib-storage/index/dbox-single/sdbox-save.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-save.c Sun Feb 07 15:44:33 2010 +0200 @@ -78,7 +78,7 @@ struct dbox_file *file; int ret; - if (mail_index_is_deleted(ctx->mbox->ibox.index)) { + if (mail_index_is_deleted(_ctx->transaction->box->index)) { mailbox_set_deleted(_ctx->transaction->box); return -1; } diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/dbox-single/sdbox-storage.c --- a/src/lib-storage/index/dbox-single/sdbox-storage.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Sun Feb 07 15:44:33 2010 +0200 @@ -65,7 +65,7 @@ mbox->ibox.box.pool = pool; mbox->ibox.box.storage = storage; mbox->ibox.box.list = list; - mbox->ibox.mail_vfuncs = &sdbox_mail_vfuncs; + mbox->ibox.box.mail_vfuncs = &sdbox_mail_vfuncs; mbox->ibox.save_commit_pre = sdbox_transaction_save_commit_pre; mbox->ibox.save_commit_post = sdbox_transaction_save_commit_post; @@ -73,7 +73,7 @@ index_storage_mailbox_alloc(&mbox->ibox, name, input, flags, DBOX_INDEX_PREFIX); - mail_index_set_fsync_types(mbox->ibox.index, + mail_index_set_fsync_types(mbox->ibox.box.index, MAIL_INDEX_SYNC_TYPE_APPEND | MAIL_INDEX_SYNC_TYPE_EXPUNGE); @@ -85,7 +85,7 @@ p_strconcat(pool, list->set.alt_dir, "/", list->set.maildir_name, NULL); mbox->hdr_ext_id = - mail_index_ext_register(mbox->ibox.index, "dbox-hdr", + mail_index_ext_register(mbox->ibox.box.index, "dbox-hdr", sizeof(struct sdbox_index_header), 0, 0); return &mbox->ibox.box; } @@ -96,7 +96,7 @@ const void *data; size_t data_size; - mail_index_get_header_ext(mbox->ibox.view, mbox->hdr_ext_id, + mail_index_get_header_ext(mbox->ibox.box.view, mbox->hdr_ext_id, &data, &data_size); if (data_size < SDBOX_INDEX_HEADER_MIN_SIZE && (!mbox->creating || data_size != 0)) { @@ -142,8 +142,8 @@ const struct mail_index_header *hdr; uint32_t uid_validity, uid_next; - hdr = mail_index_get_header(mbox->ibox.view); - trans = mail_index_transaction_begin(mbox->ibox.view, 0); + hdr = mail_index_get_header(box->view); + trans = mail_index_transaction_begin(box->view, 0); sdbox_update_header(mbox, trans, update); if (update != NULL && update->uid_validity != 0) @@ -165,7 +165,7 @@ &uid_next, sizeof(uid_next), TRUE); } if (update != NULL && update->min_highest_modseq != 0 && - mail_index_modseq_get_highest(mbox->ibox.view) < + mail_index_modseq_get_highest(box->view) < update->min_highest_modseq) { mail_index_update_highest_modseq(trans, update->min_highest_modseq); @@ -173,7 +173,7 @@ if (mail_index_transaction_commit(&trans) < 0) { mail_storage_set_internal_error(box->storage); - mail_index_reset_error(mbox->ibox.index); + mail_index_reset_error(box->index); return -1; } return 0; diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c --- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Sun Feb 07 15:44:33 2010 +0200 @@ -162,7 +162,7 @@ struct mail_index_transaction *trans; int ret; - view = mail_index_view_open(mbox->ibox.index); + view = mail_index_view_open(mbox->ibox.box.index); trans = mail_index_transaction_begin(view, MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/dbox-single/sdbox-sync.c --- a/src/lib-storage/index/dbox-single/sdbox-sync.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c Sun Feb 07 15:44:33 2010 +0200 @@ -148,14 +148,14 @@ struct sdbox_index_header hdr; int ret; - view = mail_index_view_open(mbox->ibox.index); + view = mail_index_view_open(mbox->ibox.box.index); ret = sdbox_read_header(mbox, &hdr); mail_index_view_close(&view); if (ret == 0) { ret = mbox->sync_rebuild ? -1 : 0; } else if (retry) { - (void)mail_index_refresh(mbox->ibox.index); + (void)mail_index_refresh(mbox->ibox.box.index); return sdbox_refresh_header(mbox, FALSE); } return ret; @@ -188,13 +188,13 @@ sync_flags |= MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES; for (i = 0;; i++) { - ret = mail_index_sync_begin(mbox->ibox.index, + ret = mail_index_sync_begin(mbox->ibox.box.index, &ctx->index_sync_ctx, &ctx->sync_view, &ctx->trans, sync_flags); if (ret <= 0) { if (ret < 0) - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(&mbox->ibox.box); i_free(ctx); *ctx_r = NULL; return ret; @@ -243,7 +243,7 @@ if (success) { if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) { - mail_storage_set_index_error(&ctx->mbox->ibox); + mail_storage_set_index_error(&ctx->mbox->ibox.box); ret = -1; } } else { diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-fetch.c --- a/src/lib-storage/index/index-fetch.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-fetch.c Sun Feb 07 15:44:33 2010 +0200 @@ -10,16 +10,13 @@ uint32_t uid1, uint32_t uid2, uint32_t *seq1_r, uint32_t *seq2_r) { - struct index_mailbox *ibox = (struct index_mailbox *)box; - - mail_index_lookup_seq_range(ibox->view, uid1, uid2, seq1_r, seq2_r); + mail_index_lookup_seq_range(box->view, uid1, uid2, seq1_r, seq2_r); } void index_storage_get_uid_range(struct mailbox *box, const ARRAY_TYPE(seq_range) *seqs, ARRAY_TYPE(seq_range) *uids) { - struct index_mailbox *ibox = (struct index_mailbox *)box; const struct seq_range *range; unsigned int i, count; uint32_t seq, uid; @@ -28,12 +25,12 @@ for (i = 0; i < count; i++) { if (range[i].seq2 == (uint32_t)-1) { i_assert(count == i-1); - mail_index_lookup_uid(ibox->view, range[i].seq1, &uid); + mail_index_lookup_uid(box->view, range[i].seq1, &uid); seq_range_array_add_range(uids, uid, (uint32_t)-1); break; } for (seq = range[i].seq1; seq <= range[i].seq2; seq++) { - mail_index_lookup_uid(ibox->view, seq, &uid); + mail_index_lookup_uid(box->view, seq, &uid); seq_range_array_add(uids, 0, uid); } } @@ -82,7 +79,6 @@ const ARRAY_TYPE(seq_range) *uids_filter, ARRAY_TYPE(mailbox_expunge_rec) *expunges) { - struct index_mailbox *ibox = (struct index_mailbox *)box; struct mail_transaction_log_view *log_view; const struct mail_transaction_header *thdr; const void *tdata; @@ -91,27 +87,27 @@ bool reset; int ret; - if (!mail_index_modseq_get_next_log_offset(ibox->view, prev_modseq, + if (!mail_index_modseq_get_next_log_offset(box->view, prev_modseq, &log_seq, &log_offset)) return FALSE; - if (log_seq > ibox->view->log_file_head_seq || - (log_seq == ibox->view->log_file_head_seq && - log_offset >= ibox->view->log_file_head_offset)) { + if (log_seq > box->view->log_file_head_seq || + (log_seq == box->view->log_file_head_seq && + log_offset >= box->view->log_file_head_offset)) { /* we haven't seen this high expunges at all */ return TRUE; } - log_view = mail_transaction_log_view_open(ibox->index->log); + log_view = mail_transaction_log_view_open(box->index->log); ret = mail_transaction_log_view_set(log_view, log_seq, log_offset, - ibox->view->log_file_head_seq, - ibox->view->log_file_head_offset, + box->view->log_file_head_seq, + box->view->log_file_head_offset, &reset); if (ret == 0) { - mail_transaction_log_get_tail(ibox->index->log, &tail_seq); + mail_transaction_log_get_tail(box->index->log, &tail_seq); i_assert(tail_seq > log_seq); ret = mail_transaction_log_view_set(log_view, tail_seq, 0, - ibox->view->log_file_head_seq, - ibox->view->log_file_head_offset, + box->view->log_file_head_seq, + box->view->log_file_head_offset, &reset); i_assert(ret != 0); } diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-mail-headers.c --- a/src/lib-storage/index/index-mail-headers.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-mail-headers.c Sun Feb 07 15:44:33 2010 +0200 @@ -146,7 +146,7 @@ } static unsigned int -get_header_field_idx(struct index_mailbox *ibox, const char *field, +get_header_field_idx(struct mailbox *box, const char *field, enum mail_cache_decision_type decision) { struct mail_cache_field header_field = { @@ -157,7 +157,7 @@ header_field.decision = decision; T_BEGIN { header_field.name = t_strconcat("hdr.", field, NULL); - mail_cache_register_fields(ibox->cache, &header_field, 1); + mail_cache_register_fields(box->cache, &header_field, 1); } T_END; return header_field.idx; } @@ -180,7 +180,7 @@ unsigned int i, count; all_cache_fields = - mail_cache_register_get_list(mail->ibox->cache, + mail_cache_register_get_list(mail->ibox->box.cache, pool_datastack_create(), &count); for (i = 0; i < count; i++) { if (strncasecmp(all_cache_fields[i].name, "hdr.", 4) != 0) @@ -248,7 +248,7 @@ Date: header. if we have Date field's index set at this point we know that we want it. otherwise add it and remember that we don't want it cached. */ - field_idx = get_header_field_idx(mail->ibox, "Date", + field_idx = get_header_field_idx(&mail->ibox->box, "Date", MAIL_CACHE_DECISION_NO); match = array_get(&mail->header_match, &match_count); if (field_idx < match_count && @@ -319,7 +319,7 @@ const char *cache_field_name = t_strconcat("hdr.", hdr->name, NULL); data->parse_line.field_idx = - mail_cache_register_lookup(mail->ibox->cache, + mail_cache_register_lookup(mail->ibox->box.cache, cache_field_name); } T_END; } @@ -606,7 +606,7 @@ i_assert(field != NULL); - field_idx = get_header_field_idx(mail->ibox, field, + field_idx = get_header_field_idx(&mail->ibox->box, field, MAIL_CACHE_DECISION_TEMP); dest = str_new(mail->data_pool, 128); @@ -751,7 +751,7 @@ } T_END; if (ret < 0) { - mail_cache_set_corrupted(mail->ibox->cache, + mail_cache_set_corrupted(_mail->box->cache, "Broken header %s for mail UID %u", field, _mail->uid); } @@ -779,7 +779,7 @@ } T_END; if (ret < 0) { - mail_cache_set_corrupted(mail->ibox->cache, + mail_cache_set_corrupted(_mail->box->cache, "Broken header %s for mail UID %u", field, _mail->uid); } @@ -851,7 +851,6 @@ static struct mailbox_header_lookup_ctx * index_header_lookup_init_real(struct mailbox *box, const char *const headers[]) { - struct index_mailbox *ibox = (struct index_mailbox *)box; struct mail_cache_field *fields, header_field = { NULL, 0, MAIL_CACHE_FIELD_HEADER, 0, MAIL_CACHE_DECISION_TEMP @@ -879,7 +878,7 @@ header_field.name = t_strconcat("hdr.", headers[i], NULL); fields[i] = header_field; } - mail_cache_register_fields(ibox->cache, fields, count); + mail_cache_register_fields(box->cache, fields, count); pool = pool_alloconly_create("index_header_lookup_ctx", 1024); ctx = p_new(pool, struct index_header_lookup_ctx, 1); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-mail.c Sun Feb 07 15:44:33 2010 +0200 @@ -69,7 +69,7 @@ parts = message_part_deserialize(mail->data_pool, part_buf->data, part_buf->used, &error); if (parts == NULL) { - mail_cache_set_corrupted(mail->ibox->cache, + mail_cache_set_corrupted(mail->ibox->box.cache, "Corrupted cached message_part data (%s)", error); } return parts; @@ -147,7 +147,7 @@ if (mail->data.modseq != 0) return mail->data.modseq; - mail_index_modseq_enable(mail->ibox->index); + mail_index_modseq_enable(_mail->box->index); mail->data.modseq = mail_index_modseq_lookup(mail->trans->trans_view, _mail->seq); return mail->data.modseq; @@ -429,7 +429,7 @@ if (set->mail_cache_min_mail_count > 0) { /* First check if we've configured caching not to be used with low enough message count. */ - hdr = mail_index_get_header(mail->ibox->view); + hdr = mail_index_get_header(mail->ibox->box.view); if (hdr->messages_count < set->mail_cache_min_mail_count) return; } @@ -527,7 +527,7 @@ return; } - decision = mail_cache_field_get_decision(mail->ibox->cache, + decision = mail_cache_field_get_decision(mail->ibox->box.cache, cache_field); if (decision == (MAIL_CACHE_DECISION_NO | MAIL_CACHE_DECISION_FORCED)) { /* we never want it cached */ @@ -611,7 +611,7 @@ /* normally don't cache both BODY and BODYSTRUCTURE, but do it if BODY is forced to be cached */ - dec = mail_cache_field_get_decision(mail->ibox->cache, + dec = mail_cache_field_get_decision(mail->ibox->box.cache, cache_field_body); if (plain_bodystructure || (bodystructure_cached && @@ -1090,13 +1090,13 @@ array_create(&mail->mail.module_contexts, mail->mail.pool, sizeof(void *), 5); - mail->mail.v = *ibox->mail_vfuncs; + mail->mail.v = *ibox->box.mail_vfuncs; mail->mail.mail.box = &ibox->box; mail->mail.mail.transaction = &t->mailbox_ctx; mail->mail.wanted_fields = wanted_fields; mail->mail.wanted_headers = _wanted_headers; - hdr = mail_index_get_header(ibox->view); + hdr = mail_index_get_header(ibox->box.view); mail->uid_validity = hdr->uid_validity; t->mail_ref_count++; @@ -1183,7 +1183,7 @@ /* don't waste time doing full checks for all required headers. assume that if we have "hdr.message-id" cached, we don't need to parse the header. */ - cache_field_hdr = mail_cache_register_lookup(mail->ibox->cache, + cache_field_hdr = mail_cache_register_lookup(mail->ibox->box.cache, "hdr.message-id"); if (cache_field_hdr == (unsigned int)-1 || mail_cache_field_exists(mail->trans->cache_view, @@ -1307,7 +1307,7 @@ /* open the stream only if we didn't get here from mailbox_save_init() */ - hdr = mail_index_get_header(mail->ibox->view); + hdr = mail_index_get_header(mail->ibox->box.view); if (_mail->uid != 0 && _mail->uid < hdr->next_uid) (void)mail_get_stream(_mail, NULL, NULL, &input); } @@ -1318,7 +1318,7 @@ struct index_mail *mail = (struct index_mail *)_mail; uint32_t seq; - if (mail_index_lookup_seq(mail->ibox->view, uid, &seq)) { + if (mail_index_lookup_seq(_mail->box->view, uid, &seq)) { index_mail_set_seq(_mail, seq); return TRUE; } else { @@ -1528,7 +1528,7 @@ mail_cache_transaction_reset(imail->trans->cache_trans); imail->data.no_caching = TRUE; imail->data.forced_no_caching = TRUE; - mail_cache_set_corrupted(imail->ibox->cache, + mail_cache_set_corrupted(mail->box->cache, "Broken %s for mail UID %u", field_name, mail->uid); } diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-search-result.c --- a/src/lib-storage/index/index-search-result.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-search-result.c Sun Feb 07 15:44:33 2010 +0200 @@ -139,7 +139,6 @@ int index_search_result_update_appends(struct mail_search_result *result, unsigned int old_messages_count) { - struct index_mailbox *ibox = (struct index_mailbox *)result->box; struct mailbox_transaction_context *t; struct mail_search_context *search_ctx; struct mail *mail; @@ -147,7 +146,7 @@ uint32_t message_count; int ret; - message_count = mail_index_view_get_messages_count(ibox->view); + message_count = mail_index_view_get_messages_count(result->box->view); if (old_messages_count == message_count) { /* no new messages */ return 0; @@ -184,7 +183,6 @@ void index_search_results_update_expunges(struct mailbox *box, const ARRAY_TYPE(seq_range) *expunges) { - struct index_mailbox *ibox = (struct index_mailbox *)box; const struct seq_range *seqs; uint32_t seq, uid; @@ -193,7 +191,7 @@ array_foreach(expunges, seqs) { for (seq = seqs->seq1; seq <= seqs->seq2; seq++) { - mail_index_lookup_uid(ibox->view, seq, &uid); + mail_index_lookup_uid(box->view, seq, &uid); mailbox_search_results_remove(box, uid); } } diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-search.c --- a/src/lib-storage/index/index-search.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-search.c Sun Feb 07 15:44:33 2010 +0200 @@ -96,7 +96,7 @@ case SEARCH_KEYWORDS: case SEARCH_MODSEQ: if (arg->type == SEARCH_MODSEQ) - mail_index_modseq_enable(ctx->ibox->index); + mail_index_modseq_enable(ctx->ibox->box.index); ctx->have_index_args = TRUE; break; case SEARCH_ALL: diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-sort-string.c --- a/src/lib-storage/index/index-sort-string.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-sort-string.c Sun Feb 07 15:44:33 2010 +0200 @@ -54,7 +54,6 @@ void index_sort_list_init_string(struct mail_search_sort_program *program) { - struct index_mailbox *ibox = (struct index_mailbox *)program->t->box; struct sort_string_context *ctx; const char *name; @@ -85,7 +84,7 @@ ctx->reverse = (program->sort_program[0] & MAIL_SORT_FLAG_REVERSE) != 0; ctx->program = program; ctx->primary_sort_name = name; - ctx->ext_id = mail_index_ext_register(ibox->index, name, 0, + ctx->ext_id = mail_index_ext_register(program->t->box->index, name, 0, sizeof(uint32_t), sizeof(uint32_t)); i_array_init(&ctx->zero_nodes, 128); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-status.c --- a/src/lib-storage/index/index-status.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-status.c Sun Feb 07 15:44:33 2010 +0200 @@ -7,7 +7,7 @@ #include "mail-index-modseq.h" static void -index_storage_get_status_cache_fields(struct index_mailbox *ibox, +index_storage_get_status_cache_fields(struct mailbox *box, struct mailbox_status *status_r) { const struct mail_cache_field *fields; @@ -15,13 +15,13 @@ ARRAY_TYPE(const_string) *cache_fields; unsigned int i, count; - fields = mail_cache_register_get_list(ibox->cache, + fields = mail_cache_register_get_list(box->cache, pool_datastack_create(), &count); /* a bit leaky to allocate memory from mailbox pool every time, but this is unlikely to be called more than once for the mailbox anyway. */ - cache_fields = p_new(ibox->box.pool, ARRAY_TYPE(const_string), 1); - p_array_init(cache_fields, ibox->box.pool, count); + cache_fields = p_new(box->pool, ARRAY_TYPE(const_string), 1); + p_array_init(cache_fields, box->pool, count); for (i = 0; i < count; i++) { dec = fields[i].decision & ~MAIL_CACHE_DECISION_FORCED; if (dec != MAIL_CACHE_DECISION_NO) @@ -42,7 +42,7 @@ memset(status_r, 0, sizeof(struct mailbox_status)); /* we can get most of the status items without any trouble */ - hdr = mail_index_get_header(ibox->view); + hdr = mail_index_get_header(box->view); status_r->messages = hdr->messages_count; if ((items & STATUS_RECENT) != 0) { status_r->recent = index_mailbox_get_recent_count(ibox); @@ -51,10 +51,10 @@ status_r->unseen = hdr->messages_count - hdr->seen_messages_count; status_r->uidvalidity = hdr->uid_validity; status_r->uidnext = hdr->next_uid; - status_r->nonpermanent_modseqs = mail_index_is_in_memory(ibox->index); + status_r->nonpermanent_modseqs = mail_index_is_in_memory(box->index); if ((items & STATUS_HIGHESTMODSEQ) != 0) { status_r->highest_modseq = - mail_index_modseq_get_highest(ibox->view); + mail_index_modseq_get_highest(box->view); if (status_r->highest_modseq == 0) { /* modseqs not enabled yet, but we can't return 0 */ status_r->highest_modseq = 1; @@ -62,12 +62,12 @@ } if ((items & STATUS_FIRST_UNSEEN_SEQ) != 0) { - mail_index_lookup_first(ibox->view, 0, MAIL_SEEN, + mail_index_lookup_first(box->view, 0, MAIL_SEEN, &status_r->first_unseen_seq); } if ((items & STATUS_KEYWORDS) != 0) - status_r->keywords = mail_index_get_keywords(ibox->index); + status_r->keywords = mail_index_get_keywords(box->index); if ((items & STATUS_CACHE_FIELDS) != 0) - index_storage_get_status_cache_fields(ibox, status_r); + index_storage_get_status_cache_fields(box, status_r); } diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-storage.c Sun Feb 07 15:44:33 2010 +0200 @@ -108,7 +108,7 @@ { const struct mail_storage_settings *set = ibox->box.storage->set; static bool initialized = FALSE; - struct mail_cache *cache = ibox->cache; + struct mail_cache *cache = ibox->box.cache; if (!initialized) { initialized = TRUE; @@ -198,7 +198,7 @@ ibox->index_flags &= ~MAIL_INDEX_OPEN_FLAG_CREATE; if ((index_flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) != 0) { - if (mail_index_is_in_memory(ibox->index)) { + if (mail_index_is_in_memory(box->index)) { mail_storage_set_critical(box->storage, "Couldn't create index file"); return -1; @@ -210,30 +210,30 @@ return -1; } - ret = mail_index_open(ibox->index, index_flags, lock_method); + ret = mail_index_open(box->index, index_flags, lock_method); if (ret <= 0 || ibox->move_to_memory) { if ((index_flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) != 0) { - mail_storage_set_index_error(ibox); + mail_storage_set_index_error(box); return -1; } - if (mail_index_move_to_memory(ibox->index) < 0) { + if (mail_index_move_to_memory(box->index) < 0) { /* try opening once more. it should be created directly into memory now. */ - if (mail_index_open_or_create(ibox->index, + if (mail_index_open_or_create(box->index, index_flags, lock_method) < 0) i_panic("in-memory index creation failed"); } } - ibox->cache = mail_index_get_cache(ibox->index); + box->cache = mail_index_get_cache(box->index); index_cache_register_defaults(ibox); - ibox->view = mail_index_view_open(ibox->index); - ibox->keyword_names = mail_index_get_keywords(ibox->index); + box->view = mail_index_view_open(box->index); + ibox->keyword_names = mail_index_get_keywords(box->index); - MODULE_CONTEXT_SET_FULL(ibox->view, mail_storage_mail_index_module, - ibox, &ibox->view_module_ctx); + MODULE_CONTEXT_SET_FULL(box->view, mail_storage_mail_index_module, + box, &ibox->view_module_ctx); box->opened = TRUE; @@ -241,7 +241,7 @@ if (hook_mailbox_opened != NULL) hook_mailbox_opened(box); - if (mail_index_is_deleted(ibox->index)) { + if (mail_index_is_deleted(box->index)) { mailbox_set_deleted(box); return -1; } @@ -287,11 +287,11 @@ mail_storage_settings_to_index_flags(box->storage->set); ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL; - ibox->index = index_storage_alloc(box->list, name, flags, index_prefix); + box->index = index_storage_alloc(box->list, name, flags, index_prefix); if (box->file_create_mode == 0) mailbox_refresh_permissions(box); - mail_index_set_permissions(ibox->index, box->file_create_mode, + mail_index_set_permissions(box->index, box->file_create_mode, box->file_create_gid, box->file_create_gid_origin); } @@ -299,8 +299,6 @@ int index_storage_mailbox_enable(struct mailbox *box, enum mailbox_feature feature) { - struct index_mailbox *ibox = (struct index_mailbox *)box; - if ((feature & MAILBOX_FEATURE_CONDSTORE) != 0) { box->enabled_features |= MAILBOX_FEATURE_CONDSTORE; if (!box->opened) { @@ -308,7 +306,7 @@ return -1; } T_BEGIN { - mail_index_modseq_enable(ibox->index); + mail_index_modseq_enable(box->index); } T_END; } return 0; @@ -318,14 +316,14 @@ { struct index_mailbox *ibox = (struct index_mailbox *) box; - if (ibox->view != NULL) - mail_index_view_close(&ibox->view); + if (box->view != NULL) + mail_index_view_close(&box->view); index_mailbox_check_remove_all(ibox); if (ibox->box.input != NULL) i_stream_unref(&ibox->box.input); - if (ibox->index != NULL) - mail_index_alloc_cache_unref(ibox->index); + if (box->index != NULL) + mail_index_alloc_cache_unref(box->index); if (array_is_created(&ibox->recent_flags)) array_free(&ibox->recent_flags); i_free(ibox->cache_fields); @@ -343,7 +341,7 @@ struct mail_cache_field field; unsigned int i, j, old_count; - old_fields = mail_cache_register_get_list(ibox->cache, + old_fields = mail_cache_register_get_list(ibox->box.cache, pool_datastack_create(), &old_count); @@ -373,7 +371,7 @@ } } if (array_count(&new_fields) > 0) { - mail_cache_register_fields(ibox->cache, + mail_cache_register_fields(ibox->box.cache, array_idx_modifiable(&new_fields, 0), array_count(&new_fields)); } @@ -396,8 +394,8 @@ index_storage_mailbox_update_cache_fields(ibox, update); /* make sure we get the latest index info */ - (void)mail_index_refresh(ibox->index); - view = mail_index_view_open(ibox->index); + (void)mail_index_refresh(ibox->box.index); + view = mail_index_view_open(ibox->box.index); hdr = mail_index_get_header(view); trans = mail_index_transaction_begin(view, @@ -446,18 +444,7 @@ bool index_storage_is_inconsistent(struct mailbox *box) { - struct index_mailbox *ibox = (struct index_mailbox *) box; - - return mail_index_view_is_inconsistent(ibox->view); -} - -void mail_storage_set_index_error(struct index_mailbox *ibox) -{ - if (mail_index_is_deleted(ibox->index)) - mailbox_set_deleted(&ibox->box); - else - mail_storage_set_internal_error(ibox->box.storage); - mail_index_reset_error(ibox->index); + return mail_index_view_is_inconsistent(box->view); } bool index_keyword_is_valid(struct mailbox *box, const char *keyword, @@ -467,7 +454,7 @@ unsigned int i, idx; /* if it already exists, skip validity checks */ - if (mail_index_keyword_lookup(ibox->index, keyword, &idx)) + if (mail_index_keyword_lookup(box->index, keyword, &idx)) return TRUE; if (*keyword == '\0') { @@ -507,7 +494,7 @@ array_append(&valid_keywords, keywords, 1); } (void)array_append_space(&valid_keywords); /* NULL-terminate */ - return mail_index_keywords_create(ibox->index, keywords); + return mail_index_keywords_create(ibox->box.index, keywords); } int index_keywords_create(struct mailbox *_box, const char *const keywords[], @@ -535,7 +522,7 @@ return 0; } - *keywords_r = mail_index_keywords_create(ibox->index, keywords); + *keywords_r = mail_index_keywords_create(ibox->box.index, keywords); return 0; } @@ -543,9 +530,7 @@ index_keywords_create_from_indexes(struct mailbox *_box, const ARRAY_TYPE(keyword_indexes) *idx) { - struct index_mailbox *ibox = (struct index_mailbox *)_box; - - return mail_index_keywords_create_from_indexes(ibox->index, idx); + return mail_index_keywords_create_from_indexes(_box->index, idx); } void index_keywords_ref(struct mail_keywords *keywords) diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-storage.h --- a/src/lib-storage/index/index-storage.h Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-storage.h Sun Feb 07 15:44:33 2010 +0200 @@ -39,11 +39,6 @@ struct mail_index_transaction_commit_result *result_r); void (*save_rollback)(struct mail_save_context *save_ctx); - struct mail_index *index; - struct mail_index_view *view; - struct mail_cache *cache; - struct mail_vfuncs *mail_vfuncs; - struct timeout *notify_to, *notify_delay_to; struct index_notify_file *notify_files; struct index_notify_io *notify_ios; @@ -66,8 +61,6 @@ unsigned int move_to_memory:1; }; -void mail_storage_set_index_error(struct index_mailbox *ibox); - void index_storage_lock_notify(struct index_mailbox *ibox, enum mailbox_lock_notify_type notify_type, unsigned int secs_left); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-sync-search.c --- a/src/lib-storage/index/index-sync-search.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-sync-search.c Sun Feb 07 15:44:33 2010 +0200 @@ -27,7 +27,7 @@ array_foreach(changes, range) { for (seq = range->seq1; seq <= range->seq2; seq++) { - mail_index_lookup_uid(ctx->ibox->view, seq, &uid); + mail_index_lookup_uid(ctx->ibox->box.view, seq, &uid); seq_range_array_add(&ctx->all_flag_update_uids, 0, uid); } } diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-sync.c --- a/src/lib-storage/index/index-sync.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-sync.c Sun Feb 07 15:44:33 2010 +0200 @@ -67,7 +67,7 @@ if (!array_is_created(&ibox->recent_flags)) return 0; - hdr = mail_index_get_header(ibox->view); + hdr = mail_index_get_header(ibox->box.view); recent_count = ibox->recent_flags_count; range = array_get(&ibox->recent_flags, &count); for (i = count; i > 0; ) { @@ -96,7 +96,7 @@ return; for (; seq1 <= seq2; seq1++) { - mail_index_lookup_uid(ibox->view, seq1, &uid); + mail_index_lookup_uid(ibox->box.view, seq1, &uid); if (seq_range_array_remove(&ibox->recent_flags, uid)) ibox->recent_flags_count--; } @@ -112,7 +112,7 @@ while (mail_index_view_sync_next(ctx->sync_ctx, &sync_rec)) { switch (sync_rec.type) { case MAIL_INDEX_VIEW_SYNC_TYPE_FLAGS: - if (!mail_index_lookup_seq_range(ctx->ibox->view, + if (!mail_index_lookup_seq_range(ctx->ibox->box.view, sync_rec.uid1, sync_rec.uid2, &seq1, &seq2)) @@ -166,10 +166,10 @@ ctx->messages_count = 0; } else { ctx->messages_count = - mail_index_view_get_messages_count(ibox->view); + mail_index_view_get_messages_count(box->view); } - ctx->sync_ctx = mail_index_view_sync_begin(ibox->view, sync_flags); + ctx->sync_ctx = mail_index_view_sync_begin(box->view, sync_flags); if ((flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) == 0) { mail_index_view_sync_get_expunges(ctx->sync_ctx, &ctx->expunges); @@ -242,6 +242,7 @@ index_mailbox_expunge_unseen_recent(struct index_mailbox_sync_context *ctx) { struct index_mailbox *ibox = ctx->ibox; + struct mail_index_view *view = ibox->box.view; const struct mail_index_header *hdr; uint32_t seq, start_uid, uid; @@ -252,19 +253,19 @@ visible in this view, but append+expunge would be invisible. recent_flags may however contain the append UID, so we'll have to remove it separately */ - hdr = mail_index_get_header(ibox->view); + hdr = mail_index_get_header(view); if (ctx->messages_count == 0) uid = 0; else if (ctx->messages_count <= hdr->messages_count) - mail_index_lookup_uid(ibox->view, ctx->messages_count, &uid); + mail_index_lookup_uid(view, ctx->messages_count, &uid); else { - i_assert(mail_index_view_is_inconsistent(ibox->view)); + i_assert(mail_index_view_is_inconsistent(view)); return; } for (seq = ctx->messages_count + 1; seq <= hdr->messages_count; seq++) { start_uid = uid; - mail_index_lookup_uid(ibox->view, seq, &uid); + mail_index_lookup_uid(view, seq, &uid); if (start_uid + 1 > uid - 1) continue; @@ -280,7 +281,7 @@ hdr->next_uid - 1); } #ifdef DEBUG - if (!mail_index_view_is_inconsistent(ibox->view)) { + if (!mail_index_view_is_inconsistent(view)) { const struct seq_range *range; unsigned int i, count; @@ -289,7 +290,7 @@ for (uid = range[i].seq1; uid <= range[i].seq2; uid++) { if (uid >= hdr->next_uid) break; - mail_index_lookup_seq(ibox->view, uid, &seq); + mail_index_lookup_seq(view, uid, &seq); i_assert(seq != 0); } } @@ -319,23 +320,24 @@ if (ctx->sync_ctx != NULL) { if (mail_index_view_sync_commit(&ctx->sync_ctx, &delayed_expunges) < 0) { - mail_storage_set_index_error(ibox); + mail_storage_set_index_error(_ctx->box); ret = -1; } } index_mailbox_expunge_unseen_recent(ctx); - if ((ibox->box.flags & MAILBOX_FLAG_KEEP_RECENT) != 0 && - ibox->box.opened) { + if ((_ctx->box->flags & MAILBOX_FLAG_KEEP_RECENT) != 0 && + _ctx->box->opened) { /* mailbox syncing didn't necessarily update our recent state */ - hdr = mail_index_get_header(ibox->view); + hdr = mail_index_get_header(_ctx->box->view); if (hdr->first_recent_uid > ibox->recent_flags_prev_uid) { - mail_index_lookup_seq_range(ibox->view, + mail_index_lookup_seq_range(_ctx->box->view, hdr->first_recent_uid, hdr->next_uid, &seq1, &seq2); if (seq1 != 0) { - index_mailbox_set_recent_seq(ibox, ibox->view, + index_mailbox_set_recent_seq(ibox, + _ctx->box->view, seq1, seq2); } } diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-thread.c --- a/src/lib-storage/index/index-thread.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-thread.c Sun Feb 07 15:44:33 2010 +0200 @@ -307,10 +307,9 @@ if (tbox->strmap_view == NULL) { /* first time we're threading this mailbox */ - struct index_mailbox *ibox = (struct index_mailbox *)ctx->box; - tbox->strmap_view = - mail_index_strmap_view_open(tbox->strmap, ibox->view, + mail_index_strmap_view_open(tbox->strmap, + ctx->box->view, mail_thread_hash_key_cmp, mail_thread_hash_rec_cmp, mail_thread_strmap_remap, @@ -642,7 +641,7 @@ tbox->module_ctx.super = box->v; box->v.close = mail_thread_mailbox_close; - tbox->strmap = mail_index_strmap_init(ibox->index, + tbox->strmap = mail_index_strmap_init(box->index, MAIL_THREAD_INDEX_SUFFIX); tbox->next_msgid_idx = 1; diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/index-transaction.c --- a/src/lib-storage/index/index-transaction.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/index-transaction.c Sun Feb 07 15:44:33 2010 +0200 @@ -35,7 +35,7 @@ it->super.rollback(it->trans); else { if (it->super.commit(it->trans, result_r) < 0) { - mail_storage_set_index_error(ibox); + mail_storage_set_index_error(t->box); ret = -1; } } @@ -64,7 +64,6 @@ struct mailbox *box, enum mailbox_transaction_flags flags) { - struct index_mailbox *ibox = (struct index_mailbox *)box; enum mail_index_transaction_flags trans_flags; i_assert(box->opened); @@ -75,16 +74,16 @@ if ((flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0) trans_flags |= MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL; if ((flags & MAILBOX_TRANSACTION_FLAG_REFRESH) != 0) - (void)mail_index_refresh(ibox->index); + (void)mail_index_refresh(box->index); - it->trans = mail_index_transaction_begin(ibox->view, trans_flags); - it->mailbox_ctx.box = &ibox->box; + it->trans = mail_index_transaction_begin(box->view, trans_flags); + it->mailbox_ctx.box = box; array_create(&it->mailbox_ctx.module_contexts, default_pool, sizeof(void *), 5); it->trans_view = mail_index_transaction_open_updated_view(it->trans); - it->cache_view = mail_cache_view_open(ibox->cache, it->trans_view); + it->cache_view = mail_cache_view_open(box->cache, it->trans_view); it->cache_trans = mail_cache_get_transaction(it->cache_view, it->trans); /* set up after mail_cache_get_transaction(), so that we'll still @@ -111,8 +110,8 @@ { struct index_transaction_context *t = (struct index_transaction_context *)_t; + struct mailbox *box = _t->box; struct mail_index_transaction *itrans = t->trans; - struct index_mailbox *ibox = (struct index_mailbox *)_t->box; struct mail_index_transaction_commit_result result; int ret; @@ -122,14 +121,14 @@ _t->changes = changes_r; ret = mail_index_transaction_commit_full(&itrans, &result); - if (ret < 0 && mail_index_is_deleted(ibox->index)) - mailbox_set_deleted(&ibox->box); + if (ret < 0 && mail_index_is_deleted(_t->box->index)) + mailbox_set_deleted(_t->box); changes_r->ignored_uid_changes = result.ignored_uid_changes; changes_r->ignored_modseq_changes = result.ignored_modseq_changes; - i_assert(ibox->box.transaction_count > 0 || - ibox->view->transactions == 0); + i_assert(box->transaction_count > 0 || + box->view->transactions == 0); return ret; } @@ -137,13 +136,13 @@ { struct index_transaction_context *t = (struct index_transaction_context *)_t; + struct mailbox *box = _t->box; struct mail_index_transaction *itrans = t->trans; - struct index_mailbox *ibox = (struct index_mailbox *)_t->box; mail_index_transaction_rollback(&itrans); - i_assert(ibox->box.transaction_count > 0 || - ibox->view->transactions == 0); + i_assert(box->transaction_count > 0 || + box->view->transactions == 0); } void index_transaction_set_max_modseq(struct mailbox_transaction_context *_t, diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/maildir/maildir-copy.c --- a/src/lib-storage/index/maildir/maildir-copy.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/maildir/maildir-copy.c Sun Feb 07 15:44:33 2010 +0200 @@ -170,7 +170,7 @@ return 0; } - if (mail_index_is_deleted(dest_mbox->ibox.index)) { + if (mail_index_is_deleted(dest_mbox->ibox.box.index)) { mailbox_set_deleted(&dest_mbox->ibox.box); return -1; } diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/maildir/maildir-mail.c --- a/src/lib-storage/index/maildir/maildir-mail.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/maildir/maildir-mail.c Sun Feb 07 15:44:33 2010 +0200 @@ -177,8 +177,8 @@ /* one reason this could happen is if we delayed opening dovecot-uidlist and we're trying to open a mail that got recently expunged. Let's test this theory first: */ - (void)mail_index_refresh(mbox->ibox.index); - view = mail_index_view_open(mbox->ibox.index); + (void)mail_index_refresh(mbox->ibox.box.index); + view = mail_index_view_open(mbox->ibox.box.index); exists = mail_index_lookup_seq(view, mail->uid, &seq); mail_index_view_close(&view); @@ -216,13 +216,13 @@ psize_idx = mail->ibox->cache_fields[MAIL_CACHE_PHYSICAL_FULL_SIZE].idx; vsize_idx = mail->ibox->cache_fields[MAIL_CACHE_VIRTUAL_FULL_SIZE].idx; if (not_pop3_only) { - vsize_dec = mail_cache_field_get_decision(mail->ibox->cache, + vsize_dec = mail_cache_field_get_decision(mail->ibox->box.cache, vsize_idx); vsize_dec &= ~MAIL_CACHE_DECISION_FORCED; } else { /* also check if there are any non-[pv]size cached fields */ vsize_dec = MAIL_CACHE_DECISION_NO; - fields = mail_cache_register_get_list(mail->ibox->cache, + fields = mail_cache_register_get_list(mail->ibox->box.cache, pool_datastack_create(), &count); for (i = 0; i < count; i++) { @@ -313,14 +313,14 @@ including to the uidlist if it's already in filename. do some extra checks here to catch potential cache bugs. */ if (vsize && mail->data.virtual_size != size) { - mail_cache_set_corrupted(mail->ibox->cache, + mail_cache_set_corrupted(mail->ibox->box.cache, "Corrupted virtual size for uid=%u: " "%"PRIuUOFF_T" != %"PRIuUOFF_T, mail->mail.mail.uid, mail->data.virtual_size, size); mail->data.virtual_size = size; } else if (!vsize && mail->data.physical_size != size) { - mail_cache_set_corrupted(mail->ibox->cache, + mail_cache_set_corrupted(mail->ibox->box.cache, "Corrupted physical size for uid=%u: " "%"PRIuUOFF_T" != %"PRIuUOFF_T, mail->mail.mail.uid, diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/maildir/maildir-save.c --- a/src/lib-storage/index/maildir/maildir-save.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/maildir/maildir-save.c Sun Feb 07 15:44:33 2010 +0200 @@ -305,7 +305,7 @@ string_t *path; int fd; - if (mail_index_is_deleted(mbox->ibox.index)) { + if (mail_index_is_deleted(mbox->ibox.box.index)) { mailbox_set_deleted(box); return -1; } @@ -957,7 +957,7 @@ if (ret < 0) { ctx->keywords_sync_ctx = !ctx->have_keywords ? NULL : maildir_keywords_sync_init(ctx->mbox->keywords, - ctx->mbox->ibox.index); + ctx->mbox->ibox.box.index); /* unlink the files we just moved in an attempt to rollback the transaction. uidlist is still locked, so at least other diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/maildir/maildir-storage.c Sun Feb 07 15:44:33 2010 +0200 @@ -337,7 +337,7 @@ mbox->ibox.box.pool = pool; mbox->ibox.box.storage = storage; mbox->ibox.box.list = list; - mbox->ibox.mail_vfuncs = &maildir_mail_vfuncs; + mbox->ibox.box.mail_vfuncs = &maildir_mail_vfuncs; mbox->ibox.save_commit_pre = maildir_transaction_save_commit_pre; mbox->ibox.save_commit_post = maildir_transaction_save_commit_post; @@ -348,7 +348,7 @@ mbox->storage = (struct maildir_storage *)storage; mbox->maildir_ext_id = - mail_index_ext_register(mbox->ibox.index, "maildir", + mail_index_ext_register(mbox->ibox.box.index, "maildir", sizeof(mbox->maildir_hdr), 0, 0); mbox->uidlist = maildir_uidlist_init(mbox); mbox->keywords = maildir_keywords_init(mbox); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/maildir/maildir-sync-index.c --- a/src/lib-storage/index/maildir/maildir-sync-index.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/maildir/maildir-sync-index.c Sun Feb 07 15:44:33 2010 +0200 @@ -212,6 +212,7 @@ struct maildir_sync_context *maildir_sync_ctx, struct maildir_index_sync_context **ctx_r) { + struct mailbox *_box = &mbox->ibox.box; struct maildir_index_sync_context *ctx; struct mail_index_sync_ctx *sync_ctx; struct mail_index_view *view; @@ -220,13 +221,13 @@ sync_flags = 0; /* don't drop recent messages if we're saving messages */ - if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0 && + if ((_box->flags & MAILBOX_FLAG_KEEP_RECENT) == 0 && maildir_sync_ctx != NULL) sync_flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT; - if (mail_index_sync_begin(mbox->ibox.index, &sync_ctx, &view, &trans, - sync_flags) < 0) { - mail_storage_set_index_error(&mbox->ibox); + if (mail_index_sync_begin(_box->index, &sync_ctx, &view, + &trans, sync_flags) < 0) { + mail_storage_set_index_error(_box); return -1; } @@ -237,7 +238,7 @@ ctx->view = view; ctx->trans = trans; ctx->keywords_sync_ctx = - maildir_keywords_sync_init(mbox->keywords, mbox->ibox.index); + maildir_keywords_sync_init(mbox->keywords, _box->index); ctx->sync_changes = index_sync_changes_init(&mbox->ibox, ctx->sync_ctx, ctx->view, ctx->trans, @@ -286,7 +287,7 @@ mbox->maildir_hdr.cur_mtime_nsecs = ST_MTIME_NSEC(st); } - mail_index_get_header_ext(mbox->ibox.view, mbox->maildir_ext_id, + mail_index_get_header_ext(mbox->ibox.box.view, mbox->maildir_ext_id, &data, &data_size); if (data_size != sizeof(mbox->maildir_hdr) || maildir_index_header_has_changed(data, &mbox->maildir_hdr)) { @@ -313,7 +314,7 @@ start a second index sync and crash. */ mbox->syncing_commit = TRUE; if (mail_index_sync_commit(&ctx->sync_ctx) < 0) { - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(&mbox->ibox.box); ret = -1; } mbox->syncing_commit = FALSE; @@ -356,7 +357,7 @@ static void maildir_sync_mail_keywords(struct maildir_index_sync_context *ctx, uint32_t seq) { - struct maildir_mailbox *mbox = ctx->mbox; + struct mailbox *box = &ctx->mbox->ibox.box; struct mail_keywords *kw; unsigned int i, j, old_count, new_count; const unsigned int *old_indexes, *new_indexes; @@ -386,7 +387,7 @@ if (!have_indexonly_keywords) { /* no index-only keywords found, so something changed. just replace them all. */ - kw = mail_index_keywords_create_from_indexes(mbox->ibox.index, + kw = mail_index_keywords_create_from_indexes(box->index, &ctx->keywords); mail_index_update_keywords(ctx->trans, seq, MODIFY_REPLACE, kw); mail_index_keywords_unref(&kw); @@ -417,14 +418,14 @@ } if (array_count(&ctx->idx_keywords) > 0) { - kw = mail_index_keywords_create_from_indexes(mbox->ibox.index, + kw = mail_index_keywords_create_from_indexes(box->index, &ctx->idx_keywords); mail_index_update_keywords(ctx->trans, seq, MODIFY_REMOVE, kw); mail_index_keywords_unref(&kw); } if (array_count(&ctx->keywords) > 0) { - kw = mail_index_keywords_create_from_indexes(mbox->ibox.index, + kw = mail_index_keywords_create_from_indexes(box->index, &ctx->keywords); mail_index_update_keywords(ctx->trans, seq, MODIFY_ADD, kw); mail_index_keywords_unref(&kw); @@ -523,7 +524,7 @@ struct mail_keywords *kw; kw = mail_index_keywords_create_from_indexes( - mbox->ibox.index, &ctx->keywords); + mbox->ibox.box.index, &ctx->keywords); mail_index_update_keywords(trans, seq, MODIFY_REPLACE, kw); mail_index_keywords_unref(&kw); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/maildir/maildir-sync.c --- a/src/lib-storage/index/maildir/maildir-sync.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/maildir/maildir-sync.c Sun Feb 07 15:44:33 2010 +0200 @@ -537,12 +537,12 @@ const void *data; size_t data_size; - if (mail_index_refresh(mbox->ibox.index) < 0) { - mail_storage_set_index_error(&mbox->ibox); + if (mail_index_refresh(mbox->ibox.box.index) < 0) { + mail_storage_set_index_error(&mbox->ibox.box); return -1; } - mail_index_get_header_ext(mbox->ibox.view, mbox->maildir_ext_id, + mail_index_get_header_ext(mbox->ibox.box.view, mbox->maildir_ext_id, &data, &data_size); if (data_size == 0) { /* doesn't exist */ @@ -636,7 +636,7 @@ const struct mail_index_header *hdr; uint32_t uid_validity, next_uid; - hdr = mail_index_get_header(mbox->ibox.view); + hdr = mail_index_get_header(mbox->ibox.box.view); if (hdr->uid_validity == 0) return; @@ -662,7 +662,7 @@ /* if there are files in new/, we'll need to move them. we'll check this by checking if we have any recent messages */ - hdr = mail_index_get_header(ctx->mbox->ibox.view); + hdr = mail_index_get_header(ctx->mbox->ibox.box.view); return hdr->first_recent_uid < maildir_uidlist_get_next_uid(ctx->mbox->uidlist); } @@ -696,7 +696,7 @@ if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0) flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT; - return mail_index_sync_have_any(mbox->ibox.index, flags) ? 1 : 0; + return mail_index_sync_have_any(mbox->ibox.box.index, flags) ? 1 : 0; } static int maildir_sync_context(struct maildir_sync_context *ctx, bool forced, @@ -947,12 +947,12 @@ if (mbox->flags_view == NULL) { mbox->flags_view = - mail_index_view_open(mbox->ibox.index); + mail_index_view_open(mbox->ibox.box.index); } sync_ctx = mail_index_view_sync_begin(mbox->flags_view, MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT); if (mail_index_view_sync_commit(&sync_ctx, &b) < 0) { - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(&mbox->ibox.box); ret = -1; } /* make sure the map stays in private memory */ diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/maildir/maildir-uidlist.c --- a/src/lib-storage/index/maildir/maildir-uidlist.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/maildir/maildir-uidlist.c Sun Feb 07 15:44:33 2010 +0200 @@ -961,7 +961,7 @@ int maildir_uidlist_refresh_fast_init(struct maildir_uidlist *uidlist) { const struct maildir_index_header *mhdr = &uidlist->mbox->maildir_hdr; - struct mail_index *index = uidlist->mbox->ibox.index; + struct mail_index *index = uidlist->mbox->ibox.box.index; struct mail_index_view *view; const struct mail_index_header *hdr; struct stat st; @@ -1224,7 +1224,7 @@ const struct mail_index_header *hdr; if (uidlist->ibox->box.opened) { - hdr = mail_index_get_header(uidlist->ibox->view); + hdr = mail_index_get_header(uidlist->ibox->box.view); if (hdr->uid_validity != 0) { uidlist->uid_validity = hdr->uid_validity; return; @@ -1334,8 +1334,8 @@ if (!uidlist->mbox->ibox.box.opened) return; - mail_index_refresh(uidlist->mbox->ibox.index); - view = mail_index_view_open(uidlist->mbox->ibox.index); + mail_index_refresh(uidlist->mbox->ibox.box.index); + view = mail_index_view_open(uidlist->mbox->ibox.box.index); count = array_count(&uidlist->records); hdr = mail_index_get_header(view); if (count * UIDLIST_COMPRESS_PERCENTAGE / 100 <= hdr->messages_count) { @@ -1486,7 +1486,7 @@ static bool maildir_uidlist_want_compress(struct maildir_uidlist_sync_ctx *ctx) { - struct mail_index_view *view = ctx->uidlist->mbox->ibox.view; + struct mail_index_view *view = ctx->uidlist->mbox->ibox.box.view; unsigned int min_rewrite_count, messages_count; if (!ctx->uidlist->locked_refresh) diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/maildir/maildir-util.c --- a/src/lib-storage/index/maildir/maildir-util.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/maildir/maildir-util.c Sun Feb 07 15:44:33 2010 +0200 @@ -43,7 +43,7 @@ } else { *have_flags_r = TRUE; kw_ctx = maildir_keywords_sync_init_readonly(mbox->keywords, - mbox->ibox.index); + mbox->ibox.box.index); fname = maildir_filename_set_flags(kw_ctx, fname, flags, &keywords); maildir_keywords_sync_deinit(&kw_ctx); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/mbox/mbox-lock.c --- a/src/lib-storage/index/mbox/mbox-lock.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/mbox/mbox-lock.c Sun Feb 07 15:44:33 2010 +0200 @@ -777,7 +777,7 @@ i_assert(lock_type == F_RDLCK || mbox->mbox_lock_type != F_RDLCK); /* mbox must be locked before index */ - i_assert(mbox->ibox.index->lock_type != F_WRLCK); + i_assert(mbox->ibox.box.index->lock_type != F_WRLCK); if (mbox->mbox_lock_type == F_UNLCK) { ret = mbox_update_locking(mbox, lock_type, &fcntl_locked); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/mbox/mbox-mail.c --- a/src/lib-storage/index/mbox/mbox-mail.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/mbox/mbox-mail.c Sun Feb 07 15:44:33 2010 +0200 @@ -65,8 +65,8 @@ /* refresh index file after mbox has been locked to make sure we get only up-to-date mbox offsets. */ - if (mail_index_refresh(mbox->ibox.index) < 0) { - mail_storage_set_index_error(&mbox->ibox); + if (mail_index_refresh(mbox->ibox.box.index) < 0) { + mail_storage_set_index_error(&mbox->ibox.box); return -1; } @@ -232,7 +232,7 @@ if (mbox_sync_header_refresh(mbox) < 0) return -1; - view = mail_index_view_open(mail->ibox->index); + view = mail_index_view_open(mail->ibox->box.index); hdr = mail_index_get_header(view); if (!mail_index_lookup_seq(view, mail->mail.mail.uid, &seq)) i_panic("Message unexpectedly expunged from index"); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/mbox/mbox-save.c --- a/src/lib-storage/index/mbox/mbox-save.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/mbox/mbox-save.c Sun Feb 07 15:44:33 2010 +0200 @@ -179,8 +179,8 @@ /* open a new view to get the header. this is required if we just synced the mailbox so we can get updated next_uid. */ - (void)mail_index_refresh(mbox->ibox.index); - view = mail_index_view_open(mbox->ibox.index); + (void)mail_index_refresh(mbox->ibox.box.index); + view = mail_index_view_open(mbox->ibox.box.index); hdr = mail_index_get_header(view); ctx->next_uid = hdr->next_uid; @@ -227,7 +227,7 @@ const char *const *keyword_names; unsigned int i, count, keyword_names_count; - keyword_names_list = mail_index_get_keywords(ctx->mbox->ibox.index); + keyword_names_list = mail_index_get_keywords(ctx->mbox->ibox.box.index); keyword_names = array_get(keyword_names_list, &keyword_names_count); str_append(ctx->headers, "X-Keywords:"); @@ -261,7 +261,7 @@ return -1; } - if (mail_index_is_deleted(mbox->ibox.index)) { + if (mail_index_is_deleted(mbox->ibox.box.index)) { mailbox_set_deleted(&mbox->ibox.box); return -1; } diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/mbox/mbox-storage.c --- a/src/lib-storage/index/mbox/mbox-storage.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/mbox/mbox-storage.c Sun Feb 07 15:44:33 2010 +0200 @@ -346,7 +346,7 @@ mbox->ibox.box.pool = pool; mbox->ibox.box.storage = storage; mbox->ibox.box.list = list; - mbox->ibox.mail_vfuncs = &mbox_mail_vfuncs; + mbox->ibox.box.mail_vfuncs = &mbox_mail_vfuncs; mbox->ibox.save_commit_pre = mbox_transaction_save_commit_pre; mbox->ibox.save_commit_post = mbox_transaction_save_commit_post; @@ -359,11 +359,11 @@ mbox->mbox_fd = -1; mbox->mbox_lock_type = F_UNLCK; mbox->mbox_ext_idx = - mail_index_ext_register(mbox->ibox.index, "mbox", + mail_index_ext_register(mbox->ibox.box.index, "mbox", sizeof(mbox->mbox_hdr), sizeof(uint64_t), sizeof(uint64_t)); mbox->md5hdr_ext_idx = - mail_index_ext_register(mbox->ibox.index, "header-md5", + mail_index_ext_register(mbox->ibox.box.index, "header-md5", 0, 16, 1); if ((storage->flags & MAIL_STORAGE_FLAG_KEEP_HEADER_MD5) != 0) @@ -546,8 +546,8 @@ sync_flags |= MBOX_SYNC_UNDIRTY | MBOX_SYNC_FORCE_SYNC; } - if (mbox->ibox.view != NULL) { - hdr = mail_index_get_header(mbox->ibox.view); + if (box->view != NULL) { + hdr = mail_index_get_header(box->view); if ((hdr->flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0 && !mbox->ibox.backend_readonly) { /* we've done changes to mbox which haven't been diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/mbox/mbox-sync-parse.c --- a/src/lib-storage/index/mbox/mbox-sync-parse.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/mbox/mbox-sync-parse.c Sun Feb 07 15:44:33 2010 +0200 @@ -113,6 +113,7 @@ parse_imap_keywords_list(struct mbox_sync_mail_context *ctx, struct message_header_line *hdr, size_t pos) { + struct mailbox *box = &ctx->sync_ctx->mbox->ibox.box; const char *keyword, *error; size_t keyword_start; unsigned int idx, count; @@ -136,8 +137,8 @@ pos - keyword_start); if (mailbox_keyword_is_valid(&ctx->sync_ctx->mbox->ibox.box, keyword, &error)) { - mail_index_keyword_lookup_or_create( - ctx->sync_ctx->mbox->ibox.index, keyword, &idx); + mail_index_keyword_lookup_or_create(box->index, + keyword, &idx); } count++; } @@ -246,6 +247,7 @@ static bool parse_x_keywords_real(struct mbox_sync_mail_context *ctx, struct message_header_line *hdr) { + struct mailbox *box = &ctx->sync_ctx->mbox->ibox.box; ARRAY_TYPE(keyword_indexes) keyword_list; const unsigned int *list; string_t *keyword; @@ -276,8 +278,8 @@ str_truncate(keyword, 0); str_append_n(keyword, hdr->full_value + keyword_start, pos - keyword_start); - if (!mail_index_keyword_lookup(ctx->sync_ctx->mbox->ibox.index, - str_c(keyword), &idx)) { + if (!mail_index_keyword_lookup(box->index, str_c(keyword), + &idx)) { /* keyword wasn't found. that means the sent mail originally contained X-Keywords header. Delete it. */ return FALSE; diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/mbox/mbox-sync.c --- a/src/lib-storage/index/mbox/mbox-sync.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/mbox/mbox-sync.c Sun Feb 07 15:44:33 2010 +0200 @@ -295,13 +295,14 @@ static void mbox_sync_update_index_keywords(struct mbox_sync_mail_context *mail_ctx) { - struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx; + struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx; + struct mail_index *index = sync_ctx->mbox->ibox.box.index; struct mail_keywords *keywords; keywords = !array_is_created(&mail_ctx->mail.keywords) ? - mail_index_keywords_create(sync_ctx->mbox->ibox.index, NULL) : - mail_index_keywords_create_from_indexes( - sync_ctx->mbox->ibox.index, &mail_ctx->mail.keywords); + mail_index_keywords_create(index, NULL) : + mail_index_keywords_create_from_indexes(index, + &mail_ctx->mail.keywords); mail_index_update_keywords(sync_ctx->t, sync_ctx->idx_seq, MODIFY_REPLACE, keywords); mail_index_keywords_unref(&keywords); @@ -1389,7 +1390,7 @@ mail_generate_guid_128(mbox->mbox_hdr.mailbox_guid); } - mail_index_get_header_ext(mbox->ibox.view, mbox->mbox_ext_idx, + mail_index_get_header_ext(mbox->ibox.box.view, mbox->mbox_ext_idx, &data, &data_size); if (data_size != sizeof(mbox->mbox_hdr) || memcmp(data, &mbox->mbox_hdr, data_size) != 0) { @@ -1630,16 +1631,16 @@ const void *data; size_t data_size; - if (mail_index_refresh(mbox->ibox.index) < 0) { - mail_storage_set_index_error(&mbox->ibox); + if (mail_index_refresh(mbox->ibox.box.index) < 0) { + mail_storage_set_index_error(&mbox->ibox.box); return -1; } - mail_index_get_header_ext(mbox->ibox.view, mbox->mbox_ext_idx, + mail_index_get_header_ext(mbox->ibox.box.view, mbox->mbox_ext_idx, &data, &data_size); if (data_size == 0) { /* doesn't exist. FIXME: backwards compatibility copying */ - hdr = mail_index_get_header(mbox->ibox.view); + hdr = mail_index_get_header(mbox->ibox.box.view); mbox->mbox_hdr.sync_mtime = hdr->sync_stamp; mbox->mbox_hdr.sync_size = hdr->sync_size; return 0; @@ -1797,11 +1798,11 @@ if ((flags & MBOX_SYNC_REWRITE) != 0) sync_flags |= MAIL_INDEX_SYNC_FLAG_FLUSH_DIRTY; - ret = mail_index_sync_begin(mbox->ibox.index, &index_sync_ctx, + ret = mail_index_sync_begin(mbox->ibox.box.index, &index_sync_ctx, &sync_view, &trans, sync_flags); if (ret <= 0) { if (ret < 0) - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(&mbox->ibox.box); return ret; } @@ -1818,7 +1819,7 @@ /* index may need to do internal syncing though, so commit instead of rollbacking. */ if (mail_index_sync_commit(&index_sync_ctx) < 0) { - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(&mbox->ibox.box); return -1; } return 0; @@ -1842,7 +1843,7 @@ pool_alloconly_create("mbox saved keywords", 4096); /* make sure we've read the latest keywords in index */ - (void)mail_index_get_keywords(mbox->ibox.index); + (void)mail_index_get_keywords(mbox->ibox.box.index); i_array_init(&sync_ctx.mails, 64); @@ -1894,7 +1895,7 @@ if (ret < 0) mail_index_sync_rollback(&index_sync_ctx); else if (mail_index_sync_commit(&index_sync_ctx) < 0) { - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(&mbox->ibox.box); ret = -1; } sync_ctx.t = NULL; diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/raw/raw-storage.c --- a/src/lib-storage/index/raw/raw-storage.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/raw/raw-storage.c Sun Feb 07 15:44:33 2010 +0200 @@ -50,7 +50,7 @@ mbox->ibox.box.pool = pool; mbox->ibox.box.storage = storage; mbox->ibox.box.list = list; - mbox->ibox.mail_vfuncs = &raw_mail_vfuncs; + mbox->ibox.box.mail_vfuncs = &raw_mail_vfuncs; index_storage_mailbox_alloc(&mbox->ibox, name, input, flags, NULL); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/raw/raw-sync.c --- a/src/lib-storage/index/raw/raw-sync.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/raw/raw-sync.c Sun Feb 07 15:44:33 2010 +0200 @@ -21,11 +21,11 @@ if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0) sync_flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT; - ret = mail_index_sync_begin(mbox->ibox.index, &index_sync_ctx, + ret = mail_index_sync_begin(mbox->ibox.box.index, &index_sync_ctx, &sync_view, &trans, sync_flags); if (ret <= 0) { if (ret < 0) - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(&mbox->ibox.box); return ret; } @@ -39,7 +39,7 @@ index_mailbox_set_recent_uid(&mbox->ibox, 1); if (mail_index_sync_commit(&index_sync_ctx) < 0) { - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(&mbox->ibox.box); return -1; } mbox->synced = TRUE; diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/index/test-index-fetch.c --- a/src/lib-storage/index/test-index-fetch.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/index/test-index-fetch.c Sun Feb 07 15:44:33 2010 +0200 @@ -95,11 +95,11 @@ uint64_t modseq; ibox = t_new(struct index_mailbox, 1); - ibox->index = t_new(struct mail_index, 1); - ibox->view = t_new(struct mail_index_view, 1); + ibox->box.index = t_new(struct mail_index, 1); + ibox->box.view = t_new(struct mail_index_view, 1); - ibox->view->log_file_head_seq = 101; - ibox->view->log_file_head_offset = 1024; + ibox->box.view->log_file_head_seq = 101; + ibox->box.view->log_file_head_offset = 1024; test_begin("index storage get expunges"); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/mail-storage-private.h --- a/src/lib-storage/mail-storage-private.h Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/mail-storage-private.h Sun Feb 07 15:44:33 2010 +0200 @@ -212,6 +212,13 @@ /* private: */ pool_t pool; + struct mail_index *index; + struct mail_index_view *view; + struct mail_cache *cache; + + /* default vfuncs for new struct mails. */ + const struct mail_vfuncs *mail_vfuncs; + /* mailbox's MAILBOX_LIST_PATH_TYPE_MAILBOX */ const char *path; /* mailbox's virtual name (from mail_namespace_get_vname()) */ @@ -425,6 +432,7 @@ void mail_storage_set_critical(struct mail_storage *storage, const char *fmt, ...) ATTR_FORMAT(2, 3); void mail_storage_set_internal_error(struct mail_storage *storage); +void mail_storage_set_index_error(struct mailbox *box); bool mail_storage_set_error_from_errno(struct mail_storage *storage); int mail_set_aborted(struct mail *mail); diff -r 9d3b5cbef222 -r e7f066508299 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/lib-storage/mail-storage.c Sun Feb 07 15:44:33 2010 +0200 @@ -381,6 +381,15 @@ } } +void mail_storage_set_index_error(struct mailbox *box) +{ + if (mail_index_is_deleted(box->index)) + mailbox_set_deleted(box); + else + mail_storage_set_internal_error(box->storage); + mail_index_reset_error(box->index); +} + const struct mail_storage_settings * mail_storage_get_settings(struct mail_storage *storage) { diff -r 9d3b5cbef222 -r e7f066508299 src/plugins/virtual/virtual-mail.c --- a/src/plugins/virtual/virtual-mail.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/plugins/virtual/virtual-mail.c Sun Feb 07 15:44:33 2010 +0200 @@ -116,7 +116,7 @@ const void *data; bool expunged; - mail_index_lookup_ext(mbox->ibox.view, seq, mbox->virtual_ext_id, + mail_index_lookup_ext(mail->box->view, seq, mbox->virtual_ext_id, &data, &expunged); vrec = data; @@ -130,7 +130,7 @@ vmail->imail.data.seq = seq; mail->seq = seq; - mail_index_lookup_uid(mbox->ibox.view, seq, &mail->uid); + mail_index_lookup_uid(mail->box->view, seq, &mail->uid); if (!vmail->lost) { mail->expunged = vmail->backend_mail->expunged; @@ -145,10 +145,9 @@ static bool virtual_mail_set_uid(struct mail *mail, uint32_t uid) { - struct virtual_mailbox *mbox = (struct virtual_mailbox *)mail->box; uint32_t seq; - if (!mail_index_lookup_seq(mbox->ibox.view, uid, &seq)) + if (!mail_index_lookup_seq(mail->box->view, uid, &seq)) return FALSE; virtual_mail_set_seq(mail, seq); diff -r 9d3b5cbef222 -r e7f066508299 src/plugins/virtual/virtual-search.c --- a/src/plugins/virtual/virtual-search.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/plugins/virtual/virtual-search.c Sun Feb 07 15:44:33 2010 +0200 @@ -82,7 +82,7 @@ seq_range_array_add(&vctx->result, 0, ctx->seq); } else { /* possible match, save and check later */ - mail_index_lookup_ext(mbox->ibox.view, ctx->seq, + mail_index_lookup_ext(mbox->ibox.box.view, ctx->seq, mbox->virtual_ext_id, &data, &expunged); vrec = data; diff -r 9d3b5cbef222 -r e7f066508299 src/plugins/virtual/virtual-storage.c --- a/src/plugins/virtual/virtual-storage.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/plugins/virtual/virtual-storage.c Sun Feb 07 15:44:33 2010 +0200 @@ -201,7 +201,7 @@ mbox->ibox.box.pool = pool; mbox->ibox.box.storage = _storage; mbox->ibox.box.list = list; - mbox->ibox.mail_vfuncs = &virtual_mail_vfuncs; + mbox->ibox.box.mail_vfuncs = &virtual_mail_vfuncs; index_storage_mailbox_alloc(&mbox->ibox, name, input, flags, VIRTUAL_INDEX_PREFIX); @@ -210,7 +210,7 @@ mbox->vseq_lookup_prev_mailbox = i_strdup(""); mbox->virtual_ext_id = - mail_index_ext_register(mbox->ibox.index, "virtual", 0, + mail_index_ext_register(mbox->ibox.box.index, "virtual", 0, sizeof(struct virtual_mail_index_record), sizeof(uint32_t)); return &mbox->ibox.box; diff -r 9d3b5cbef222 -r e7f066508299 src/plugins/virtual/virtual-sync.c --- a/src/plugins/virtual/virtual-sync.c Sun Feb 07 04:50:40 2010 +0200 +++ b/src/plugins/virtual/virtual-sync.c Sun Feb 07 15:44:33 2010 +0200 @@ -642,7 +642,6 @@ struct virtual_backend_box *bbox, struct mail_search_result *result) { - struct index_mailbox *ibox = (struct index_mailbox *)bbox->box; const struct virtual_mail_index_record *vrec; struct virtual_backend_uidmap uidmap; const void *data; @@ -666,8 +665,8 @@ uidmap.virtual_uid = vuid; array_append(&bbox->uids, &uidmap, 1); - if (mail_index_lookup_seq(ibox->view, vrec->real_uid, - &seq)) { + if (mail_index_lookup_seq(bbox->box->view, + vrec->real_uid, &seq)) { seq_range_array_add(&result->uids, 0, vrec->real_uid); } else { @@ -686,7 +685,7 @@ const enum mailbox_search_result_flags result_flags = MAILBOX_SEARCH_RESULT_FLAG_UPDATE | MAILBOX_SEARCH_RESULT_FLAG_QUEUE_SYNC; - struct index_mailbox *ibox = (struct index_mailbox *)bbox->box; + struct mail_index_view *view = bbox->box->view; struct mail_search_result *result; ARRAY_TYPE(seq_range) removed_uids, added_uids, flag_update_uids; uint64_t modseq, old_highest_modseq; @@ -703,17 +702,17 @@ virtual index), based on modseq changes. (we'll assume all modseq changes are due to flag changes, which may not be true in future) */ if (bbox->sync_next_uid <= 1 || - !mail_index_lookup_seq_range(ibox->view, 1, bbox->sync_next_uid-1, + !mail_index_lookup_seq_range(view, 1, bbox->sync_next_uid-1, &seq, &old_msg_count)) old_msg_count = 0; - old_highest_modseq = mail_index_modseq_get_highest(ibox->view); + old_highest_modseq = mail_index_modseq_get_highest(view); t_array_init(&flag_update_uids, I_MIN(128, old_msg_count)); if (bbox->sync_highest_modseq < old_highest_modseq) { for (seq = 1; seq <= old_msg_count; seq++) { - modseq = mail_index_modseq_lookup(ibox->view, seq); + modseq = mail_index_modseq_lookup(view, seq); if (modseq > bbox->sync_highest_modseq) { - mail_index_lookup_uid(ibox->view, seq, &uid); + mail_index_lookup_uid(view, seq, &uid); seq_range_array_add(&flag_update_uids, 0, uid); } } @@ -882,13 +881,12 @@ unsigned int *idx1_r, unsigned int *idx2_r) { - struct index_mailbox *ibox = (struct index_mailbox *)bbox->box; const struct virtual_backend_uidmap *uidmap; unsigned int idx, count; uint32_t uid1, uid2; - mail_index_lookup_uid(ibox->view, sync_rec->seq1, &uid1); - mail_index_lookup_uid(ibox->view, sync_rec->seq2, &uid2); + mail_index_lookup_uid(bbox->box->view, sync_rec->seq1, &uid1); + mail_index_lookup_uid(bbox->box->view, sync_rec->seq2, &uid2); (void)array_bsearch_insert_pos(&bbox->uids, &uid1, virtual_backend_uidmap_bsearch_cmp, &idx); @@ -907,13 +905,12 @@ struct virtual_backend_box *bbox, const struct mailbox_sync_rec *sync_rec) { - struct index_mailbox *ibox = (struct index_mailbox *)bbox->box; struct virtual_backend_uidmap *uidmap; uint32_t uid1, uid2; unsigned int i, idx1, count; - mail_index_lookup_uid(ibox->view, sync_rec->seq1, &uid1); - mail_index_lookup_uid(ibox->view, sync_rec->seq2, &uid2); + mail_index_lookup_uid(bbox->box->view, sync_rec->seq1, &uid1); + mail_index_lookup_uid(bbox->box->view, sync_rec->seq2, &uid2); /* remember only the expunges for messages that already exist for this mailbox */ @@ -1019,7 +1016,6 @@ static int virtual_sync_backend_box(struct virtual_sync_context *ctx, struct virtual_backend_box *bbox) { - struct index_mailbox *ibox = (struct index_mailbox *)bbox->box; enum mailbox_sync_flags sync_flags; struct mailbox_status status; int ret; @@ -1034,7 +1030,7 @@ virtual_backend_box_sync_mail_unset(bbox); /* we use modseqs for speeding up initial search result build. make sure the backend has them enabled. */ - mail_index_modseq_enable(ibox->index); + mail_index_modseq_enable(bbox->box->index); sync_flags = ctx->flags & (MAILBOX_SYNC_FLAG_FULL_READ | MAILBOX_SYNC_FLAG_FULL_WRITE | @@ -1356,7 +1352,7 @@ seq_range_array_iter_init(&iter, isync_ctx->expunges); while (seq_range_array_iter_nth(&iter, n++, &seq)) { - mail_index_lookup_ext(mbox->ibox.view, seq, + mail_index_lookup_ext(mbox->ibox.box.view, seq, mbox->virtual_ext_id, &data, &expunged); vrec = data; @@ -1418,7 +1414,7 @@ virtual_sync_backend_boxes_finish(ctx); if (success) { if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) { - mail_storage_set_index_error(&ctx->mbox->ibox); + mail_storage_set_index_error(&ctx->mbox->ibox.box); ret = -1; } } else { @@ -1447,7 +1443,7 @@ ctx = i_new(struct virtual_sync_context, 1); ctx->mbox = mbox; ctx->flags = flags; - ctx->index = mbox->ibox.index; + ctx->index = mbox->ibox.box.index; /* Removed messages are expunged when a) EXPUNGE is used b) Mailbox is being opened (FIX_INCONSISTENT is set) */ @@ -1465,7 +1461,7 @@ index_sync_flags); if (ret <= 0) { if (ret < 0) - mail_storage_set_index_error(&mbox->ibox); + mail_storage_set_index_error(&mbox->ibox.box); i_free(ctx); return ret; }