Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6279:f52e7d1402b5 HEAD
mail_index_view_sync_next() and mailbox_sync_next() returns now bool.
Renamed void mailbox_index_view_sync_end() to int
mailbox_index_view_sync_commit().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 12 Aug 2007 18:16:40 +0300 |
parents | ce83635191d4 |
children | eb7c9d8ece54 |
files | src/deliver/deliver.c src/imap/imap-sync.c src/lib-index/mail-index-view-sync.c src/lib-index/mail-index.h src/lib-storage/index/index-storage.h src/lib-storage/index/index-sync.c src/lib-storage/list/index-mailbox-list-sync.c src/lib-storage/mail-storage-private.h src/lib-storage/mail-storage.c src/lib-storage/mail-storage.h src/plugins/convert/convert-storage.c src/plugins/mbox-snarf/mbox-snarf-plugin.c src/plugins/trash/trash-plugin.c src/pop3/client.c |
diffstat | 14 files changed, 44 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/src/deliver/deliver.c Sun Aug 12 18:07:22 2007 +0300 +++ b/src/deliver/deliver.c Sun Aug 12 18:16:40 2007 +0300 @@ -75,7 +75,7 @@ struct mailbox_sync_rec sync_rec; ctx = mailbox_sync_init(box, 0); - while (mailbox_sync_next(ctx, &sync_rec) > 0) + while (mailbox_sync_next(ctx, &sync_rec)) ; return mailbox_sync_deinit(&ctx, 0, NULL); }
--- a/src/imap/imap-sync.c Sun Aug 12 18:07:22 2007 +0300 +++ b/src/imap/imap-sync.c Sun Aug 12 18:16:40 2007 +0300 @@ -113,13 +113,9 @@ for (;;) { if (ctx->seq == 0) { /* get next one */ - ret = mailbox_sync_next(ctx->sync_ctx, - &ctx->sync_rec); - if (ret <= 0) { - if (ret == 0) { - /* all finished ok */ - ret = 1; - } + if (!mailbox_sync_next(ctx->sync_ctx, &ctx->sync_rec)) { + /* finished */ + ret = 1; break; } } @@ -199,7 +195,7 @@ struct mailbox_sync_rec sync_rec; ctx = mailbox_sync_init(box, flags); - while (mailbox_sync_next(ctx, &sync_rec) > 0) + while (mailbox_sync_next(ctx, &sync_rec)) ; return mailbox_sync_deinit(&ctx, 0, NULL); }
--- a/src/lib-index/mail-index-view-sync.c Sun Aug 12 18:07:22 2007 +0300 +++ b/src/lib-index/mail-index-view-sync.c Sun Aug 12 18:16:40 2007 +0300 @@ -19,6 +19,7 @@ const void *data; size_t data_offset; + unsigned int failed:1; unsigned int sync_map_update:1; unsigned int skipped_expunges:1; unsigned int last_read:1; @@ -556,22 +557,25 @@ return TRUE; } -int mail_index_view_sync_next(struct mail_index_view_sync_ctx *ctx, - struct mail_index_view_sync_rec *sync_rec) +bool mail_index_view_sync_next(struct mail_index_view_sync_ctx *ctx, + struct mail_index_view_sync_rec *sync_rec) { int ret; do { if (ctx->hdr == NULL || ctx->data_offset == ctx->hdr->size) { ret = mail_index_view_sync_get_next_transaction(ctx); - if (ret <= 0) - return ret; + if (ret <= 0) { + if (ret < 0) + ctx->failed = TRUE; + return FALSE; + } ctx->data_offset = 0; } } while (!mail_index_view_sync_get_rec(ctx, sync_rec)); - return 1; + return TRUE; } void mail_index_view_sync_get_expunges(struct mail_index_view_sync_ctx *ctx, @@ -602,10 +606,11 @@ array_delete(&view->syncs_hidden, 0, i); } -void mail_index_view_sync_end(struct mail_index_view_sync_ctx **_ctx) +int mail_index_view_sync_commit(struct mail_index_view_sync_ctx **_ctx) { struct mail_index_view_sync_ctx *ctx = *_ctx; struct mail_index_view *view = ctx->view; + int ret = ctx->failed ? -1 : 0; i_assert(view->syncing); @@ -614,6 +619,7 @@ if (!ctx->last_read) { /* we didn't sync everything */ view->inconsistent = TRUE; + ret = -1; } if (view->sync_new_map != NULL) { @@ -652,6 +658,7 @@ view->syncing = FALSE; i_free(ctx); + return ret; } void mail_index_view_add_hidden_transaction(struct mail_index_view *view,
--- a/src/lib-index/mail-index.h Sun Aug 12 18:07:22 2007 +0300 +++ b/src/lib-index/mail-index.h Sun Aug 12 18:16:40 2007 +0300 @@ -284,13 +284,12 @@ int mail_index_view_sync_begin(struct mail_index_view *view, enum mail_index_view_sync_flags flags, struct mail_index_view_sync_ctx **ctx_r); -/* Returns -1 if error, 0 if sync is finished, 1 if record was filled. */ -int mail_index_view_sync_next(struct mail_index_view_sync_ctx *ctx, - struct mail_index_view_sync_rec *sync_rec); +bool mail_index_view_sync_next(struct mail_index_view_sync_ctx *ctx, + struct mail_index_view_sync_rec *sync_rec); void mail_index_view_sync_get_expunges(struct mail_index_view_sync_ctx *ctx, const ARRAY_TYPE(seq_range) **expunges_r); -void mail_index_view_sync_end(struct mail_index_view_sync_ctx **ctx); +int mail_index_view_sync_commit(struct mail_index_view_sync_ctx **ctx); /* Returns the index header. */ const struct mail_index_header *
--- a/src/lib-storage/index/index-storage.h Sun Aug 12 18:07:22 2007 +0300 +++ b/src/lib-storage/index/index-storage.h Sun Aug 12 18:16:40 2007 +0300 @@ -129,8 +129,8 @@ struct mailbox_sync_context * index_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags, bool failed); -int index_mailbox_sync_next(struct mailbox_sync_context *ctx, - struct mailbox_sync_rec *sync_rec_r); +bool index_mailbox_sync_next(struct mailbox_sync_context *ctx, + struct mailbox_sync_rec *sync_rec_r); int index_mailbox_sync_deinit(struct mailbox_sync_context *ctx, enum mailbox_status_items status_items, struct mailbox_status *status_r);
--- a/src/lib-storage/index/index-sync.c Sun Aug 12 18:07:22 2007 +0300 +++ b/src/lib-storage/index/index-sync.c Sun Aug 12 18:16:40 2007 +0300 @@ -179,18 +179,17 @@ return TRUE; } -int index_mailbox_sync_next(struct mailbox_sync_context *_ctx, - struct mailbox_sync_rec *sync_rec_r) +bool index_mailbox_sync_next(struct mailbox_sync_context *_ctx, + struct mailbox_sync_rec *sync_rec_r) { struct index_mailbox_sync_context *ctx = (struct index_mailbox_sync_context *)_ctx; struct mail_index_view_sync_rec sync; - int ret; if (ctx->failed) - return -1; + return FALSE; - while ((ret = mail_index_view_sync_next(ctx->sync_ctx, &sync)) > 0) { + while (mail_index_view_sync_next(ctx->sync_ctx, &sync)) { switch (sync.type) { case MAIL_INDEX_SYNC_TYPE_APPEND: /* not interested */ @@ -220,10 +219,6 @@ return 1; } } - if (ret < 0) { - mail_storage_set_index_error(ctx->ibox); - return -1; - } if (ctx->expunge_pos > 0) { /* expunges is a sorted array of sequences. it's easiest for @@ -316,8 +311,10 @@ uint32_t seq1, seq2; int ret = ctx->failed ? -1 : 0; - if (ctx->sync_ctx != NULL) - mail_index_view_sync_end(&ctx->sync_ctx); + if (ctx->sync_ctx != NULL) { + if (mail_index_view_sync_commit(&ctx->sync_ctx) < 0) + ret = -1; + } index_mailbox_expunge_unseen_recent(ctx); if (ibox->keep_recent) {
--- a/src/lib-storage/list/index-mailbox-list-sync.c Sun Aug 12 18:07:22 2007 +0300 +++ b/src/lib-storage/list/index-mailbox-list-sync.c Sun Aug 12 18:16:40 2007 +0300 @@ -296,13 +296,13 @@ return ibox->module_ctx.super.sync_init(box, flags); } -static int index_list_sync_next(struct mailbox_sync_context *ctx, - struct mailbox_sync_rec *sync_rec_r) +static bool index_list_sync_next(struct mailbox_sync_context *ctx, + struct mailbox_sync_rec *sync_rec_r) { struct index_list_mailbox *ibox = INDEX_LIST_STORAGE_CONTEXT(ctx->box); if (!ctx->box->opened) - return 0; + return FALSE; return ibox->module_ctx.super.sync_next(ctx, sync_rec_r); }
--- a/src/lib-storage/mail-storage-private.h Sun Aug 12 18:07:22 2007 +0300 +++ b/src/lib-storage/mail-storage-private.h Sun Aug 12 18:16:40 2007 +0300 @@ -92,8 +92,8 @@ struct mailbox_sync_context * (*sync_init)(struct mailbox *box, enum mailbox_sync_flags flags); - int (*sync_next)(struct mailbox_sync_context *ctx, - struct mailbox_sync_rec *sync_rec_r); + bool (*sync_next)(struct mailbox_sync_context *ctx, + struct mailbox_sync_rec *sync_rec_r); int (*sync_deinit)(struct mailbox_sync_context *ctx, enum mailbox_status_items status_items, struct mailbox_status *status_r);
--- a/src/lib-storage/mail-storage.c Sun Aug 12 18:07:22 2007 +0300 +++ b/src/lib-storage/mail-storage.c Sun Aug 12 18:16:40 2007 +0300 @@ -498,8 +498,8 @@ return box->v.sync_init(box, flags); } -int mailbox_sync_next(struct mailbox_sync_context *ctx, - struct mailbox_sync_rec *sync_rec_r) +bool mailbox_sync_next(struct mailbox_sync_context *ctx, + struct mailbox_sync_rec *sync_rec_r) { return ctx->box->v.sync_next(ctx, sync_rec_r); }
--- a/src/lib-storage/mail-storage.h Sun Aug 12 18:07:22 2007 +0300 +++ b/src/lib-storage/mail-storage.h Sun Aug 12 18:16:40 2007 +0300 @@ -285,8 +285,8 @@ /* Synchronize the mailbox. */ struct mailbox_sync_context * mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags); -int mailbox_sync_next(struct mailbox_sync_context *ctx, - struct mailbox_sync_rec *sync_rec_r); +bool mailbox_sync_next(struct mailbox_sync_context *ctx, + struct mailbox_sync_rec *sync_rec_r); int mailbox_sync_deinit(struct mailbox_sync_context **ctx, enum mailbox_status_items status_items, struct mailbox_status *status_r);
--- a/src/plugins/convert/convert-storage.c Sun Aug 12 18:07:22 2007 +0300 +++ b/src/plugins/convert/convert-storage.c Sun Aug 12 18:16:40 2007 +0300 @@ -31,7 +31,7 @@ struct mailbox_sync_rec sync_rec; ctx = mailbox_sync_init(box, MAILBOX_SYNC_FLAG_FULL_READ); - while (mailbox_sync_next(ctx, &sync_rec) > 0) + while (mailbox_sync_next(ctx, &sync_rec)) ; return mailbox_sync_deinit(&ctx, 0, NULL); }
--- a/src/plugins/mbox-snarf/mbox-snarf-plugin.c Sun Aug 12 18:07:22 2007 +0300 +++ b/src/plugins/mbox-snarf/mbox-snarf-plugin.c Sun Aug 12 18:16:40 2007 +0300 @@ -41,7 +41,7 @@ struct mailbox_sync_rec sync_rec; ctx = mailbox_sync_init(box, MAILBOX_SYNC_FLAG_FULL_READ); - while (mailbox_sync_next(ctx, &sync_rec) > 0) + while (mailbox_sync_next(ctx, &sync_rec)) ; return mailbox_sync_deinit(&ctx, 0, NULL); }
--- a/src/plugins/trash/trash-plugin.c Sun Aug 12 18:07:22 2007 +0300 +++ b/src/plugins/trash/trash-plugin.c Sun Aug 12 18:16:40 2007 +0300 @@ -48,7 +48,7 @@ struct mailbox_sync_rec sync_rec; ctx = mailbox_sync_init(box, MAILBOX_SYNC_FLAG_FULL_READ); - while (mailbox_sync_next(ctx, &sync_rec) > 0) + while (mailbox_sync_next(ctx, &sync_rec)) ; return mailbox_sync_deinit(&ctx, 0, NULL); }
--- a/src/pop3/client.c Sun Aug 12 18:07:22 2007 +0300 +++ b/src/pop3/client.c Sun Aug 12 18:16:40 2007 +0300 @@ -44,7 +44,7 @@ struct mailbox_sync_rec sync_rec; ctx = mailbox_sync_init(box, MAILBOX_SYNC_FLAG_FULL_READ); - while (mailbox_sync_next(ctx, &sync_rec) > 0) + while (mailbox_sync_next(ctx, &sync_rec)) ; return mailbox_sync_deinit(&ctx, STATUS_UIDVALIDITY, status); }