Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5728:7aab5d99fb45 HEAD
Removed sync_mask parameter from mail_transaction_log_view_set(). The user
will now have to check the types itself.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 13 Jun 2007 23:00:58 +0300 |
parents | d9d047b743d5 |
children | c3e32c3fb2bf |
files | src/lib-index/mail-index-sync-update.c src/lib-index/mail-index-sync.c src/lib-index/mail-index-view-sync.c src/lib-index/mail-transaction-log-view.c src/lib-index/mail-transaction-log.h |
diffstat | 5 files changed, 50 insertions(+), 80 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-sync-update.c Wed Jun 13 22:57:25 2007 +0300 +++ b/src/lib-index/mail-index-sync-update.c Wed Jun 13 23:00:58 2007 +0300 @@ -801,8 +801,7 @@ if (mail_transaction_log_view_set(view->log_view, map->hdr.log_file_seq, map->hdr.log_file_index_int_offset, - (uint32_t)-1, (uoff_t)-1, - MAIL_TRANSACTION_TYPE_MASK) <= 0) { + (uint32_t)-1, (uoff_t)-1) <= 0) { /* can't use it. sync by re-reading index. */ mail_index_view_close(&view); return 0; @@ -848,7 +847,7 @@ all */ expunge_seq = expunge_offset = 0; while ((ret = mail_transaction_log_view_next(view->log_view, &thdr, - &tdata, NULL)) > 0) { + &tdata)) > 0) { mail_transaction_log_view_get_prev_pos(view->log_view, &prev_seq, &prev_offset);
--- a/src/lib-index/mail-index-sync.c Wed Jun 13 22:57:25 2007 +0300 +++ b/src/lib-index/mail-index-sync.c Wed Jun 13 23:00:58 2007 +0300 @@ -241,7 +241,7 @@ included in our view */ while ((ret = mail_transaction_log_view_next(ctx->view->log_view, &ctx->hdr, - &ctx->data, NULL)) > 0) { + &ctx->data)) > 0) { if ((ctx->hdr->type & MAIL_TRANSACTION_EXTERNAL) != 0) continue; @@ -321,8 +321,7 @@ ret = mail_transaction_log_view_set(view->log_view, start_file_seq, start_file_offset, - log_seq, log_offset, - MAIL_TRANSACTION_TYPE_MASK); + log_seq, log_offset); if (ret <= 0) { /* either corrupted or the file was deleted for some reason. either way, we can't go forward */
--- a/src/lib-index/mail-index-view-sync.c Wed Jun 13 22:57:25 2007 +0300 +++ b/src/lib-index/mail-index-view-sync.c Wed Jun 13 23:00:58 2007 +0300 @@ -87,8 +87,7 @@ return 0; } -static int view_sync_set_log_view_range(struct mail_index_view *view, - enum mail_transaction_type type_mask) +static int view_sync_set_log_view_range(struct mail_index_view *view) { const struct mail_index_header *hdr = view->index->hdr; int ret; @@ -98,8 +97,7 @@ view->log_file_seq, view->log_file_offset, hdr->log_file_seq, - hdr->log_file_index_int_offset, - type_mask); + hdr->log_file_index_int_offset); if (ret <= 0) { if (ret == 0) { /* FIXME: use the new index to get needed changes */ @@ -123,7 +121,7 @@ unsigned int count; int ret; - if (view_sync_set_log_view_range(view, MAIL_TRANSACTION_EXPUNGE) < 0) + if (view_sync_set_log_view_range(view) < 0) return -1; /* get a list of expunge transactions. there may be some that we have @@ -131,8 +129,10 @@ out when converting to sequences */ i_array_init(expunges_r, 64); while ((ret = mail_transaction_log_view_next(view->log_view, - &hdr, &data, NULL)) > 0) { - i_assert((hdr->type & MAIL_TRANSACTION_EXPUNGE) != 0); + &hdr, &data)) > 0) { + if ((hdr->type & MAIL_TRANSACTION_EXPUNGE) == 0) + continue; + if (mail_transaction_log_sort_expunges(expunges_r, data, hdr->size) < 0) { mail_transaction_log_view_set_corrupted(view->log_view, @@ -250,7 +250,7 @@ { struct mail_index_view_sync_ctx *ctx; struct mail_index_map *map; - enum mail_transaction_type log_get_mask, visible_mask = 0; + enum mail_transaction_type visible_mask = 0; ARRAY_TYPE(seq_range) expunges = ARRAY_INIT; i_assert(!view->syncing); @@ -280,12 +280,7 @@ break; } - /* we want to also get non-visible changes. especially because we use - the returned skipped-flag in mail_transaction_log_view_next() to - tell us if any visible changes were skipped. */ - log_get_mask = visible_mask | (MAIL_TRANSACTION_TYPE_MASK ^ - MAIL_TRANSACTION_VISIBLE_SYNC_MASK); - if (view_sync_set_log_view_range(view, log_get_mask) < 0) { + if (view_sync_set_log_view_range(view) < 0) { if (array_is_created(&expunges)) array_free(&expunges); return -1; @@ -418,23 +413,16 @@ { struct mail_transaction_log_view *log_view = ctx->view->log_view; struct mail_index_view *view = ctx->view; + const struct mail_transaction_header *hdr; uint32_t seq; uoff_t offset; int ret; - bool skipped, synced_to_map; + bool synced_to_map; for (;;) { /* Get the next transaction from log. */ ret = mail_transaction_log_view_next(log_view, &ctx->hdr, - &ctx->data, &skipped); - - if (skipped) { - /* We skipped some (visible) transactions that were - outside our sync mask. Note that we may get here - even when ret=0. */ - ctx->skipped_some = TRUE; - } - + &ctx->data); if (ret <= 0) { if (ret < 0) return -1; @@ -444,14 +432,23 @@ return 0; } + hdr = ctx->hdr; + if ((hdr->type & ctx->visible_sync_mask) == 0 && + (hdr->type & MAIL_TRANSACTION_VISIBLE_SYNC_MASK) != 0) { + /* This is a visible record that we don't want to + sync. */ + ctx->skipped_some = TRUE; + continue; + } + mail_transaction_log_view_get_prev_pos(log_view, &seq, &offset); if (!ctx->skipped_some) { /* We haven't skipped anything while syncing this view. Update this view's synced log offset. */ view->log_file_seq = seq; - view->log_file_offset = offset + sizeof(*ctx->hdr) + - ctx->hdr->size; + view->log_file_offset = offset + sizeof(*hdr) + + hdr->size; } /* skip everything we've already synced */ @@ -473,20 +470,19 @@ subsequent syncs. */ synced_to_map = offset < view->hdr.log_file_index_ext_offset && seq == view->hdr.log_file_seq && - (ctx->hdr->type & MAIL_TRANSACTION_EXTERNAL) != 0; + (hdr->type & MAIL_TRANSACTION_EXTERNAL) != 0; /* Apply transaction to view's mapping if needed (meaning we didn't just re-map the view to head mapping). */ if (ctx->sync_map_update && !synced_to_map) { - i_assert((ctx->hdr->type & - MAIL_TRANSACTION_EXPUNGE) == 0); + i_assert((hdr->type & MAIL_TRANSACTION_EXPUNGE) == 0); if (mail_index_sync_record(&ctx->sync_map_ctx, - ctx->hdr, ctx->data) < 0) + hdr, ctx->data) < 0) return -1; } - if ((ctx->hdr->type & ctx->visible_sync_mask) == 0) { + if ((hdr->type & ctx->visible_sync_mask) == 0) { /* non-visible change that we just wanted to update to map. */ continue; @@ -709,8 +705,7 @@ view->log_file_seq, view->log_file_offset, view->log_file_seq, - view->log_file_offset, - MAIL_TRANSACTION_TYPE_MASK); + view->log_file_offset); if (array_is_created(&ctx->expunges)) array_free(&ctx->expunges);
--- a/src/lib-index/mail-transaction-log-view.c Wed Jun 13 22:57:25 2007 +0300 +++ b/src/lib-index/mail-transaction-log-view.c Wed Jun 13 23:00:58 2007 +0300 @@ -12,7 +12,6 @@ uint32_t min_file_seq, max_file_seq; uoff_t min_file_offset, max_file_offset; - enum mail_transaction_type type_mask; struct mail_transaction_header tmp_hdr; /* a list of log files we've referenced. we have to keep this list @@ -92,8 +91,7 @@ int mail_transaction_log_view_set(struct mail_transaction_log_view *view, uint32_t min_file_seq, uoff_t min_file_offset, - uint32_t max_file_seq, uoff_t max_file_offset, - enum mail_transaction_type type_mask) + uint32_t max_file_seq, uoff_t max_file_offset) { struct mail_transaction_log_file *file, *first; uint32_t seq; @@ -230,7 +228,6 @@ view->min_file_offset = min_file_offset; view->max_file_seq = max_file_seq; view->max_file_offset = max_file_offset; - view->type_mask = type_mask; view->broken = FALSE; i_assert(view->cur_offset <= view->cur->sync_offset); @@ -520,52 +517,33 @@ int mail_transaction_log_view_next(struct mail_transaction_log_view *view, const struct mail_transaction_header **hdr_r, - const void **data_r, bool *skipped_r) + const void **data_r) { const struct mail_transaction_header *hdr; const void *data; - uint32_t hdr_type = 0; int ret = 0; - if (skipped_r != NULL) - *skipped_r = FALSE; if (view->broken) return -1; - while ((ret = log_view_get_next(view, &hdr, &data)) > 0) { - /* drop expunge protection */ - if ((hdr->type & MAIL_TRANSACTION_TYPE_MASK) == - (MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXPUNGE_PROT)) - hdr_type = hdr->type & ~MAIL_TRANSACTION_EXPUNGE_PROT; - else - hdr_type = hdr->type; - - if ((view->type_mask & hdr_type) != 0) { - /* the record is within our wanted mask */ - break; - } - - /* we don't want this record */ - if (skipped_r != NULL) - *skipped_r = TRUE; - - /* FIXME: hide flag/cache updates for appends if - append isn't in mask */ + ret = log_view_get_next(view, &hdr, &data); + if (ret <= 0) { + if (ret < 0) + view->cur_offset = view->cur->sync_offset; + return ret; } - if (ret < 0) { - view->cur_offset = view->cur->sync_offset; - return -1; - } - if (ret == 0) - return 0; + /* drop expunge protection */ + if ((hdr->type & MAIL_TRANSACTION_TYPE_MASK) == + (MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXPUNGE_PROT)) + view->tmp_hdr.type = hdr->type & ~MAIL_TRANSACTION_EXPUNGE_PROT; + else + view->tmp_hdr.type = hdr->type; - /* return type without expunge protection */ - view->tmp_hdr.type = hdr_type; /* return record's size */ - view->tmp_hdr.size = - mail_index_offset_to_uint32(hdr->size) - sizeof(*hdr); - i_assert(view->tmp_hdr.size != 0); + view->tmp_hdr.size = mail_index_offset_to_uint32(hdr->size); + i_assert(view->tmp_hdr.size > sizeof(*hdr)); + view->tmp_hdr.size -= sizeof(*hdr); *hdr_r = &view->tmp_hdr; *data_r = data;
--- a/src/lib-index/mail-transaction-log.h Wed Jun 13 22:57:25 2007 +0300 +++ b/src/lib-index/mail-transaction-log.h Wed Jun 13 23:00:58 2007 +0300 @@ -140,14 +140,13 @@ int mail_transaction_log_view_set(struct mail_transaction_log_view *view, uint32_t min_file_seq, uoff_t min_file_offset, - uint32_t max_file_seq, uoff_t max_file_offset, - enum mail_transaction_type type_mask); + uint32_t max_file_seq, uoff_t max_file_offset); /* Read next transaction record from current position. The position is updated. Returns -1 if error, 0 if we're at end of the view, 1 if ok. */ int mail_transaction_log_view_next(struct mail_transaction_log_view *view, const struct mail_transaction_header **hdr_r, - const void **data_r, bool *skipped_r); + const void **data_r); /* Seek to given position within view. Must be inside the view's range. */ void mail_transaction_log_view_seek(struct mail_transaction_log_view *view, uint32_t seq, uoff_t offset);