[dovecot-cvs] dovecot/src/lib-index mail-index-private.h, 1.68,
1.69 mail-index-sync-private.h, 1.28,
1.29 mail-index-sync-update.c, 1.94,
1.95 mail-index-view-private.h, 1.21,
1.22 mail-index-view-sync.c, 1.51, 1.52 mail-index-view.c,
1.43, 1.44
cras at dovecot.org
cras at dovecot.org
Wed May 3 01:06:34 EEST 2006
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv31256
Modified Files:
mail-index-private.h mail-index-sync-private.h
mail-index-sync-update.c mail-index-view-private.h
mail-index-view-sync.c mail-index-view.c
Log Message:
Index header's seen/recent/deleted counters weren't always correct after
syncing a view. This caused some problems with recent SEARCH optimizations,
eg. EXPUNGE not always working.
Index: mail-index-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-private.h,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- mail-index-private.h 2 May 2006 11:04:30 -0000 1.68
+++ mail-index-private.h 2 May 2006 22:06:32 -0000 1.69
@@ -246,6 +246,7 @@
uint32_t ext_id, uint32_t *idx_r);
const struct mail_index_ext *
mail_index_view_get_ext(struct mail_index_view *view, uint32_t ext_id);
+void mail_index_view_recalc_counters(struct mail_index_view *view);
int mail_index_map_parse_keywords(struct mail_index *index,
struct mail_index_map *map);
Index: mail-index-sync-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-private.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- mail-index-sync-private.h 13 Jan 2006 20:26:13 -0000 1.28
+++ mail-index-sync-private.h 2 May 2006 22:06:32 -0000 1.29
@@ -52,6 +52,7 @@
unsigned int expunge_handlers_used:1;
unsigned int cur_ext_ignore:1;
unsigned int keywords_read:1;
+ unsigned int unreliable_flags:1;
};
extern struct mail_transaction_map_functions mail_index_map_sync_funcs;
Index: mail-index-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -d -r1.94 -r1.95
--- mail-index-sync-update.c 2 May 2006 11:04:30 -0000 1.94
+++ mail-index-sync-update.c 2 May 2006 22:06:32 -0000 1.95
@@ -82,6 +82,29 @@
}
}
+void mail_index_view_recalc_counters(struct mail_index_view *view)
+{
+ struct mail_index_map *map = view->map;
+ const struct mail_index_record *rec;
+ unsigned int i;
+
+ map->hdr.recent_messages_count = 0;
+ map->hdr.seen_messages_count = 0;
+ map->hdr.deleted_messages_count = 0;
+
+ for (i = 0; i < view->hdr.messages_count; i++) {
+ rec = MAIL_INDEX_MAP_IDX(map, i);
+ mail_index_header_update_counts(view->index, &map->hdr,
+ 0, rec->flags);
+ }
+
+ view->hdr.recent_messages_count = map->hdr.recent_messages_count;
+ view->hdr.seen_messages_count = map->hdr.seen_messages_count;
+ view->hdr.deleted_messages_count = map->hdr.deleted_messages_count;
+
+ view->broken_counters = FALSE;
+}
+
static void
mail_index_header_update_lowwaters(struct mail_index_header *hdr,
const struct mail_index_record *rec)
@@ -149,10 +172,14 @@
expunge_handlers_count = 0;
}
- for (seq = seq1; seq <= seq2; seq++) {
- rec = MAIL_INDEX_MAP_IDX(map, seq-1);
- mail_index_header_update_counts(view->index, &map->hdr,
- rec->flags, 0);
+ if (ctx->unreliable_flags)
+ view->broken_counters = TRUE;
+ else {
+ for (seq = seq1; seq <= seq2; seq++) {
+ rec = MAIL_INDEX_MAP_IDX(map, seq-1);
+ mail_index_header_update_counts(view->index, &map->hdr,
+ rec->flags, 0);
+ }
}
for (i = 0; i < expunge_handlers_count; i++) {
@@ -264,15 +291,27 @@
flag_mask = ~u->remove_flags;
- for (idx = seq1-1; idx < seq2; idx++) {
- rec = MAIL_INDEX_MAP_IDX(view->map, idx);
+ if (ctx->unreliable_flags &&
+ ((u->add_flags | u->remove_flags) &
+ (MAIL_SEEN | MAIL_DELETED | MAIL_RECENT)) != 0) {
+ view->broken_counters = TRUE;
+ for (idx = seq1-1; idx < seq2; idx++) {
+ rec = MAIL_INDEX_MAP_IDX(view->map, idx);
+ rec->flags = (rec->flags & flag_mask) | u->add_flags;
- old_flags = rec->flags;
- rec->flags = (rec->flags & flag_mask) | u->add_flags;
+ mail_index_header_update_lowwaters(hdr, rec);
+ }
+ } else {
+ for (idx = seq1-1; idx < seq2; idx++) {
+ rec = MAIL_INDEX_MAP_IDX(view->map, idx);
- mail_index_header_update_counts(view->index, hdr,
- old_flags, rec->flags);
- mail_index_header_update_lowwaters(hdr, rec);
+ old_flags = rec->flags;
+ rec->flags = (rec->flags & flag_mask) | u->add_flags;
+
+ mail_index_header_update_counts(view->index, hdr,
+ old_flags, rec->flags);
+ mail_index_header_update_lowwaters(hdr, rec);
+ }
}
return 1;
}
Index: mail-index-view-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view-private.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- mail-index-view-private.h 13 Jan 2006 20:26:13 -0000 1.21
+++ mail-index-view-private.h 2 May 2006 22:06:32 -0000 1.22
@@ -54,6 +54,7 @@
unsigned int inconsistent:1;
unsigned int syncing:1;
+ unsigned int broken_counters:1;
};
void mail_index_view_clone(struct mail_index_view *dest,
Index: mail-index-view-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view-sync.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- mail-index-view-sync.c 24 Apr 2006 09:19:33 -0000 1.51
+++ mail-index-view-sync.c 2 May 2006 22:06:32 -0000 1.52
@@ -254,6 +254,9 @@
view->sync_new_map = view->index->map;
view->sync_new_map->refcount++;
+ /* since we're syncing everything, the counters get fixed */
+ view->broken_counters = FALSE;
+
/* keep the old mapping without expunges until we're
fully synced */
} else {
@@ -270,6 +273,14 @@
/* Using non-head mapping. We have to apply
transactions to it to get latest changes into it. */
ctx->sync_map_update = TRUE;
+ /* Unless map was synced at the exact same position as
+ view, the message flags can't be reliably used to
+ update flag counters. */
+ ctx->sync_map_ctx.unreliable_flags =
+ !(view->map->hdr.log_file_seq ==
+ view->log_file_seq &&
+ view->map->hdr.log_file_int_offset ==
+ view->log_file_offset);
/* Copy only the mails that we see currently, since
we're going to append the new ones when we see
Index: mail-index-view.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- mail-index-view.c 16 Feb 2006 15:23:03 -0000 1.43
+++ mail-index-view.c 2 May 2006 22:06:32 -0000 1.44
@@ -19,6 +19,7 @@
dest->map = src->map;
dest->map->refcount++;
dest->hdr = src->hdr;
+ dest->broken_counters = src->broken_counters;
dest->log_file_seq = src->log_file_seq;
dest->log_file_offset = src->log_file_offset;
@@ -174,6 +175,8 @@
static const struct mail_index_header *
_view_get_header(struct mail_index_view *view)
{
+ if (view->broken_counters)
+ mail_index_view_recalc_counters(view);
return &view->hdr;
}
More information about the dovecot-cvs
mailing list