Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6100:a55ee2e3caac HEAD
Don't write list index header if it hasn't changed.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 19 Jul 2007 04:18:30 +0300 |
parents | 33d589af9933 |
children | 6805ccf0b82e |
files | src/lib-index/mailbox-list-index-sync.c |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mailbox-list-index-sync.c Thu Jul 19 04:18:10 2007 +0300 +++ b/src/lib-index/mailbox-list-index-sync.c Thu Jul 19 04:18:30 2007 +0300 @@ -64,6 +64,7 @@ buffer_t *output_buf; unsigned int failed:1; + unsigned int changed:1; unsigned int restart:1; unsigned int partial:1; unsigned int seen_sync_root:1; @@ -180,6 +181,8 @@ { struct mailbox_list_sync_record *rec; + ctx->changed = TRUE; + rec = array_insert_space(&dir->records, idx); rec->name_hash = crc32_str(name); rec->name = p_strdup(ctx->pool, name); @@ -525,6 +528,7 @@ *base_offset_r = pos; ctx->hdr.used_space = pos + size; + ctx->changed = TRUE; return 0; } @@ -683,6 +687,7 @@ } ctx->hdr.deleted_space += deleted_space; + ctx->changed = TRUE; sync_dir->offset = base_offset; return 0; } @@ -758,6 +763,7 @@ o_stream_seek(ctx->output, old_offset); t_pop(); } + ctx->changed = TRUE; return 0; } @@ -862,7 +868,9 @@ if (mailbox_list_index_sync_write_dir(ctx, ctx->root, 0, partial) < 0) ret = -1; - if (!ctx->index->mmap_disable) { + if (!ctx->changed) { + /* nothing written */ + } else if (!ctx->index->mmap_disable) { /* update header */ hdr = ctx->index->mmap_base; if (ret == 0) @@ -891,7 +899,8 @@ "fdatasync()"); ret = -1; } - + } + if (ctx->index->mmap_disable) { o_stream_destroy(&ctx->output); buffer_free(ctx->output_buf); }