[dovecot-cvs] dovecot: Removed sync_mask parameter from mail_transaction_log_v...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jun 13 23:01:02 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/7aab5d99fb45
changeset: 5728:7aab5d99fb45
user: Timo Sirainen <tss at iki.fi>
date: Wed Jun 13 23:00:58 2007 +0300
description:
Removed sync_mask parameter from mail_transaction_log_view_set(). The user
will now have to check the types itself.
diffstat:
5 files changed, 53 insertions(+), 83 deletions(-)
src/lib-index/mail-index-sync-update.c | 5 --
src/lib-index/mail-index-sync.c | 5 --
src/lib-index/mail-index-view-sync.c | 61 +++++++++++++----------------
src/lib-index/mail-transaction-log-view.c | 60 +++++++++-------------------
src/lib-index/mail-transaction-log.h | 5 --
diffs (truncated from 321 to 300 lines):
diff -r d9d047b743d5 -r 7aab5d99fb45 src/lib-index/mail-index-sync-update.c
--- 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 @@ int mail_index_sync_map(struct mail_inde
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 @@ int mail_index_sync_map(struct mail_inde
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);
diff -r d9d047b743d5 -r 7aab5d99fb45 src/lib-index/mail-index-sync.c
--- 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 @@ mail_index_sync_read_and_sort(struct mai
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 @@ mail_index_sync_set_log_view(struct mail
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 */
diff -r d9d047b743d5 -r 7aab5d99fb45 src/lib-index/mail-index-view-sync.c
--- 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 @@ mail_transaction_log_sort_expunges(ARRAY
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 @@ static int view_sync_set_log_view_range(
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 @@ view_sync_get_expunges(struct mail_index
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 @@ view_sync_get_expunges(struct mail_index
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 @@ int mail_index_view_sync_begin(struct ma
{
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 @@ int mail_index_view_sync_begin(struct ma
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 @@ mail_index_view_sync_get_next_transactio
{
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;
@@ -442,6 +430,15 @@ mail_index_view_sync_get_next_transactio
ctx->hdr = NULL;
ctx->last_read = TRUE;
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);
@@ -450,8 +447,8 @@ mail_index_view_sync_get_next_transactio
/* 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 @@ mail_index_view_sync_get_next_transactio
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 @@ void mail_index_view_sync_end(struct mai
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);
diff -r d9d047b743d5 -r 7aab5d99fb45 src/lib-index/mail-transaction-log-view.c
--- 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 @@ struct mail_transaction_log_view {
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
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 @@ mail_transaction_log_view_set(struct mai
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 @@ log_view_get_next(struct mail_transactio
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 */
- }
-
- if (ret < 0) {
- view->cur_offset = view->cur->sync_offset;
- return -1;
- }
- if (ret == 0)
- return 0;
-
- /* return type without expunge protection */
- view->tmp_hdr.type = hdr_type;
+ ret = log_view_get_next(view, &hdr, &data);
+ if (ret <= 0) {
+ if (ret < 0)
+ view->cur_offset = view->cur->sync_offset;
+ return ret;
+ }
+
+ /* 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 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;
More information about the dovecot-cvs
mailing list