dovecot: Don't update cache record links if we know it's already...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jun 16 00:18:30 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/18fb3f1fc41b
changeset: 5750:18fb3f1fc41b
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Jun 16 00:18:27 2007 +0300
description:
Don't update cache record links if we know it's already been done.

diffstat:

1 file changed, 10 insertions(+), 3 deletions(-)
src/lib-index/mail-cache-sync-update.c |   13 ++++++++++---

diffs (30 lines):

diff -r 420a386fa27a -r 18fb3f1fc41b src/lib-index/mail-cache-sync-update.c
--- a/src/lib-index/mail-cache-sync-update.c	Fri Jun 15 23:52:47 2007 +0300
+++ b/src/lib-index/mail-cache-sync-update.c	Sat Jun 16 00:18:27 2007 +0300
@@ -105,7 +105,8 @@ int mail_cache_sync_handler(struct mail_
 	struct mail_cache_sync_context *ctx = *context;
 	const uint32_t *old_cache_offset = old_data;
 	const uint32_t *new_cache_offset = new_data;
-	uint32_t cache_file_seq;
+	uint32_t cache_file_seq, cur_seq, tail_seq;
+	uoff_t cur_offset, tail_offset;
 	int ret;
 
 	if (new_cache_offset == NULL) {
@@ -126,8 +127,14 @@ int mail_cache_sync_handler(struct mail_
 	    sync_ctx->type == MAIL_INDEX_SYNC_HANDLER_VIEW)
 		return 1;
 
-	/* FIXME: we should do this only once to avoid extra overhead.
-	   currently this can happen multiple times as map is synchronized. */
+	mail_transaction_log_view_get_prev_pos(view->log_view,
+					       &cur_seq, &cur_offset);
+	mail_transaction_log_get_mailbox_sync_pos(view->index->log,
+						  &tail_seq, &tail_offset);
+	if (LOG_IS_BEFORE(cur_seq, cur_offset, tail_seq, tail_offset)) {
+		/* already been linked */
+		return 1;
+	}
 
 	/* we'll need to link the old and new cache records */
 	ret = mail_cache_handler_init(&ctx, cache);


More information about the dovecot-cvs mailing list