Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2321:d803ba0206f0 HEAD
View syncing fixes/cleanups.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 12 Jul 2004 14:31:34 +0300 |
parents | 8a6666a9ac98 |
children | aae574ed7f4c |
files | src/lib-index/mail-index-view-sync.c |
diffstat | 1 files changed, 19 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-view-sync.c Mon Jul 12 11:07:03 2004 +0300 +++ b/src/lib-index/mail-index-view-sync.c Mon Jul 12 14:31:34 2004 +0300 @@ -9,14 +9,14 @@ struct mail_index_view_sync_ctx { struct mail_index_view *view; - enum mail_index_sync_type sync_mask; + enum mail_transaction_type trans_sync_mask; buffer_t *expunges; const struct mail_transaction_header *hdr; const void *data; size_t data_offset; - unsigned int skipped:1; + unsigned int skipped_some:1; unsigned int last_read:1; unsigned int sync_map_update:1; }; @@ -78,13 +78,12 @@ const struct mail_index_header *hdr; struct mail_index_view_sync_ctx *ctx; struct mail_index_map *map; - enum mail_transaction_type mask; + enum mail_transaction_type mask, want_mask; buffer_t *expunges = NULL; /* We must sync flags as long as view is mmap()ed, as the flags may have already changed under us. */ i_assert((sync_mask & MAIL_INDEX_SYNC_TYPE_FLAGS) != 0); - i_assert(view->transactions == 0); i_assert(!view->syncing); if (mail_index_view_lock_head(view, TRUE) < 0) @@ -97,7 +96,13 @@ return -1; } - mask = mail_transaction_type_mask_get(sync_mask); + /* only flags, appends and expunges can be left to be synced later */ + want_mask = mail_transaction_type_mask_get(sync_mask); + mask = want_mask | + (MAIL_TRANSACTION_TYPE_MASK ^ + (MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_APPEND | + MAIL_TRANSACTION_FLAG_UPDATE)); + if (mail_transaction_log_view_set(view->log_view, view->log_file_seq, view->log_file_offset, @@ -110,7 +115,7 @@ ctx = i_new(struct mail_index_view_sync_ctx, 1); ctx->view = view; - ctx->sync_mask = sync_mask; + ctx->trans_sync_mask = want_mask; ctx->expunges = expunges; if ((sync_mask & MAIL_INDEX_SYNC_TYPE_EXPUNGE) != 0) { @@ -177,7 +182,7 @@ } if (skipped) - ctx->skipped = TRUE; + ctx->skipped_some = TRUE; mail_transaction_log_view_get_prev_pos(log_view, seq_r, offset_r); @@ -201,6 +206,9 @@ return -1; } + if ((ctx->hdr->type & ctx->trans_sync_mask) == 0) + return 0; + return 1; } @@ -273,7 +281,7 @@ if (ctx->last_read) return 0; - if (!ctx->skipped) { + if (!ctx->skipped_some) { view->log_file_seq = seq; view->log_file_offset = offset + sizeof(*ctx->hdr) + @@ -281,7 +289,7 @@ } } while (ret == 0); - if (ctx->skipped) { + if (ctx->skipped_some) { mail_index_view_add_synced_transaction(view, seq, offset); @@ -310,7 +318,7 @@ i_assert(view->syncing); - if (view->log_syncs != NULL && !ctx->skipped) + if (view->log_syncs != NULL && !ctx->skipped_some) buffer_set_used_size(view->log_syncs, 0); if (!ctx->last_read && ctx->hdr != NULL && @@ -326,7 +334,7 @@ view->map_protected = FALSE; } - if ((ctx->sync_mask & MAIL_INDEX_SYNC_TYPE_APPEND) != 0) + if ((ctx->trans_sync_mask & MAIL_TRANSACTION_APPEND) != 0) view->messages_count = view->map->records_count; (void)mail_transaction_log_view_set(view->log_view,