dovecot: If we can do initial sync from .log file by reading les...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Jul 1 01:40:37 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/fb91e7d729d1
changeset: 5851:fb91e7d729d1
user: Timo Sirainen <tss at iki.fi>
date: Sun Jul 01 01:40:25 2007 +0300
description:
If we can do initial sync from .log file by reading less than 2k, do it
instead of opening main index file.
diffstat:
1 file changed, 14 insertions(+), 3 deletions(-)
src/lib-index/mail-index-sync-update.c | 17 ++++++++++++++---
diffs (36 lines):
diff -r f8caf3c6a5a7 -r fb91e7d729d1 src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c Sun Jul 01 01:05:40 2007 +0300
+++ b/src/lib-index/mail-index-sync-update.c Sun Jul 01 01:40:25 2007 +0300
@@ -8,6 +8,10 @@
#include "mail-index-sync-private.h"
#include "mail-transaction-log.h"
#include "mail-transaction-log-private.h"
+
+/* If we have less than this many bytes to sync from log file, don't bother
+ reading the main index */
+#define MAIL_INDEX_SYNC_MIN_READ_INDEX_SIZE 2048
static void
mail_index_sync_update_log_offset(struct mail_index_sync_map_ctx *ctx,
@@ -706,11 +710,18 @@ int mail_index_sync_map(struct mail_inde
syncing the current map from the transaction log */
uoff_t log_size, index_size;
- if (index->log->head == NULL || index->fd == -1)
+ if (index->log->head == NULL)
return 0;
- index_size = map->hdr.header_size +
- map->records_count * map->hdr.record_size;
+ if (index->fd == -1 &&
+ index->log->head->hdr.prev_file_seq != 0) {
+ /* we don't know the index's size, so use the
+ smallest index size we're willing to read */
+ index_size = MAIL_INDEX_SYNC_MIN_READ_INDEX_SIZE;
+ } else {
+ index_size = map->hdr.header_size +
+ map->records_count * map->hdr.record_size;
+ }
/* this isn't necessary correct currently, but it should be
close enough */
More information about the dovecot-cvs
mailing list