[dovecot-cvs]
dovecot/src/lib-index mail-index-sync-private.h, 1.20,
1.21 mail-index-sync-update.c, 1.78, 1.79 mail-index-sync.c,
1.46, 1.47
cras at dovecot.org
cras at dovecot.org
Mon Jan 31 21:43:22 EET 2005
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv9620/lib-index
Modified Files:
mail-index-sync-private.h mail-index-sync-update.c
mail-index-sync.c
Log Message:
Recent flags weren't being removed from index causing needless syncing.
Index: mail-index-sync-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-private.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mail-index-sync-private.h 22 Jan 2005 16:56:37 -0000 1.20
+++ mail-index-sync-private.h 31 Jan 2005 19:43:20 -0000 1.21
@@ -23,6 +23,7 @@
unsigned int lock_id;
unsigned int sync_appends:1;
+ unsigned int sync_recent:1;
unsigned int sync_dirty:1;
};
Index: mail-index-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- mail-index-sync-update.c 26 Dec 2004 09:12:40 -0000 1.78
+++ mail-index-sync-update.c 31 Jan 2005 19:43:20 -0000 1.79
@@ -528,6 +528,19 @@
mail_index_sync_deinit_handlers(sync_map_ctx);
}
+static void mail_index_sync_remove_recent(struct mail_index_sync_ctx *sync_ctx)
+{
+ struct mail_index_map *map = sync_ctx->view->map;
+ struct mail_index_record *rec;
+ unsigned int i;
+
+ for (i = 0; i < map->records_count; i++) {
+ rec = MAIL_INDEX_MAP_IDX(map, i);
+ if ((rec->flags & MAIL_RECENT) != 0)
+ rec->flags &= ~MAIL_RECENT;
+ }
+}
+
int mail_index_sync_update_index(struct mail_index_sync_ctx *sync_ctx,
int sync_only_external)
{
@@ -574,6 +587,11 @@
if (had_dirty)
map->hdr.flags &= ~MAIL_INDEX_HDR_FLAG_HAVE_DIRTY;
+ if (sync_ctx->sync_recent) {
+ /* mark all messages non-recent */
+ mail_index_sync_remove_recent(sync_ctx);
+ }
+
/* make sure we don't go doing fsck while modifying the index */
index->sync_update = TRUE;
Index: mail-index-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- mail-index-sync.c 22 Jan 2005 16:56:37 -0000 1.46
+++ mail-index-sync.c 31 Jan 2005 19:43:20 -0000 1.47
@@ -99,6 +99,7 @@
{
const struct mail_index_record *rec;
uint32_t seq, messages_count;
+ int seen_recent = FALSE;
messages_count = mail_index_view_get_messages_count(ctx->view);
for (seq = 1; seq <= messages_count; seq++) {
@@ -106,15 +107,23 @@
return -1;
if ((rec->flags & MAIL_RECENT) != 0) {
+ seen_recent = TRUE;
mail_index_update_flags(ctx->trans, rec->uid,
MODIFY_REMOVE, MAIL_RECENT);
}
}
+
+ if (!seen_recent) {
+ /* no recent messages, drop the sync_recent flag so we
+ don't scan through the message again */
+ ctx->sync_recent = FALSE;
+ }
+
return 0;
}
static int
-mail_index_sync_read_and_sort(struct mail_index_sync_ctx *ctx, int sync_recent,
+mail_index_sync_read_and_sort(struct mail_index_sync_ctx *ctx,
int *seen_external_r)
{
size_t size;
@@ -129,7 +138,7 @@
return -1;
}
- if (sync_recent) {
+ if (ctx->sync_recent) {
if (mail_index_sync_add_recent_updates(ctx) < 0)
return -1;
}
@@ -250,6 +259,7 @@
ctx = i_new(struct mail_index_sync_ctx, 1);
ctx->index = index;
ctx->lock_id = lock_id;
+ ctx->sync_recent = sync_recent;
ctx->sync_dirty = sync_dirty;
ctx->view = mail_index_view_open(index);
@@ -311,8 +321,7 @@
/* we need to have all the transactions sorted to optimize
caller's mailbox access patterns */
- if (mail_index_sync_read_and_sort(ctx, sync_recent,
- &seen_external) < 0) {
+ if (mail_index_sync_read_and_sort(ctx, &seen_external) < 0) {
mail_index_sync_rollback(ctx);
return -1;
}
More information about the dovecot-cvs
mailing list