Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6278:ce83635191d4 HEAD
mail_index_sync_next() can't fail anymore.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 12 Aug 2007 18:07:22 +0300 |
parents | 5f66277bbe40 |
children | f52e7d1402b5 |
files | src/lib-index/mail-index-sync.c src/lib-index/mail-index.h src/lib-index/mailbox-list-index-sync.c src/lib-storage/index/cydir/cydir-sync.c src/lib-storage/index/dbox/dbox-sync.c src/lib-storage/index/index-sync-changes.c src/lib-storage/index/index-sync-changes.h src/lib-storage/index/maildir/maildir-sync-index.c src/lib-storage/index/mbox/mbox-sync.c src/lib-storage/list/index-mailbox-list-sync.c |
diffstat | 10 files changed, 26 insertions(+), 59 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-sync.c Sun Aug 12 18:02:29 2007 +0300 +++ b/src/lib-index/mail-index-sync.c Sun Aug 12 18:07:22 2007 +0300 @@ -445,8 +445,8 @@ rec->uid2 = range->uid2; } -int mail_index_sync_next(struct mail_index_sync_ctx *ctx, - struct mail_index_sync_rec *sync_rec) +bool mail_index_sync_next(struct mail_index_sync_ctx *ctx, + struct mail_index_sync_rec *sync_rec) { struct mail_index_transaction *sync_trans = ctx->sync_trans; struct mail_index_sync_list *sync_list; @@ -485,9 +485,9 @@ sync_rec->type = MAIL_INDEX_SYNC_TYPE_APPEND; sync_rec->uid1 = ctx->append_uid_first; sync_rec->uid2 = ctx->append_uid_last; - return 1; + return TRUE; } - return 0; + return FALSE; } ctx->next_uid = next_found_uid; i = next_i; @@ -507,7 +507,7 @@ &sync_list[i]); } sync_list[i].idx++; - return 1; + return TRUE; } bool mail_index_sync_have_more(struct mail_index_sync_ctx *ctx)
--- a/src/lib-index/mail-index.h Sun Aug 12 18:02:29 2007 +0300 +++ b/src/lib-index/mail-index.h Sun Aug 12 18:07:22 2007 +0300 @@ -258,8 +258,8 @@ uint32_t log_file_seq, uoff_t log_file_offset, enum mail_index_sync_flags flags); /* Returns -1 if error, 0 if sync is finished, 1 if record was filled. */ -int mail_index_sync_next(struct mail_index_sync_ctx *ctx, - struct mail_index_sync_rec *sync_rec); +bool mail_index_sync_next(struct mail_index_sync_ctx *ctx, + struct mail_index_sync_rec *sync_rec); /* Returns TRUE if there's more to sync. */ bool mail_index_sync_have_more(struct mail_index_sync_ctx *ctx); /* Reset syncing to initial state after mail_index_sync_begin(), so you can
--- a/src/lib-index/mailbox-list-index-sync.c Sun Aug 12 18:02:29 2007 +0300 +++ b/src/lib-index/mailbox-list-index-sync.c Sun Aug 12 18:07:22 2007 +0300 @@ -371,7 +371,7 @@ /* we should have only external transactions in here, for which we don't need to do anything but write them to the index */ - while (mail_index_sync_next(ctx->mail_sync_ctx, &sync_rec) > 0) + while (mail_index_sync_next(ctx->mail_sync_ctx, &sync_rec)) ; return 0; }
--- a/src/lib-storage/index/cydir/cydir-sync.c Sun Aug 12 18:02:29 2007 +0300 +++ b/src/lib-storage/index/cydir/cydir-sync.c Sun Aug 12 18:07:22 2007 +0300 @@ -59,13 +59,12 @@ } } -static int cydir_sync_index(struct cydir_sync_context *ctx) +static void cydir_sync_index(struct cydir_sync_context *ctx) { struct mailbox *box = &ctx->mbox->ibox.box; const struct mail_index_header *hdr; struct mail_index_sync_rec sync_rec; uint32_t seq1, seq2; - int ret = 1; hdr = mail_index_get_header(ctx->sync_view); if (hdr->uid_validity != 0) @@ -81,9 +80,7 @@ seq1, seq2); } - while (ret > 0 && - (ret = mail_index_sync_next(ctx->index_sync_ctx, - &sync_rec)) > 0) { + while (mail_index_sync_next(ctx->index_sync_ctx, &sync_rec)) { mail_index_lookup_uid_range(ctx->sync_view, sync_rec.uid1, sync_rec.uid2, &seq1, &seq2); @@ -110,7 +107,6 @@ if (box->v.sync_notify != NULL) box->v.sync_notify(box, 0, 0); - return ret; } int cydir_sync_begin(struct cydir_mailbox *mbox, @@ -137,12 +133,7 @@ return ret; } - if (cydir_sync_index(ctx) < 0) { - mail_index_sync_rollback(&ctx->index_sync_ctx); - i_free(ctx); - return -1; - } - + cydir_sync_index(ctx); *ctx_r = ctx; return 0; }
--- a/src/lib-storage/index/dbox/dbox-sync.c Sun Aug 12 18:02:29 2007 +0300 +++ b/src/lib-storage/index/dbox/dbox-sync.c Sun Aug 12 18:07:22 2007 +0300 @@ -420,12 +420,8 @@ ctx->syncs = hash_create(default_pool, ctx->pool, 0, NULL, NULL); i_array_init(&ctx->added_file_seqs, 64); for (;;) { - ret = mail_index_sync_next(ctx->index_sync_ctx, &sync_rec); - if (ret <= 0) { - if (ret < 0) - mail_storage_set_index_error(&ctx->mbox->ibox); + if (!mail_index_sync_next(ctx->index_sync_ctx, &sync_rec)) break; - } if (dbox_sync_add(ctx, &sync_rec) < 0) { ret = -1; break;
--- a/src/lib-storage/index/index-sync-changes.c Sun Aug 12 18:02:29 2007 +0300 +++ b/src/lib-storage/index/index-sync-changes.c Sun Aug 12 18:07:22 2007 +0300 @@ -86,13 +86,12 @@ return FALSE; } -int index_sync_changes_read(struct index_sync_changes_context *ctx, - uint32_t uid, bool *sync_expunge_r) +void index_sync_changes_read(struct index_sync_changes_context *ctx, + uint32_t uid, bool *sync_expunge_r) { struct mail_index_sync_rec *sync_rec = &ctx->sync_rec; uint32_t seq1, seq2; unsigned int orig_count; - int ret; *sync_expunge_r = FALSE; @@ -108,13 +107,7 @@ *sync_expunge_r = TRUE; } - ret = mail_index_sync_next(ctx->index_sync_ctx, sync_rec); - if (ret < 0) { - mail_storage_set_index_error(ctx->ibox); - return -1; - } - - if (ret == 0) { + if (!mail_index_sync_next(ctx->index_sync_ctx, sync_rec)) { memset(sync_rec, 0, sizeof(*sync_rec)); break; } @@ -154,8 +147,6 @@ *sync_expunge_r = index_sync_changes_have_expunges(ctx, orig_count); } - - return 0; } bool index_sync_changes_have(struct index_sync_changes_context *ctx)
--- a/src/lib-storage/index/index-sync-changes.h Sun Aug 12 18:02:29 2007 +0300 +++ b/src/lib-storage/index/index-sync-changes.h Sun Aug 12 18:07:22 2007 +0300 @@ -13,8 +13,8 @@ void index_sync_changes_delete_to(struct index_sync_changes_context *ctx, uint32_t last_uid); -int index_sync_changes_read(struct index_sync_changes_context *ctx, - uint32_t uid, bool *sync_expunge_r); +void index_sync_changes_read(struct index_sync_changes_context *ctx, + uint32_t uid, bool *sync_expunge_r); bool index_sync_changes_have(struct index_sync_changes_context *ctx); uint32_t index_sync_changes_get_next_uid(struct index_sync_changes_context *ctx);
--- a/src/lib-storage/index/maildir/maildir-sync-index.c Sun Aug 12 18:02:29 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-sync-index.c Sun Aug 12 18:07:22 2007 +0300 @@ -362,12 +362,7 @@ continue; } - if (index_sync_changes_read(ctx->sync_changes, rec->uid, - &expunged) < 0) { - ret = -1; - break; - } - + index_sync_changes_read(ctx->sync_changes, rec->uid, &expunged); if (expunged) { if (maildir_file_do(mbox, ctx->uid, maildir_expunge, ctx) >= 0) {
--- a/src/lib-storage/index/mbox/mbox-sync.c Sun Aug 12 18:02:29 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync.c Sun Aug 12 18:07:22 2007 +0300 @@ -163,23 +163,19 @@ return 1; } -static int mbox_sync_read_index_syncs(struct mbox_sync_context *sync_ctx, - uint32_t uid, bool *sync_expunge_r) +static void mbox_sync_read_index_syncs(struct mbox_sync_context *sync_ctx, + uint32_t uid, bool *sync_expunge_r) { if (uid == 0 || sync_ctx->index_reset) { /* nothing for this or the future ones */ uid = (uint32_t)-1; } - if (index_sync_changes_read(sync_ctx->sync_changes, uid, - sync_expunge_r) < 0) - return -1; - + index_sync_changes_read(sync_ctx->sync_changes, uid, sync_expunge_r); if (sync_ctx->mbox->mbox_readonly) { /* we can't expunge anything from read-only mboxes */ *sync_expunge_r = FALSE; } - return 0; } static bool @@ -1017,10 +1013,9 @@ /* get all sync records related to this message. with pseudo message just get the first sync record so we can jump to it with partial seeking. */ - if (mbox_sync_read_index_syncs(sync_ctx, - mail_ctx->mail.pseudo ? 1 : uid, - &expunged) < 0) - return -1; + mbox_sync_read_index_syncs(sync_ctx, + mail_ctx->mail.pseudo ? 1 : uid, + &expunged); if (mail_ctx->mail.pseudo) { /* if it was set, it was for the next message */ @@ -1690,8 +1685,7 @@ bool expunged; uint32_t uid; - if (mbox_sync_read_index_syncs(&sync_ctx, 1, &expunged) < 0) - return -1; + mbox_sync_read_index_syncs(&sync_ctx, 1, &expunged); uid = expunged ? 1 : index_sync_changes_get_next_uid(sync_ctx.sync_changes); if (uid == 0) {
--- a/src/lib-storage/list/index-mailbox-list-sync.c Sun Aug 12 18:02:29 2007 +0300 +++ b/src/lib-storage/list/index-mailbox-list-sync.c Sun Aug 12 18:07:22 2007 +0300 @@ -75,7 +75,7 @@ /* we should have only external transactions in here, for which we don't need to do anything but write them to the index */ - while (mail_index_sync_next(mail_sync_ctx, &sync_rec) > 0) + while (mail_index_sync_next(mail_sync_ctx, &sync_rec)) ; return mail_index_sync_commit(&mail_sync_ctx);